| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Donators Gravatars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @package     Give | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @subpackage  Classes/Donators | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @copyright   Copyright (c) 2016, WordImpress | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @since       1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | // Exit if accessed directly | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | if ( ! defined( 'ABSPATH' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class Give_Donators_Gravatars { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	 * Start your engines | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	 * @return void | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	public function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		$this->setup_actions(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	 * Setup the default hooks and actions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	private function setup_actions() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		//		add_action( 'widgets_init', array( $this, 'register_widget' ) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		//		add_shortcode( 'give_donators_gravatars', array( $this, 'shortcode' ) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		//		add_filter( 'give_settings_display', array( $this, 'settings' ) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		//		do_action( 'give_donators_gravatars_setup_actions' ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	 * Utility function to check if a gravatar exists for a given email or id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	 * @param int|string|object $id_or_email A user ID, email address, or comment object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 * @return bool if the gravatar exists or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	// https://gist.github.com/justinph/5197810 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	function validate_gravatar( $id_or_email ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		//id or email code borrowed from wp-includes/pluggable.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		$email = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		if ( is_numeric( $id_or_email ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 			$id   = (int) $id_or_email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 			$user = get_userdata( $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 			if ( $user ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 				$email = $user->user_email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		} elseif ( is_object( $id_or_email ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 			// No avatar for pingbacks or trackbacks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 			if ( ! empty( $id_or_email->user_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 				$id   = (int) $id_or_email->user_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 				$user = get_userdata( $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 				if ( $user ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 					$email = $user->user_email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 			} elseif ( ! empty( $id_or_email->comment_author_email ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 				$email = $id_or_email->comment_author_email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			$email = $id_or_email; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		$hashkey = md5( strtolower( trim( $email ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		$data = wp_cache_get( $hashkey ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		if ( false === $data ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 			$response = wp_remote_head( $uri ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 			if ( is_wp_error( $response ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 				$data = 'not200'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 				$data = $response['response']['code']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 			wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 		if ( $data == '200' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 			return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 	 * Get an array of all the log IDs using the Give Logging Class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	 * @return array if logs, false otherwise | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	 * @param int $form_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	function get_log_ids( $form_id = '' ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		// get Give_Logging class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		global $give_logs; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		// get log for this form | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 		$logs = $give_logs->get_logs( $form_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		if ( $logs ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			// make an array with all the donor IDs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 			foreach ( $logs as $log ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 				$log_ids[] = $log->ID; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			return $log_ids; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 	 * Get payment ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	function get_payment_ids( $form_id = '' ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 		global $give_options; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		$log_ids = $this->get_log_ids( $form_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		if ( $log_ids ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 			$payment_ids = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 			foreach ( $log_ids as $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 				// get the payment ID for each corresponding log ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 				$payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 			// remove donors who have purchased more than once so we can have unique avatars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 			$unique_emails = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 			foreach ( $payment_ids as $key => $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 				$email = get_post_meta( $id, '_give_payment_user_email', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 				if ( isset ( $give_options['give_donators_gravatars_has_gravatar_account'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 					if ( ! $this->validate_gravatar( $email ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 						continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 				$unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 			// strip duplicate emails | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 			$unique_emails = array_unique( $unique_emails ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 			// convert the unique IDs back into simple array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 			foreach ( $unique_emails as $id => $email ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 				$unique_ids[] = $id; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 			// randomize the payment IDs if enabled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 			if ( isset( $give_options['give_donators_gravatars_random_gravatars'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 				shuffle( $unique_ids ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 			// return our unique IDs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 			return $unique_ids; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	 * Gravatars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	function gravatars( $form_id = false, $title = '' ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 		// unique $payment_ids  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 		$payment_ids = $this->get_payment_ids( $form_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 		global $give_options; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 		// return if no ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 		if ( ! $form_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 		// minimum amount of purchases before showing gravatars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 		// if the number of items in array is not greater or equal to the number specified, then exit | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 		if ( isset( $give_options['give_donators_gravatars_min_purchases_required'] ) && '' != $give_options['give_donators_gravatars_min_purchases_required'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 			if ( ! ( count( $payment_ids ) >= $give_options['give_donators_gravatars_min_purchases_required'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 				return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 		ob_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 		$output = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 		echo '<div id="give-purchase-gravatars">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		if ( isset ( $title ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 			if ( $title ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 			} elseif ( isset( $give_options['give_donators_gravatars_heading'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 				echo apply_filters( 'give_donators_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donators_gravatars_heading'] ) . '</h2>' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 		echo '<ul class="give-purchase-gravatars-list">'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		$i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 		if ( $payment_ids ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 			foreach ( $payment_ids as $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 				// Give saves a blank option even when the control is turned off, hence the extra check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 				if ( isset( $give_options['give_donators_gravatars_maximum_number'] ) && '' != $give_options['give_donators_gravatars_maximum_number'] && $i == $give_options['give_donators_gravatars_maximum_number'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 					continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 				// get the payment meta | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 				$payment_meta = get_post_meta( $id, '_give_payment_meta', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 				// unserialize the payment meta | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 				$user_info = maybe_unserialize( $payment_meta['user_info'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 				// get donor's first name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 				$name = $user_info['first_name']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 				// get donor's email | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 				$email = get_post_meta( $id, '_give_payment_user_email', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 				// set gravatar size and provide filter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 				$size = isset( $give_options['give_donators_gravatars_gravatar_size'] ) ? apply_filters( 'give_donators_gravatars_gravatar_size', $give_options['give_donators_gravatars_gravatar_size'] ) : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 				// default image | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 				$default_image = apply_filters( 'give_donators_gravatars_gravatar_default_image', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 				// assemble output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 				$output .= '<li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 				$output .= get_avatar( $email, $size, $default_image, $name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 				$output .= '</li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 				$i ++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 			} // end foreach | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 		echo $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 		echo '</ul>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		echo '</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 		return apply_filters( 'give_donators_gravatars', ob_get_clean() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 	 * Register widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 	function register_widget() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 		register_widget( 'Give_Donators_Gravatars_Widget' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 	 * Shortcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 	 * @todo  set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 	function shortcode( $atts, $content = null ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 		$atts = shortcode_atts( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 			'id'    => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 			'title' => '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 		), $atts, 'give_donators_gravatars' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 		// if no ID is passed on single give_forms pages, get the correct ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 		if ( is_singular( 'give_forms' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 			$id = get_the_ID(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		$content = $this->gravatars( $atts['id'], $atts['title'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		return $content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 	 * Settings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 	 * @since 1.0 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 315 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 316 |  |  | 	function settings( $settings ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  | 		$give_gravatar_settings = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  | 			array( | 
            
                                                                        
                            
            
                                    
            
            
                | 320 |  |  | 				'name' => __( 'Donator Gravatars', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 321 |  |  | 				'desc' => '<hr>', | 
            
                                                                        
                            
            
                                    
            
            
                | 322 |  |  | 				'id'   => 'give_title', | 
            
                                                                        
                            
            
                                    
            
            
                | 323 |  |  | 				'type' => 'give_title' | 
            
                                                                        
                            
            
                                    
            
            
                | 324 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 325 |  |  | 			array( | 
            
                                                                        
                            
            
                                    
            
            
                | 326 |  |  | 				'name' => __( 'Heading', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  | 				'desc' => __( 'The heading to display above the Gravatars', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  | 				'type' => 'text', | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  | 				'id'   => 'give_donators_gravatars_heading' | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  | 			array( | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  | 				'name'    => __( 'Gravatar Size', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  | 				'desc'    => __( 'The size of each Gravatar in pixels (512px maximum)', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  | 				'type'    => 'text_small', | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  | 				'id'      => 'give_donators_gravatars_gravatar_size', | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  | 				'default' => '64' | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  | 			array( | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  | 				'name' => __( 'Minimum Unique Purchases Required', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  | 				'desc' => sprintf( __( 'The minimum number of unique purchases a %s must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), strtolower( give_get_forms_label_singular() ) ), | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  | 				'type' => 'text_small', | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  | 				'id'   => 'give_donators_gravatars_min_purchases_required', | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  | 			array( | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  | 				'name'    => __( 'Maximum Gravatars To Show', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  | 				'desc'    => __( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  | 				'type'    => 'text', | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  | 				'id'      => 'give_donators_gravatars_maximum_number', | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  | 				'default' => '20', | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  | 			array( | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  | 				'name' => __( 'Gravatar Visibility', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  | 				'desc' => __( 'Only show donators with a Gravatar account', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  | 				'id'   => 'give_donators_gravatars_has_gravatar_account', | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  | 				'type' => 'checkbox', | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  | 			array( | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  | 				'name' => __( 'Randomize Gravatars', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  | 				'desc' => __( 'Randomize the Gravatars', 'give' ), | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  | 				'id'   => 'give_donators_gravatars_random_gravatars', | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  | 				'type' => 'checkbox', | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  | 			), | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  | 		); | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  | 		return array_merge( $settings, $give_gravatar_settings ); | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |  * Widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |  * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | class Give_Donators_Gravatars_Widget extends WP_Widget { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 	 * widget constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 	public function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 		$give_label_singular = function_exists( 'give_get_forms_label_singular' ) ? strtolower( give_get_forms_label_singular() ) : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 		// widget settings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		$widget_ops = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 			'classname'   => 'give-donators-gravatars', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 			'description' => sprintf( __( 'Displays gravatars of people who have donated using your your %s. Will only show on the single %s page.', 'give' ), $give_label_singular, $give_label_singular ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 		// widget control settings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 		$control_ops = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 			'width'   => 250, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 			'height'  => 350, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 			'id_base' => 'give_gravatars_widget' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 		// create the widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 		parent::__construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 			'give_donators_gravatars_widget', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 			__( 'Give Donators Gravatars', 'give' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 			$widget_ops, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 			$control_ops | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 	} // end constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 	 * Outputs the content of the widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 	function widget( $args, $instance ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 		global $give_options; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		//@TODO: Don't extract it!!! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		extract( $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 		if ( ! is_singular( 'give_forms' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 		// Variables from widget settings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 		$title = apply_filters( 'widget_title', $instance['title'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 		// Used by themes. Opens the widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 		echo $before_widget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 		// Display the widget title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 		if ( $title ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 			echo $before_title . $title . $after_title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 		$gravatars = new Give_Donators_Gravatars(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 		echo $gravatars->gravatars( get_the_ID(), null ); // remove title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 		// Used by themes. Closes the widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 		echo $after_widget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 	} // end WIDGET function | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 	 * Update function. Processes widget options to be saved | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 	function update( $new_instance, $old_instance ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		$instance = $old_instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 		$instance['title'] = strip_tags( $new_instance['title'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 		return $instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 	} // end UPDATE function | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 	/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 	 * Form function. Displays the actual form on the widget page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 	function form( $instance ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 		// Set up some default widget settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 			'title' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 		$instance = wp_parse_args( (array) $instance, $defaults ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 		<!-- Title --> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 		<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'give' ) ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 		</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 	} // end FORM function | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 477 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 478 |  |  |  | 
            
                        
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.