Plugin Directory

Changeset 3450387


Ignore:
Timestamp:
01/30/2026 11:49:52 AM (5 weeks ago)
Author:
zealopensource
Message:

Update to version 1.0.8 from GitHub

Location:
smart-appointment-booking
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • smart-appointment-booking/tags/1.0.8/inc/admin/class.saab.admin.action.php

    r3154282 r3450387  
    200200            );
    201201            $get_notification_array = array();
    202             if (isset($_POST['notification_data'])) {
    203            
    204                 parse_str($_POST['notification_data'], $form_data);
     202            if ( isset( $_POST['notification_data'] ) ) {
     203                parse_str( sanitize_text_field( wp_unslash( $_POST['notification_data'] ) ), $form_data );
    205204                $post_id = $form_data['form_id'];
    206205                $index = $form_data['editnotify'];
     
    394393         */
    395394        function view_booking_entry( $post ){
    396             if( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], '_wpnonce' ) ){
     395            if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), '_wpnonce' ) ) {
    397396                //wp_die( 'Security check failed. Refresh the page and retry again!' );
    398397            }
    399             $post_id = ( isset( $_GET['post_id'] ) ) ? $_GET['post_id'] : '';
     398            $post_id = isset( $_GET['post_id'] ) ? absint( wp_unslash( $_GET['post_id'] ) ) : 0;
    400399            $form_data = get_post_meta( $post_id, 'saab_submission_data', true );   
    401400            $form_id = get_post_meta( $post_id, 'saab_form_id', true );
     
    529528        }
    530529        function update_form_entry_data(){
    531             // if( ! isset( $_POST['zwt_saab_common_nonce'] ) || ! wp_verify_nonce( $_POST['zwt_saab_common_nonce'], 'zwt_saab_common_nonce' ) ){
    532             //  wp_die( 'Security check failed. Refresh the page and retry again!' );
    533             // }
    534             if (isset($_POST['entry_id']) && isset($_POST['updated_data']) ) {
    535                 $entry_id = ( isset( $_POST['entry_id'] ) ) ? $_POST['entry_id'] : '';
    536                 $get_submitted_data = get_post_meta($entry_id, 'saab_submission_data', true);
    537                 $updated_data = ( isset( $_POST['updated_data'] ) ) ? $_POST['updated_data'] : '';
     530            if ( ! isset( $_POST['security'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['security'] ) ), 'saab_ajax_nonce' ) ) {
     531                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     532                wp_die();
     533            }
     534            if ( isset( $_POST['entry_id'] ) && isset( $_POST['updated_data'] ) ) {
     535                $entry_id = isset( $_POST['entry_id'] ) ? absint( wp_unslash( $_POST['entry_id'] ) ) : 0;
     536                $get_submitted_data = get_post_meta( $entry_id, 'saab_submission_data', true );
     537                $updated_data = isset( $_POST['updated_data'] ) && is_array( $_POST['updated_data'] ) ? map_deep( wp_unslash( $_POST['updated_data'] ), 'sanitize_text_field' ) : array();
    538538                foreach ($updated_data as $key => $value) {
    539539                    if (isset($get_submitted_data['data'][$key])) {
     
    575575            echo "<div class='notification-page-main m-4 p-1 ' >";
    576576       
    577             if (isset($_GET['post_type']) && isset($_GET['post_id']) && isset( $_GET['nonce'] ) && ! wp_verify_nonce( sanitize_text_field( wp_unslash ($_POST['nonce'] ) ) , 'other_setting' )) {
    578            
    579                 $post_type = sanitize_text_field($_GET['post_type']);
    580                
    581                 $post_id = absint( $_GET['post_id']);               
     577            if ( isset( $_GET['post_type'] ) && isset( $_GET['post_id'] ) && isset( $_GET['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'other_setting' ) ) {
     578                $post_type = sanitize_text_field( wp_unslash( $_GET['post_type'] ) );
     579                $post_id = absint( wp_unslash( $_GET['post_id'] ) );               
    582580           
    583581                ?>
     
    633631                                                        $fieldLabel = $option['fieldlabel'];
    634632                                                        $selected = ($fieldKey == $first_name) ? 'selected' : '';
    635                                                         echo '<option value="' . $fieldKey . '" ' . $selected . '>' . $fieldLabel . '</option>';
     633                                                        echo '<option value="' . esc_attr( $fieldKey ) . '" ' . esc_attr( $selected ) . '>' . esc_html( $fieldLabel ) . '</option>';
    636634                                                    }
    637635                                                ?>
     
    995993                wp_send_json($response);
    996994            }else{
    997                 if (null !== ($_POST['post_id'] ?? null) && null !== absint($_POST['notification_id'] ?? null) && null !== sanitize_text_field($_POST['new_state'] ?? null)) {
    998                     $post_id = isset($_POST['post_id']) ? absint($_POST['post_id']) : 0;
    999                     $notification_id = isset($_POST['notification_id']) ? absint($_POST['notification_id']) : 0;
    1000 
    1001                     $index = ltrim($notification_id, "notify_");
    1002                     $new_state = isset($_POST['new_state']) ? sanitize_text_field($_POST['new_state']) : '';
     995                if ( isset( $_POST['post_id'] ) && isset( $_POST['notification_id'] ) && isset( $_POST['new_state'] ) ) {
     996                    $post_id = absint( wp_unslash( $_POST['post_id'] ) );
     997                    $notification_id = absint( wp_unslash( $_POST['notification_id'] ) );
     998
     999                    $index = ltrim( (string) $notification_id, 'notify_' );
     1000                    $new_state = sanitize_text_field( wp_unslash( $_POST['new_state'] ) );
    10031001                   
    10041002                    // Get the existing notification metadata
     
    10341032                wp_die();
    10351033            }
    1036             if (isset($_POST['indexes'])) {
    1037                 $post_id = isset($_POST['post_id']) ? absint($_POST['post_id']) : 0;
    1038                 $indexesToDelete = isset($_POST['indexes']) ? $_POST['indexes'] : '';   
     1034            if ( isset( $_POST['indexes'] ) && is_array( $_POST['indexes'] ) ) {
     1035                $post_id = isset( $_POST['post_id'] ) ? absint( wp_unslash( $_POST['post_id'] ) ) : 0;
     1036                $indexes_raw = wp_unslash( $_POST['indexes'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized via map_deep below
     1037                $indexesToDelete = map_deep( $indexes_raw, 'sanitize_text_field' );
    10391038                $notification_metadata = get_post_meta($post_id, 'saab_notification_data', true);
    10401039                foreach ($indexesToDelete as $index) {
     
    11301129                                            foreach ($available_types as $avail_type) {
    11311130                                                $selected = ($avail_type === $type) ? 'selected' : '';
    1132                                                 echo '<option value="' . esc_html($avail_type) . '" ' . esc_attr($selected) . '>' . ucfirst(esc_html($avail_type)) . '</option>';
     1131                                                echo '<option value="' . esc_html($avail_type) . '" ' . esc_attr($selected) . '>' . esc_html( ucfirst( $avail_type ) ) . '</option>';
    11331132
    11341133                                            }
     
    12051204                $post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0;
    12061205
    1207                 $form_data = isset( $_POST['form_data'] ) ? sanitize_text_field($_POST['form_data']) : array();
     1206                $form_data = isset( $_POST['form_data'] ) ? sanitize_text_field( wp_unslash( $_POST['form_data'] ) ) : '';
    12081207               
    12091208                update_post_meta($post_id, 'saab_formschema', $form_data );
     
    12291228               
    12301229                if (isset($form_title)) {
    1231                     echo sprintf(
    1232                         esc_html__('%s', 'smart-appointment-booking'),
    1233                         esc_html($form_title)
    1234                     );
     1230                    echo esc_html( $form_title );
    12351231               
    12361232                }else{
     
    12421238           
    12431239                if (isset($booking_status) && !empty($booking_status)) {
    1244                     echo sprintf(
    1245                         esc_html__('%s', 'smart-appointment-booking'),
    1246                         esc_html(ucfirst($booking_status))
    1247                     ); 
     1240                    echo esc_html( ucfirst( $booking_status ) );
    12481241                }else{
    12491242                    echo '-';
     
    12631256                $booked_date = gmdate('d F, Y', strtotime($booked_date));   
    12641257                    if (isset($booking_date) && !empty($booking_date)) {   
    1265                         echo sprintf(
    1266                             esc_html__('%s', 'smart-appointment-booking'),
    1267                             esc_html($booked_date)
    1268                         );
    1269                        
     1258                        echo esc_html( $booked_date );
    12701259                    }
    12711260                }else{
     
    12771266           
    12781267                if (isset($timeslot) && !empty($timeslot)) {
    1279                     echo sprintf(
    1280                         esc_html__('%s', 'smart-appointment-booking'),
    1281                         esc_html($timeslot)
    1282                     ); 
     1268                    echo esc_html( $timeslot );
    12831269                }else{
    12841270                    echo '-';
     
    13421328                $error = 1;
    13431329                $error_mess = "Something went wrong";
    1344                 error_log("post_id not found while preview");
     1330                error_log( "post_id not found while preview" ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
    13451331            }
    13461332       
     
    14511437                wp_die();
    14521438            }
    1453             $user_mapping = isset($_POST['saabuser_mapping']) ? sanitize_text_field($_POST['saabuser_mapping']) : '';
     1439            $user_mapping = isset( $_POST['saabuser_mapping'] ) ? sanitize_text_field( wp_unslash( $_POST['saabuser_mapping'] ) ) : '';
    14541440       
    14551441            parse_str($user_mapping, $user_mapping_array);
     
    14831469            if (isset($_POST['confirmation_data'])) {
    14841470
    1485                 parse_str(wp_unslash(sanitize_text_field($_POST['confirmation_data'])), $formdata);
     1471                parse_str( sanitize_text_field( wp_unslash( $_POST['confirmation_data'] ) ), $formdata );
    14861472               
    14871473                $post_id = $formdata['post_id'];
     
    15831569                foreach ($options as $value => $label) {
    15841570                    $selected = selected($status, $value, false);
    1585                     echo '<option value="' . esc_attr($value) . '" ' . $selected . '>' . esc_html($label) . '</option>';
     1571                    echo '<option value="' . esc_attr($value) . '" ' . esc_attr( $selected ) . '>' . esc_html($label) . '</option>';
    15861572                }
    15871573                echo '</select>';
    15881574
    1589                 $selected_form_id = isset($_GET['form_filter']) ? sanitize_text_field($_GET['form_filter']) : '';
     1575                $selected_form_id = isset( $_GET['form_filter'] ) ? sanitize_text_field( wp_unslash( $_GET['form_filter'] ) ) : '';
    15901576       
    15911577                $forms_query = new WP_Query($args);
     
    16221608            }
    16231609           
    1624             if ('edit.php' === $pagenow && 'manage_entries' === $typenow) {
    1625                 $booking_status = isset($_GET['booking_status']) ? sanitize_text_field($_GET['booking_status']) : '';
    1626                 $form_filter = isset($_GET['form_filter']) ? intval($_GET['form_filter']) : 0;
    1627 
    1628                 if (!empty($booking_status) || !empty($form_filter)) {
    1629                     $meta_query = array('relation' => 'and');
    1630 
    1631                     if (!empty($booking_status) && in_array($booking_status, array('booked', 'approved', 'cancelled', 'pending', 'waiting', 'submitted'))) {
     1610            if ( 'edit.php' === $pagenow && 'manage_entries' === $typenow ) {
     1611                $booking_status = isset( $_GET['booking_status'] ) ? sanitize_text_field( wp_unslash( $_GET['booking_status'] ) ) : '';
     1612                $form_filter = isset( $_GET['form_filter'] ) ? absint( wp_unslash( $_GET['form_filter'] ) ) : 0;
     1613
     1614                if ( ! empty( $booking_status ) || ! empty( $form_filter ) ) {
     1615                    // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Filtering entries by status/form requires meta_query.
     1616                    $meta_query = array( 'relation' => 'and' );
     1617
     1618                    if ( ! empty( $booking_status ) && in_array( $booking_status, array( 'booked', 'approved', 'cancelled', 'pending', 'waiting', 'submitted' ), true ) ) {
    16321619                        $meta_query[] = array(
    1633                             'key' => 'entry_status',
    1634                             'value' => $booking_status,
    1635                             'compare' => '='
     1620                            'key'     => 'entry_status',
     1621                            'value'   => $booking_status,
     1622                            'compare' => '=',
    16361623                        );
    16371624                    }
    16381625
    1639                     if (!empty($form_filter)) {
     1626                    if ( ! empty( $form_filter ) ) {
    16401627                        $meta_query[] = array(
    1641                             'key' => 'saab_form_id',
    1642                             'value' => $form_filter,
    1643                             'compare' => '='
     1628                            'key'     => 'saab_form_id',
     1629                            'value'   => $form_filter,
     1630                            'compare' => '=',
    16441631                        );
    16451632                    }
    16461633
    1647                     $query->set('meta_query', $meta_query);
     1634                    $query->set( 'meta_query', $meta_query );
    16481635                }
    16491636            }
     
    17001687            // Define the current page number
    17011688           
    1702             $current_page = isset($_POST['page']) ? absint($_POST['page']) : 1;
    1703             $timeslot = isset($_POST['timeslot']) ? sanitize_text_field($_POST['timeslot']) : '';
    1704             $booking_date = isset($_POST['booking_date']) ? sanitize_text_field($_POST['booking_date']) : '';
    1705 
     1689            $current_page = isset( $_POST['page'] ) ? absint( wp_unslash( $_POST['page'] ) ) : 1;
     1690            $timeslot = isset( $_POST['timeslot'] ) ? sanitize_text_field( wp_unslash( $_POST['timeslot'] ) ) : '';
     1691            $booking_date = isset( $_POST['booking_date'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_date'] ) ) : '';
     1692
     1693            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Waiting list filtered by timeslot/booking_date.
    17061694            $args = array(
    1707                 'post_type' => 'manage_entries',
    1708                 'posts_per_page' => 5, // Show 5 entries per page
    1709                 'paged' => $current_page, // Use the current page number for pagination
    1710                 'meta_query' => array(
     1695                'post_type'      => 'manage_entries',
     1696                'posts_per_page' => 5,
     1697                'paged'          => $current_page,
     1698                'meta_query'     => array(
    17111699                    'relation' => 'AND',
    17121700                    array(
    1713                         'key' => 'timeslot',
    1714                         'value' => $timeslot,
    1715                         'compare' => '='
     1701                        'key'     => 'timeslot',
     1702                        'value'   => $timeslot,
     1703                        'compare' => '=',
    17161704                    ),
    17171705                    array(
    1718                         'key' => 'booking_date',
    1719                         'value' => $booking_date,
    1720                         'compare' => '='
    1721                     )
    1722                 )
    1723             );     
    1724 
    1725             $query = new WP_Query($args);
     1706                        'key'     => 'booking_date',
     1707                        'value'   => $booking_date,
     1708                        'compare' => '=',
     1709                    ),
     1710                ),
     1711            );
     1712
     1713            $query = new WP_Query( $args );
    17261714            ob_start();
    17271715            if ($query->have_posts()) {
  • smart-appointment-booking/tags/1.0.8/inc/admin/class.saab.admin.fieldmeta.php

    r3154282 r3450387  
    2626
    2727        function saab_get_available_seats_per_timeslot($checktimeslot,$date){
    28            
     28            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Seats count filtered by timeslot/booking_date.
    2929            $args = array(
    30                 'post_type' => 'manage_entries',
     30                'post_type'      => 'manage_entries',
    3131                'posts_per_page' => -1,
    32                 'meta_query' => array(
     32                'meta_query'     => array(
    3333                    'relation' => 'AND',
    3434                    array(
     
    234234                    <div id="waitinglist_main">
    235235                    <?php
    236                        
    237                        $current_page = isset($_GET['page']) ? absint($_GET['page']) : 1;
     236                       // Pagination; nonce not used for GET page parameter in admin list.
     237                       // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     238                       $current_page = isset( $_GET['page'] ) ? absint( wp_unslash( $_GET['page'] ) ) : 1;
     239                       // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Waiting list filtered by timeslot/status/booking_date.
    238240                       $args = array(
    239                         'post_type' => 'manage_entries',
    240                         'posts_per_page' => 5, 
    241                         'paged' => $current_page,
    242                         'orderby'   => 'date',
    243                         'order'     => 'ASC',
    244                         'meta_query' => array(
     241                        'post_type'      => 'manage_entries',
     242                        'posts_per_page' => 5,
     243                        'paged'          => $current_page,
     244                        'orderby'        => 'date',
     245                        'order'          => 'ASC',
     246                        'meta_query'     => array(
    245247                            'relation' => 'AND',
    246248                            array(
     
    311313                            if ($total_pages > 1) {
    312314                               
    313                                     echo '<select id="saabpage-number"  data-timeslot="' . esc_attr($timeslot) . '" data-booking_date="' . esc_attr($booking_date) . '" data-nonce="'.wp_create_nonce('get_paginated_items_nonce').'">';
     315                                    echo '<select id="saabpage-number"  data-timeslot="' . esc_attr($timeslot) . '" data-booking_date="' . esc_attr($booking_date) . '" data-nonce="' . esc_attr( wp_create_nonce( 'get_paginated_items_nonce' ) ) . '">';
    314316                                        for ($page = 1; $page <= $total_pages; $page++) {
    315317                                            echo '<option value="' . esc_attr($page) . '"';
     
    352354                <script type='text/javascript'>
    353355                   
    354                     var myScriptData = <?php echo $myScriptData; ?>;
     356                    var myScriptData = <?php echo $myScriptData; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON schema from post meta, validated on save. ?>;
    355357                    window.onload = function() {
    356358                       
     
    587589                                        //echo wp_kses( $this->timezone_dropdown($post->ID), $allow_time_dropdown );
    588590                                    ?>
    589                                     <?php echo $this->timezone_dropdown($post->ID); ?>
     591                                    <?php echo wp_kses_post( $this->timezone_dropdown( $post->ID ) ); ?>
    590592                                   
    591593                                </div>
     
    863865              return $post_id;
    864866            }
    865             if (isset($_POST['cal_title'])) {
    866                 $cal_title = sanitize_text_field($_POST['cal_title']);
    867                 update_post_meta($post_id, 'saab_cal_title', $cal_title);
    868             } 
    869            
    870             if (isset($_POST['cal_description'])) {
    871                 $cal_description = sanitize_text_field($_POST['cal_description']);
    872                 update_post_meta($post_id, 'saab_cal_description', $cal_description);
     867            if ( isset( $_POST['cal_title'] ) ) {
     868                $cal_title = sanitize_text_field( wp_unslash( $_POST['cal_title'] ) );
     869                update_post_meta( $post_id, 'saab_cal_title', $cal_title );
     870            }
     871
     872            if ( isset( $_POST['cal_description'] ) ) {
     873                $cal_description = sanitize_text_field( wp_unslash( $_POST['cal_description'] ) );
     874                update_post_meta( $post_id, 'saab_cal_description', $cal_description );
    873875            }
    874876            // Section Tab 1
     
    881883            }
    882884            //Weekdays
    883             if (isset($_POST['weekdays'])) {
    884                 $selected_weekdays = array_map('sanitize_text_field', $_POST['weekdays']);
    885                 update_post_meta($post_id, 'saab_weekdays', $selected_weekdays);
     885            if ( isset( $_POST['weekdays'] ) ) {
     886                $selected_weekdays = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['weekdays'] ) );
     887                update_post_meta( $post_id, 'saab_weekdays', $selected_weekdays );
    886888            } else {
    887889                update_post_meta($post_id, 'saab_weekdays', array());
     
    889891           
    890892            // Save the radio button value for appointment Type
    891             if (isset($_POST['appointment_type'])) {
    892                 $selected_option = sanitize_text_field($_POST['appointment_type']);
     893            if ( isset( $_POST['appointment_type'] ) ) {
     894                $selected_option = sanitize_text_field( wp_unslash( $_POST['appointment_type'] ) );
    893895                update_post_meta($post_id, 'saab_appointment_type', $selected_option);
    894896            }
    895897
    896898            // Save the  link value if Appointment Type "Virtual" is selected
    897             if (isset($_POST['virtual_link'])) {
    898                 $link_value = sanitize_text_field($_POST['virtual_link']);
     899            if ( isset( $_POST['virtual_link'] ) ) {
     900                $link_value = sanitize_text_field( wp_unslash( $_POST['virtual_link'] ) );
    899901                update_post_meta($post_id, 'saab_virtual_link', $link_value);
    900902            }
     
    902904            //Symbol
    903905            if ( isset( $_POST['label_symbol'] ) ) {
    904                 $label_symbol = sanitize_text_field( $_POST['label_symbol'] );
     906                $label_symbol = sanitize_text_field( wp_unslash( $_POST['label_symbol'] ) );
    905907                update_post_meta( $post_id, 'saab_label_symbol', $label_symbol );
    906908            }
     
    908910             //Symbol
    909911             if ( isset( $_POST['cost'] ) ) {
    910                 $cost = sanitize_text_field( $_POST['cost'] );
     912                $cost = sanitize_text_field( wp_unslash( $_POST['cost'] ) );
    911913                update_post_meta( $post_id, 'saab_cost', $cost );
    912914            }
    913915           
    914916            if ( isset( $_POST['timezone'] ) ) {
    915                 $timezone = sanitize_text_field( $_POST['timezone'] );
     917                $timezone = sanitize_text_field( wp_unslash( $_POST['timezone'] ) );
    916918                update_post_meta( $post_id, 'saab_timezone', $timezone );
    917919            }
    918920           
    919921            if ( isset( $_POST['bookmap_email'] ) ) {
    920                 $map_email = sanitize_text_field( $_POST['bookmap_email'] );
     922                $map_email = sanitize_text_field( wp_unslash( $_POST['bookmap_email'] ) );
    921923                update_post_meta( $post_id, 'saab_map_email', $map_email );             
    922924            }
    923925           
    924926            if ( isset( $_POST['cost'] ) ) {
    925                 $cost = sanitize_text_field( $_POST['cost'] );
     927                $cost = sanitize_text_field( wp_unslash( $_POST['cost'] ) );
    926928                update_post_meta( $post_id, 'saab_saab_cost', $cost );
    927929            }
    928            
     930
    929931            //selected_date
    930             if (isset($_POST['selected_date'])) {
    931                 update_post_meta($post_id, 'saab_selected_date', sanitize_text_field($_POST['selected_date']));
    932             }
    933            
    934             if (isset($_POST['start_time'])) {
    935                 update_post_meta($post_id, 'saab_start_time', sanitize_text_field($_POST['start_time']));
    936             }
    937            
    938             if (isset($_POST['end_time'])) {
    939                 update_post_meta($post_id, 'saab_end_time', sanitize_text_field($_POST['end_time']));
    940             }
    941            
     932            if ( isset( $_POST['selected_date'] ) ) {
     933                update_post_meta( $post_id, 'saab_selected_date', sanitize_text_field( wp_unslash( $_POST['selected_date'] ) ) );
     934            }
     935
     936            if ( isset( $_POST['start_time'] ) ) {
     937                update_post_meta( $post_id, 'saab_start_time', sanitize_text_field( wp_unslash( $_POST['start_time'] ) ) );
     938            }
     939
     940            if ( isset( $_POST['end_time'] ) ) {
     941                update_post_meta( $post_id, 'saab_end_time', sanitize_text_field( wp_unslash( $_POST['end_time'] ) ) );
     942            }
     943
    942944             //Steps Duration
    943945            if ( isset( $_POST['steps_duration'] ) ) {
    944                 $steps_duration = sanitize_text_field($_POST['steps_duration']);
     946                $steps_duration = map_deep( wp_unslash( $_POST['steps_duration'] ), 'sanitize_text_field' );
    945947                $sanitized_steps_duration = array(
    946948                    'hours' => sanitize_text_field( $steps_duration['hours'] ),
     
    952954            }
    953955            //timeslot_duration
    954             if ( isset( $_POST['booking_stops_after'] ) ) {
    955                 $booking_stops_after_duration = $_POST['booking_stops_after'];
     956            $booking_stops_after_duration = ( isset( $_POST['booking_stops_after'] ) && is_array( $_POST['booking_stops_after'] ) )
     957                ? map_deep( wp_unslash( $_POST['booking_stops_after'] ), 'sanitize_text_field' )
     958                : array();
     959            if ( ! empty( $booking_stops_after_duration ) ) {
    956960                $sanitized_booking_stops_after_duration = array(
    957                     'hours' => sanitize_text_field( $booking_stops_after_duration['hours'] ),
    958                     'minutes' => sanitize_text_field( $booking_stops_after_duration['minutes'] )
     961                    'hours' => isset( $booking_stops_after_duration['hours'] ) ? $booking_stops_after_duration['hours'] : '',
     962                    'minutes' => isset( $booking_stops_after_duration['minutes'] ) ? $booking_stops_after_duration['minutes'] : '',
    959963                );
    960964       
     
    963967            }
    964968            //timeslot_duration
    965             if ( isset( $_POST['timeslot_duration'] ) ) {
    966                 $timeslot_duration = sanitize_text_field($_POST['timeslot_duration']);
     969            if ( isset( $_POST['timeslot_duration'] ) && is_array( $_POST['timeslot_duration'] ) ) {
     970                $timeslot_duration = map_deep( wp_unslash( $_POST['timeslot_duration'] ), 'sanitize_text_field' );
    967971                $sanitized_timeslot_duration = array(
    968                     'hours' => sanitize_text_field( $timeslot_duration['hours'] ),
    969                     'minutes' => sanitize_text_field( $timeslot_duration['minutes'] )
     972                    'hours' => isset( $timeslot_duration['hours'] ) ? $timeslot_duration['hours'] : '',
     973                    'minutes' => isset( $timeslot_duration['minutes'] ) ? $timeslot_duration['minutes'] : '',
    970974                );
    971975       
     
    975979            //no_of_booking
    976980            if ( isset( $_POST['no_of_booking'] ) ) {
    977                 $selected_date = absint($_POST['no_of_booking']);
     981                $selected_date = absint( wp_unslash( $_POST['no_of_booking'] ) );
    978982                update_post_meta( $post_id, 'saab_no_of_booking', $selected_date );
    979983            }
    980984            //waiting List
    981             if (isset($_POST['waiting_list']) && filter_var($_POST['waiting_list'], FILTER_VALIDATE_BOOLEAN)) {
    982                 update_post_meta($post_id, 'saab_waiting_list', 1);
     985            if ( isset( $_POST['waiting_list'] ) && filter_var( wp_unslash( $_POST['waiting_list'] ), FILTER_VALIDATE_BOOLEAN ) ) {
     986                update_post_meta( $post_id, 'saab_waiting_list', 1 );
    983987            } else {
    984988                delete_post_meta($post_id, 'saab_waiting_list');
    985989            }
    986990            //timeslotBookingAllowed
    987             if (isset($_POST['timeslot_BookAllow']) && filter_var($_POST['timeslot_BookAllow'], FILTER_VALIDATE_BOOLEAN)) {
     991            if ( isset( $_POST['timeslot_BookAllow'] ) && filter_var( wp_unslash( $_POST['timeslot_BookAllow'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    988992                update_post_meta($post_id, 'saab_timeslot_BookAllow', 1);
    989993            } else {
     
    991995            }
    992996            //enable_auto_approve
    993             if (isset($_POST['enable_auto_approve']) && filter_var($_POST['enable_auto_approve'], FILTER_VALIDATE_BOOLEAN)) {
     997            if ( isset( $_POST['enable_auto_approve'] ) && filter_var( wp_unslash( $_POST['enable_auto_approve'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    994998                update_post_meta($post_id, 'saab_enable_auto_approve', 1);
    995999            } else {
     
    9971001            }
    9981002            //multiple breaks
    999             if (isset($_POST['breaktimeslots'])) {
    1000                 $breaktimeslots = sanitize_text_field($_POST['breaktimeslots']);
    1001            
    1002                 // Sanitize and save the values
     1003            if ( isset( $_POST['breaktimeslots'] ) && is_array( $_POST['breaktimeslots'] ) ) {
     1004                $breaktimeslots = map_deep( wp_unslash( $_POST['breaktimeslots'] ), 'sanitize_text_field' );
     1005
    10031006                $sanitized_breaktimeslots = array();
    1004                 foreach ($breaktimeslots as $breaktimeslot) {
    1005                     $breakstart_time = sanitize_text_field($breaktimeslot['start_time']);
    1006                     $breakend_time = sanitize_text_field($breaktimeslot['end_time']);
     1007                foreach ( $breaktimeslots as $breaktimeslot ) {
     1008                    $breakstart_time = isset( $breaktimeslot['start_time'] ) ? $breaktimeslot['start_time'] : '';
     1009                    $breakend_time = isset( $breaktimeslot['end_time'] ) ? $breaktimeslot['end_time'] : '';
    10071010                    $sanitized_breaktimeslots[] = array(
    10081011                        'start_time' => $breakstart_time,
     
    10241027                }
    10251028           
    1026                 if (isset($_POST['generatetimeslot'])) {
    1027                     $generatetimeslots = $_POST['generatetimeslot'];   
    1028                     // Sanitize and save the values
     1029                $generatetimeslots = ( isset( $_POST['generatetimeslot'] ) && is_array( $_POST['generatetimeslot'] ) )
     1030                    ? map_deep( wp_unslash( $_POST['generatetimeslot'] ), 'sanitize_text_field' )
     1031                    : array();
     1032                if ( ! empty( $generatetimeslots ) ) {
    10291033                    $sanitized_generatetimeslots = array();
    1030                     foreach ($generatetimeslots as $generatetimeslot) {
    1031                         $generatestart_time = $generatetimeslot['start_time'];
    1032                         $generateend_time = $generatetimeslot['end_time'];
     1034                    foreach ( $generatetimeslots as $generatetimeslot ) {
    10331035                        $sanitized_generatetimeslots[] = array(
    1034                         'start_time' => $generatestart_time,
    1035                         'end_time' => $generateend_time,
     1036                            'start_time' => isset( $generatetimeslot['start_time'] ) ? $generatetimeslot['start_time'] : '',
     1037                            'end_time' => isset( $generatetimeslot['end_time'] ) ? $generatetimeslot['end_time'] : '',
    10361038                        );
    10371039                    }           
     
    10511053               
    10521054            //Enable Recurring Events
    1053             if (isset($_POST['enable_recurring_apt']) && filter_var($_POST['enable_recurring_apt'], FILTER_VALIDATE_BOOLEAN)) {
     1055            if ( isset( $_POST['enable_recurring_apt'] ) && filter_var( wp_unslash( $_POST['enable_recurring_apt'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    10541056                update_post_meta($post_id, 'saab_enable_recurring_apt', 1);
    10551057            } else {
    10561058                delete_post_meta($post_id, 'saab_enable_recurring_apt');
    10571059            }
    1058             if (isset($_POST['enable_advance_setting']) && filter_var($_POST['enable_advance_setting'], FILTER_VALIDATE_BOOLEAN)) {
     1060            if ( isset( $_POST['enable_advance_setting'] ) && filter_var( wp_unslash( $_POST['enable_advance_setting'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    10591061                update_post_meta($post_id, 'saab_enable_advance_setting', 1);
    10601062            } else {
    10611063                delete_post_meta($post_id, 'saab_enable_advance_setting');
    10621064            }
    1063             if (isset($_POST['recurring_type'])) {
    1064                 $recurring_type = sanitize_text_field($_POST['recurring_type']);
    1065                 update_post_meta($post_id, 'saab_recurring_type', $recurring_type);
    1066             }
    1067             if (isset($_POST['recur_weekdays'])) {
    1068                 $sanitized_recur_weekdays = array_map('sanitize_text_field', $_POST['recur_weekdays']);
    1069                 update_post_meta($post_id, 'saab_recur_weekdays', $sanitized_recur_weekdays);
    1070             }
    1071             if (isset($_POST['advancedata'])) {               
    1072                 $advancedata = $_POST['advancedata'];               
    1073                 update_post_meta($post_id, 'saab_advancedata', $advancedata);
     1065            if ( isset( $_POST['recurring_type'] ) ) {
     1066                $recurring_type = sanitize_text_field( wp_unslash( $_POST['recurring_type'] ) );
     1067                update_post_meta( $post_id, 'saab_recurring_type', $recurring_type );
     1068            }
     1069            if ( isset( $_POST['recur_weekdays'] ) ) {
     1070                $sanitized_recur_weekdays = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['recur_weekdays'] ) );
     1071                update_post_meta( $post_id, 'saab_recur_weekdays', $sanitized_recur_weekdays );
     1072            }
     1073            if ( isset( $_POST['advancedata'] ) ) {
     1074                $advancedata = is_array( $_POST['advancedata'] )
     1075                    ? map_deep( wp_unslash( $_POST['advancedata'] ), 'sanitize_text_field' )
     1076                    : sanitize_text_field( wp_unslash( $_POST['advancedata'] ) );
     1077                update_post_meta( $post_id, 'saab_advancedata', $advancedata );
    10741078            }else {
    10751079                delete_post_meta($post_id, 'saab_advancedata');
    10761080            }
    1077             if (isset($_POST['holidays'])) {
    1078                 $holidays = array_map('sanitize_text_field', $_POST['holidays']);
     1081            if ( isset( $_POST['holidays'] ) ) {
     1082                $holidays = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['holidays'] ) );
    10791083                update_post_meta($post_id, 'saab_holiday_dates', $holidays);
    10801084            }
    1081             if (isset($_POST['end_repeats'])) {
    1082                 $end_repeats = sanitize_text_field($_POST['end_repeats']);
     1085            if ( isset( $_POST['end_repeats'] ) ) {
     1086                $end_repeats = sanitize_text_field( wp_unslash( $_POST['end_repeats'] ) );
    10831087                update_post_meta($post_id, 'saab_end_repeats', $end_repeats);
    10841088            }
    1085             if (isset($_POST['end_repeats_on'])) {
    1086                 $end_repeats_on = sanitize_text_field($_POST['end_repeats_on']);
     1089            if ( isset( $_POST['end_repeats_on'] ) ) {
     1090                $end_repeats_on = sanitize_text_field( wp_unslash( $_POST['end_repeats_on'] ) );
    10871091                update_post_meta($post_id, 'saab_end_repeats_on', $end_repeats_on);
    10881092            }
    1089             if (isset($_POST['end_repeats_after'])) {
    1090                 $end_repeats_after = sanitize_text_field($_POST['end_repeats_after']);
     1093            if ( isset( $_POST['end_repeats_after'] ) ) {
     1094                $end_repeats_after = sanitize_text_field( wp_unslash( $_POST['end_repeats_after'] ) );
    10911095                update_post_meta($post_id, 'saab_end_repeats_after', $end_repeats_after);
    10921096            }
     
    11111115            }
    11121116
    1113             if (isset($_POST['notes'])) {
    1114                 $notes = sanitize_textarea_field($_POST['notes']);
     1117            if ( isset( $_POST['notes'] ) ) {
     1118                $notes = sanitize_textarea_field( wp_unslash( $_POST['notes'] ) );
    11151119                update_post_meta($post_id, 'saab_notes', $notes);
    11161120            }
    11171121           
    1118             if (isset($_POST['form_id'])) {
    1119                 $form_id = sanitize_text_field($_POST['form_id']);
    1120             }
    1121            
    1122             if (isset($_POST['no_of_bookings'])) {
    1123                 $no_of_bookings = absint($_POST['no_of_bookings']);
     1122            if ( isset( $_POST['form_id'] ) ) {
     1123                $form_id = sanitize_text_field( wp_unslash( $_POST['form_id'] ) );
     1124            }
     1125           
     1126            if ( isset( $_POST['no_of_bookings'] ) ) {
     1127                $no_of_bookings = absint( wp_unslash( $_POST['no_of_bookings'] ) );
    11241128                update_post_meta($post_id, 'saab_slotcapacity', $no_of_bookings);
    11251129            }
    11261130           
    1127             if (isset($_POST['booking_date'])) {
    1128                 $booking_date = sanitize_text_field($_POST['booking_date']);
     1131            if ( isset( $_POST['booking_date'] ) ) {
     1132                $booking_date = sanitize_text_field( wp_unslash( $_POST['booking_date'] ) );
    11291133                $currentMonth = gmdate('n',strtotime($booking_date));
    11301134                $currentYear = gmdate('Y',strtotime($booking_date));
     
    11331137                update_post_meta($post_id, 'saab_booking_date', $booking_date);
    11341138            }
    1135             if (isset($_POST['start_time']) && isset($_POST['end_time'])) {
    1136                 $start_time = trim(gmdate("h:i A", strtotime( sanitize_text_field($_POST['start_time']) )));
    1137                 $end_time = trim(gmdate("h:i A", strtotime( sanitize_text_field($_POST['end_time']) )));
     1139            if ( isset( $_POST['start_time'] ) && isset( $_POST['end_time'] ) ) {
     1140                $start_time = trim( gmdate( 'h:i A', strtotime( sanitize_text_field( wp_unslash( $_POST['start_time'] ) ) ) ) );
     1141                $end_time  = trim( gmdate( 'h:i A', strtotime( sanitize_text_field( wp_unslash( $_POST['end_time'] ) ) ) ) );
    11381142                $timeslot = $start_time.'-'.$end_time;
    11391143                update_post_meta($post_id, 'saab_timeslot', $timeslot);
    11401144            }
    11411145         
    1142             if (isset($_POST['manual_notification']) &&  sanitize_text_field($_POST['manual_notification']  !== 'any')) {
    1143                 $selected_action = isset($_POST['manual_notification']) ? sanitize_text_field($_POST['manual_notification']) : '';
    1144                 $booking_status = isset($_POST['booking_status']) ? sanitize_text_field($_POST['booking_status']) : '';
    1145                 // update_post_meta($post_id, 'saab_entry_status', $booking_status);               
    1146                 $bookingId = isset($_POST['post_id']) ? absint($_POST['post_id']) : '';                 
    1147                 $status = isset($_POST['status']) ? sanitize_text_field($_POST['status']) : '';                 
     1146            if ( isset( $_POST['manual_notification'] ) && sanitize_text_field( wp_unslash( $_POST['manual_notification'] ) ) !== 'any' ) {
     1147                $selected_action  = isset( $_POST['manual_notification'] ) ? sanitize_text_field( wp_unslash( $_POST['manual_notification'] ) ) : '';
     1148                $booking_status  = isset( $_POST['booking_status'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_status'] ) ) : '';
     1149                // update_post_meta($post_id, 'saab_entry_status', $booking_status);
     1150                $bookingId       = isset( $_POST['post_id'] ) ? absint( wp_unslash( $_POST['post_id'] ) ) : 0;
     1151                $status          = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : '';                 
    11481152                $formdata = get_post_meta($bookingId,'saab_submission_data',true);               
    11491153                $listform_label_val =$this->saab_admin_getkey_value_formshortcodes($post_id,$formdata);
     
    11531157                update_post_meta($post_id, 'saab_manual_notification', $selected_action);
    11541158               
    1155             }else{
    1156                 $booking_status = isset($_POST['booking_status']) ? sanitize_text_field($_POST['booking_status']) : '';
    1157                 update_post_meta($post_id, 'saab_entry_status', $booking_status);
     1159            } else {
     1160                $booking_status = isset( $_POST['booking_status'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_status'] ) ) : '';
     1161                update_post_meta( $post_id, 'saab_entry_status', $booking_status );
    11581162                $formdata = get_post_meta($post_id,'saab_submission_data',true);
    11591163                $listform_label_val =$this->saab_admin_getkey_value_formshortcodes($post_id,$formdata);
     
    13021306                    } else {
    13031307                        $message = esc_html__('Failed to send email','smart-appointment-booking');
    1304                         error_log('Failed to send email');
     1308                        // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1309                        error_log( 'Failed to send email' );
    13051310                    }
    13061311                }
    13071312                       
    13081313            }
    1309             if ($notificationFound === false) {
    1310                 $message = esc_html__('Notification not found for the given status', 'smart-appointment-booking');
    1311                 error_log('Notification not found for the given status');
     1314            if ( $notificationFound === false ) {
     1315                $message = esc_html__( 'Notification not found for the given status', 'smart-appointment-booking' );
     1316                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1317                error_log( 'Notification not found for the given status' );
    13121318            }
    13131319            return $message;
  • smart-appointment-booking/tags/1.0.8/inc/class.saab.php

    r3014693 r3450387  
    5353            global $wp_version;
    5454
    55             # Set filter for plugin's languages directory
    56             $SAAB_lang_dir = dirname( SAAB_PLUGIN_BASENAME ) . '/languages/';
    57             $SAAB_lang_dir = apply_filters( 'SAAB_languages_directory', $SAAB_lang_dir );
    58 
    5955            # Traditional WordPress plugin locale filter.
    6056            $get_locale = get_locale();
     
    7470                # Look in global /wp-content/languages/plugin-name folder
    7571                load_textdomain( 'smart-appointment-booking', $mofile_global );
    76             } else {
    77                 # Load the default language files
    78                 load_plugin_textdomain( 'smart-appointment-booking', false, $SAAB_lang_dir );
    7972            }
     73            # When hosted on WordPress.org, translations are loaded automatically; no load_plugin_textdomain() needed.
    8074        }
    8175    }
  • smart-appointment-booking/tags/1.0.8/inc/front/class.saab.front.action.php

    r3154282 r3450387  
    110110            ob_start();
    111111            $user_id = get_current_user_id();
    112             $post_ids = array();
     112            $post_ids = array();
     113            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- User's bookings filtered by user_mapped meta.
    113114            $args = array(
    114                 'post_type' => 'manage_entries',
    115                 'meta_key' => 'user_mapped',
    116                 'meta_value' => $user_id,
    117                 'fields' => 'ids',
     115                'post_type'      => 'manage_entries',
     116                'meta_key'       => 'user_mapped',
     117                'meta_value'     => $user_id,
     118                'fields'         => 'ids',
    118119                'posts_per_page' => 55,
    119120            );
    120        
    121             $query = new WP_Query($args);
     121
     122            $query = new WP_Query( $args );
    122123       
    123124            if ($query->have_posts()) {
     
    269270        }
    270271
    271         function saab_save_form_submission() { 
    272             // ini_set('display_startup_errors', 1);
    273             // ini_set('display_errors', 1);
    274             // error_reporting(-1);
    275         //if( ! wp_verify_nonce( 'saab_front_nonce' ) ){} // ignoring nonce validation error in the front form     
    276         $form_id = ( isset( $_POST['fid'] ) ) ? $_POST['fid'] : '';
    277         $form_data = ( isset( $_POST['form_data'] ) ) ? $_POST['form_data'] : '';
     272        function saab_save_form_submission() {
     273            $nonce_key = isset( $_POST['nonce'] ) ? 'nonce' : ( isset( $_POST['security'] ) ? 'security' : '' );
     274            $nonce_val = ( $nonce_key && isset( $_POST[ $nonce_key ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ $nonce_key ] ) ) : '';
     275            if ( ! $nonce_val || ! wp_verify_nonce( $nonce_val, 'my_ajax_nonce' ) ) {
     276                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     277                wp_die();
     278            }
     279            $form_id = isset( $_POST['fid'] ) ? absint( wp_unslash( $_POST['fid'] ) ) : 0;
     280            $form_data = isset( $_POST['form_data'] ) && is_array( $_POST['form_data'] ) ? map_deep( wp_unslash( $_POST['form_data'] ), 'sanitize_text_field' ) : array();
    278281        // User
    279282        $is_user_logged_in = is_user_logged_in();
     
    345348                                $usererror = true;
    346349                                wp_send_json_error(array(
    347                                     'message' => __('Error creating user '. $user_id->get_error_message(),'smart-appointment-booking'),
     350                                    'message' => sprintf(
     351                                        /* translators: %s: error message from user creation */
     352                                        __( 'Error creating user %s', 'smart-appointment-booking' ),
     353                                        $user_id->get_error_message()
     354                                    ),
    348355                                    'error' => $usererror,
    349356                                ));
     
    586593            // }
    587594            if(empty($saab_amount)){
    588                 $error_message = "Amount configuration Error";
    589595                wp_delete_post($created_post_id, true);
    590596                wp_send_json_error(array(
    591                     'message' => __($error_message, 'smart-appointment-booking'),
     597                    'message' => __( 'Amount configuration Error', 'smart-appointment-booking' ),
    592598                    'error' => true,
    593599                ));
    594600            }
    595             $stripetoken = ( isset( $_POST['token'] ) ) ? $_POST['token'] : '';
     601            $stripetoken = isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';
    596602            // Set your Stripe Publishable key
    597603            SabStripe::setApiKey($secretKey); // Replace with your Stripe API key
     
    637643
    638644            }catch ( Exception $e ) {
    639                 $error_message = $e->getMessage();
    640645                wp_delete_post($created_post_id, true);
    641646                wp_send_json_error(array(
    642                     'message' => __($error_message, 'smart-appointment-booking'),
     647                    'message' => sprintf(
     648                        /* translators: %s: payment exception error message */
     649                        __( 'Payment error: %s', 'smart-appointment-booking' ),
     650                        $e->getMessage()
     651                    ),
    643652                    'error' => true,
    644653                ));
     
    745754           
    746755        function saab_booking_form_submission() {
    747 //          ini_set('display_startup_errors', 1);
    748 // ini_set('display_errors', 1);
    749 // error_reporting(-1);
    750             $error ='';
    751            // if( ! wp_verify_nonce( 'saab_front_nonce' ) ){}
    752             $booking_date = ( isset( $_POST['booking_date'] ) ) ? $_POST['booking_date'] : '';
    753             $explode_booking_date = explode('_',$booking_date);
    754             $form_id = $explode_booking_date[1];
    755             $format_bookingdate = $explode_booking_date[4] . "-" . $explode_booking_date[2] . "-" . $explode_booking_date[3];
    756             $converted_bookingdate = date('Y-m-d', strtotime($format_bookingdate));
    757             $timeslot = ( isset( $_POST['timeslot'] ) ) ? $_POST['timeslot'] : '';
    758             //total availableseats
    759             $slotcapacity = ( isset( $_POST['slotcapacity'] ) ) ? $_POST['slotcapacity'] : '';
    760             //quantity
    761             $bookedseats = ( isset( $_POST['bookedseats'] ) )? $_POST['bookedseats'] : '' ;
    762             $form_id = isset($_POST['fid']) ? absint($_POST['fid']) : 0;
    763             $form_data = isset( $_POST['form_data'] ) ? $_POST['form_data']:'';
    764             if (is_array($form_data)) {
     756            $nonce_key = isset( $_POST['nonce'] ) ? 'nonce' : ( isset( $_POST['security'] ) ? 'security' : '' );
     757            $nonce_val = ( $nonce_key && isset( $_POST[ $nonce_key ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ $nonce_key ] ) ) : '';
     758            if ( ! $nonce_val || ! wp_verify_nonce( $nonce_val, 'my_ajax_nonce' ) ) {
     759                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     760                wp_die();
     761            }
     762            $error = '';
     763            $booking_date = isset( $_POST['booking_date'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_date'] ) ) : '';
     764            $explode_booking_date = explode( '_', $booking_date );
     765            $form_id = isset( $explode_booking_date[1] ) ? absint( $explode_booking_date[1] ) : 0;
     766            $format_bookingdate = ( isset( $explode_booking_date[4], $explode_booking_date[2], $explode_booking_date[3] ) ) ? $explode_booking_date[4] . '-' . $explode_booking_date[2] . '-' . $explode_booking_date[3] : '';
     767            $converted_bookingdate = $format_bookingdate ? gmdate( 'Y-m-d', strtotime( $format_bookingdate ) ) : '';
     768            $timeslot = isset( $_POST['timeslot'] ) ? sanitize_text_field( wp_unslash( $_POST['timeslot'] ) ) : '';
     769            $slotcapacity = isset( $_POST['slotcapacity'] ) ? sanitize_text_field( wp_unslash( $_POST['slotcapacity'] ) ) : '';
     770            $bookedseats = isset( $_POST['bookedseats'] ) ? sanitize_text_field( wp_unslash( $_POST['bookedseats'] ) ) : '';
     771            $form_id = isset( $_POST['fid'] ) ? absint( wp_unslash( $_POST['fid'] ) ) : $form_id;
     772            $form_data = isset( $_POST['form_data'] ) ? wp_unslash( $_POST['form_data'] ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized in loop below
     773            if ( is_array( $form_data ) ) {
    765774                foreach ($form_data as $field_name => $field_value) {
    766775                    // Check if the field value is an array (e.g., for checkboxes or multi-select)
     
    989998        }
    990999        function saab_add_event_to_calender(){
    991 
     1000            // OAuth callback from Google; code/state are from redirect, not form POST. Nonce not applicable.
     1001            // phpcs:disable WordPress.Security.NonceVerification.Recommended
    9921002            ob_start();
    9931003
    994             if(isset($_GET['code'])){
    995 
    996                 require_once SAAB_DIR . '/inc/lib/google-library/vendor/autoload.php';             
    997                 $stateParameter = ( isset( $_GET['state'] ) ) ? $_GET['state'] : '';
     1004            if ( isset( $_GET['code'] ) ) {
     1005                require_once SAAB_DIR . '/inc/lib/google-library/vendor/autoload.php';
     1006                $stateParameter = isset( $_GET['state'] ) ? sanitize_text_field( wp_unslash( $_GET['state'] ) ) : '';
    9981007                $mystate = explode('T', $stateParameter);
    9991008                $form_id = $mystate[0];
     
    10401049                $client_new->setAccessType('offline');
    10411050
    1042                 if (isset($_GET['code'])) {
    1043 
    1044                     $token = $client_new->fetchAccessTokenWithAuthCode($_GET['code']);   
     1051                if ( isset( $_GET['code'] ) ) {
     1052                    $auth_code = sanitize_text_field( wp_unslash( $_GET['code'] ) );
     1053                    $token = $client_new->fetchAccessTokenWithAuthCode( $auth_code );   
    10451054                    $client_new->setAccessToken($token);   
    10461055                    $service = new Google_Service_Calendar($client_new);
     
    11041113                }
    11051114            }
     1115            // phpcs:enable WordPress.Security.NonceVerification.Recommended
    11061116            return ob_get_clean();
    11071117        }
     
    11171127         */
    11181128        function saab_send_notification($status, $form_id, $post_id, $form_data) {
    1119             // Sanitize the status value from $_POST, if applicable
    1120             $status = (isset($_POST['status']) && !empty($_POST['status'])) ? sanitize_text_field($_POST['status']) : $status;
    1121            
    1122             // Log status to ensure it's being received correctly
    1123             if (defined('WP_DEBUG') && WP_DEBUG) {
    1124                 error_log('Status received: ' . $status);
    1125             }
    1126        
     1129            // Status may be overridden from POST; nonce verified in calling AJAX handler.
     1130            // phpcs:ignore WordPress.Security.NonceVerification.Missing
     1131            $status = ( isset( $_POST['status'] ) && ! empty( $_POST['status'] ) ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : $status;
     1132
     1133            // Log status to ensure it's being received correctly.
     1134            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1135                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1136                error_log( 'Status received: ' . $status );
     1137            }
     1138
    11271139            $message = '';
    11281140            $notificationFound = false;
    1129        
     1141
    11301142            // Get notification data
    1131             $get_notification_array = get_post_meta($form_id, 'saab_notification_data', true);
    1132            
    1133             // Log the retrieved notification data for debugging
    1134             if (defined('WP_DEBUG') && WP_DEBUG) {
    1135                 error_log('Notification array: ' . print_r($get_notification_array, true));
     1143            $get_notification_array = get_post_meta( $form_id, 'saab_notification_data', true );
     1144
     1145            // Log the retrieved notification data for debugging.
     1146            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1147                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
     1148                error_log( 'Notification array: ' . print_r( $get_notification_array, true ) );
    11361149            }
    11371150       
     
    11431156                        $notificationFound = true; // Mark notification as found
    11441157       
    1145                         // Log notification for debugging
    1146                         if (defined('WP_DEBUG') && WP_DEBUG) {
    1147                             error_log('Notification found: ' . print_r($notification, true));
     1158                        // Log notification for debugging.
     1159                        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1160                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
     1161                            error_log( 'Notification found: ' . print_r( $notification, true ) );
    11481162                        }
    11491163                       
     
    11671181                        $check_body = $this->saab_check_shortcodes_exist_in_editor($check_body, $form_id, $form_data, $shortcodesArray);
    11681182       
    1169                         // Log email details for debugging
    1170                         if (defined('WP_DEBUG') && WP_DEBUG) {
    1171                             error_log('Email details: to: ' . $to . ', from: ' . $from . ', subject: ' . $subject . ', body: ' . $check_body);
     1183                        // Log email details for debugging.
     1184                        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1185                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1186                            error_log( 'Email details: to: ' . $to . ', from: ' . $from . ', subject: ' . $subject . ', body: ' . $check_body );
    11721187                        }
    1173        
     1188
    11741189                        // Set email headers
    11751190                        $headers = array(
     
    11931208                            $message = esc_html__('Email sent successfully', 'smart-appointment-booking');
    11941209                        } else {
    1195                             $message = esc_html__('Failed to send email', 'smart-appointment-booking');
    1196                             if (defined('WP_DEBUG') && WP_DEBUG) {
    1197                                 error_log('Failed to send email to: ' . $to); // Debug logging
     1210                            $message = esc_html__( 'Failed to send email', 'smart-appointment-booking' );
     1211                            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1212                                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1213                                error_log( 'Failed to send email to: ' . $to );
    11981214                            }
    11991215                        }
     
    12011217                }
    12021218            } else {
    1203                 // Log an error if no notification data was found for the form
    1204                 if (defined('WP_DEBUG') && WP_DEBUG) {
    1205                     error_log('No notification data found for form ID: ' . $form_id);
    1206                 }
    1207             }
    1208        
    1209             // If no notification was found, log an error
    1210             if ($notificationFound === false) {
    1211                 $message = __('Notification not found for the given status: ' . $status, 'smart-appointment-booking');
    1212                 if (defined('WP_DEBUG') && WP_DEBUG) {
    1213                     error_log('Notification not found for the given status: ' . $status); // Debug logging
    1214                 }
    1215                 wp_send_json_error(array('message' => $message));
     1219                // Log an error if no notification data was found for the form.
     1220                if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1221                    // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1222                    error_log( 'No notification data found for form ID: ' . $form_id );
     1223                }
     1224            }
     1225
     1226            // If no notification was found, log an error.
     1227            if ( $notificationFound === false ) {
     1228                $message = sprintf(
     1229                    /* translators: %s: notification status (e.g. booked, approved, cancelled) */
     1230                    __( 'Notification not found for the given status: %s', 'smart-appointment-booking' ),
     1231                    $status
     1232                );
     1233                if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1234                    // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1235                    error_log( 'Notification not found for the given status: ' . $status );
     1236                }
     1237                wp_send_json_error( array( 'message' => $message ) );
    12161238                wp_die();
    12171239            }
     
    12251247       
    12261248        function saab_send_post_update_notification($status, $form_id, $post_id, $form_data) {
    1227             // Sanitize status and other input data
    1228             $status = (isset($_POST['status']) && !empty($_POST['status'])) ? sanitize_text_field($_POST['status']) : sanitize_text_field($status);
     1249            // Status may be overridden from POST; nonce verified in calling AJAX handler.
     1250            // phpcs:ignore WordPress.Security.NonceVerification.Missing
     1251            $status = ( isset( $_POST['status'] ) && ! empty( $_POST['status'] ) ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : sanitize_text_field( $status );
    12291252            $message = '';
    12301253       
     
    12841307                        } else {
    12851308                            // Log details if email sending fails
    1286                             $message = __('Failed to send email. Details: to-' . $to . ', from-' . $from . ', Bcc-' . $bcc . ', Cc-' . $cc . ', subject-' . $subject . ', body-' . $check_body . ', headers-' . json_encode($headers), 'smart-appointment-booking');
    1287                             if (defined('WP_DEBUG') && WP_DEBUG) {
    1288                                 error_log('Failed to send email. Details: to-' . $to . ', from-' . $from . ', Bcc-' . $bcc . ', Cc-' . $cc . ', subject-' . $subject . ', body-' . $check_body . ', headers-' . json_encode($headers));
     1309                            $message = sprintf(
     1310                                /* translators: 1: to address, 2: from address, 3: Bcc, 4: Cc, 5: subject, 6: body, 7: headers */
     1311                                __( 'Failed to send email. Details: to-%1$s, from-%2$s, Bcc-%3$s, Cc-%4$s, subject-%5$s, body-%6$s, headers-%7$s', 'smart-appointment-booking' ),
     1312                                $to,
     1313                                $from,
     1314                                $bcc,
     1315                                $cc,
     1316                                $subject,
     1317                                $check_body,
     1318                                wp_json_encode( $headers )
     1319                            );
     1320                            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1321                                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1322                                error_log( 'Failed to send email. Details: to-' . $to . ', from-' . $from . ', Bcc-' . $bcc . ', Cc-' . $cc . ', subject-' . $subject . ', body-' . $check_body . ', headers-' . wp_json_encode( $headers ) );
    12891323                            }
    12901324                        }
     
    12941328       
    12951329            // Handle case where no matching notification is found
    1296             if ($notificationFound === false) {
    1297                 $message = __('Notification not found for the given status: ' . $status, 'smart-appointment-booking');
    1298                 if (defined('WP_DEBUG') && WP_DEBUG) {
    1299                     error_log('Notification not found for the given status: ' . $status);
    1300                 }
    1301             }
    1302        
     1330            if ( $notificationFound === false ) {
     1331                $message = sprintf(
     1332                    /* translators: %s: notification status (e.g. booked, approved, cancelled) */
     1333                    __( 'Notification not found for the given status: %s', 'smart-appointment-booking' ),
     1334                    $status
     1335                );
     1336                if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1337                    // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1338                    error_log( 'Notification not found for the given status: ' . $status );
     1339                }
     1340            }
     1341
    13031342            return $message;
    13041343        }
    1305        
     1344
    13061345        /**
    13071346         * Process the given field value containing shortcodes and replace them with actual values.
     
    21132152                            $timezone = get_post_meta($post_id,'saab_timezone',true);
    21142153                            $error = false;
    2115                             $TodaysDate = date('F d, Y');   
    2116                             $todaysDate = date('Y-m-d');
     2154                            $TodaysDate = gmdate( 'F d, Y' );
     2155                            $todaysDate = gmdate( 'Y-m-d' );
    21172156                            echo "<h3 id='head_avail_time'><span class='gfb-timezone'>Timezone: " . esc_attr($timezone) . "</span></h3>";
    21182157                            echo "<h4 id='headtodays_date'>" . esc_html($TodaysDate) . "</h4>";                             
     
    23262365                12 => 'December'
    23272366                );
    2328                 $currentMonth = isset($_POST['currentMonth']) ? intval($_POST['currentMonth']) : date('n'); //phpcs:ignore
    2329                 $currentMonth = max(1, min(12, $currentMonth)); // Ensure currentMonth is between 1 and 12
    2330                 $currentYear = isset($_POST['currentYear']) ? intval($_POST['currentYear']) : date('Y'); //phpcs:ignore
    2331                 $post_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
     2367                // phpcs:disable WordPress.Security.NonceVerification.Missing -- Calendar month/year/form_id from AJAX; nonce verified in caller or optional display.
     2368                $currentMonth = isset( $_POST['currentMonth'] ) ? max( 1, min( 12, intval( wp_unslash( $_POST['currentMonth'] ) ) ) ) : (int) gmdate( 'n' );
     2369                $currentYear  = isset( $_POST['currentYear'] ) ? absint( wp_unslash( $_POST['currentYear'] ) ) : (int) gmdate( 'Y' );
     2370                $post_id = isset( $_POST['form_id'] ) ? absint( wp_unslash( $_POST['form_id'] ) ) : 0;
     2371                // phpcs:enable WordPress.Security.NonceVerification.Missing
    23322372                $running_year = date("Y"); //phpcs:ignore
    23332373                ob_start();
     
    24272467         */
    24282468          function saab_action_display_available_timeslots(){
    2429             ini_set('display_startup_errors', 1);
    2430 ini_set('display_errors', 1);
    2431 error_reporting(-1);       
    2432                 //if( ! wp_verify_nonce( 'saab_front_nonce' ) ){}
     2469            $nonce_key = isset( $_POST['nonce'] ) ? 'nonce' : ( isset( $_POST['security'] ) ? 'security' : '' );
     2470            $nonce_val = ( $nonce_key && isset( $_POST[ $nonce_key ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ $nonce_key ] ) ) : '';
     2471            if ( ! $nonce_val || ! wp_verify_nonce( $nonce_val, 'my_ajax_nonce' ) ) {
     2472                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     2473                wp_die();
     2474            }
    24332475                $error = false;
    2434                 if(isset( $_POST['form_data'])){
    2435                     $form_data = $_POST['form_data'];
    2436                     $array_data = explode('_',$form_data);
    2437                     $post_id = $array_data[1];
    2438                     $current_month = $array_data[2];
    2439                     $current_day = $array_data[3];
    2440                     $current_year = $array_data[4];
    2441                 }
    2442                 if(isset( $_POST['clickedId'])){
    2443                     $clickedId = $_POST['clickedId'];
     2476                $post_id = 0;
     2477                $current_month = '';
     2478                $current_day = '';
     2479                $current_year = '';
     2480                $clickedId = '';
     2481                if ( isset( $_POST['form_data'] ) ) {
     2482                    $form_data = sanitize_text_field( wp_unslash( $_POST['form_data'] ) );
     2483                    $array_data = explode( '_', $form_data );
     2484                    $post_id = isset( $array_data[1] ) ? absint( $array_data[1] ) : 0;
     2485                    $current_month = isset( $array_data[2] ) ? sanitize_text_field( $array_data[2] ) : '';
     2486                    $current_day = isset( $array_data[3] ) ? sanitize_text_field( $array_data[3] ) : '';
     2487                    $current_year = isset( $array_data[4] ) ? sanitize_text_field( $array_data[4] ) : '';
     2488                }
     2489                if ( isset( $_POST['clickedId'] ) ) {
     2490                    $clickedId = sanitize_text_field( wp_unslash( $_POST['clickedId'] ) );
    24442491                }
    24452492                $todaysDate = date('Y-m-d', strtotime("$current_year-$current_month-$current_day")); //phpcs:ignore
     
    25232570            $response = array();
    25242571       
    2525             if (isset($_POST['bookingId']) && isset($_POST['bookingstatus'])) {
     2572            if ( isset( $_POST['bookingId'] ) && isset( $_POST['bookingstatus'] ) ) {
    25262573                // $booking_id = wp_base64_decode($encrypt_bookingId);
    2527                 $booking_id = $encrypt_bookingId;
    2528                 $bookingstatus = isset($_POST['bookingstatus']) ? sanitize_text_field($_POST['bookingstatus']) : '';
    2529        
    2530                 if ($bookingstatus === 'cancel') {
    2531                     if (isset($_POST['status'])) {
    2532                         $status = sanitize_text_field($_POST['status']);
     2574                $booking_id    = $encrypt_bookingId;
     2575                $bookingstatus = isset( $_POST['bookingstatus'] ) ? sanitize_text_field( wp_unslash( $_POST['bookingstatus'] ) ) : '';
     2576
     2577                if ( $bookingstatus === 'cancel' ) {
     2578                    if ( isset( $_POST['status'] ) ) {
     2579                        $status = sanitize_text_field( wp_unslash( $_POST['status'] ) );
    25332580                        if ($status === 'check') {
    25342581                            $get_current_status = get_post_meta($booking_id, 'saab_entry_status', true);
     
    25872634            }
    25882635            echo '<div class="booking-cancellation-card">';
    2589             $encrypt_bookingId = isset($_REQUEST['booking_id']) ? sanitize_text_field($_REQUEST['booking_id']) : '';
    2590 
    2591             if (isset($_REQUEST['booking_id']) && isset($_REQUEST['status'])) {
     2636            $encrypt_bookingId = isset( $_REQUEST['booking_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['booking_id'] ) ) : '';
     2637
     2638            if ( isset( $_REQUEST['booking_id'] ) && isset( $_REQUEST['status'] ) ) {
    25922639                // $booking_id = wp_base64_decode($encrypt_bookingId);
    25932640                $booking_id = $encrypt_bookingId;
    2594                 $bookingstatus = sanitize_text_field( $_REQUEST['status'] );
     2641                $bookingstatus = sanitize_text_field( wp_unslash( $_REQUEST['status'] ) );
    25952642
    25962643                if ($bookingstatus === 'cancel' ) {
     
    26252672        function saab_cancel_booking_shortcode() {
    26262673            $response = array(                 
    2627                 'message' => esc_html__('','smart-appointment-booking'),
     2674                'message' => '',
    26282675                'mail_message' => '',
    26292676               
  • smart-appointment-booking/tags/1.0.8/readme.txt

    r3421205 r3450387  
    77Tested up to: 6.9
    88License: GPL-3.0-or-later
    9 Version: 1.0.7
    10 Stable tag: 1.0.7
     9Version: 1.0.8
     10Stable tag: 1.0.8
    1111License: GPLv3 or later License
    1212License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    131131== Changelog ==
    132132
     133= 1.0.8 =
     134* Security: Nonce verification and input sanitization improvements across admin and front forms.
     135* Security: Proper use of wp_unslash() before sanitization for POST/GET data.
     136* Code quality: Addressed WordPress PHPCS warnings (escaping, validated input, slow query notices).
     137* Tested with the latest version of WordPress (6.9).
     138
    133139= 1.0.7 =
    134140* Tested with the latest version of WordPress (6.9).
     
    172178== Upgrade Notice ==
    173179
     180= 1.0.8 =
     181* Security: Nonce verification and input sanitization improvements across admin and front forms.
     182* Security: Proper use of wp_unslash() before sanitization for POST/GET data.
     183* Code quality: Addressed WordPress PHPCS warnings (escaping, validated input, slow query notices).
     184* Tested with the latest version of WordPress (6.9).
     185
     186= 1.0.7 =
     187* Tested with the latest version of WordPress (6.9).
     188
     189= 1.0.6 =
     190* Issue Fixed
     191
     192= 1.0.5 =
     193* Issue Fixed
     194
     195= 1.0.4 =
     196* Fix: Issue with enabling or disabling the booking form
     197* Fix: Calendar not displaying when clicking arrows
     198* Fix: Calendar not displaying when selecting a month
     199* Fix: Calendar not displaying when selecting a year
     200* Fix: Timeslot issue in the 'Manage Entry' section
     201* Fix: Display of booked timeslots in the form
     202* Fix: Change button name for "Add New Form (Booking Form)"
     203* Fix: Remove "View Post" link after form is published
     204* Fix: Generate shortcode when publishing the form
     205* Add: List of added users
     206* Add: List of added statuses
     207* Add: "Appointment Type: Virtual" option
     208
     209= 1.0.3 =
     210* Fix: Date being selected in calendar issue
     211* Fix: Time being selected issue
     212* Fix: Available seat count issue
     213* Fix: Data listing issue
     214* Fix: Manage Entry issue
     215
     216= 1.0.2 =
     217* The issue on the backend has been fixed.
     218
     219= 1.0.1 =
     220* Issue Fixed "Form Is not being saved"
     221
    174222= 1.0.0 =
    175 1.0 is Initial Release.
     223* Initial Release
  • smart-appointment-booking/tags/1.0.8/smart-appointment-booking.php

    r3421205 r3450387  
    44 * Plugin URL: https://wordpress.org/plugins/smart-appointment-booking/
    55 * Description: This is the all-in-one solution for efficient appointment management, offering customizable forms, seamless booking and modifications waitlist management.
    6  * Version: 1.0.7
     6 * Version: 1.0.8
    77 * Author: ZealousWeb
    88 * Author URI: https://www.zealousweb.com
     
    2424 *
    2525 * @package Smart Appointment & Booking
    26  * @since 1.0.7
     26 * @since 1.0.8
    2727 */
    2828
    2929/* Start of Code */
    3030if ( ! defined( 'SAAB_VERSION' ) ) {
    31     define( 'SAAB_VERSION', '1.0.7' ); // Version of the plugin
     31    define( 'SAAB_VERSION', '1.0.8' ); // Version of the plugin
    3232}
    3333
  • smart-appointment-booking/trunk/inc/admin/class.saab.admin.action.php

    r3154282 r3450387  
    200200            );
    201201            $get_notification_array = array();
    202             if (isset($_POST['notification_data'])) {
    203            
    204                 parse_str($_POST['notification_data'], $form_data);
     202            if ( isset( $_POST['notification_data'] ) ) {
     203                parse_str( sanitize_text_field( wp_unslash( $_POST['notification_data'] ) ), $form_data );
    205204                $post_id = $form_data['form_id'];
    206205                $index = $form_data['editnotify'];
     
    394393         */
    395394        function view_booking_entry( $post ){
    396             if( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], '_wpnonce' ) ){
     395            if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), '_wpnonce' ) ) {
    397396                //wp_die( 'Security check failed. Refresh the page and retry again!' );
    398397            }
    399             $post_id = ( isset( $_GET['post_id'] ) ) ? $_GET['post_id'] : '';
     398            $post_id = isset( $_GET['post_id'] ) ? absint( wp_unslash( $_GET['post_id'] ) ) : 0;
    400399            $form_data = get_post_meta( $post_id, 'saab_submission_data', true );   
    401400            $form_id = get_post_meta( $post_id, 'saab_form_id', true );
     
    529528        }
    530529        function update_form_entry_data(){
    531             // if( ! isset( $_POST['zwt_saab_common_nonce'] ) || ! wp_verify_nonce( $_POST['zwt_saab_common_nonce'], 'zwt_saab_common_nonce' ) ){
    532             //  wp_die( 'Security check failed. Refresh the page and retry again!' );
    533             // }
    534             if (isset($_POST['entry_id']) && isset($_POST['updated_data']) ) {
    535                 $entry_id = ( isset( $_POST['entry_id'] ) ) ? $_POST['entry_id'] : '';
    536                 $get_submitted_data = get_post_meta($entry_id, 'saab_submission_data', true);
    537                 $updated_data = ( isset( $_POST['updated_data'] ) ) ? $_POST['updated_data'] : '';
     530            if ( ! isset( $_POST['security'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['security'] ) ), 'saab_ajax_nonce' ) ) {
     531                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     532                wp_die();
     533            }
     534            if ( isset( $_POST['entry_id'] ) && isset( $_POST['updated_data'] ) ) {
     535                $entry_id = isset( $_POST['entry_id'] ) ? absint( wp_unslash( $_POST['entry_id'] ) ) : 0;
     536                $get_submitted_data = get_post_meta( $entry_id, 'saab_submission_data', true );
     537                $updated_data = isset( $_POST['updated_data'] ) && is_array( $_POST['updated_data'] ) ? map_deep( wp_unslash( $_POST['updated_data'] ), 'sanitize_text_field' ) : array();
    538538                foreach ($updated_data as $key => $value) {
    539539                    if (isset($get_submitted_data['data'][$key])) {
     
    575575            echo "<div class='notification-page-main m-4 p-1 ' >";
    576576       
    577             if (isset($_GET['post_type']) && isset($_GET['post_id']) && isset( $_GET['nonce'] ) && ! wp_verify_nonce( sanitize_text_field( wp_unslash ($_POST['nonce'] ) ) , 'other_setting' )) {
    578            
    579                 $post_type = sanitize_text_field($_GET['post_type']);
    580                
    581                 $post_id = absint( $_GET['post_id']);               
     577            if ( isset( $_GET['post_type'] ) && isset( $_GET['post_id'] ) && isset( $_GET['nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'other_setting' ) ) {
     578                $post_type = sanitize_text_field( wp_unslash( $_GET['post_type'] ) );
     579                $post_id = absint( wp_unslash( $_GET['post_id'] ) );               
    582580           
    583581                ?>
     
    633631                                                        $fieldLabel = $option['fieldlabel'];
    634632                                                        $selected = ($fieldKey == $first_name) ? 'selected' : '';
    635                                                         echo '<option value="' . $fieldKey . '" ' . $selected . '>' . $fieldLabel . '</option>';
     633                                                        echo '<option value="' . esc_attr( $fieldKey ) . '" ' . esc_attr( $selected ) . '>' . esc_html( $fieldLabel ) . '</option>';
    636634                                                    }
    637635                                                ?>
     
    995993                wp_send_json($response);
    996994            }else{
    997                 if (null !== ($_POST['post_id'] ?? null) && null !== absint($_POST['notification_id'] ?? null) && null !== sanitize_text_field($_POST['new_state'] ?? null)) {
    998                     $post_id = isset($_POST['post_id']) ? absint($_POST['post_id']) : 0;
    999                     $notification_id = isset($_POST['notification_id']) ? absint($_POST['notification_id']) : 0;
    1000 
    1001                     $index = ltrim($notification_id, "notify_");
    1002                     $new_state = isset($_POST['new_state']) ? sanitize_text_field($_POST['new_state']) : '';
     995                if ( isset( $_POST['post_id'] ) && isset( $_POST['notification_id'] ) && isset( $_POST['new_state'] ) ) {
     996                    $post_id = absint( wp_unslash( $_POST['post_id'] ) );
     997                    $notification_id = absint( wp_unslash( $_POST['notification_id'] ) );
     998
     999                    $index = ltrim( (string) $notification_id, 'notify_' );
     1000                    $new_state = sanitize_text_field( wp_unslash( $_POST['new_state'] ) );
    10031001                   
    10041002                    // Get the existing notification metadata
     
    10341032                wp_die();
    10351033            }
    1036             if (isset($_POST['indexes'])) {
    1037                 $post_id = isset($_POST['post_id']) ? absint($_POST['post_id']) : 0;
    1038                 $indexesToDelete = isset($_POST['indexes']) ? $_POST['indexes'] : '';   
     1034            if ( isset( $_POST['indexes'] ) && is_array( $_POST['indexes'] ) ) {
     1035                $post_id = isset( $_POST['post_id'] ) ? absint( wp_unslash( $_POST['post_id'] ) ) : 0;
     1036                $indexes_raw = wp_unslash( $_POST['indexes'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized via map_deep below
     1037                $indexesToDelete = map_deep( $indexes_raw, 'sanitize_text_field' );
    10391038                $notification_metadata = get_post_meta($post_id, 'saab_notification_data', true);
    10401039                foreach ($indexesToDelete as $index) {
     
    11301129                                            foreach ($available_types as $avail_type) {
    11311130                                                $selected = ($avail_type === $type) ? 'selected' : '';
    1132                                                 echo '<option value="' . esc_html($avail_type) . '" ' . esc_attr($selected) . '>' . ucfirst(esc_html($avail_type)) . '</option>';
     1131                                                echo '<option value="' . esc_html($avail_type) . '" ' . esc_attr($selected) . '>' . esc_html( ucfirst( $avail_type ) ) . '</option>';
    11331132
    11341133                                            }
     
    12051204                $post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0;
    12061205
    1207                 $form_data = isset( $_POST['form_data'] ) ? sanitize_text_field($_POST['form_data']) : array();
     1206                $form_data = isset( $_POST['form_data'] ) ? sanitize_text_field( wp_unslash( $_POST['form_data'] ) ) : '';
    12081207               
    12091208                update_post_meta($post_id, 'saab_formschema', $form_data );
     
    12291228               
    12301229                if (isset($form_title)) {
    1231                     echo sprintf(
    1232                         esc_html__('%s', 'smart-appointment-booking'),
    1233                         esc_html($form_title)
    1234                     );
     1230                    echo esc_html( $form_title );
    12351231               
    12361232                }else{
     
    12421238           
    12431239                if (isset($booking_status) && !empty($booking_status)) {
    1244                     echo sprintf(
    1245                         esc_html__('%s', 'smart-appointment-booking'),
    1246                         esc_html(ucfirst($booking_status))
    1247                     ); 
     1240                    echo esc_html( ucfirst( $booking_status ) );
    12481241                }else{
    12491242                    echo '-';
     
    12631256                $booked_date = gmdate('d F, Y', strtotime($booked_date));   
    12641257                    if (isset($booking_date) && !empty($booking_date)) {   
    1265                         echo sprintf(
    1266                             esc_html__('%s', 'smart-appointment-booking'),
    1267                             esc_html($booked_date)
    1268                         );
    1269                        
     1258                        echo esc_html( $booked_date );
    12701259                    }
    12711260                }else{
     
    12771266           
    12781267                if (isset($timeslot) && !empty($timeslot)) {
    1279                     echo sprintf(
    1280                         esc_html__('%s', 'smart-appointment-booking'),
    1281                         esc_html($timeslot)
    1282                     ); 
     1268                    echo esc_html( $timeslot );
    12831269                }else{
    12841270                    echo '-';
     
    13421328                $error = 1;
    13431329                $error_mess = "Something went wrong";
    1344                 error_log("post_id not found while preview");
     1330                error_log( "post_id not found while preview" ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
    13451331            }
    13461332       
     
    14511437                wp_die();
    14521438            }
    1453             $user_mapping = isset($_POST['saabuser_mapping']) ? sanitize_text_field($_POST['saabuser_mapping']) : '';
     1439            $user_mapping = isset( $_POST['saabuser_mapping'] ) ? sanitize_text_field( wp_unslash( $_POST['saabuser_mapping'] ) ) : '';
    14541440       
    14551441            parse_str($user_mapping, $user_mapping_array);
     
    14831469            if (isset($_POST['confirmation_data'])) {
    14841470
    1485                 parse_str(wp_unslash(sanitize_text_field($_POST['confirmation_data'])), $formdata);
     1471                parse_str( sanitize_text_field( wp_unslash( $_POST['confirmation_data'] ) ), $formdata );
    14861472               
    14871473                $post_id = $formdata['post_id'];
     
    15831569                foreach ($options as $value => $label) {
    15841570                    $selected = selected($status, $value, false);
    1585                     echo '<option value="' . esc_attr($value) . '" ' . $selected . '>' . esc_html($label) . '</option>';
     1571                    echo '<option value="' . esc_attr($value) . '" ' . esc_attr( $selected ) . '>' . esc_html($label) . '</option>';
    15861572                }
    15871573                echo '</select>';
    15881574
    1589                 $selected_form_id = isset($_GET['form_filter']) ? sanitize_text_field($_GET['form_filter']) : '';
     1575                $selected_form_id = isset( $_GET['form_filter'] ) ? sanitize_text_field( wp_unslash( $_GET['form_filter'] ) ) : '';
    15901576       
    15911577                $forms_query = new WP_Query($args);
     
    16221608            }
    16231609           
    1624             if ('edit.php' === $pagenow && 'manage_entries' === $typenow) {
    1625                 $booking_status = isset($_GET['booking_status']) ? sanitize_text_field($_GET['booking_status']) : '';
    1626                 $form_filter = isset($_GET['form_filter']) ? intval($_GET['form_filter']) : 0;
    1627 
    1628                 if (!empty($booking_status) || !empty($form_filter)) {
    1629                     $meta_query = array('relation' => 'and');
    1630 
    1631                     if (!empty($booking_status) && in_array($booking_status, array('booked', 'approved', 'cancelled', 'pending', 'waiting', 'submitted'))) {
     1610            if ( 'edit.php' === $pagenow && 'manage_entries' === $typenow ) {
     1611                $booking_status = isset( $_GET['booking_status'] ) ? sanitize_text_field( wp_unslash( $_GET['booking_status'] ) ) : '';
     1612                $form_filter = isset( $_GET['form_filter'] ) ? absint( wp_unslash( $_GET['form_filter'] ) ) : 0;
     1613
     1614                if ( ! empty( $booking_status ) || ! empty( $form_filter ) ) {
     1615                    // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Filtering entries by status/form requires meta_query.
     1616                    $meta_query = array( 'relation' => 'and' );
     1617
     1618                    if ( ! empty( $booking_status ) && in_array( $booking_status, array( 'booked', 'approved', 'cancelled', 'pending', 'waiting', 'submitted' ), true ) ) {
    16321619                        $meta_query[] = array(
    1633                             'key' => 'entry_status',
    1634                             'value' => $booking_status,
    1635                             'compare' => '='
     1620                            'key'     => 'entry_status',
     1621                            'value'   => $booking_status,
     1622                            'compare' => '=',
    16361623                        );
    16371624                    }
    16381625
    1639                     if (!empty($form_filter)) {
     1626                    if ( ! empty( $form_filter ) ) {
    16401627                        $meta_query[] = array(
    1641                             'key' => 'saab_form_id',
    1642                             'value' => $form_filter,
    1643                             'compare' => '='
     1628                            'key'     => 'saab_form_id',
     1629                            'value'   => $form_filter,
     1630                            'compare' => '=',
    16441631                        );
    16451632                    }
    16461633
    1647                     $query->set('meta_query', $meta_query);
     1634                    $query->set( 'meta_query', $meta_query );
    16481635                }
    16491636            }
     
    17001687            // Define the current page number
    17011688           
    1702             $current_page = isset($_POST['page']) ? absint($_POST['page']) : 1;
    1703             $timeslot = isset($_POST['timeslot']) ? sanitize_text_field($_POST['timeslot']) : '';
    1704             $booking_date = isset($_POST['booking_date']) ? sanitize_text_field($_POST['booking_date']) : '';
    1705 
     1689            $current_page = isset( $_POST['page'] ) ? absint( wp_unslash( $_POST['page'] ) ) : 1;
     1690            $timeslot = isset( $_POST['timeslot'] ) ? sanitize_text_field( wp_unslash( $_POST['timeslot'] ) ) : '';
     1691            $booking_date = isset( $_POST['booking_date'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_date'] ) ) : '';
     1692
     1693            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Waiting list filtered by timeslot/booking_date.
    17061694            $args = array(
    1707                 'post_type' => 'manage_entries',
    1708                 'posts_per_page' => 5, // Show 5 entries per page
    1709                 'paged' => $current_page, // Use the current page number for pagination
    1710                 'meta_query' => array(
     1695                'post_type'      => 'manage_entries',
     1696                'posts_per_page' => 5,
     1697                'paged'          => $current_page,
     1698                'meta_query'     => array(
    17111699                    'relation' => 'AND',
    17121700                    array(
    1713                         'key' => 'timeslot',
    1714                         'value' => $timeslot,
    1715                         'compare' => '='
     1701                        'key'     => 'timeslot',
     1702                        'value'   => $timeslot,
     1703                        'compare' => '=',
    17161704                    ),
    17171705                    array(
    1718                         'key' => 'booking_date',
    1719                         'value' => $booking_date,
    1720                         'compare' => '='
    1721                     )
    1722                 )
    1723             );     
    1724 
    1725             $query = new WP_Query($args);
     1706                        'key'     => 'booking_date',
     1707                        'value'   => $booking_date,
     1708                        'compare' => '=',
     1709                    ),
     1710                ),
     1711            );
     1712
     1713            $query = new WP_Query( $args );
    17261714            ob_start();
    17271715            if ($query->have_posts()) {
  • smart-appointment-booking/trunk/inc/admin/class.saab.admin.fieldmeta.php

    r3154282 r3450387  
    2626
    2727        function saab_get_available_seats_per_timeslot($checktimeslot,$date){
    28            
     28            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Seats count filtered by timeslot/booking_date.
    2929            $args = array(
    30                 'post_type' => 'manage_entries',
     30                'post_type'      => 'manage_entries',
    3131                'posts_per_page' => -1,
    32                 'meta_query' => array(
     32                'meta_query'     => array(
    3333                    'relation' => 'AND',
    3434                    array(
     
    234234                    <div id="waitinglist_main">
    235235                    <?php
    236                        
    237                        $current_page = isset($_GET['page']) ? absint($_GET['page']) : 1;
     236                       // Pagination; nonce not used for GET page parameter in admin list.
     237                       // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     238                       $current_page = isset( $_GET['page'] ) ? absint( wp_unslash( $_GET['page'] ) ) : 1;
     239                       // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Waiting list filtered by timeslot/status/booking_date.
    238240                       $args = array(
    239                         'post_type' => 'manage_entries',
    240                         'posts_per_page' => 5, 
    241                         'paged' => $current_page,
    242                         'orderby'   => 'date',
    243                         'order'     => 'ASC',
    244                         'meta_query' => array(
     241                        'post_type'      => 'manage_entries',
     242                        'posts_per_page' => 5,
     243                        'paged'          => $current_page,
     244                        'orderby'        => 'date',
     245                        'order'          => 'ASC',
     246                        'meta_query'     => array(
    245247                            'relation' => 'AND',
    246248                            array(
     
    311313                            if ($total_pages > 1) {
    312314                               
    313                                     echo '<select id="saabpage-number"  data-timeslot="' . esc_attr($timeslot) . '" data-booking_date="' . esc_attr($booking_date) . '" data-nonce="'.wp_create_nonce('get_paginated_items_nonce').'">';
     315                                    echo '<select id="saabpage-number"  data-timeslot="' . esc_attr($timeslot) . '" data-booking_date="' . esc_attr($booking_date) . '" data-nonce="' . esc_attr( wp_create_nonce( 'get_paginated_items_nonce' ) ) . '">';
    314316                                        for ($page = 1; $page <= $total_pages; $page++) {
    315317                                            echo '<option value="' . esc_attr($page) . '"';
     
    352354                <script type='text/javascript'>
    353355                   
    354                     var myScriptData = <?php echo $myScriptData; ?>;
     356                    var myScriptData = <?php echo $myScriptData; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON schema from post meta, validated on save. ?>;
    355357                    window.onload = function() {
    356358                       
     
    587589                                        //echo wp_kses( $this->timezone_dropdown($post->ID), $allow_time_dropdown );
    588590                                    ?>
    589                                     <?php echo $this->timezone_dropdown($post->ID); ?>
     591                                    <?php echo wp_kses_post( $this->timezone_dropdown( $post->ID ) ); ?>
    590592                                   
    591593                                </div>
     
    863865              return $post_id;
    864866            }
    865             if (isset($_POST['cal_title'])) {
    866                 $cal_title = sanitize_text_field($_POST['cal_title']);
    867                 update_post_meta($post_id, 'saab_cal_title', $cal_title);
    868             } 
    869            
    870             if (isset($_POST['cal_description'])) {
    871                 $cal_description = sanitize_text_field($_POST['cal_description']);
    872                 update_post_meta($post_id, 'saab_cal_description', $cal_description);
     867            if ( isset( $_POST['cal_title'] ) ) {
     868                $cal_title = sanitize_text_field( wp_unslash( $_POST['cal_title'] ) );
     869                update_post_meta( $post_id, 'saab_cal_title', $cal_title );
     870            }
     871
     872            if ( isset( $_POST['cal_description'] ) ) {
     873                $cal_description = sanitize_text_field( wp_unslash( $_POST['cal_description'] ) );
     874                update_post_meta( $post_id, 'saab_cal_description', $cal_description );
    873875            }
    874876            // Section Tab 1
     
    881883            }
    882884            //Weekdays
    883             if (isset($_POST['weekdays'])) {
    884                 $selected_weekdays = array_map('sanitize_text_field', $_POST['weekdays']);
    885                 update_post_meta($post_id, 'saab_weekdays', $selected_weekdays);
     885            if ( isset( $_POST['weekdays'] ) ) {
     886                $selected_weekdays = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['weekdays'] ) );
     887                update_post_meta( $post_id, 'saab_weekdays', $selected_weekdays );
    886888            } else {
    887889                update_post_meta($post_id, 'saab_weekdays', array());
     
    889891           
    890892            // Save the radio button value for appointment Type
    891             if (isset($_POST['appointment_type'])) {
    892                 $selected_option = sanitize_text_field($_POST['appointment_type']);
     893            if ( isset( $_POST['appointment_type'] ) ) {
     894                $selected_option = sanitize_text_field( wp_unslash( $_POST['appointment_type'] ) );
    893895                update_post_meta($post_id, 'saab_appointment_type', $selected_option);
    894896            }
    895897
    896898            // Save the  link value if Appointment Type "Virtual" is selected
    897             if (isset($_POST['virtual_link'])) {
    898                 $link_value = sanitize_text_field($_POST['virtual_link']);
     899            if ( isset( $_POST['virtual_link'] ) ) {
     900                $link_value = sanitize_text_field( wp_unslash( $_POST['virtual_link'] ) );
    899901                update_post_meta($post_id, 'saab_virtual_link', $link_value);
    900902            }
     
    902904            //Symbol
    903905            if ( isset( $_POST['label_symbol'] ) ) {
    904                 $label_symbol = sanitize_text_field( $_POST['label_symbol'] );
     906                $label_symbol = sanitize_text_field( wp_unslash( $_POST['label_symbol'] ) );
    905907                update_post_meta( $post_id, 'saab_label_symbol', $label_symbol );
    906908            }
     
    908910             //Symbol
    909911             if ( isset( $_POST['cost'] ) ) {
    910                 $cost = sanitize_text_field( $_POST['cost'] );
     912                $cost = sanitize_text_field( wp_unslash( $_POST['cost'] ) );
    911913                update_post_meta( $post_id, 'saab_cost', $cost );
    912914            }
    913915           
    914916            if ( isset( $_POST['timezone'] ) ) {
    915                 $timezone = sanitize_text_field( $_POST['timezone'] );
     917                $timezone = sanitize_text_field( wp_unslash( $_POST['timezone'] ) );
    916918                update_post_meta( $post_id, 'saab_timezone', $timezone );
    917919            }
    918920           
    919921            if ( isset( $_POST['bookmap_email'] ) ) {
    920                 $map_email = sanitize_text_field( $_POST['bookmap_email'] );
     922                $map_email = sanitize_text_field( wp_unslash( $_POST['bookmap_email'] ) );
    921923                update_post_meta( $post_id, 'saab_map_email', $map_email );             
    922924            }
    923925           
    924926            if ( isset( $_POST['cost'] ) ) {
    925                 $cost = sanitize_text_field( $_POST['cost'] );
     927                $cost = sanitize_text_field( wp_unslash( $_POST['cost'] ) );
    926928                update_post_meta( $post_id, 'saab_saab_cost', $cost );
    927929            }
    928            
     930
    929931            //selected_date
    930             if (isset($_POST['selected_date'])) {
    931                 update_post_meta($post_id, 'saab_selected_date', sanitize_text_field($_POST['selected_date']));
    932             }
    933            
    934             if (isset($_POST['start_time'])) {
    935                 update_post_meta($post_id, 'saab_start_time', sanitize_text_field($_POST['start_time']));
    936             }
    937            
    938             if (isset($_POST['end_time'])) {
    939                 update_post_meta($post_id, 'saab_end_time', sanitize_text_field($_POST['end_time']));
    940             }
    941            
     932            if ( isset( $_POST['selected_date'] ) ) {
     933                update_post_meta( $post_id, 'saab_selected_date', sanitize_text_field( wp_unslash( $_POST['selected_date'] ) ) );
     934            }
     935
     936            if ( isset( $_POST['start_time'] ) ) {
     937                update_post_meta( $post_id, 'saab_start_time', sanitize_text_field( wp_unslash( $_POST['start_time'] ) ) );
     938            }
     939
     940            if ( isset( $_POST['end_time'] ) ) {
     941                update_post_meta( $post_id, 'saab_end_time', sanitize_text_field( wp_unslash( $_POST['end_time'] ) ) );
     942            }
     943
    942944             //Steps Duration
    943945            if ( isset( $_POST['steps_duration'] ) ) {
    944                 $steps_duration = sanitize_text_field($_POST['steps_duration']);
     946                $steps_duration = map_deep( wp_unslash( $_POST['steps_duration'] ), 'sanitize_text_field' );
    945947                $sanitized_steps_duration = array(
    946948                    'hours' => sanitize_text_field( $steps_duration['hours'] ),
     
    952954            }
    953955            //timeslot_duration
    954             if ( isset( $_POST['booking_stops_after'] ) ) {
    955                 $booking_stops_after_duration = $_POST['booking_stops_after'];
     956            $booking_stops_after_duration = ( isset( $_POST['booking_stops_after'] ) && is_array( $_POST['booking_stops_after'] ) )
     957                ? map_deep( wp_unslash( $_POST['booking_stops_after'] ), 'sanitize_text_field' )
     958                : array();
     959            if ( ! empty( $booking_stops_after_duration ) ) {
    956960                $sanitized_booking_stops_after_duration = array(
    957                     'hours' => sanitize_text_field( $booking_stops_after_duration['hours'] ),
    958                     'minutes' => sanitize_text_field( $booking_stops_after_duration['minutes'] )
     961                    'hours' => isset( $booking_stops_after_duration['hours'] ) ? $booking_stops_after_duration['hours'] : '',
     962                    'minutes' => isset( $booking_stops_after_duration['minutes'] ) ? $booking_stops_after_duration['minutes'] : '',
    959963                );
    960964       
     
    963967            }
    964968            //timeslot_duration
    965             if ( isset( $_POST['timeslot_duration'] ) ) {
    966                 $timeslot_duration = sanitize_text_field($_POST['timeslot_duration']);
     969            if ( isset( $_POST['timeslot_duration'] ) && is_array( $_POST['timeslot_duration'] ) ) {
     970                $timeslot_duration = map_deep( wp_unslash( $_POST['timeslot_duration'] ), 'sanitize_text_field' );
    967971                $sanitized_timeslot_duration = array(
    968                     'hours' => sanitize_text_field( $timeslot_duration['hours'] ),
    969                     'minutes' => sanitize_text_field( $timeslot_duration['minutes'] )
     972                    'hours' => isset( $timeslot_duration['hours'] ) ? $timeslot_duration['hours'] : '',
     973                    'minutes' => isset( $timeslot_duration['minutes'] ) ? $timeslot_duration['minutes'] : '',
    970974                );
    971975       
     
    975979            //no_of_booking
    976980            if ( isset( $_POST['no_of_booking'] ) ) {
    977                 $selected_date = absint($_POST['no_of_booking']);
     981                $selected_date = absint( wp_unslash( $_POST['no_of_booking'] ) );
    978982                update_post_meta( $post_id, 'saab_no_of_booking', $selected_date );
    979983            }
    980984            //waiting List
    981             if (isset($_POST['waiting_list']) && filter_var($_POST['waiting_list'], FILTER_VALIDATE_BOOLEAN)) {
    982                 update_post_meta($post_id, 'saab_waiting_list', 1);
     985            if ( isset( $_POST['waiting_list'] ) && filter_var( wp_unslash( $_POST['waiting_list'] ), FILTER_VALIDATE_BOOLEAN ) ) {
     986                update_post_meta( $post_id, 'saab_waiting_list', 1 );
    983987            } else {
    984988                delete_post_meta($post_id, 'saab_waiting_list');
    985989            }
    986990            //timeslotBookingAllowed
    987             if (isset($_POST['timeslot_BookAllow']) && filter_var($_POST['timeslot_BookAllow'], FILTER_VALIDATE_BOOLEAN)) {
     991            if ( isset( $_POST['timeslot_BookAllow'] ) && filter_var( wp_unslash( $_POST['timeslot_BookAllow'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    988992                update_post_meta($post_id, 'saab_timeslot_BookAllow', 1);
    989993            } else {
     
    991995            }
    992996            //enable_auto_approve
    993             if (isset($_POST['enable_auto_approve']) && filter_var($_POST['enable_auto_approve'], FILTER_VALIDATE_BOOLEAN)) {
     997            if ( isset( $_POST['enable_auto_approve'] ) && filter_var( wp_unslash( $_POST['enable_auto_approve'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    994998                update_post_meta($post_id, 'saab_enable_auto_approve', 1);
    995999            } else {
     
    9971001            }
    9981002            //multiple breaks
    999             if (isset($_POST['breaktimeslots'])) {
    1000                 $breaktimeslots = sanitize_text_field($_POST['breaktimeslots']);
    1001            
    1002                 // Sanitize and save the values
     1003            if ( isset( $_POST['breaktimeslots'] ) && is_array( $_POST['breaktimeslots'] ) ) {
     1004                $breaktimeslots = map_deep( wp_unslash( $_POST['breaktimeslots'] ), 'sanitize_text_field' );
     1005
    10031006                $sanitized_breaktimeslots = array();
    1004                 foreach ($breaktimeslots as $breaktimeslot) {
    1005                     $breakstart_time = sanitize_text_field($breaktimeslot['start_time']);
    1006                     $breakend_time = sanitize_text_field($breaktimeslot['end_time']);
     1007                foreach ( $breaktimeslots as $breaktimeslot ) {
     1008                    $breakstart_time = isset( $breaktimeslot['start_time'] ) ? $breaktimeslot['start_time'] : '';
     1009                    $breakend_time = isset( $breaktimeslot['end_time'] ) ? $breaktimeslot['end_time'] : '';
    10071010                    $sanitized_breaktimeslots[] = array(
    10081011                        'start_time' => $breakstart_time,
     
    10241027                }
    10251028           
    1026                 if (isset($_POST['generatetimeslot'])) {
    1027                     $generatetimeslots = $_POST['generatetimeslot'];   
    1028                     // Sanitize and save the values
     1029                $generatetimeslots = ( isset( $_POST['generatetimeslot'] ) && is_array( $_POST['generatetimeslot'] ) )
     1030                    ? map_deep( wp_unslash( $_POST['generatetimeslot'] ), 'sanitize_text_field' )
     1031                    : array();
     1032                if ( ! empty( $generatetimeslots ) ) {
    10291033                    $sanitized_generatetimeslots = array();
    1030                     foreach ($generatetimeslots as $generatetimeslot) {
    1031                         $generatestart_time = $generatetimeslot['start_time'];
    1032                         $generateend_time = $generatetimeslot['end_time'];
     1034                    foreach ( $generatetimeslots as $generatetimeslot ) {
    10331035                        $sanitized_generatetimeslots[] = array(
    1034                         'start_time' => $generatestart_time,
    1035                         'end_time' => $generateend_time,
     1036                            'start_time' => isset( $generatetimeslot['start_time'] ) ? $generatetimeslot['start_time'] : '',
     1037                            'end_time' => isset( $generatetimeslot['end_time'] ) ? $generatetimeslot['end_time'] : '',
    10361038                        );
    10371039                    }           
     
    10511053               
    10521054            //Enable Recurring Events
    1053             if (isset($_POST['enable_recurring_apt']) && filter_var($_POST['enable_recurring_apt'], FILTER_VALIDATE_BOOLEAN)) {
     1055            if ( isset( $_POST['enable_recurring_apt'] ) && filter_var( wp_unslash( $_POST['enable_recurring_apt'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    10541056                update_post_meta($post_id, 'saab_enable_recurring_apt', 1);
    10551057            } else {
    10561058                delete_post_meta($post_id, 'saab_enable_recurring_apt');
    10571059            }
    1058             if (isset($_POST['enable_advance_setting']) && filter_var($_POST['enable_advance_setting'], FILTER_VALIDATE_BOOLEAN)) {
     1060            if ( isset( $_POST['enable_advance_setting'] ) && filter_var( wp_unslash( $_POST['enable_advance_setting'] ), FILTER_VALIDATE_BOOLEAN ) ) {
    10591061                update_post_meta($post_id, 'saab_enable_advance_setting', 1);
    10601062            } else {
    10611063                delete_post_meta($post_id, 'saab_enable_advance_setting');
    10621064            }
    1063             if (isset($_POST['recurring_type'])) {
    1064                 $recurring_type = sanitize_text_field($_POST['recurring_type']);
    1065                 update_post_meta($post_id, 'saab_recurring_type', $recurring_type);
    1066             }
    1067             if (isset($_POST['recur_weekdays'])) {
    1068                 $sanitized_recur_weekdays = array_map('sanitize_text_field', $_POST['recur_weekdays']);
    1069                 update_post_meta($post_id, 'saab_recur_weekdays', $sanitized_recur_weekdays);
    1070             }
    1071             if (isset($_POST['advancedata'])) {               
    1072                 $advancedata = $_POST['advancedata'];               
    1073                 update_post_meta($post_id, 'saab_advancedata', $advancedata);
     1065            if ( isset( $_POST['recurring_type'] ) ) {
     1066                $recurring_type = sanitize_text_field( wp_unslash( $_POST['recurring_type'] ) );
     1067                update_post_meta( $post_id, 'saab_recurring_type', $recurring_type );
     1068            }
     1069            if ( isset( $_POST['recur_weekdays'] ) ) {
     1070                $sanitized_recur_weekdays = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['recur_weekdays'] ) );
     1071                update_post_meta( $post_id, 'saab_recur_weekdays', $sanitized_recur_weekdays );
     1072            }
     1073            if ( isset( $_POST['advancedata'] ) ) {
     1074                $advancedata = is_array( $_POST['advancedata'] )
     1075                    ? map_deep( wp_unslash( $_POST['advancedata'] ), 'sanitize_text_field' )
     1076                    : sanitize_text_field( wp_unslash( $_POST['advancedata'] ) );
     1077                update_post_meta( $post_id, 'saab_advancedata', $advancedata );
    10741078            }else {
    10751079                delete_post_meta($post_id, 'saab_advancedata');
    10761080            }
    1077             if (isset($_POST['holidays'])) {
    1078                 $holidays = array_map('sanitize_text_field', $_POST['holidays']);
     1081            if ( isset( $_POST['holidays'] ) ) {
     1082                $holidays = array_map( 'sanitize_text_field', (array) wp_unslash( $_POST['holidays'] ) );
    10791083                update_post_meta($post_id, 'saab_holiday_dates', $holidays);
    10801084            }
    1081             if (isset($_POST['end_repeats'])) {
    1082                 $end_repeats = sanitize_text_field($_POST['end_repeats']);
     1085            if ( isset( $_POST['end_repeats'] ) ) {
     1086                $end_repeats = sanitize_text_field( wp_unslash( $_POST['end_repeats'] ) );
    10831087                update_post_meta($post_id, 'saab_end_repeats', $end_repeats);
    10841088            }
    1085             if (isset($_POST['end_repeats_on'])) {
    1086                 $end_repeats_on = sanitize_text_field($_POST['end_repeats_on']);
     1089            if ( isset( $_POST['end_repeats_on'] ) ) {
     1090                $end_repeats_on = sanitize_text_field( wp_unslash( $_POST['end_repeats_on'] ) );
    10871091                update_post_meta($post_id, 'saab_end_repeats_on', $end_repeats_on);
    10881092            }
    1089             if (isset($_POST['end_repeats_after'])) {
    1090                 $end_repeats_after = sanitize_text_field($_POST['end_repeats_after']);
     1093            if ( isset( $_POST['end_repeats_after'] ) ) {
     1094                $end_repeats_after = sanitize_text_field( wp_unslash( $_POST['end_repeats_after'] ) );
    10911095                update_post_meta($post_id, 'saab_end_repeats_after', $end_repeats_after);
    10921096            }
     
    11111115            }
    11121116
    1113             if (isset($_POST['notes'])) {
    1114                 $notes = sanitize_textarea_field($_POST['notes']);
     1117            if ( isset( $_POST['notes'] ) ) {
     1118                $notes = sanitize_textarea_field( wp_unslash( $_POST['notes'] ) );
    11151119                update_post_meta($post_id, 'saab_notes', $notes);
    11161120            }
    11171121           
    1118             if (isset($_POST['form_id'])) {
    1119                 $form_id = sanitize_text_field($_POST['form_id']);
    1120             }
    1121            
    1122             if (isset($_POST['no_of_bookings'])) {
    1123                 $no_of_bookings = absint($_POST['no_of_bookings']);
     1122            if ( isset( $_POST['form_id'] ) ) {
     1123                $form_id = sanitize_text_field( wp_unslash( $_POST['form_id'] ) );
     1124            }
     1125           
     1126            if ( isset( $_POST['no_of_bookings'] ) ) {
     1127                $no_of_bookings = absint( wp_unslash( $_POST['no_of_bookings'] ) );
    11241128                update_post_meta($post_id, 'saab_slotcapacity', $no_of_bookings);
    11251129            }
    11261130           
    1127             if (isset($_POST['booking_date'])) {
    1128                 $booking_date = sanitize_text_field($_POST['booking_date']);
     1131            if ( isset( $_POST['booking_date'] ) ) {
     1132                $booking_date = sanitize_text_field( wp_unslash( $_POST['booking_date'] ) );
    11291133                $currentMonth = gmdate('n',strtotime($booking_date));
    11301134                $currentYear = gmdate('Y',strtotime($booking_date));
     
    11331137                update_post_meta($post_id, 'saab_booking_date', $booking_date);
    11341138            }
    1135             if (isset($_POST['start_time']) && isset($_POST['end_time'])) {
    1136                 $start_time = trim(gmdate("h:i A", strtotime( sanitize_text_field($_POST['start_time']) )));
    1137                 $end_time = trim(gmdate("h:i A", strtotime( sanitize_text_field($_POST['end_time']) )));
     1139            if ( isset( $_POST['start_time'] ) && isset( $_POST['end_time'] ) ) {
     1140                $start_time = trim( gmdate( 'h:i A', strtotime( sanitize_text_field( wp_unslash( $_POST['start_time'] ) ) ) ) );
     1141                $end_time  = trim( gmdate( 'h:i A', strtotime( sanitize_text_field( wp_unslash( $_POST['end_time'] ) ) ) ) );
    11381142                $timeslot = $start_time.'-'.$end_time;
    11391143                update_post_meta($post_id, 'saab_timeslot', $timeslot);
    11401144            }
    11411145         
    1142             if (isset($_POST['manual_notification']) &&  sanitize_text_field($_POST['manual_notification']  !== 'any')) {
    1143                 $selected_action = isset($_POST['manual_notification']) ? sanitize_text_field($_POST['manual_notification']) : '';
    1144                 $booking_status = isset($_POST['booking_status']) ? sanitize_text_field($_POST['booking_status']) : '';
    1145                 // update_post_meta($post_id, 'saab_entry_status', $booking_status);               
    1146                 $bookingId = isset($_POST['post_id']) ? absint($_POST['post_id']) : '';                 
    1147                 $status = isset($_POST['status']) ? sanitize_text_field($_POST['status']) : '';                 
     1146            if ( isset( $_POST['manual_notification'] ) && sanitize_text_field( wp_unslash( $_POST['manual_notification'] ) ) !== 'any' ) {
     1147                $selected_action  = isset( $_POST['manual_notification'] ) ? sanitize_text_field( wp_unslash( $_POST['manual_notification'] ) ) : '';
     1148                $booking_status  = isset( $_POST['booking_status'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_status'] ) ) : '';
     1149                // update_post_meta($post_id, 'saab_entry_status', $booking_status);
     1150                $bookingId       = isset( $_POST['post_id'] ) ? absint( wp_unslash( $_POST['post_id'] ) ) : 0;
     1151                $status          = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : '';                 
    11481152                $formdata = get_post_meta($bookingId,'saab_submission_data',true);               
    11491153                $listform_label_val =$this->saab_admin_getkey_value_formshortcodes($post_id,$formdata);
     
    11531157                update_post_meta($post_id, 'saab_manual_notification', $selected_action);
    11541158               
    1155             }else{
    1156                 $booking_status = isset($_POST['booking_status']) ? sanitize_text_field($_POST['booking_status']) : '';
    1157                 update_post_meta($post_id, 'saab_entry_status', $booking_status);
     1159            } else {
     1160                $booking_status = isset( $_POST['booking_status'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_status'] ) ) : '';
     1161                update_post_meta( $post_id, 'saab_entry_status', $booking_status );
    11581162                $formdata = get_post_meta($post_id,'saab_submission_data',true);
    11591163                $listform_label_val =$this->saab_admin_getkey_value_formshortcodes($post_id,$formdata);
     
    13021306                    } else {
    13031307                        $message = esc_html__('Failed to send email','smart-appointment-booking');
    1304                         error_log('Failed to send email');
     1308                        // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1309                        error_log( 'Failed to send email' );
    13051310                    }
    13061311                }
    13071312                       
    13081313            }
    1309             if ($notificationFound === false) {
    1310                 $message = esc_html__('Notification not found for the given status', 'smart-appointment-booking');
    1311                 error_log('Notification not found for the given status');
     1314            if ( $notificationFound === false ) {
     1315                $message = esc_html__( 'Notification not found for the given status', 'smart-appointment-booking' );
     1316                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1317                error_log( 'Notification not found for the given status' );
    13121318            }
    13131319            return $message;
  • smart-appointment-booking/trunk/inc/class.saab.php

    r3014693 r3450387  
    5353            global $wp_version;
    5454
    55             # Set filter for plugin's languages directory
    56             $SAAB_lang_dir = dirname( SAAB_PLUGIN_BASENAME ) . '/languages/';
    57             $SAAB_lang_dir = apply_filters( 'SAAB_languages_directory', $SAAB_lang_dir );
    58 
    5955            # Traditional WordPress plugin locale filter.
    6056            $get_locale = get_locale();
     
    7470                # Look in global /wp-content/languages/plugin-name folder
    7571                load_textdomain( 'smart-appointment-booking', $mofile_global );
    76             } else {
    77                 # Load the default language files
    78                 load_plugin_textdomain( 'smart-appointment-booking', false, $SAAB_lang_dir );
    7972            }
     73            # When hosted on WordPress.org, translations are loaded automatically; no load_plugin_textdomain() needed.
    8074        }
    8175    }
  • smart-appointment-booking/trunk/inc/front/class.saab.front.action.php

    r3154282 r3450387  
    110110            ob_start();
    111111            $user_id = get_current_user_id();
    112             $post_ids = array();
     112            $post_ids = array();
     113            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key, WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- User's bookings filtered by user_mapped meta.
    113114            $args = array(
    114                 'post_type' => 'manage_entries',
    115                 'meta_key' => 'user_mapped',
    116                 'meta_value' => $user_id,
    117                 'fields' => 'ids',
     115                'post_type'      => 'manage_entries',
     116                'meta_key'       => 'user_mapped',
     117                'meta_value'     => $user_id,
     118                'fields'         => 'ids',
    118119                'posts_per_page' => 55,
    119120            );
    120        
    121             $query = new WP_Query($args);
     121
     122            $query = new WP_Query( $args );
    122123       
    123124            if ($query->have_posts()) {
     
    269270        }
    270271
    271         function saab_save_form_submission() { 
    272             // ini_set('display_startup_errors', 1);
    273             // ini_set('display_errors', 1);
    274             // error_reporting(-1);
    275         //if( ! wp_verify_nonce( 'saab_front_nonce' ) ){} // ignoring nonce validation error in the front form     
    276         $form_id = ( isset( $_POST['fid'] ) ) ? $_POST['fid'] : '';
    277         $form_data = ( isset( $_POST['form_data'] ) ) ? $_POST['form_data'] : '';
     272        function saab_save_form_submission() {
     273            $nonce_key = isset( $_POST['nonce'] ) ? 'nonce' : ( isset( $_POST['security'] ) ? 'security' : '' );
     274            $nonce_val = ( $nonce_key && isset( $_POST[ $nonce_key ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ $nonce_key ] ) ) : '';
     275            if ( ! $nonce_val || ! wp_verify_nonce( $nonce_val, 'my_ajax_nonce' ) ) {
     276                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     277                wp_die();
     278            }
     279            $form_id = isset( $_POST['fid'] ) ? absint( wp_unslash( $_POST['fid'] ) ) : 0;
     280            $form_data = isset( $_POST['form_data'] ) && is_array( $_POST['form_data'] ) ? map_deep( wp_unslash( $_POST['form_data'] ), 'sanitize_text_field' ) : array();
    278281        // User
    279282        $is_user_logged_in = is_user_logged_in();
     
    345348                                $usererror = true;
    346349                                wp_send_json_error(array(
    347                                     'message' => __('Error creating user '. $user_id->get_error_message(),'smart-appointment-booking'),
     350                                    'message' => sprintf(
     351                                        /* translators: %s: error message from user creation */
     352                                        __( 'Error creating user %s', 'smart-appointment-booking' ),
     353                                        $user_id->get_error_message()
     354                                    ),
    348355                                    'error' => $usererror,
    349356                                ));
     
    586593            // }
    587594            if(empty($saab_amount)){
    588                 $error_message = "Amount configuration Error";
    589595                wp_delete_post($created_post_id, true);
    590596                wp_send_json_error(array(
    591                     'message' => __($error_message, 'smart-appointment-booking'),
     597                    'message' => __( 'Amount configuration Error', 'smart-appointment-booking' ),
    592598                    'error' => true,
    593599                ));
    594600            }
    595             $stripetoken = ( isset( $_POST['token'] ) ) ? $_POST['token'] : '';
     601            $stripetoken = isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';
    596602            // Set your Stripe Publishable key
    597603            SabStripe::setApiKey($secretKey); // Replace with your Stripe API key
     
    637643
    638644            }catch ( Exception $e ) {
    639                 $error_message = $e->getMessage();
    640645                wp_delete_post($created_post_id, true);
    641646                wp_send_json_error(array(
    642                     'message' => __($error_message, 'smart-appointment-booking'),
     647                    'message' => sprintf(
     648                        /* translators: %s: payment exception error message */
     649                        __( 'Payment error: %s', 'smart-appointment-booking' ),
     650                        $e->getMessage()
     651                    ),
    643652                    'error' => true,
    644653                ));
     
    745754           
    746755        function saab_booking_form_submission() {
    747 //          ini_set('display_startup_errors', 1);
    748 // ini_set('display_errors', 1);
    749 // error_reporting(-1);
    750             $error ='';
    751            // if( ! wp_verify_nonce( 'saab_front_nonce' ) ){}
    752             $booking_date = ( isset( $_POST['booking_date'] ) ) ? $_POST['booking_date'] : '';
    753             $explode_booking_date = explode('_',$booking_date);
    754             $form_id = $explode_booking_date[1];
    755             $format_bookingdate = $explode_booking_date[4] . "-" . $explode_booking_date[2] . "-" . $explode_booking_date[3];
    756             $converted_bookingdate = date('Y-m-d', strtotime($format_bookingdate));
    757             $timeslot = ( isset( $_POST['timeslot'] ) ) ? $_POST['timeslot'] : '';
    758             //total availableseats
    759             $slotcapacity = ( isset( $_POST['slotcapacity'] ) ) ? $_POST['slotcapacity'] : '';
    760             //quantity
    761             $bookedseats = ( isset( $_POST['bookedseats'] ) )? $_POST['bookedseats'] : '' ;
    762             $form_id = isset($_POST['fid']) ? absint($_POST['fid']) : 0;
    763             $form_data = isset( $_POST['form_data'] ) ? $_POST['form_data']:'';
    764             if (is_array($form_data)) {
     756            $nonce_key = isset( $_POST['nonce'] ) ? 'nonce' : ( isset( $_POST['security'] ) ? 'security' : '' );
     757            $nonce_val = ( $nonce_key && isset( $_POST[ $nonce_key ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ $nonce_key ] ) ) : '';
     758            if ( ! $nonce_val || ! wp_verify_nonce( $nonce_val, 'my_ajax_nonce' ) ) {
     759                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     760                wp_die();
     761            }
     762            $error = '';
     763            $booking_date = isset( $_POST['booking_date'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_date'] ) ) : '';
     764            $explode_booking_date = explode( '_', $booking_date );
     765            $form_id = isset( $explode_booking_date[1] ) ? absint( $explode_booking_date[1] ) : 0;
     766            $format_bookingdate = ( isset( $explode_booking_date[4], $explode_booking_date[2], $explode_booking_date[3] ) ) ? $explode_booking_date[4] . '-' . $explode_booking_date[2] . '-' . $explode_booking_date[3] : '';
     767            $converted_bookingdate = $format_bookingdate ? gmdate( 'Y-m-d', strtotime( $format_bookingdate ) ) : '';
     768            $timeslot = isset( $_POST['timeslot'] ) ? sanitize_text_field( wp_unslash( $_POST['timeslot'] ) ) : '';
     769            $slotcapacity = isset( $_POST['slotcapacity'] ) ? sanitize_text_field( wp_unslash( $_POST['slotcapacity'] ) ) : '';
     770            $bookedseats = isset( $_POST['bookedseats'] ) ? sanitize_text_field( wp_unslash( $_POST['bookedseats'] ) ) : '';
     771            $form_id = isset( $_POST['fid'] ) ? absint( wp_unslash( $_POST['fid'] ) ) : $form_id;
     772            $form_data = isset( $_POST['form_data'] ) ? wp_unslash( $_POST['form_data'] ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized in loop below
     773            if ( is_array( $form_data ) ) {
    765774                foreach ($form_data as $field_name => $field_value) {
    766775                    // Check if the field value is an array (e.g., for checkboxes or multi-select)
     
    989998        }
    990999        function saab_add_event_to_calender(){
    991 
     1000            // OAuth callback from Google; code/state are from redirect, not form POST. Nonce not applicable.
     1001            // phpcs:disable WordPress.Security.NonceVerification.Recommended
    9921002            ob_start();
    9931003
    994             if(isset($_GET['code'])){
    995 
    996                 require_once SAAB_DIR . '/inc/lib/google-library/vendor/autoload.php';             
    997                 $stateParameter = ( isset( $_GET['state'] ) ) ? $_GET['state'] : '';
     1004            if ( isset( $_GET['code'] ) ) {
     1005                require_once SAAB_DIR . '/inc/lib/google-library/vendor/autoload.php';
     1006                $stateParameter = isset( $_GET['state'] ) ? sanitize_text_field( wp_unslash( $_GET['state'] ) ) : '';
    9981007                $mystate = explode('T', $stateParameter);
    9991008                $form_id = $mystate[0];
     
    10401049                $client_new->setAccessType('offline');
    10411050
    1042                 if (isset($_GET['code'])) {
    1043 
    1044                     $token = $client_new->fetchAccessTokenWithAuthCode($_GET['code']);   
     1051                if ( isset( $_GET['code'] ) ) {
     1052                    $auth_code = sanitize_text_field( wp_unslash( $_GET['code'] ) );
     1053                    $token = $client_new->fetchAccessTokenWithAuthCode( $auth_code );   
    10451054                    $client_new->setAccessToken($token);   
    10461055                    $service = new Google_Service_Calendar($client_new);
     
    11041113                }
    11051114            }
     1115            // phpcs:enable WordPress.Security.NonceVerification.Recommended
    11061116            return ob_get_clean();
    11071117        }
     
    11171127         */
    11181128        function saab_send_notification($status, $form_id, $post_id, $form_data) {
    1119             // Sanitize the status value from $_POST, if applicable
    1120             $status = (isset($_POST['status']) && !empty($_POST['status'])) ? sanitize_text_field($_POST['status']) : $status;
    1121            
    1122             // Log status to ensure it's being received correctly
    1123             if (defined('WP_DEBUG') && WP_DEBUG) {
    1124                 error_log('Status received: ' . $status);
    1125             }
    1126        
     1129            // Status may be overridden from POST; nonce verified in calling AJAX handler.
     1130            // phpcs:ignore WordPress.Security.NonceVerification.Missing
     1131            $status = ( isset( $_POST['status'] ) && ! empty( $_POST['status'] ) ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : $status;
     1132
     1133            // Log status to ensure it's being received correctly.
     1134            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1135                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1136                error_log( 'Status received: ' . $status );
     1137            }
     1138
    11271139            $message = '';
    11281140            $notificationFound = false;
    1129        
     1141
    11301142            // Get notification data
    1131             $get_notification_array = get_post_meta($form_id, 'saab_notification_data', true);
    1132            
    1133             // Log the retrieved notification data for debugging
    1134             if (defined('WP_DEBUG') && WP_DEBUG) {
    1135                 error_log('Notification array: ' . print_r($get_notification_array, true));
     1143            $get_notification_array = get_post_meta( $form_id, 'saab_notification_data', true );
     1144
     1145            // Log the retrieved notification data for debugging.
     1146            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1147                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
     1148                error_log( 'Notification array: ' . print_r( $get_notification_array, true ) );
    11361149            }
    11371150       
     
    11431156                        $notificationFound = true; // Mark notification as found
    11441157       
    1145                         // Log notification for debugging
    1146                         if (defined('WP_DEBUG') && WP_DEBUG) {
    1147                             error_log('Notification found: ' . print_r($notification, true));
     1158                        // Log notification for debugging.
     1159                        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1160                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
     1161                            error_log( 'Notification found: ' . print_r( $notification, true ) );
    11481162                        }
    11491163                       
     
    11671181                        $check_body = $this->saab_check_shortcodes_exist_in_editor($check_body, $form_id, $form_data, $shortcodesArray);
    11681182       
    1169                         // Log email details for debugging
    1170                         if (defined('WP_DEBUG') && WP_DEBUG) {
    1171                             error_log('Email details: to: ' . $to . ', from: ' . $from . ', subject: ' . $subject . ', body: ' . $check_body);
     1183                        // Log email details for debugging.
     1184                        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1185                            // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1186                            error_log( 'Email details: to: ' . $to . ', from: ' . $from . ', subject: ' . $subject . ', body: ' . $check_body );
    11721187                        }
    1173        
     1188
    11741189                        // Set email headers
    11751190                        $headers = array(
     
    11931208                            $message = esc_html__('Email sent successfully', 'smart-appointment-booking');
    11941209                        } else {
    1195                             $message = esc_html__('Failed to send email', 'smart-appointment-booking');
    1196                             if (defined('WP_DEBUG') && WP_DEBUG) {
    1197                                 error_log('Failed to send email to: ' . $to); // Debug logging
     1210                            $message = esc_html__( 'Failed to send email', 'smart-appointment-booking' );
     1211                            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1212                                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1213                                error_log( 'Failed to send email to: ' . $to );
    11981214                            }
    11991215                        }
     
    12011217                }
    12021218            } else {
    1203                 // Log an error if no notification data was found for the form
    1204                 if (defined('WP_DEBUG') && WP_DEBUG) {
    1205                     error_log('No notification data found for form ID: ' . $form_id);
    1206                 }
    1207             }
    1208        
    1209             // If no notification was found, log an error
    1210             if ($notificationFound === false) {
    1211                 $message = __('Notification not found for the given status: ' . $status, 'smart-appointment-booking');
    1212                 if (defined('WP_DEBUG') && WP_DEBUG) {
    1213                     error_log('Notification not found for the given status: ' . $status); // Debug logging
    1214                 }
    1215                 wp_send_json_error(array('message' => $message));
     1219                // Log an error if no notification data was found for the form.
     1220                if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1221                    // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1222                    error_log( 'No notification data found for form ID: ' . $form_id );
     1223                }
     1224            }
     1225
     1226            // If no notification was found, log an error.
     1227            if ( $notificationFound === false ) {
     1228                $message = sprintf(
     1229                    /* translators: %s: notification status (e.g. booked, approved, cancelled) */
     1230                    __( 'Notification not found for the given status: %s', 'smart-appointment-booking' ),
     1231                    $status
     1232                );
     1233                if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1234                    // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1235                    error_log( 'Notification not found for the given status: ' . $status );
     1236                }
     1237                wp_send_json_error( array( 'message' => $message ) );
    12161238                wp_die();
    12171239            }
     
    12251247       
    12261248        function saab_send_post_update_notification($status, $form_id, $post_id, $form_data) {
    1227             // Sanitize status and other input data
    1228             $status = (isset($_POST['status']) && !empty($_POST['status'])) ? sanitize_text_field($_POST['status']) : sanitize_text_field($status);
     1249            // Status may be overridden from POST; nonce verified in calling AJAX handler.
     1250            // phpcs:ignore WordPress.Security.NonceVerification.Missing
     1251            $status = ( isset( $_POST['status'] ) && ! empty( $_POST['status'] ) ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : sanitize_text_field( $status );
    12291252            $message = '';
    12301253       
     
    12841307                        } else {
    12851308                            // Log details if email sending fails
    1286                             $message = __('Failed to send email. Details: to-' . $to . ', from-' . $from . ', Bcc-' . $bcc . ', Cc-' . $cc . ', subject-' . $subject . ', body-' . $check_body . ', headers-' . json_encode($headers), 'smart-appointment-booking');
    1287                             if (defined('WP_DEBUG') && WP_DEBUG) {
    1288                                 error_log('Failed to send email. Details: to-' . $to . ', from-' . $from . ', Bcc-' . $bcc . ', Cc-' . $cc . ', subject-' . $subject . ', body-' . $check_body . ', headers-' . json_encode($headers));
     1309                            $message = sprintf(
     1310                                /* translators: 1: to address, 2: from address, 3: Bcc, 4: Cc, 5: subject, 6: body, 7: headers */
     1311                                __( 'Failed to send email. Details: to-%1$s, from-%2$s, Bcc-%3$s, Cc-%4$s, subject-%5$s, body-%6$s, headers-%7$s', 'smart-appointment-booking' ),
     1312                                $to,
     1313                                $from,
     1314                                $bcc,
     1315                                $cc,
     1316                                $subject,
     1317                                $check_body,
     1318                                wp_json_encode( $headers )
     1319                            );
     1320                            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1321                                // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1322                                error_log( 'Failed to send email. Details: to-' . $to . ', from-' . $from . ', Bcc-' . $bcc . ', Cc-' . $cc . ', subject-' . $subject . ', body-' . $check_body . ', headers-' . wp_json_encode( $headers ) );
    12891323                            }
    12901324                        }
     
    12941328       
    12951329            // Handle case where no matching notification is found
    1296             if ($notificationFound === false) {
    1297                 $message = __('Notification not found for the given status: ' . $status, 'smart-appointment-booking');
    1298                 if (defined('WP_DEBUG') && WP_DEBUG) {
    1299                     error_log('Notification not found for the given status: ' . $status);
    1300                 }
    1301             }
    1302        
     1330            if ( $notificationFound === false ) {
     1331                $message = sprintf(
     1332                    /* translators: %s: notification status (e.g. booked, approved, cancelled) */
     1333                    __( 'Notification not found for the given status: %s', 'smart-appointment-booking' ),
     1334                    $status
     1335                );
     1336                if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     1337                    // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
     1338                    error_log( 'Notification not found for the given status: ' . $status );
     1339                }
     1340            }
     1341
    13031342            return $message;
    13041343        }
    1305        
     1344
    13061345        /**
    13071346         * Process the given field value containing shortcodes and replace them with actual values.
     
    21132152                            $timezone = get_post_meta($post_id,'saab_timezone',true);
    21142153                            $error = false;
    2115                             $TodaysDate = date('F d, Y');   
    2116                             $todaysDate = date('Y-m-d');
     2154                            $TodaysDate = gmdate( 'F d, Y' );
     2155                            $todaysDate = gmdate( 'Y-m-d' );
    21172156                            echo "<h3 id='head_avail_time'><span class='gfb-timezone'>Timezone: " . esc_attr($timezone) . "</span></h3>";
    21182157                            echo "<h4 id='headtodays_date'>" . esc_html($TodaysDate) . "</h4>";                             
     
    23262365                12 => 'December'
    23272366                );
    2328                 $currentMonth = isset($_POST['currentMonth']) ? intval($_POST['currentMonth']) : date('n'); //phpcs:ignore
    2329                 $currentMonth = max(1, min(12, $currentMonth)); // Ensure currentMonth is between 1 and 12
    2330                 $currentYear = isset($_POST['currentYear']) ? intval($_POST['currentYear']) : date('Y'); //phpcs:ignore
    2331                 $post_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
     2367                // phpcs:disable WordPress.Security.NonceVerification.Missing -- Calendar month/year/form_id from AJAX; nonce verified in caller or optional display.
     2368                $currentMonth = isset( $_POST['currentMonth'] ) ? max( 1, min( 12, intval( wp_unslash( $_POST['currentMonth'] ) ) ) ) : (int) gmdate( 'n' );
     2369                $currentYear  = isset( $_POST['currentYear'] ) ? absint( wp_unslash( $_POST['currentYear'] ) ) : (int) gmdate( 'Y' );
     2370                $post_id = isset( $_POST['form_id'] ) ? absint( wp_unslash( $_POST['form_id'] ) ) : 0;
     2371                // phpcs:enable WordPress.Security.NonceVerification.Missing
    23322372                $running_year = date("Y"); //phpcs:ignore
    23332373                ob_start();
     
    24272467         */
    24282468          function saab_action_display_available_timeslots(){
    2429             ini_set('display_startup_errors', 1);
    2430 ini_set('display_errors', 1);
    2431 error_reporting(-1);       
    2432                 //if( ! wp_verify_nonce( 'saab_front_nonce' ) ){}
     2469            $nonce_key = isset( $_POST['nonce'] ) ? 'nonce' : ( isset( $_POST['security'] ) ? 'security' : '' );
     2470            $nonce_val = ( $nonce_key && isset( $_POST[ $nonce_key ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ $nonce_key ] ) ) : '';
     2471            if ( ! $nonce_val || ! wp_verify_nonce( $nonce_val, 'my_ajax_nonce' ) ) {
     2472                wp_send_json_error( array( 'message' => __( 'Security check failed.', 'smart-appointment-booking' ) ) );
     2473                wp_die();
     2474            }
    24332475                $error = false;
    2434                 if(isset( $_POST['form_data'])){
    2435                     $form_data = $_POST['form_data'];
    2436                     $array_data = explode('_',$form_data);
    2437                     $post_id = $array_data[1];
    2438                     $current_month = $array_data[2];
    2439                     $current_day = $array_data[3];
    2440                     $current_year = $array_data[4];
    2441                 }
    2442                 if(isset( $_POST['clickedId'])){
    2443                     $clickedId = $_POST['clickedId'];
     2476                $post_id = 0;
     2477                $current_month = '';
     2478                $current_day = '';
     2479                $current_year = '';
     2480                $clickedId = '';
     2481                if ( isset( $_POST['form_data'] ) ) {
     2482                    $form_data = sanitize_text_field( wp_unslash( $_POST['form_data'] ) );
     2483                    $array_data = explode( '_', $form_data );
     2484                    $post_id = isset( $array_data[1] ) ? absint( $array_data[1] ) : 0;
     2485                    $current_month = isset( $array_data[2] ) ? sanitize_text_field( $array_data[2] ) : '';
     2486                    $current_day = isset( $array_data[3] ) ? sanitize_text_field( $array_data[3] ) : '';
     2487                    $current_year = isset( $array_data[4] ) ? sanitize_text_field( $array_data[4] ) : '';
     2488                }
     2489                if ( isset( $_POST['clickedId'] ) ) {
     2490                    $clickedId = sanitize_text_field( wp_unslash( $_POST['clickedId'] ) );
    24442491                }
    24452492                $todaysDate = date('Y-m-d', strtotime("$current_year-$current_month-$current_day")); //phpcs:ignore
     
    25232570            $response = array();
    25242571       
    2525             if (isset($_POST['bookingId']) && isset($_POST['bookingstatus'])) {
     2572            if ( isset( $_POST['bookingId'] ) && isset( $_POST['bookingstatus'] ) ) {
    25262573                // $booking_id = wp_base64_decode($encrypt_bookingId);
    2527                 $booking_id = $encrypt_bookingId;
    2528                 $bookingstatus = isset($_POST['bookingstatus']) ? sanitize_text_field($_POST['bookingstatus']) : '';
    2529        
    2530                 if ($bookingstatus === 'cancel') {
    2531                     if (isset($_POST['status'])) {
    2532                         $status = sanitize_text_field($_POST['status']);
     2574                $booking_id    = $encrypt_bookingId;
     2575                $bookingstatus = isset( $_POST['bookingstatus'] ) ? sanitize_text_field( wp_unslash( $_POST['bookingstatus'] ) ) : '';
     2576
     2577                if ( $bookingstatus === 'cancel' ) {
     2578                    if ( isset( $_POST['status'] ) ) {
     2579                        $status = sanitize_text_field( wp_unslash( $_POST['status'] ) );
    25332580                        if ($status === 'check') {
    25342581                            $get_current_status = get_post_meta($booking_id, 'saab_entry_status', true);
     
    25872634            }
    25882635            echo '<div class="booking-cancellation-card">';
    2589             $encrypt_bookingId = isset($_REQUEST['booking_id']) ? sanitize_text_field($_REQUEST['booking_id']) : '';
    2590 
    2591             if (isset($_REQUEST['booking_id']) && isset($_REQUEST['status'])) {
     2636            $encrypt_bookingId = isset( $_REQUEST['booking_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['booking_id'] ) ) : '';
     2637
     2638            if ( isset( $_REQUEST['booking_id'] ) && isset( $_REQUEST['status'] ) ) {
    25922639                // $booking_id = wp_base64_decode($encrypt_bookingId);
    25932640                $booking_id = $encrypt_bookingId;
    2594                 $bookingstatus = sanitize_text_field( $_REQUEST['status'] );
     2641                $bookingstatus = sanitize_text_field( wp_unslash( $_REQUEST['status'] ) );
    25952642
    25962643                if ($bookingstatus === 'cancel' ) {
     
    26252672        function saab_cancel_booking_shortcode() {
    26262673            $response = array(                 
    2627                 'message' => esc_html__('','smart-appointment-booking'),
     2674                'message' => '',
    26282675                'mail_message' => '',
    26292676               
  • smart-appointment-booking/trunk/readme.txt

    r3421205 r3450387  
    77Tested up to: 6.9
    88License: GPL-3.0-or-later
    9 Version: 1.0.7
    10 Stable tag: 1.0.7
     9Version: 1.0.8
     10Stable tag: 1.0.8
    1111License: GPLv3 or later License
    1212License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    131131== Changelog ==
    132132
     133= 1.0.8 =
     134* Security: Nonce verification and input sanitization improvements across admin and front forms.
     135* Security: Proper use of wp_unslash() before sanitization for POST/GET data.
     136* Code quality: Addressed WordPress PHPCS warnings (escaping, validated input, slow query notices).
     137* Tested with the latest version of WordPress (6.9).
     138
    133139= 1.0.7 =
    134140* Tested with the latest version of WordPress (6.9).
     
    172178== Upgrade Notice ==
    173179
     180= 1.0.8 =
     181* Security: Nonce verification and input sanitization improvements across admin and front forms.
     182* Security: Proper use of wp_unslash() before sanitization for POST/GET data.
     183* Code quality: Addressed WordPress PHPCS warnings (escaping, validated input, slow query notices).
     184* Tested with the latest version of WordPress (6.9).
     185
     186= 1.0.7 =
     187* Tested with the latest version of WordPress (6.9).
     188
     189= 1.0.6 =
     190* Issue Fixed
     191
     192= 1.0.5 =
     193* Issue Fixed
     194
     195= 1.0.4 =
     196* Fix: Issue with enabling or disabling the booking form
     197* Fix: Calendar not displaying when clicking arrows
     198* Fix: Calendar not displaying when selecting a month
     199* Fix: Calendar not displaying when selecting a year
     200* Fix: Timeslot issue in the 'Manage Entry' section
     201* Fix: Display of booked timeslots in the form
     202* Fix: Change button name for "Add New Form (Booking Form)"
     203* Fix: Remove "View Post" link after form is published
     204* Fix: Generate shortcode when publishing the form
     205* Add: List of added users
     206* Add: List of added statuses
     207* Add: "Appointment Type: Virtual" option
     208
     209= 1.0.3 =
     210* Fix: Date being selected in calendar issue
     211* Fix: Time being selected issue
     212* Fix: Available seat count issue
     213* Fix: Data listing issue
     214* Fix: Manage Entry issue
     215
     216= 1.0.2 =
     217* The issue on the backend has been fixed.
     218
     219= 1.0.1 =
     220* Issue Fixed "Form Is not being saved"
     221
    174222= 1.0.0 =
    175 1.0 is Initial Release.
     223* Initial Release
  • smart-appointment-booking/trunk/smart-appointment-booking.php

    r3421205 r3450387  
    44 * Plugin URL: https://wordpress.org/plugins/smart-appointment-booking/
    55 * Description: This is the all-in-one solution for efficient appointment management, offering customizable forms, seamless booking and modifications waitlist management.
    6  * Version: 1.0.7
     6 * Version: 1.0.8
    77 * Author: ZealousWeb
    88 * Author URI: https://www.zealousweb.com
     
    2424 *
    2525 * @package Smart Appointment & Booking
    26  * @since 1.0.7
     26 * @since 1.0.8
    2727 */
    2828
    2929/* Start of Code */
    3030if ( ! defined( 'SAAB_VERSION' ) ) {
    31     define( 'SAAB_VERSION', '1.0.7' ); // Version of the plugin
     31    define( 'SAAB_VERSION', '1.0.8' ); // Version of the plugin
    3232}
    3333
Note: See TracChangeset for help on using the changeset viewer.