| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * HTML elements | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @package     Give | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @subpackage  Classes/Give_HTML_Elements | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @copyright   Copyright (c) 2016, WordImpress | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @license     https://opensource.org/licenses/gpl-license GNU Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @since       1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | // Exit if accessed directly. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | if ( ! defined( 'ABSPATH' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * Give_HTML_Elements Class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * A helper class for outputting common HTML elements, such as product drop downs. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | class Give_HTML_Elements { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	 * Donations Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	 * Renders an HTML Dropdown of all the donations. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	 * @param  array $args Arguments for the dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	 * @return string       Donations dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	public function donations_dropdown( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 			'name'        => 'donations', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 			'id'          => 'donations', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 			'class'       => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 			'multiple'    => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 			'selected'    => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			'chosen'      => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			'number'      => 30, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 			'placeholder' => __( 'Select a donation', 'give' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		$payments = new Give_Payments_Query( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 			'number' => $args['number'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		$payments = $payments->get_payments(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		$options = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		//Provide nice human readable options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		if ( $payments ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 			$options[0] = $args['placeholder']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			foreach ( $payments as $payment ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 				$options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 			$options[0] = __( 'No donations found.', 'give' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		$output = $this->select( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 			'name'             => $args['name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			'selected'         => $args['selected'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 			'id'               => $args['id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			'class'            => $args['class'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			'options'          => $options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			'chosen'           => $args['chosen'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 			'multiple'         => $args['multiple'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			'placeholder'      => $args['placeholder'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 			'select_atts'      => $args['select_atts'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			'show_option_all'  => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 			'show_option_none' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 * Give Forms Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	 * Renders an HTML Dropdown of all the Give Forms. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 	 * @param  array $args Arguments for the dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	 * @return string      Give forms dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	public function forms_dropdown( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 			'name'        => 'forms', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			'id'          => 'forms', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			'class'       => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 			'multiple'    => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 			'selected'    => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 			'chosen'      => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 			'number'      => 30, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 			'placeholder' => esc_attr__( 'Select a Donation Form', 'give' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 			'data'        => array( 'search-type' => 'form' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		$forms = get_posts( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			'post_type'      => 'give_forms', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 			'orderby'        => 'title', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 			'order'          => 'ASC', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			'posts_per_page' => $args['number'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		$options = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		// Ensure the selected. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 		if ( false !== $args['selected'] && $args['selected'] !== 0 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 			$options[ $args['selected'] ] = get_the_title( $args['selected'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		if ( $forms ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 			$options[0] = $args['placeholder']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 			foreach ( $forms as $form ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 				$form_title                     = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 				$options[ absint( $form->ID ) ] = esc_html( $form_title ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 			$options[0] = esc_html__( 'No forms found.', 'give' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		$output = $this->select( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 			'name'             => $args['name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 			'selected'         => $args['selected'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 			'id'               => $args['id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 			'class'            => $args['class'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 			'options'          => $options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 			'chosen'           => $args['chosen'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 			'multiple'         => $args['multiple'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 			'placeholder'      => $args['placeholder'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 			'show_option_all'  => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 			'show_option_none' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 			'data'             => $args['data'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	 * Donors Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	 * Renders an HTML Dropdown of all customers. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 	 * @param  array $args Arguments for the dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	 * @return string      Donors dropdown. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 172 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  | 	public function donor_dropdown( $args = array() ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  | 		$defaults = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  | 			'name'        => 'donors', | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  | 			'id'          => 'donors', | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  | 			'class'       => '', | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  | 			'multiple'    => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  | 			'selected'    => 0, | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  | 			'chosen'      => true, | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  | 			'placeholder' => esc_attr__( 'Select a Donor', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  | 			'number'      => 30, | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  | 			'data'        => array( 'search-type' => 'donor' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  | 		); | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  | 		$customers = Give()->customers->get_customers( array( | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  | 			'number' => $args['number'] | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  | 		) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 193 |  |  | 		$options = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  | 		if ( $customers ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  | 			$options[0] = esc_html__( 'No donor attached', 'give' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  | 			foreach ( $customers as $customer ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  | 				$options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 199 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 200 |  |  | 		} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 201 |  |  | 			$options[0] = esc_html__( 'No donors found.', 'give' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 202 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  | 		if ( ! empty( $args['selected'] ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  | 			// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. | 
            
                                                                        
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 208 |  |  | 			if ( ! array_key_exists( $args['selected'], $options ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 210 |  |  | 				$customer = new Give_Customer( $args['selected'] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 212 |  |  | 				if ( $customer ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 214 |  |  | 					$options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 218 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 220 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 222 |  |  | 		$output = $this->select( array( | 
            
                                                                        
                            
            
                                    
            
            
                | 223 |  |  | 			'name'             => $args['name'], | 
            
                                                                        
                            
            
                                    
            
            
                | 224 |  |  | 			'selected'         => $args['selected'], | 
            
                                                                        
                            
            
                                    
            
            
                | 225 |  |  | 			'id'               => $args['id'], | 
            
                                                                        
                            
            
                                    
            
            
                | 226 |  |  | 			'class'            => $args['class'] . ' give-customer-select', | 
            
                                                                        
                            
            
                                    
            
            
                | 227 |  |  | 			'options'          => $options, | 
            
                                                                        
                            
            
                                    
            
            
                | 228 |  |  | 			'multiple'         => $args['multiple'], | 
            
                                                                        
                            
            
                                    
            
            
                | 229 |  |  | 			'chosen'           => $args['chosen'], | 
            
                                                                        
                            
            
                                    
            
            
                | 230 |  |  | 			'show_option_all'  => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 231 |  |  | 			'show_option_none' => false, | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  | 			'data'             => $args['data'], | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  | 		) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  | 		return $output; | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 	 * Categories Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 	 * Renders an HTML Dropdown of all the Categories. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 	 * @param  string $name Name attribute of the dropdown. Default is 'give_forms_categories'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	 * @param  int $selected Category to select automatically. Default is 0. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 	 * @param  array $args Select box options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 	 * @return string           Categories dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 	public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 		$categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 		$options    = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		foreach ( $categories as $category ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 			$options[ absint( $category->term_id ) ] = esc_html( $category->name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 		$output = $this->select( wp_parse_args( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 			$args, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 				'name'             => $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 				'selected'         => $selected, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 				'options'          => $options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 				'show_option_all'  => esc_html__( 'All Categories', 'give' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 				'show_option_none' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 	 * Tags Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 	 * Renders an HTML Dropdown of all the Tags. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 	 * @since  1.8 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 	 * @param  string $name Name attribute of the dropdown. Default is 'give_forms_tags'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 	 * @param  int $selected Tag to select automatically. Default is 0. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 	 * @param  array $args Select box options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 	 * @return string           Tags dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 	public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 		$tags    = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 		$options = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 		foreach ( $tags as $tag ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 			$options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 		$output = $this->select( wp_parse_args( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 			$args, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 				'name'             => $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 				'selected'         => $selected, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 				'options'          => $options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 				'show_option_all'  => esc_html__( 'All Tags', 'give' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 				'show_option_none' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 	 * Years Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 	 * Renders an HTML Dropdown of years. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 	 * @param  string $name Name attribute of the dropdown. Default is 'year'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 	 * @param  int $selected Year to select automatically. Default is 0. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 	 * @param  int $years_before Number of years before the current year the dropdown should start with. Default is 5. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 	 * @param  int $years_after Number of years after the current year the dropdown should finish at. Default is 0. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 	 * @return string               Years dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 	public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 		$current    = date( 'Y' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 		$start_year = $current - absint( $years_before ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 		$end_year   = $current + absint( $years_after ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 		$selected   = empty( $selected ) ? date( 'Y' ) : $selected; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 		$options    = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 		while ( $start_year <= $end_year ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 			$options[ absint( $start_year ) ] = $start_year; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 			$start_year ++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 		$output = $this->select( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 			'name'             => $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 			'selected'         => $selected, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 			'options'          => $options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 			'show_option_all'  => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 			'show_option_none' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 	 * Months Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 	 * Renders an HTML Dropdown of months. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 	 * @param  string $name Name attribute of the dropdown. Default is 'month'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 	 * @param  int $selected Month to select automatically. Default is 0. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 	 * @return string           Months dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 	public function month_dropdown( $name = 'month', $selected = 0 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 		$month    = 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 		$options  = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 		$selected = empty( $selected ) ? date( 'n' ) : $selected; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 		while ( $month <= 12 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 			$options[ absint( $month ) ] = give_month_num_to_name( $month ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 			$month ++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 		$output = $this->select( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 			'name'             => $name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 			'selected'         => $selected, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 			'options'          => $options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 			'show_option_all'  => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 			'show_option_none' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 	 * Dropdown | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 	 * Renders an HTML Dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 	 * @param  array $args Arguments for the dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 	 * @return string      The dropdown. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 	public function select( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 			'options'          => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 			'name'             => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 			'class'            => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 			'id'               => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 			'selected'         => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 			'chosen'           => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 			'placeholder'      => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 			'multiple'         => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 			'select_atts'      => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 			'show_option_all'  => __( 'All', 'give' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 			'show_option_none' => __( 'None', 'give' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 			'data'             => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 			'readonly'         => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 			'disabled'         => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		$data_elements = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		foreach ( $args['data'] as $key => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 			$data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 		if ( $args['multiple'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 			$multiple = ' MULTIPLE'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 			$multiple = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 		if ( $args['chosen'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 			$args['class'] .= ' give-select-chosen'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 		if ( $args['placeholder'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 			$placeholder = $args['placeholder']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 			$placeholder = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 		$output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 		if ( $args['show_option_all'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 			if ( $args['multiple'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 				$selected = selected( true, in_array( 0, $args['selected'] ), false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 				$selected = selected( $args['selected'], 0, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 			$output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		if ( ! empty( $args['options'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 			if ( $args['show_option_none'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 				if ( $args['multiple'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 					$selected = selected( true, in_array( - 1, $args['selected'] ), false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 					$selected = selected( $args['selected'], - 1, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 				$output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 			foreach ( $args['options'] as $key => $option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 				if ( $args['multiple'] && is_array( $args['selected'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 					$selected = selected( true, in_array( $key, $args['selected'] ), false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 					$selected = selected( $args['selected'], $key, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 				$output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 		$output .= '</select>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 	 * Checkbox | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 	 * Renders an HTML Checkbox. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 	 * @param  array $args Arguments for the Checkbox. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 	 * @return string      The checkbox. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 	public function checkbox( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 			'name'    => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 			'current' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 			'class'   => 'give-checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 			'options' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 				'disabled' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 				'readonly' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 		$options = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 		if ( ! empty( $args['options']['disabled'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 			$options .= ' disabled="disabled"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 		} elseif ( ! empty( $args['options']['readonly'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 			$options .= ' readonly'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		$output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 	 * Text Field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 	 * Renders an HTML Text field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 	 * @param  array $args Arguments for the text field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 	 * @return string      The text field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 	public function text( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 		// Backwards compatibility. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 		if ( func_num_args() > 1 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 			$args = func_get_args(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 			$name  = $args[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 			$value = isset( $args[1] ) ? $args[1] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 			$label = isset( $args[2] ) ? $args[2] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 			$desc  = isset( $args[3] ) ? $args[3] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 			'name'         => isset( $name ) ? $name : 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 			'value'        => isset( $value ) ? $value : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 			'label'        => isset( $label ) ? $label : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 			'desc'         => isset( $desc ) ? $desc : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 			'placeholder'  => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 			'class'        => 'regular-text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 			'disabled'     => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 			'autocomplete' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 			'data'         => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 		$disabled = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 		if ( $args['disabled'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 			$disabled = ' disabled="disabled"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 		$data = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 		if ( ! empty( $args['data'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 			foreach ( $args['data'] as $key => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 				$data .= 'data-' . $key . '="' . $value . '" '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 		if ( ! empty( $args['desc'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 		$output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 		$output .= '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 	 * Date Picker | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 	 * Renders a date picker field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 	 * @since  1.5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 	 * @param  array $args Arguments for the date picker. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 	 * @return string      The date picker. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 	public function date_field( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 		if ( empty( $args['class'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 			$args['class'] = 'give_datepicker'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 		} elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 			$args['class'] .= ' give_datepicker'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 		return $this->text( $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 	 * Textarea | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 	 * Renders an HTML textarea. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 	 * @param  array $args Arguments for the textarea. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 	 * @return string      The textarea. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 	public function textarea( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 			'name'     => 'textarea', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 			'value'    => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 			'label'    => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 			'desc'     => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 			'class'    => 'large-text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 			'disabled' => false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 		$disabled = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 		if ( $args['disabled'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 			$disabled = ' disabled="disabled"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 		$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 		if ( ! empty( $args['desc'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 		$output .= '</span>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 	 * User Search Field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 	 * Renders an ajax user search field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 	 * @since  1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 	 * @param  array $args Arguments for the search field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 	 * @return string      The text field with ajax search. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 	public function ajax_user_search( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  | 			'name'        => 'users', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 			'id'          => 'users', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 			'class'       => 'give-ajax-user-search', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 			'multiple'    => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 			'selected'    => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 			'chosen'      => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 			'number'      => 30, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 			'select_atts' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 			'placeholder' => __( 'Select a user', 'give' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 			'data'        => array( 'search-type' => 'user' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  | 		$get_users_args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 			'number' => $args['number'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 		$users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 		$options = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 		if ( $users ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 			$options[0] = $args['placeholder']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 			foreach ( $users as $user ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 				$options[ absint( $user->id ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 			$options[0] = esc_html__( 'No users found.', 'give' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  | 		$output = $this->select( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 			'name'             => $args['name'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 			'selected'         => $args['selected'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 			'id'               => $args['id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 			'class'            => $args['class'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 			'options'          => $options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 			'chosen'           => $args['chosen'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 			'multiple'         => $args['multiple'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 			'placeholder'      => $args['placeholder'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 			'select_atts'      => $args['select_atts'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 			'show_option_all'  => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 			'show_option_none' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  | 			'data'             => $args['data'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 		) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 708 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 709 |  |  |  | 
            
                        
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.