← All changes
|
templates/woocommerce/coupon-restriction-option.php
+15
-10
1.0.21
→
1.0.64
View file →
| @@ -4,32 +4,37 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package Timetics |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -$selected_ids = get_post_meta( $coupon_id, 'timetics_meeting_ids', true ); | |
| 9 | -$selected_ids = ! empty( $selected_ids ) ? $selected_ids : []; | |
| 8 | +defined( 'ABSPATH' ) || exit; | |
| 10 | 9 | |
| 10 | +$timetics_selected_ids = get_post_meta( $coupon_id, 'timetics_meeting_ids', true ); | |
| 11 | +$timetics_selected_ids = ! empty( $timetics_selected_ids ) ? $timetics_selected_ids : []; | |
| 12 | + | |
| 13 | +// Add nonce field for security | |
| 14 | +wp_nonce_field( 'timetics_coupon_action', 'timetics_coupon_nonce' ); | |
| 15 | + | |
| 11 | 16 | ?> |
| 12 | 17 | <p class="form-field"> |
| 13 | - <label><?php _e( 'Timetics Meetings', 'timetics' ); ?></label> | |
| 18 | + <label><?php esc_html_e( 'Timetics Meetings', 'timetics' ); ?></label> | |
| 14 | 19 | <select class="timetics-product-search" multiple="multiple" style="width: 50%;" name="timetics_meeting_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'timetics' ); ?>"> |
| 15 | 20 | <?php |
| 16 | - $args = array( | |
| 21 | + $timetics_args = array( | |
| 17 | 22 | 'status' => 'publish', |
| 18 | 23 | 'limit' => -1, |
| 19 | 24 | 'category' => array( 'timetics-meeting' ), |
| 20 | 25 | ); |
| 21 | - $products = wc_get_products( $args ); | |
| 26 | + $timetics_products = wc_get_products( $timetics_args ); | |
| 22 | 27 | |
| 23 | - foreach ( $products as $product ) { | |
| 24 | - $selected = in_array( $product->get_id(), $selected_ids ); | |
| 25 | - if ( is_object( $product ) ) { | |
| 26 | - echo '<option value="' . esc_attr( $product->get_id() ) . '"' . selected( $selected, true, false ) . '>' . esc_html( wp_strip_all_tags( $product->get_formatted_name() ) ) . '</option>'; | |
| 28 | + foreach ( $timetics_products as $timetics_product ) { | |
| 29 | + $timetics_selected = in_array( $timetics_product->get_id(), $timetics_selected_ids ); | |
| 30 | + if ( is_object( $timetics_product ) ) { | |
| 31 | + echo '<option value="' . esc_attr( $timetics_product->get_id() ) . '"' . selected( $timetics_selected, true, false ) . '>' . esc_html( wp_strip_all_tags( $timetics_product->get_formatted_name() ) ) . '</option>'; | |
| 27 | 32 | } |
| 28 | 33 | } |
| 29 | 34 | ?> |
| 30 | 35 | </select> |
| 31 | - <?php echo wc_help_tip( __( 'Products that the coupon will be applied to, or that need to be in the cart in order for the "Fixed cart discount" to be applied.', 'timetics' ) ); ?> | |
| 36 | + <?php echo wc_help_tip( __( 'Products that the coupon will be applied to, or that need to be in the cart in order for the "Fixed cart discount" to be applied.', 'timetics' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> | |
| 32 | 37 | </p> |
| 33 | 38 | <script> |
| 34 | 39 | jQuery(function($) { |
| 35 | 40 | $('.timetics-product-search').select2(); |