← All changes
|
includes/widgets/class-charitable-donate-widget.php
+20
-19
1.6.6
→
1.8.13
View file →
| @@ -3,15 +3,17 @@ | ||
| 3 | 3 | * Class responsible for setting up the donate widget. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Donate_Widget |
| 6 | 6 | * @version 1.0.0 |
| 7 | - * @author Eric Daams | |
| 8 | - * @copyright Copyright (c) 2018, Studio 164a | |
| 7 | + * @author David Bisset | |
| 8 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 9 | 9 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { exit; } | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 14 | 16 | |
| 15 | 17 | if ( ! class_exists( 'Charitable_Donate_Widget' ) ) : |
| 16 | 18 | |
| 17 | 19 | /** |
| @@ -32,13 +34,12 @@ | ||
| 32 | 34 | parent::__construct( |
| 33 | 35 | 'charitable_donate_widget', |
| 34 | 36 | __( 'Campaign Donation', 'charitable' ), |
| 35 | 37 | array( |
| 36 | - 'description' => __( 'Display a donation widget.', 'charitable' ), | |
| 38 | + 'description' => __( 'Display a donation widget.', 'charitable' ), | |
| 37 | 39 | 'customize_selective_refresh' => true, |
| 38 | 40 | ) |
| 39 | 41 | ); |
| 40 | - | |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | /** |
| 44 | 45 | * Displays the widget on the frontend. |
| @@ -44,14 +45,14 @@ | ||
| 44 | 45 | * Displays the widget on the frontend. |
| 45 | 46 | * |
| 46 | 47 | * @since 1.0.0 |
| 47 | 48 | * |
| 48 | - * @param array $args Widget args. | |
| 49 | + * @param array $args Widget args. | |
| 49 | 50 | * @param array $instance Widget instance. |
| 50 | 51 | * @return void |
| 51 | 52 | */ |
| 52 | 53 | public function widget( $args, $instance ) { |
| 53 | - if ( ! array_key_exists( 'campaign_id', $instance ) || '' == $instance['campaign_id'] ) { | |
| 54 | + if ( ! array_key_exists( 'campaign_id', $instance ) || '' === $instance['campaign_id'] ) { | |
| 54 | 55 | return; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | charitable_template( 'widgets/donate.php', array_merge( $args, $instance ) ); |
| @@ -61,9 +62,9 @@ | ||
| 61 | 62 | * Displays the widget form. |
| 62 | 63 | * |
| 63 | 64 | * @since 1.0.0 |
| 64 | 65 | * |
| 65 | - * @param array $instance Widget instance. | |
| 66 | + * @param array $instance Widget instance. | |
| 66 | 67 | * @return void |
| 67 | 68 | */ |
| 68 | 69 | public function form( $instance ) { |
| 69 | 70 | |
| @@ -77,24 +78,24 @@ | ||
| 77 | 78 | $campaign_id = $instance['campaign_id']; |
| 78 | 79 | $campaigns = Charitable_Campaigns::query( array( 'posts_per_page' => -1 ) ); |
| 79 | 80 | ?> |
| 80 | 81 | <p> |
| 81 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'charitable' ) ?> | |
| 82 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> | |
| 82 | + <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'charitable' ); ?> | |
| 83 | + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> | |
| 83 | 84 | </label> |
| 84 | - </p> | |
| 85 | + </p> | |
| 85 | 86 | <p> |
| 86 | - <label for="<?php echo $this->get_field_id( 'campaign_id' ); ?>"><?php _e( 'Campaign:', 'charitable' ) ?> | |
| 87 | - <select name="<?php echo $this->get_field_name( 'campaign_id' ) ?>"> | |
| 88 | - <option value="current"><?php _e( 'Campaign currently viewed', 'charitable' ) ?></option> | |
| 89 | - <optgroup label="<?php _e( 'Specific campaigns', 'charitable' ) ?>"> | |
| 87 | + <label for="<?php echo esc_attr( $this->get_field_id( 'campaign_id' ) ); ?>"><?php esc_html_e( 'Campaign:', 'charitable' ); ?> | |
| 88 | + <select name="<?php echo esc_attr( $this->get_field_name( 'campaign_id' ) ); ?>"> | |
| 89 | + <option value="current"><?php esc_html_e( 'Campaign currently viewed', 'charitable' ); ?></option> | |
| 90 | + <optgroup label="<?php esc_html_e( 'Specific campaigns', 'charitable' ); ?>"> | |
| 90 | 91 | <?php foreach ( $campaigns->posts as $campaign ) : ?> |
| 91 | - <option value="<?php echo $campaign->ID ?>" <?php selected( $campaign->ID, $campaign_id ) ?>><?php echo $campaign->post_title ?></option> | |
| 92 | + <option value="<?php echo esc_attr( $campaign->ID ); ?>" <?php selected( $campaign->ID, $campaign_id ); ?>><?php echo esc_html( $campaign->post_title ); ?></option> | |
| 92 | 93 | <?php endforeach ?> |
| 93 | 94 | </optgroup> |
| 94 | - </select> | |
| 95 | - </label> | |
| 96 | - </p> | |
| 95 | + </select> | |
| 96 | + </label> | |
| 97 | + </p> | |
| 97 | 98 | <?php |
| 98 | 99 | } |
| 99 | 100 | |
| 100 | 101 | /** |