PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.6
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.6
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / widgets / class-charitable-campaign-terms-widget.php

class-charitable-campaign-terms-widget.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.6.6, at includes/widgets/class-charitable-campaign-terms-widget.php

117 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Campaign categories/tags widget class.
4 *
5 * @package Charitable/Widgets/Charitable_Campaign_Terms_Widget
6 * @category Class
7 * @author Eric Daams
8 * @since 1.0.0
9 * @version 1.5.4
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) { exit; }
14
15 if ( ! class_exists( 'Charitable_Campaign_Terms_Widget' ) ) :
16
17 /**
18 * Charitable_Campaign_Terms_Widget class.
19 *
20 * @since 1.0.0
21 */
22 class Charitable_Campaign_Terms_Widget extends WP_Widget {
23
24 /**
25 * Instantiate the widget and set up basic configuration.
26 *
27 * @since 1.0.0
28 */
29 public function __construct() {
30 parent::__construct(
31 'charitable_campaign_terms_widget',
32 __( 'Campaign Categories / Tags', 'charitable' ),
33 array(
34 'description' => __( 'Displays your Charitable campaign categories or tags.', 'charitable' ),
35 // 'customize_selective_refresh' => true
36 )
37 );
38 }
39
40 /**
41 * Display the widget contents on the front-end.
42 *
43 * @since 1.0.0
44 *
45 * @param array $args
46 * @param array $instance
47 * @return void
48 */
49 public function widget( $args, $instance ) {
50 $view_args = array_merge( $args, $instance );
51 $template = array_key_exists( 'dropdown', $view_args ) && $view_args['dropdown'] ? 'widgets/campaign-terms-dropdown.php' : 'widgets/campaign-terms.php';
52
53 charitable_template( $template, $view_args );
54 }
55
56 /**
57 * Display the widget form in the admin.
58 *
59 * @since 1.0.0
60 *
61 * @param array $instance The current settings for the widget options.
62 * @return void
63 */
64 public function form( $instance ) {
65 $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
66 $taxonomy = isset( $instance['taxonomy'] ) ? $instance['taxonomy'] : 'campaign_category';
67 $show_count = isset( $instance['show_count'] ) && $instance['show_count'];
68 $hide_empty = isset( $instance['hide_empty'] ) && $instance['hide_empty'];
69 $dropdown = isset( $instance['dropdown'] ) && $instance['dropdown'];
70 ?>
71 <p>
72 <label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _e( 'Title:', 'charitable' ) ?></label>
73 <input type="text" name="<?php echo $this->get_field_name('title' ) ?>" id="<?php echo $this->get_field_id( 'title' ) ?>" value="<?php echo $title ?>"/>
74 </p>
75 <p>
76 <label for="<?php echo $this->get_field_id( 'taxonomy' ) ?>"><?php _e( 'Taxonomy', 'charitable' ) ?></label>
77 <select name="<?php echo $this->get_field_name('taxonomy' ) ?>" id="<?php echo $this->get_field_id( 'taxonomy' ) ?>">
78 <option value="campaign_category" <?php selected( 'campaign_category', $taxonomy ) ?>><?php _e( 'Categories', 'charitable' ) ?></option>
79 <option value="campaign_tag" <?php selected( 'campaign_tag', $taxonomy ) ?>><?php _e( 'Tags', 'charitable' ) ?></option>
80 </select>
81 </p>
82 <p>
83 <label for="<?php echo $this->get_field_id( 'show_count' ) ?>"><?php _e( 'Show count:', 'charitable' ) ?></label>
84 <input type="checkbox" name="<?php echo $this->get_field_name('show_count' ) ?>" id="<?php echo $this->get_field_id( 'show_count' ) ?>" <?php checked( $show_count ) ?> />
85 </p>
86 <p>
87 <label for="<?php echo $this->get_field_id( 'hide_empty' ) ?>"><?php _e( 'Hide empty:', 'charitable' ) ?></label>
88 <input type="checkbox" name="<?php echo $this->get_field_name('hide_empty' ) ?>" id="<?php echo $this->get_field_id( 'hide_empty' ) ?>" <?php checked( $hide_empty ) ?> />
89 </p>
90 <p>
91 <label for="<?php echo $this->get_field_id( 'dropdown' ) ?>"><?php _e( 'Display as dropdown:', 'charitable' ) ?></label>
92 <input type="checkbox" name="<?php echo $this->get_field_name( 'dropdown' ) ?>" id="<?php echo $this->get_field_id( 'dropdown' ) ?>" <?php checked( $dropdown ) ?> />
93 </p>
94 <?php
95 }
96
97 /**
98 * Update the widget settings in the admin.
99 *
100 * @since 1.0.0
101 *
102 * @param array $new_instance The updated settings.
103 * @param array $new_instance The old settings.
104 * @return void
105 */
106 public function update( $new_instance, $old_instance ) {
107 $instance = array();
108 $instance['title'] = isset( $new_instance['title'] ) ? $new_instance['title'] : $old_instance['title'];
109 $instance['taxonomy'] = isset( $new_instance['taxonomy'] ) ? $new_instance['taxonomy'] : $old_instance['taxonomy'];
110 $instance['show_count'] = isset( $new_instance['show_count'] ) && $new_instance['show_count'] == 'on';
111 $instance['hide_empty'] = isset( $new_instance['hide_empty'] ) && $new_instance['hide_empty'] == 'on';
112 $instance['dropdown'] = isset( $new_instance['dropdown'] ) && $new_instance['dropdown'] == 'on';
113 return $instance;
114 }
115 }
116
117 endif;