← All changes
|
includes/widgets/class-charitable-campaigns-widget.php
+32
-32
1.7.0.11
→
1.8.13
View file →
| @@ -1,13 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Campaigns widget class. |
| 4 | 4 | * |
| 5 | - * @class Charitable_Campaigns_Widget | |
| 6 | - * @version 1.0.0 | |
| 7 | - * @package Charitable/Widgets/Campaigns Widget | |
| 8 | - * @category Class | |
| 9 | - * @author David Bisset | |
| 5 | + * @class Charitable_Campaigns_Widget | |
| 6 | + * @version 1.0.0 | |
| 7 | + * @package Charitable/Widgets/Campaigns Widget | |
| 8 | + * @category Class | |
| 9 | + * @author David Bisset | |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -32,9 +32,9 @@ | ||
| 32 | 32 | parent::__construct( |
| 33 | 33 | 'charitable_campaigns_widget', |
| 34 | 34 | __( 'Campaigns', 'charitable' ), |
| 35 | 35 | array( |
| 36 | - 'description' => __( 'Displays your Charitable campaigns.', 'charitable' ), | |
| 36 | + 'description' => __( 'Displays your Charitable campaigns.', 'charitable' ), | |
| 37 | 37 | 'customize_selective_refresh' => true, |
| 38 | 38 | ) |
| 39 | 39 | ); |
| 40 | 40 | } |
| @@ -43,16 +43,16 @@ | ||
| 43 | 43 | * Display the widget contents on the front-end. |
| 44 | 44 | * |
| 45 | 45 | * @since 1.0.0 |
| 46 | 46 | * |
| 47 | - * @param array $args | |
| 48 | - * @param array $instance | |
| 47 | + * @param array $args The widget arguments. | |
| 48 | + * @param array $instance The widget instance. | |
| 49 | 49 | */ |
| 50 | 50 | public function widget( $args, $instance ) { |
| 51 | 51 | $view_args = array_merge( $args, $instance ); |
| 52 | - $view_args['campaigns'] = $this->get_widget_campaigns( $instance ); | |
| 52 | + $view_args['campaigns'] = $this->get_widget_campaigns( $instance ); | |
| 53 | 53 | |
| 54 | - charitable_template( 'widgets/campaigns.php', $view_args ); | |
| 54 | + charitable_template( 'widgets/campaigns.php', $view_args ); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Display the widget form in the admin. |
| @@ -58,38 +58,38 @@ | ||
| 58 | 58 | * Display the widget form in the admin. |
| 59 | 59 | * |
| 60 | 60 | * @since 1.0.0 |
| 61 | 61 | * |
| 62 | - * @param array $instance The current settings for the widget options. | |
| 63 | - * @return void | |
| 62 | + * @param array $instance The current settings for the widget options. | |
| 63 | + * @return void | |
| 64 | 64 | */ |
| 65 | 65 | public function form( $instance ) { |
| 66 | 66 | $defaults = array( |
| 67 | - 'title' => '', | |
| 68 | - 'number' => 10, | |
| 69 | - 'order' => 'recent', | |
| 70 | - 'show_thumbnail' => false, | |
| 71 | - ); | |
| 67 | + 'title' => '', | |
| 68 | + 'number' => 10, | |
| 69 | + 'order' => 'recent', | |
| 70 | + 'show_thumbnail' => false, | |
| 71 | + ); | |
| 72 | 72 | |
| 73 | - $args = wp_parse_args( $instance, $defaults ); | |
| 73 | + $args = wp_parse_args( $instance, $defaults ); | |
| 74 | 74 | ?> |
| 75 | 75 | <p> |
| 76 | - <label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _e( 'Title:', 'charitable' ) ?></label> | |
| 77 | - <input type="text" name="<?php echo $this->get_field_name( 'title' ) ?>" id="<?php echo $this->get_field_id( 'title' ) ?>" value="<?php echo $args['title'] ?>"/> | |
| 76 | + <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'charitable' ); ?></label> | |
| 77 | + <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" value="<?php echo esc_attr( $args['title'] ); ?>"/> | |
| 78 | 78 | </p> |
| 79 | 79 | <p> |
| 80 | - <label for="<?php echo $this->get_field_id( 'number' ) ?>"><?php _e( 'Number of campaigns to display:', 'charitable' ) ?></label> | |
| 81 | - <input type="text" name="<?php echo $this->get_field_name( 'number' ) ?>" id="<?php echo $this->get_field_id( 'number' ) ?>" value="<?php echo $args['number'] ?>" /> | |
| 80 | + <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of campaigns to display:', 'charitable' ); ?></label> | |
| 81 | + <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" value="<?php echo esc_attr( $args['number'] ); ?>" /> | |
| 82 | 82 | </p> |
| 83 | 83 | <p> |
| 84 | - <input id="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ) ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_thumbnail' ) ); ?>" <?php checked( $args['show_thumbnail'] ) ?>> | |
| 85 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ) ?>"><?php _e( 'Show thumbnail', 'charitable' ) ?></label> | |
| 84 | + <input id="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>" type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_thumbnail' ) ); ?>" <?php checked( $args['show_thumbnail'] ); ?>> | |
| 85 | + <label for="<?php echo esc_attr( $this->get_field_id( 'show_thumbnail' ) ); ?>"><?php esc_html_e( 'Show thumbnail', 'charitable' ); ?></label> | |
| 86 | 86 | </p> |
| 87 | 87 | <p> |
| 88 | - <label for="<?php echo $this->get_field_id( 'order' ) ?>"><?php _e( 'Order:', 'charitable' ) ?></label> | |
| 89 | - <select name="<?php echo $this->get_field_name( 'order' ) ?>" id="<?php echo $this->get_field_id( 'order' ) ?>"> | |
| 90 | - <option value="recent" <?php selected( 'recent', $args['order'] ) ?>><?php _e( 'Date published', 'charitable' ) ?></option> | |
| 91 | - <option value="ending" <?php selected( 'ending', $args['order'] ) ?>><?php _e( 'Ending soonest', 'charitable' ) ?></option> | |
| 88 | + <label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order:', 'charitable' ); ?></label> | |
| 89 | + <select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"> | |
| 90 | + <option value="recent" <?php selected( 'recent', $args['order'] ); ?>><?php esc_html_e( 'Date published', 'charitable' ); ?></option> | |
| 91 | + <option value="ending" <?php selected( 'ending', $args['order'] ); ?>><?php esc_html_e( 'Ending soonest', 'charitable' ); ?></option> | |
| 92 | 92 | </select> |
| 93 | 93 | </p> |
| 94 | 94 | <?php |
| 95 | 95 | } |
| @@ -98,11 +98,11 @@ | ||
| 98 | 98 | * Update the widget settings in the admin. |
| 99 | 99 | * |
| 100 | 100 | * @since 1.0.0 |
| 101 | 101 | * |
| 102 | - * @param array $new_instance The updated settings. | |
| 103 | - * @param array $new_instance The old settings. | |
| 104 | - * @return void | |
| 102 | + * @param array $new_instance The updated settings. | |
| 103 | + * @param array $old_instance The old settings. | |
| 104 | + * @return array | |
| 105 | 105 | */ |
| 106 | 106 | public function update( $new_instance, $old_instance ) { |
| 107 | 107 | |
| 108 | 108 | $instance = array(); |
| @@ -117,9 +117,9 @@ | ||
| 117 | 117 | * Return campaigns to display in the widget. |
| 118 | 118 | * |
| 119 | 119 | * @since 1.0.0 |
| 120 | 120 | * |
| 121 | - * @param array $instance | |
| 121 | + * @param array $instance The widget instance. | |
| 122 | 122 | * @return WP_Query |
| 123 | 123 | */ |
| 124 | 124 | protected function get_widget_campaigns( $instance ) { |
| 125 | 125 | |