@@ -77,7 +77,7 @@  | 
                                                    ||
| 77 | 77 | * @uses api_request()  | 
                                                        
| 78 | 78 | *  | 
                                                        
| 79 | 79 | * @param array $_transient_data Update array build by WordPress.  | 
                                                        
| 80 | - * @return array Modified update array with custom plugin data.  | 
                                                        |
| 80 | + * @return stdClass Modified update array with custom plugin data.  | 
                                                        |
| 81 | 81 | */  | 
                                                        
| 82 | 82 |  	public function check_update( $_transient_data ) { | 
                                                        
| 83 | 83 | |
@@ -1,7 +1,7 @@ discard block  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly  | 
                                                        
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit;  | 
                                                        |
| 4 | +if ( ! defined('ABSPATH')) exit; | 
                                                        |
| 5 | 5 | |
| 6 | 6 | /**  | 
                                                        
| 7 | 7 | * Allows plugins to use their own update API.  | 
                                                        
@@ -29,20 +29,20 @@ discard block  | 
                                                    ||
| 29 | 29 | * @param string $_plugin_file Path to the plugin file.  | 
                                                        
| 30 | 30 | * @param array $_api_data Optional data to send with API calls.  | 
                                                        
| 31 | 31 | */  | 
                                                        
| 32 | -	public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { | 
                                                        |
| 32 | +	public function __construct($_api_url, $_plugin_file, $_api_data = null) { | 
                                                        |
| 33 | 33 | |
| 34 | 34 | global $edd_plugin_data;  | 
                                                        
| 35 | 35 | |
| 36 | - $this->api_url = trailingslashit( $_api_url );  | 
                                                        |
| 36 | + $this->api_url = trailingslashit($_api_url);  | 
                                                        |
| 37 | 37 | $this->api_data = $_api_data;  | 
                                                        
| 38 | - $this->name = plugin_basename( $_plugin_file );  | 
                                                        |
| 39 | - $this->slug = basename( $_plugin_file, '.php' );  | 
                                                        |
| 38 | + $this->name = plugin_basename($_plugin_file);  | 
                                                        |
| 39 | + $this->slug = basename($_plugin_file, '.php');  | 
                                                        |
| 40 | 40 | $this->version = $_api_data['version'];  | 
                                                        
| 41 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;  | 
                                                        |
| 42 | - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;  | 
                                                        |
| 43 | - $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );  | 
                                                        |
| 41 | + $this->wp_override = isset($_api_data['wp_override']) ? (bool) $_api_data['wp_override'] : false;  | 
                                                        |
| 42 | + $this->beta = ! empty($this->api_data['beta']) ? true : false;  | 
                                                        |
| 43 | + $this->cache_key = md5(serialize($this->slug.$this->api_data['license'].$this->beta));  | 
                                                        |
| 44 | 44 | |
| 45 | - $edd_plugin_data[ $this->slug ] = $this->api_data;  | 
                                                        |
| 45 | + $edd_plugin_data[$this->slug] = $this->api_data;  | 
                                                        |
| 46 | 46 | |
| 47 | 47 | // Set up hooks.  | 
                                                        
| 48 | 48 | $this->init();  | 
                                                        
@@ -58,11 +58,11 @@ discard block  | 
                                                    ||
| 58 | 58 | */  | 
                                                        
| 59 | 59 |  	public function init() { | 
                                                        
| 60 | 60 | |
| 61 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );  | 
                                                        |
| 62 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );  | 
                                                        |
| 63 | - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );  | 
                                                        |
| 64 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );  | 
                                                        |
| 65 | - add_action( 'admin_init', array( $this, 'show_changelog' ) );  | 
                                                        |
| 61 | +		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); | 
                                                        |
| 62 | +		add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); | 
                                                        |
| 63 | +		remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10); | 
                                                        |
| 64 | +		add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); | 
                                                        |
| 65 | +		add_action('admin_init', array($this, 'show_changelog')); | 
                                                        |
| 66 | 66 | |
| 67 | 67 | }  | 
                                                        
| 68 | 68 | |
@@ -79,41 +79,41 @@ discard block  | 
                                                    ||
| 79 | 79 | * @param array $_transient_data Update array build by WordPress.  | 
                                                        
| 80 | 80 | * @return array Modified update array with custom plugin data.  | 
                                                        
| 81 | 81 | */  | 
                                                        
| 82 | -	public function check_update( $_transient_data ) { | 
                                                        |
| 82 | +	public function check_update($_transient_data) { | 
                                                        |
| 83 | 83 | |
| 84 | 84 | global $pagenow;  | 
                                                        
| 85 | 85 | |
| 86 | -		if ( ! is_object( $_transient_data ) ) { | 
                                                        |
| 86 | +		if ( ! is_object($_transient_data)) { | 
                                                        |
| 87 | 87 | $_transient_data = new stdClass;  | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | 89 | |
| 90 | -		if ( 'plugins.php' == $pagenow && is_multisite() ) { | 
                                                        |
| 90 | +		if ('plugins.php' == $pagenow && is_multisite()) { | 
                                                        |
| 91 | 91 | return $_transient_data;  | 
                                                        
| 92 | 92 | }  | 
                                                        
| 93 | 93 | |
| 94 | -		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { | 
                                                        |
| 94 | +		if ( ! empty($_transient_data->response) && ! empty($_transient_data->response[$this->name]) && false === $this->wp_override) { | 
                                                        |
| 95 | 95 | return $_transient_data;  | 
                                                        
| 96 | 96 | }  | 
                                                        
| 97 | 97 | |
| 98 | 98 | $version_info = $this->get_cached_version_info();  | 
                                                        
| 99 | 99 | |
| 100 | -		if ( false === $version_info ) { | 
                                                        |
| 101 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );  | 
                                                        |
| 100 | +		if (false === $version_info) { | 
                                                        |
| 101 | +			$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug, 'beta' => $this->beta)); | 
                                                        |
| 102 | 102 | |
| 103 | - $this->set_version_info_cache( $version_info );  | 
                                                        |
| 103 | + $this->set_version_info_cache($version_info);  | 
                                                        |
| 104 | 104 | |
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
| 107 | -		if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { | 
                                                        |
| 107 | +		if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { | 
                                                        |
| 108 | 108 | |
| 109 | -			if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { | 
                                                        |
| 109 | +			if (version_compare($this->version, $version_info->new_version, '<')) { | 
                                                        |
| 110 | 110 | |
| 111 | - $_transient_data->response[ $this->name ] = $version_info;  | 
                                                        |
| 111 | + $_transient_data->response[$this->name] = $version_info;  | 
                                                        |
| 112 | 112 | |
| 113 | 113 | }  | 
                                                        
| 114 | 114 | |
| 115 | - $_transient_data->last_checked = current_time( 'timestamp' );  | 
                                                        |
| 116 | - $_transient_data->checked[ $this->name ] = $this->version;  | 
                                                        |
| 115 | +			$_transient_data->last_checked           = current_time('timestamp'); | 
                                                        |
| 116 | + $_transient_data->checked[$this->name] = $this->version;  | 
                                                        |
| 117 | 117 | |
| 118 | 118 | }  | 
                                                        
| 119 | 119 | |
@@ -126,97 +126,97 @@ discard block  | 
                                                    ||
| 126 | 126 | * @param string $file  | 
                                                        
| 127 | 127 | * @param array $plugin  | 
                                                        
| 128 | 128 | */  | 
                                                        
| 129 | -	public function show_update_notification( $file, $plugin ) { | 
                                                        |
| 129 | +	public function show_update_notification($file, $plugin) { | 
                                                        |
| 130 | 130 | |
| 131 | -		if ( is_network_admin() ) { | 
                                                        |
| 131 | +		if (is_network_admin()) { | 
                                                        |
| 132 | 132 | return;  | 
                                                        
| 133 | 133 | }  | 
                                                        
| 134 | 134 | |
| 135 | -		if( ! current_user_can( 'update_plugins' ) ) { | 
                                                        |
| 135 | +		if ( ! current_user_can('update_plugins')) { | 
                                                        |
| 136 | 136 | return;  | 
                                                        
| 137 | 137 | }  | 
                                                        
| 138 | 138 | |
| 139 | -		if( ! is_multisite() ) { | 
                                                        |
| 139 | +		if ( ! is_multisite()) { | 
                                                        |
| 140 | 140 | return;  | 
                                                        
| 141 | 141 | }  | 
                                                        
| 142 | 142 | |
| 143 | -		if ( $this->name != $file ) { | 
                                                        |
| 143 | +		if ($this->name != $file) { | 
                                                        |
| 144 | 144 | return;  | 
                                                        
| 145 | 145 | }  | 
                                                        
| 146 | 146 | |
| 147 | 147 | // Remove our filter on the site transient  | 
                                                        
| 148 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );  | 
                                                        |
| 148 | +		remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); | 
                                                        |
| 149 | 149 | |
| 150 | - $update_cache = get_site_transient( 'update_plugins' );  | 
                                                        |
| 150 | +		$update_cache = get_site_transient('update_plugins'); | 
                                                        |
| 151 | 151 | |
| 152 | - $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();  | 
                                                        |
| 152 | + $update_cache = is_object($update_cache) ? $update_cache : new stdClass();  | 
                                                        |
| 153 | 153 | |
| 154 | -		if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { | 
                                                        |
| 154 | +		if (empty($update_cache->response) || empty($update_cache->response[$this->name])) { | 
                                                        |
| 155 | 155 | |
| 156 | 156 | $version_info = $this->get_cached_version_info();  | 
                                                        
| 157 | 157 | |
| 158 | -			if ( false === $version_info ) { | 
                                                        |
| 159 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );  | 
                                                        |
| 158 | +			if (false === $version_info) { | 
                                                        |
| 159 | +				$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug, 'beta' => $this->beta)); | 
                                                        |
| 160 | 160 | |
| 161 | - $this->set_version_info_cache( $version_info );  | 
                                                        |
| 161 | + $this->set_version_info_cache($version_info);  | 
                                                        |
| 162 | 162 | }  | 
                                                        
| 163 | 163 | |
| 164 | -			if ( ! is_object( $version_info ) ) { | 
                                                        |
| 164 | +			if ( ! is_object($version_info)) { | 
                                                        |
| 165 | 165 | return;  | 
                                                        
| 166 | 166 | }  | 
                                                        
| 167 | 167 | |
| 168 | -			if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { | 
                                                        |
| 168 | +			if (version_compare($this->version, $version_info->new_version, '<')) { | 
                                                        |
| 169 | 169 | |
| 170 | - $update_cache->response[ $this->name ] = $version_info;  | 
                                                        |
| 170 | + $update_cache->response[$this->name] = $version_info;  | 
                                                        |
| 171 | 171 | |
| 172 | 172 | }  | 
                                                        
| 173 | 173 | |
| 174 | - $update_cache->last_checked = current_time( 'timestamp' );  | 
                                                        |
| 175 | - $update_cache->checked[ $this->name ] = $this->version;  | 
                                                        |
| 174 | +			$update_cache->last_checked = current_time('timestamp'); | 
                                                        |
| 175 | + $update_cache->checked[$this->name] = $this->version;  | 
                                                        |
| 176 | 176 | |
| 177 | - set_site_transient( 'update_plugins', $update_cache );  | 
                                                        |
| 177 | +			set_site_transient('update_plugins', $update_cache); | 
                                                        |
| 178 | 178 | |
| 179 | 179 |  		} else { | 
                                                        
| 180 | 180 | |
| 181 | - $version_info = $update_cache->response[ $this->name ];  | 
                                                        |
| 181 | + $version_info = $update_cache->response[$this->name];  | 
                                                        |
| 182 | 182 | |
| 183 | 183 | }  | 
                                                        
| 184 | 184 | |
| 185 | 185 | // Restore our filter  | 
                                                        
| 186 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );  | 
                                                        |
| 186 | +		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); | 
                                                        |
| 187 | 187 | |
| 188 | -		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { | 
                                                        |
| 188 | +		if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { | 
                                                        |
| 189 | 189 | |
| 190 | 190 | // build a plugin list row, with update notification  | 
                                                        
| 191 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );  | 
                                                        |
| 191 | +			$wp_list_table = _get_list_table('WP_Plugins_List_Table'); | 
                                                        |
| 192 | 192 | # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">  | 
                                                        
| 193 | - echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';  | 
                                                        |
| 193 | + echo '<tr class="plugin-update-tr" id="'.$this->slug.'-update" data-slug="'.$this->slug.'" data-plugin="'.$this->slug.'/'.$file.'">';  | 
                                                        |
| 194 | 194 | echo '<td colspan="3" class="plugin-update colspanchange">';  | 
                                                        
| 195 | 195 | echo '<div class="update-message notice inline notice-warning notice-alt">';  | 
                                                        
| 196 | 196 | |
| 197 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );  | 
                                                        |
| 197 | +			$changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); | 
                                                        |
| 198 | 198 | |
| 199 | -			if ( empty( $version_info->download_link ) ) { | 
                                                        |
| 199 | +			if (empty($version_info->download_link)) { | 
                                                        |
| 200 | 200 | printf(  | 
                                                        
| 201 | - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),  | 
                                                        |
| 202 | - esc_html( $version_info->name ),  | 
                                                        |
| 203 | - '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',  | 
                                                        |
| 204 | - esc_html( $version_info->new_version ),  | 
                                                        |
| 201 | +					__('There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads'), | 
                                                        |
| 202 | + esc_html($version_info->name),  | 
                                                        |
| 203 | + '<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">',  | 
                                                        |
| 204 | + esc_html($version_info->new_version),  | 
                                                        |
| 205 | 205 | '</a>'  | 
                                                        
| 206 | 206 | );  | 
                                                        
| 207 | 207 |  			} else { | 
                                                        
| 208 | 208 | printf(  | 
                                                        
| 209 | - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),  | 
                                                        |
| 210 | - esc_html( $version_info->name ),  | 
                                                        |
| 211 | - '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',  | 
                                                        |
| 212 | - esc_html( $version_info->new_version ),  | 
                                                        |
| 209 | +					__('There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads'), | 
                                                        |
| 210 | + esc_html($version_info->name),  | 
                                                        |
| 211 | + '<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">',  | 
                                                        |
| 212 | + esc_html($version_info->new_version),  | 
                                                        |
| 213 | 213 | '</a>',  | 
                                                        
| 214 | - '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',  | 
                                                        |
| 214 | +					'<a href="'.esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)).'">', | 
                                                        |
| 215 | 215 | '</a>'  | 
                                                        
| 216 | 216 | );  | 
                                                        
| 217 | 217 | }  | 
                                                        
| 218 | 218 | |
| 219 | -			do_action( "in_plugin_update_message-{$file}", $plugin, $version_info ); | 
                                                        |
| 219 | +			do_action("in_plugin_update_message-{$file}", $plugin, $version_info); | 
                                                        |
| 220 | 220 | |
| 221 | 221 | echo '</div></td></tr>';  | 
                                                        
| 222 | 222 | }  | 
                                                        
@@ -232,15 +232,15 @@ discard block  | 
                                                    ||
| 232 | 232 | * @param object $_args  | 
                                                        
| 233 | 233 | * @return object $_data  | 
                                                        
| 234 | 234 | */  | 
                                                        
| 235 | -	public function plugins_api_filter( $_data, $_action = '', $_args = null ) { | 
                                                        |
| 235 | +	public function plugins_api_filter($_data, $_action = '', $_args = null) { | 
                                                        |
| 236 | 236 | |
| 237 | -		if ( $_action != 'plugin_information' ) { | 
                                                        |
| 237 | +		if ($_action != 'plugin_information') { | 
                                                        |
| 238 | 238 | |
| 239 | 239 | return $_data;  | 
                                                        
| 240 | 240 | |
| 241 | 241 | }  | 
                                                        
| 242 | 242 | |
| 243 | -		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { | 
                                                        |
| 243 | +		if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) { | 
                                                        |
| 244 | 244 | |
| 245 | 245 | return $_data;  | 
                                                        
| 246 | 246 | |
@@ -255,20 +255,20 @@ discard block  | 
                                                    ||
| 255 | 255 | )  | 
                                                        
| 256 | 256 | );  | 
                                                        
| 257 | 257 | |
| 258 | - $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );  | 
                                                        |
| 258 | + $cache_key = 'edd_api_request_'.md5(serialize($this->slug.$this->api_data['license'].$this->beta));  | 
                                                        |
| 259 | 259 | |
| 260 | 260 | // Get the transient where we store the api request for this plugin for 24 hours  | 
                                                        
| 261 | - $edd_api_request_transient = $this->get_cached_version_info( $cache_key );  | 
                                                        |
| 261 | + $edd_api_request_transient = $this->get_cached_version_info($cache_key);  | 
                                                        |
| 262 | 262 | |
| 263 | 263 | //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.  | 
                                                        
| 264 | -		if ( empty( $edd_api_request_transient ) ) { | 
                                                        |
| 264 | +		if (empty($edd_api_request_transient)) { | 
                                                        |
| 265 | 265 | |
| 266 | - $api_response = $this->api_request( 'plugin_information', $to_send );  | 
                                                        |
| 266 | +			$api_response = $this->api_request('plugin_information', $to_send); | 
                                                        |
| 267 | 267 | |
| 268 | 268 | // Expires in 3 hours  | 
                                                        
| 269 | - $this->set_version_info_cache( $api_response, $cache_key );  | 
                                                        |
| 269 | + $this->set_version_info_cache($api_response, $cache_key);  | 
                                                        |
| 270 | 270 | |
| 271 | -			if ( false !== $api_response ) { | 
                                                        |
| 271 | +			if (false !== $api_response) { | 
                                                        |
| 272 | 272 | $_data = $api_response;  | 
                                                        
| 273 | 273 | }  | 
                                                        
| 274 | 274 | |
@@ -277,20 +277,20 @@ discard block  | 
                                                    ||
| 277 | 277 | }  | 
                                                        
| 278 | 278 | |
| 279 | 279 | // Convert sections into an associative array, since we're getting an object, but Core expects an array.  | 
                                                        
| 280 | -		if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) { | 
                                                        |
| 280 | +		if (isset($_data->sections) && ! is_array($_data->sections)) { | 
                                                        |
| 281 | 281 | $new_sections = array();  | 
                                                        
| 282 | -			foreach ( $_data->sections as $key => $key ) { | 
                                                        |
| 283 | - $new_sections[ $key ] = $key;  | 
                                                        |
| 282 | +			foreach ($_data->sections as $key => $key) { | 
                                                        |
| 283 | + $new_sections[$key] = $key;  | 
                                                        |
| 284 | 284 | }  | 
                                                        
| 285 | 285 | |
| 286 | 286 | $_data->sections = $new_sections;  | 
                                                        
| 287 | 287 | }  | 
                                                        
| 288 | 288 | |
| 289 | 289 | // Convert banners into an associative array, since we're getting an object, but Core expects an array.  | 
                                                        
| 290 | -		if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) { | 
                                                        |
| 290 | +		if (isset($_data->banners) && ! is_array($_data->banners)) { | 
                                                        |
| 291 | 291 | $new_banners = array();  | 
                                                        
| 292 | -			foreach ( $_data->banners as $key => $key ) { | 
                                                        |
| 293 | - $new_banners[ $key ] = $key;  | 
                                                        |
| 292 | +			foreach ($_data->banners as $key => $key) { | 
                                                        |
| 293 | + $new_banners[$key] = $key;  | 
                                                        |
| 294 | 294 | }  | 
                                                        
| 295 | 295 | |
| 296 | 296 | $_data->banners = $new_banners;  | 
                                                        
@@ -306,9 +306,9 @@ discard block  | 
                                                    ||
| 306 | 306 | * @param string $url  | 
                                                        
| 307 | 307 | * @return object $array  | 
                                                        
| 308 | 308 | */  | 
                                                        
| 309 | -	public function http_request_args( $args, $url ) { | 
                                                        |
| 309 | +	public function http_request_args($args, $url) { | 
                                                        |
| 310 | 310 | // If it is an https request and we are performing a package download, disable ssl verification  | 
                                                        
| 311 | -		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { | 
                                                        |
| 311 | +		if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { | 
                                                        |
| 312 | 312 | $args['sslverify'] = false;  | 
                                                        
| 313 | 313 | }  | 
                                                        
| 314 | 314 | return $args;  | 
                                                        
@@ -325,50 +325,50 @@ discard block  | 
                                                    ||
| 325 | 325 | * @param array $_data Parameters for the API action.  | 
                                                        
| 326 | 326 | * @return false|object  | 
                                                        
| 327 | 327 | */  | 
                                                        
| 328 | -	private function api_request( $_action, $_data ) { | 
                                                        |
| 328 | +	private function api_request($_action, $_data) { | 
                                                        |
| 329 | 329 | |
| 330 | 330 | global $wp_version;  | 
                                                        
| 331 | 331 | |
| 332 | - $data = array_merge( $this->api_data, $_data );  | 
                                                        |
| 332 | + $data = array_merge($this->api_data, $_data);  | 
                                                        |
| 333 | 333 | |
| 334 | -		if ( $data['slug'] != $this->slug ) { | 
                                                        |
| 334 | +		if ($data['slug'] != $this->slug) { | 
                                                        |
| 335 | 335 | return;  | 
                                                        
| 336 | 336 | }  | 
                                                        
| 337 | 337 | |
| 338 | -		if( $this->api_url == trailingslashit (home_url() ) ) { | 
                                                        |
| 338 | +		if ($this->api_url == trailingslashit(home_url())) { | 
                                                        |
| 339 | 339 | return false; // Don't allow a plugin to ping itself  | 
                                                        
| 340 | 340 | }  | 
                                                        
| 341 | 341 | |
| 342 | 342 | $api_params = array(  | 
                                                        
| 343 | 343 | 'edd_action' => 'get_version',  | 
                                                        
| 344 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '',  | 
                                                        |
| 345 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,  | 
                                                        |
| 346 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,  | 
                                                        |
| 347 | - 'version' => isset( $data['version'] ) ? $data['version'] : false,  | 
                                                        |
| 344 | + 'license' => ! empty($data['license']) ? $data['license'] : '',  | 
                                                        |
| 345 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false,  | 
                                                        |
| 346 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false,  | 
                                                        |
| 347 | + 'version' => isset($data['version']) ? $data['version'] : false,  | 
                                                        |
| 348 | 348 | 'slug' => $data['slug'],  | 
                                                        
| 349 | 349 | 'author' => $data['author'],  | 
                                                        
| 350 | 350 | 'url' => home_url(),  | 
                                                        
| 351 | - 'beta' => ! empty( $data['beta'] ),  | 
                                                        |
| 351 | + 'beta' => ! empty($data['beta']),  | 
                                                        |
| 352 | 352 | );  | 
                                                        
| 353 | 353 | |
| 354 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );  | 
                                                        |
| 354 | +		$request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); | 
                                                        |
| 355 | 355 | |
| 356 | -		if ( ! is_wp_error( $request ) ) { | 
                                                        |
| 357 | - $request = json_decode( wp_remote_retrieve_body( $request ) );  | 
                                                        |
| 356 | +		if ( ! is_wp_error($request)) { | 
                                                        |
| 357 | + $request = json_decode(wp_remote_retrieve_body($request));  | 
                                                        |
| 358 | 358 | }  | 
                                                        
| 359 | 359 | |
| 360 | -		if ( $request && isset( $request->sections ) ) { | 
                                                        |
| 361 | - $request->sections = maybe_unserialize( $request->sections );  | 
                                                        |
| 360 | +		if ($request && isset($request->sections)) { | 
                                                        |
| 361 | + $request->sections = maybe_unserialize($request->sections);  | 
                                                        |
| 362 | 362 |  		} else { | 
                                                        
| 363 | 363 | $request = false;  | 
                                                        
| 364 | 364 | }  | 
                                                        
| 365 | 365 | |
| 366 | -		if ( $request && isset( $request->banners ) ) { | 
                                                        |
| 367 | - $request->banners = maybe_unserialize( $request->banners );  | 
                                                        |
| 366 | +		if ($request && isset($request->banners)) { | 
                                                        |
| 367 | + $request->banners = maybe_unserialize($request->banners);  | 
                                                        |
| 368 | 368 | }  | 
                                                        
| 369 | 369 | |
| 370 | -		if( ! empty( $request->sections ) ) { | 
                                                        |
| 371 | -			foreach( $request->sections as $key => $section ) { | 
                                                        |
| 370 | +		if ( ! empty($request->sections)) { | 
                                                        |
| 371 | +			foreach ($request->sections as $key => $section) { | 
                                                        |
| 372 | 372 | $request->$key = (array) $section;  | 
                                                        
| 373 | 373 | }  | 
                                                        
| 374 | 374 | }  | 
                                                        
@@ -380,97 +380,97 @@ discard block  | 
                                                    ||
| 380 | 380 | |
| 381 | 381 | global $edd_plugin_data;  | 
                                                        
| 382 | 382 | |
| 383 | -		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { | 
                                                        |
| 383 | +		if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { | 
                                                        |
| 384 | 384 | return;  | 
                                                        
| 385 | 385 | }  | 
                                                        
| 386 | 386 | |
| 387 | -		if( empty( $_REQUEST['plugin'] ) ) { | 
                                                        |
| 387 | +		if (empty($_REQUEST['plugin'])) { | 
                                                        |
| 388 | 388 | return;  | 
                                                        
| 389 | 389 | }  | 
                                                        
| 390 | 390 | |
| 391 | -		if( empty( $_REQUEST['slug'] ) ) { | 
                                                        |
| 391 | +		if (empty($_REQUEST['slug'])) { | 
                                                        |
| 392 | 392 | return;  | 
                                                        
| 393 | 393 | }  | 
                                                        
| 394 | 394 | |
| 395 | -		if( ! current_user_can( 'update_plugins' ) ) { | 
                                                        |
| 396 | - wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );  | 
                                                        |
| 395 | +		if ( ! current_user_can('update_plugins')) { | 
                                                        |
| 396 | +			wp_die(__('You do not have permission to install plugin updates', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403)); | 
                                                        |
| 397 | 397 | }  | 
                                                        
| 398 | 398 | |
| 399 | - $data = $edd_plugin_data[ $_REQUEST['slug'] ];  | 
                                                        |
| 400 | - $beta = ! empty( $data['beta'] ) ? true : false;  | 
                                                        |
| 401 | - $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );  | 
                                                        |
| 402 | - $version_info = $this->get_cached_version_info( $cache_key );  | 
                                                        |
| 399 | + $data = $edd_plugin_data[$_REQUEST['slug']];  | 
                                                        |
| 400 | + $beta = ! empty($data['beta']) ? true : false;  | 
                                                        |
| 401 | +		$cache_key    = md5('edd_plugin_'.sanitize_key($_REQUEST['plugin']).'_'.$beta.'_version_info'); | 
                                                        |
| 402 | + $version_info = $this->get_cached_version_info($cache_key);  | 
                                                        |
| 403 | 403 | |
| 404 | -		if( false === $version_info ) { | 
                                                        |
| 404 | +		if (false === $version_info) { | 
                                                        |
| 405 | 405 | |
| 406 | 406 | $api_params = array(  | 
                                                        
| 407 | 407 | 'edd_action' => 'get_version',  | 
                                                        
| 408 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,  | 
                                                        |
| 409 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,  | 
                                                        |
| 408 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false,  | 
                                                        |
| 409 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false,  | 
                                                        |
| 410 | 410 | 'slug' => $_REQUEST['slug'],  | 
                                                        
| 411 | 411 | 'author' => $data['author'],  | 
                                                        
| 412 | 412 | 'url' => home_url(),  | 
                                                        
| 413 | - 'beta' => ! empty( $data['beta'] )  | 
                                                        |
| 413 | + 'beta' => ! empty($data['beta'])  | 
                                                        |
| 414 | 414 | );  | 
                                                        
| 415 | 415 | |
| 416 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );  | 
                                                        |
| 416 | +			$request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); | 
                                                        |
| 417 | 417 | |
| 418 | -			if ( ! is_wp_error( $request ) ) { | 
                                                        |
| 419 | - $version_info = json_decode( wp_remote_retrieve_body( $request ) );  | 
                                                        |
| 418 | +			if ( ! is_wp_error($request)) { | 
                                                        |
| 419 | + $version_info = json_decode(wp_remote_retrieve_body($request));  | 
                                                        |
| 420 | 420 | }  | 
                                                        
| 421 | 421 | |
| 422 | 422 | |
| 423 | -			if ( ! empty( $version_info ) && isset( $version_info->sections ) ) { | 
                                                        |
| 424 | - $version_info->sections = maybe_unserialize( $version_info->sections );  | 
                                                        |
| 423 | +			if ( ! empty($version_info) && isset($version_info->sections)) { | 
                                                        |
| 424 | + $version_info->sections = maybe_unserialize($version_info->sections);  | 
                                                        |
| 425 | 425 |  			} else { | 
                                                        
| 426 | 426 | $version_info = false;  | 
                                                        
| 427 | 427 | }  | 
                                                        
| 428 | 428 | |
| 429 | -			if( ! empty( $version_info ) ) { | 
                                                        |
| 430 | -				foreach( $version_info->sections as $key => $section ) { | 
                                                        |
| 429 | +			if ( ! empty($version_info)) { | 
                                                        |
| 430 | +				foreach ($version_info->sections as $key => $section) { | 
                                                        |
| 431 | 431 | $version_info->$key = (array) $section;  | 
                                                        
| 432 | 432 | }  | 
                                                        
| 433 | 433 | }  | 
                                                        
| 434 | 434 | |
| 435 | - $this->set_version_info_cache( $version_info, $cache_key );  | 
                                                        |
| 435 | + $this->set_version_info_cache($version_info, $cache_key);  | 
                                                        |
| 436 | 436 | |
| 437 | 437 | }  | 
                                                        
| 438 | 438 | |
| 439 | -		if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { | 
                                                        |
| 440 | - echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';  | 
                                                        |
| 439 | +		if ( ! empty($version_info) && isset($version_info->sections['changelog'])) { | 
                                                        |
| 440 | + echo '<div style="background:#fff;padding:10px;">'.$version_info->sections['changelog'].'</div>';  | 
                                                        |
| 441 | 441 | }  | 
                                                        
| 442 | 442 | |
| 443 | 443 | exit;  | 
                                                        
| 444 | 444 | }  | 
                                                        
| 445 | 445 | |
| 446 | -	public function get_cached_version_info( $cache_key = '' ) { | 
                                                        |
| 446 | +	public function get_cached_version_info($cache_key = '') { | 
                                                        |
| 447 | 447 | |
| 448 | -		if( empty( $cache_key ) ) { | 
                                                        |
| 448 | +		if (empty($cache_key)) { | 
                                                        |
| 449 | 449 | $cache_key = $this->cache_key;  | 
                                                        
| 450 | 450 | }  | 
                                                        
| 451 | 451 | |
| 452 | - $cache = get_option( $cache_key );  | 
                                                        |
| 452 | + $cache = get_option($cache_key);  | 
                                                        |
| 453 | 453 | |
| 454 | -		if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) { | 
                                                        |
| 454 | +		if (empty($cache['timeout']) || current_time('timestamp') > $cache['timeout']) { | 
                                                        |
| 455 | 455 | return false; // Cache is expired  | 
                                                        
| 456 | 456 | }  | 
                                                        
| 457 | 457 | |
| 458 | - return json_decode( $cache['value'] );  | 
                                                        |
| 458 | + return json_decode($cache['value']);  | 
                                                        |
| 459 | 459 | |
| 460 | 460 | }  | 
                                                        
| 461 | 461 | |
| 462 | -	public function set_version_info_cache( $value = '', $cache_key = '' ) { | 
                                                        |
| 462 | +	public function set_version_info_cache($value = '', $cache_key = '') { | 
                                                        |
| 463 | 463 | |
| 464 | -		if( empty( $cache_key ) ) { | 
                                                        |
| 464 | +		if (empty($cache_key)) { | 
                                                        |
| 465 | 465 | $cache_key = $this->cache_key;  | 
                                                        
| 466 | 466 | }  | 
                                                        
| 467 | 467 | |
| 468 | 468 | $data = array(  | 
                                                        
| 469 | - 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),  | 
                                                        |
| 470 | - 'value' => json_encode( $value )  | 
                                                        |
| 469 | +			'timeout' => strtotime('+3 hours', current_time('timestamp')), | 
                                                        |
| 470 | + 'value' => json_encode($value)  | 
                                                        |
| 471 | 471 | );  | 
                                                        
| 472 | 472 | |
| 473 | - update_option( $cache_key, $data );  | 
                                                        |
| 473 | + update_option($cache_key, $data);  | 
                                                        |
| 474 | 474 | |
| 475 | 475 | }  | 
                                                        
| 476 | 476 | |
@@ -1,7 +1,9 @@  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly  | 
                                                        
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit;  | 
                                                        |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | 
                                                        |
| 5 | + exit;  | 
                                                        |
| 6 | +}  | 
                                                        |
| 5 | 7 | |
| 6 | 8 | /**  | 
                                                        
| 7 | 9 | * Allows plugins to use their own update API.  | 
                                                        
@@ -40,11 +40,11 @@ discard block  | 
                                                    ||
| 40 | 40 | */  | 
                                                        
| 41 | 41 | |
| 42 | 42 | // Exit if accessed directly.  | 
                                                        
| 43 | -if ( ! defined( 'ABSPATH' ) ) {
 | 
                                                        |
| 43 | +if ( ! defined('ABSPATH')) {
 | 
                                                        |
| 44 | 44 | exit;  | 
                                                        
| 45 | 45 | }  | 
                                                        
| 46 | 46 | |
| 47 | -if ( ! class_exists( 'Give' ) ) :  | 
                                                        |
| 47 | +if ( ! class_exists('Give')) :
 | 
                                                        |
| 48 | 48 | |
| 49 | 49 | /**  | 
                                                        
| 50 | 50 | * Main Give Class  | 
                                                        
@@ -195,11 +195,11 @@ discard block  | 
                                                    ||
| 195 | 195 | * @return Give  | 
                                                        
| 196 | 196 | */  | 
                                                        
| 197 | 197 |  		public static function instance() {
 | 
                                                        
| 198 | -			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) {
 | 
                                                        |
| 198 | +			if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) {
 | 
                                                        |
| 199 | 199 | self::$instance = new Give;  | 
                                                        
| 200 | 200 | self::$instance->setup_constants();  | 
                                                        
| 201 | 201 | |
| 202 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );  | 
                                                        |
| 202 | +				add_action('plugins_loaded', array(self::$instance, 'load_textdomain'));
 | 
                                                        |
| 203 | 203 | |
| 204 | 204 | self::$instance->includes();  | 
                                                        
| 205 | 205 | self::$instance->roles = new Give_Roles();  | 
                                                        
@@ -232,7 +232,7 @@ discard block  | 
                                                    ||
| 232 | 232 | */  | 
                                                        
| 233 | 233 |  		public function __clone() {
 | 
                                                        
| 234 | 234 | // Cloning instances of the class is forbidden  | 
                                                        
| 235 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' );  | 
                                                        |
| 235 | +			_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0');
 | 
                                                        |
| 236 | 236 | }  | 
                                                        
| 237 | 237 | |
| 238 | 238 | /**  | 
                                                        
@@ -245,7 +245,7 @@ discard block  | 
                                                    ||
| 245 | 245 | */  | 
                                                        
| 246 | 246 |  		public function __wakeup() {
 | 
                                                        
| 247 | 247 | // Unserializing instances of the class is forbidden.  | 
                                                        
| 248 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' );  | 
                                                        |
| 248 | +			_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0');
 | 
                                                        |
| 249 | 249 | }  | 
                                                        
| 250 | 250 | |
| 251 | 251 | /**  | 
                                                        
@@ -259,33 +259,33 @@ discard block  | 
                                                    ||
| 259 | 259 |  		private function setup_constants() {
 | 
                                                        
| 260 | 260 | |
| 261 | 261 | // Plugin version  | 
                                                        
| 262 | -			if ( ! defined( 'GIVE_VERSION' ) ) {
 | 
                                                        |
| 263 | - define( 'GIVE_VERSION', '1.8.4' );  | 
                                                        |
| 262 | +			if ( ! defined('GIVE_VERSION')) {
 | 
                                                        |
| 263 | +				define('GIVE_VERSION', '1.8.4');
 | 
                                                        |
| 264 | 264 | }  | 
                                                        
| 265 | 265 | |
| 266 | 266 | // Plugin Folder Path  | 
                                                        
| 267 | -			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
 | 
                                                        |
| 268 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );  | 
                                                        |
| 267 | +			if ( ! defined('GIVE_PLUGIN_DIR')) {
 | 
                                                        |
| 268 | +				define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__));
 | 
                                                        |
| 269 | 269 | }  | 
                                                        
| 270 | 270 | |
| 271 | 271 | // Plugin Folder URL  | 
                                                        
| 272 | -			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
 | 
                                                        |
| 273 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );  | 
                                                        |
| 272 | +			if ( ! defined('GIVE_PLUGIN_URL')) {
 | 
                                                        |
| 273 | +				define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__));
 | 
                                                        |
| 274 | 274 | }  | 
                                                        
| 275 | 275 | |
| 276 | 276 | // Plugin Basename aka: "give/give.php"  | 
                                                        
| 277 | -			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
 | 
                                                        |
| 278 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );  | 
                                                        |
| 277 | +			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
 | 
                                                        |
| 278 | +				define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__));
 | 
                                                        |
| 279 | 279 | }  | 
                                                        
| 280 | 280 | |
| 281 | 281 | // Plugin Root File  | 
                                                        
| 282 | -			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
 | 
                                                        |
| 283 | - define( 'GIVE_PLUGIN_FILE', __FILE__ );  | 
                                                        |
| 282 | +			if ( ! defined('GIVE_PLUGIN_FILE')) {
 | 
                                                        |
| 283 | +				define('GIVE_PLUGIN_FILE', __FILE__);
 | 
                                                        |
| 284 | 284 | }  | 
                                                        
| 285 | 285 | |
| 286 | 286 | // Make sure CAL_GREGORIAN is defined  | 
                                                        
| 287 | -			if ( ! defined( 'CAL_GREGORIAN' ) ) {
 | 
                                                        |
| 288 | - define( 'CAL_GREGORIAN', 1 );  | 
                                                        |
| 287 | +			if ( ! defined('CAL_GREGORIAN')) {
 | 
                                                        |
| 288 | +				define('CAL_GREGORIAN', 1);
 | 
                                                        |
| 289 | 289 | }  | 
                                                        
| 290 | 290 | }  | 
                                                        
| 291 | 291 | |
@@ -300,122 +300,122 @@ discard block  | 
                                                    ||
| 300 | 300 |  		private function includes() {
 | 
                                                        
| 301 | 301 | global $give_options;  | 
                                                        
| 302 | 302 | |
| 303 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';  | 
                                                        |
| 304 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';  | 
                                                        |
| 303 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';  | 
                                                        |
| 304 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';  | 
                                                        |
| 305 | 305 | $give_options = give_get_settings();  | 
                                                        
| 306 | 306 | |
| 307 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';  | 
                                                        |
| 308 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';  | 
                                                        |
| 309 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';  | 
                                                        |
| 310 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';  | 
                                                        |
| 311 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php';  | 
                                                        |
| 312 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php';  | 
                                                        |
| 313 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';  | 
                                                        |
| 314 | -  | 
                                                        |
| 315 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';  | 
                                                        |
| 316 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';  | 
                                                        |
| 317 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';  | 
                                                        |
| 318 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';  | 
                                                        |
| 319 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php';  | 
                                                        |
| 320 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php';  | 
                                                        |
| 321 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php';  | 
                                                        |
| 322 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';  | 
                                                        |
| 323 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';  | 
                                                        |
| 324 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';  | 
                                                        |
| 325 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';  | 
                                                        |
| 326 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';  | 
                                                        |
| 327 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';  | 
                                                        |
| 328 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';  | 
                                                        |
| 329 | -  | 
                                                        |
| 330 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';  | 
                                                        |
| 331 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';  | 
                                                        |
| 332 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';  | 
                                                        |
| 333 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';  | 
                                                        |
| 334 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';  | 
                                                        |
| 335 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';  | 
                                                        |
| 336 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';  | 
                                                        |
| 337 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';  | 
                                                        |
| 338 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';  | 
                                                        |
| 339 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';  | 
                                                        |
| 340 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';  | 
                                                        |
| 341 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';  | 
                                                        |
| 342 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';  | 
                                                        |
| 343 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';  | 
                                                        |
| 344 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';  | 
                                                        |
| 345 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';  | 
                                                        |
| 346 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';  | 
                                                        |
| 347 | -  | 
                                                        |
| 348 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';  | 
                                                        |
| 349 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';  | 
                                                        |
| 350 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';  | 
                                                        |
| 351 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';  | 
                                                        |
| 352 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';  | 
                                                        |
| 353 | -  | 
                                                        |
| 354 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';  | 
                                                        |
| 355 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';  | 
                                                        |
| 356 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';  | 
                                                        |
| 357 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';  | 
                                                        |
| 358 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';  | 
                                                        |
| 359 | -  | 
                                                        |
| 360 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';  | 
                                                        |
| 361 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';  | 
                                                        |
| 362 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';  | 
                                                        |
| 363 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';  | 
                                                        |
| 364 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';  | 
                                                        |
| 365 | -  | 
                                                        |
| 366 | -            if( defined( 'WP_CLI' ) && WP_CLI ) {
 | 
                                                        |
| 367 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';  | 
                                                        |
| 307 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';  | 
                                                        |
| 308 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php';  | 
                                                        |
| 309 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php';  | 
                                                        |
| 310 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';  | 
                                                        |
| 311 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php';  | 
                                                        |
| 312 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php';  | 
                                                        |
| 313 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';  | 
                                                        |
| 314 | +  | 
                                                        |
| 315 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';  | 
                                                        |
| 316 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';  | 
                                                        |
| 317 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';  | 
                                                        |
| 318 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';  | 
                                                        |
| 319 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php';  | 
                                                        |
| 320 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php';  | 
                                                        |
| 321 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php';  | 
                                                        |
| 322 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';  | 
                                                        |
| 323 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';  | 
                                                        |
| 324 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';  | 
                                                        |
| 325 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';  | 
                                                        |
| 326 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';  | 
                                                        |
| 327 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';  | 
                                                        |
| 328 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';  | 
                                                        |
| 329 | +  | 
                                                        |
| 330 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';  | 
                                                        |
| 331 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';  | 
                                                        |
| 332 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';  | 
                                                        |
| 333 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';  | 
                                                        |
| 334 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';  | 
                                                        |
| 335 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';  | 
                                                        |
| 336 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';  | 
                                                        |
| 337 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php';  | 
                                                        |
| 338 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';  | 
                                                        |
| 339 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';  | 
                                                        |
| 340 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';  | 
                                                        |
| 341 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php';  | 
                                                        |
| 342 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';  | 
                                                        |
| 343 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';  | 
                                                        |
| 344 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';  | 
                                                        |
| 345 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';  | 
                                                        |
| 346 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';  | 
                                                        |
| 347 | +  | 
                                                        |
| 348 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';  | 
                                                        |
| 349 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';  | 
                                                        |
| 350 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';  | 
                                                        |
| 351 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';  | 
                                                        |
| 352 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';  | 
                                                        |
| 353 | +  | 
                                                        |
| 354 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';  | 
                                                        |
| 355 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';  | 
                                                        |
| 356 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';  | 
                                                        |
| 357 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';  | 
                                                        |
| 358 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';  | 
                                                        |
| 359 | +  | 
                                                        |
| 360 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';  | 
                                                        |
| 361 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';  | 
                                                        |
| 362 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';  | 
                                                        |
| 363 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';  | 
                                                        |
| 364 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';  | 
                                                        |
| 365 | +  | 
                                                        |
| 366 | +            if (defined('WP_CLI') && WP_CLI) {
 | 
                                                        |
| 367 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';  | 
                                                        |
| 368 | 368 | }  | 
                                                        
| 369 | 369 | |
| 370 | -			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
 | 
                                                        |
| 371 | -  | 
                                                        |
| 372 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';  | 
                                                        |
| 373 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';  | 
                                                        |
| 374 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';  | 
                                                        |
| 375 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php';  | 
                                                        |
| 376 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';  | 
                                                        |
| 377 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';  | 
                                                        |
| 378 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';  | 
                                                        |
| 379 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';  | 
                                                        |
| 380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php';  | 
                                                        |
| 381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';  | 
                                                        |
| 382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';  | 
                                                        |
| 383 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';  | 
                                                        |
| 384 | -  | 
                                                        |
| 385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';  | 
                                                        |
| 386 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';  | 
                                                        |
| 387 | -  | 
                                                        |
| 388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php';  | 
                                                        |
| 389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php';  | 
                                                        |
| 390 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php';  | 
                                                        |
| 391 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';  | 
                                                        |
| 392 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';  | 
                                                        |
| 393 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';  | 
                                                        |
| 394 | -  | 
                                                        |
| 395 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php';  | 
                                                        |
| 396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php';  | 
                                                        |
| 397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php';  | 
                                                        |
| 398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php';  | 
                                                        |
| 399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php';  | 
                                                        |
| 400 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php';  | 
                                                        |
| 401 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php';  | 
                                                        |
| 402 | -  | 
                                                        |
| 403 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';  | 
                                                        |
| 404 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';  | 
                                                        |
| 405 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';  | 
                                                        |
| 406 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';  | 
                                                        |
| 407 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';  | 
                                                        |
| 408 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';  | 
                                                        |
| 409 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';  | 
                                                        |
| 410 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';  | 
                                                        |
| 411 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';  | 
                                                        |
| 412 | -  | 
                                                        |
| 413 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';  | 
                                                        |
| 414 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php';  | 
                                                        |
| 370 | +			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
 | 
                                                        |
| 371 | +  | 
                                                        |
| 372 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';  | 
                                                        |
| 373 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';  | 
                                                        |
| 374 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';  | 
                                                        |
| 375 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php';  | 
                                                        |
| 376 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';  | 
                                                        |
| 377 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';  | 
                                                        |
| 378 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';  | 
                                                        |
| 379 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';  | 
                                                        |
| 380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php';  | 
                                                        |
| 381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';  | 
                                                        |
| 382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';  | 
                                                        |
| 383 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';  | 
                                                        |
| 384 | +  | 
                                                        |
| 385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';  | 
                                                        |
| 386 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';  | 
                                                        |
| 387 | +  | 
                                                        |
| 388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php';  | 
                                                        |
| 389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php';  | 
                                                        |
| 390 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php';  | 
                                                        |
| 391 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';  | 
                                                        |
| 392 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';  | 
                                                        |
| 393 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';  | 
                                                        |
| 394 | +  | 
                                                        |
| 395 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php';  | 
                                                        |
| 396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php';  | 
                                                        |
| 397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php';  | 
                                                        |
| 398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php';  | 
                                                        |
| 399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php';  | 
                                                        |
| 400 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php';  | 
                                                        |
| 401 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php';  | 
                                                        |
| 402 | +  | 
                                                        |
| 403 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';  | 
                                                        |
| 404 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';  | 
                                                        |
| 405 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';  | 
                                                        |
| 406 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';  | 
                                                        |
| 407 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';  | 
                                                        |
| 408 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';  | 
                                                        |
| 409 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';  | 
                                                        |
| 410 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';  | 
                                                        |
| 411 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';  | 
                                                        |
| 412 | +  | 
                                                        |
| 413 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';  | 
                                                        |
| 414 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php';  | 
                                                        |
| 415 | 415 | |
| 416 | 416 | }  | 
                                                        
| 417 | 417 | |
| 418 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php';  | 
                                                        |
| 418 | + require_once GIVE_PLUGIN_DIR.'includes/install.php';  | 
                                                        |
| 419 | 419 | |
| 420 | 420 | }  | 
                                                        
| 421 | 421 | |
@@ -429,26 +429,26 @@ discard block  | 
                                                    ||
| 429 | 429 | */  | 
                                                        
| 430 | 430 |  		public function load_textdomain() {
 | 
                                                        
| 431 | 431 | // Set filter for Give's languages directory  | 
                                                        
| 432 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';  | 
                                                        |
| 433 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );  | 
                                                        |
| 432 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';  | 
                                                        |
| 433 | +			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
 | 
                                                        |
| 434 | 434 | |
| 435 | 435 | // Traditional WordPress plugin locale filter  | 
                                                        
| 436 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' );  | 
                                                        |
| 437 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale );  | 
                                                        |
| 436 | +			$locale = apply_filters('plugin_locale', get_locale(), 'give');
 | 
                                                        |
| 437 | +			$mofile = sprintf('%1$s-%2$s.mo', 'give', $locale);
 | 
                                                        |
| 438 | 438 | |
| 439 | 439 | // Setup paths to current locale file  | 
                                                        
| 440 | - $mofile_local = $give_lang_dir . $mofile;  | 
                                                        |
| 441 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile;  | 
                                                        |
| 440 | + $mofile_local = $give_lang_dir.$mofile;  | 
                                                        |
| 441 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile;  | 
                                                        |
| 442 | 442 | |
| 443 | -			if ( file_exists( $mofile_global ) ) {
 | 
                                                        |
| 443 | +			if (file_exists($mofile_global)) {
 | 
                                                        |
| 444 | 444 | // Look in global /wp-content/languages/give folder  | 
                                                        
| 445 | - load_textdomain( 'give', $mofile_global );  | 
                                                        |
| 446 | -			} elseif ( file_exists( $mofile_local ) ) {
 | 
                                                        |
| 445 | +				load_textdomain('give', $mofile_global);
 | 
                                                        |
| 446 | +			} elseif (file_exists($mofile_local)) {
 | 
                                                        |
| 447 | 447 | // Look in local location from filter `give_languages_directory`  | 
                                                        
| 448 | - load_textdomain( 'give', $mofile_local );  | 
                                                        |
| 448 | +				load_textdomain('give', $mofile_local);
 | 
                                                        |
| 449 | 449 |  			} else {
 | 
                                                        
| 450 | 450 | // Load the default language files packaged up w/ Give  | 
                                                        
| 451 | - load_plugin_textdomain( 'give', false, $give_lang_dir );  | 
                                                        |
| 451 | +				load_plugin_textdomain('give', false, $give_lang_dir);
 | 
                                                        |
| 452 | 452 | }  | 
                                                        
| 453 | 453 | }  | 
                                                        
| 454 | 454 | |
@@ -9,11 +9,11 @@ discard block  | 
                                                    ||
| 9 | 9 | * @since 1.8  | 
                                                        
| 10 | 10 | */  | 
                                                        
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { | 
                                                        |
| 12 | +if ( ! defined('ABSPATH')) { | 
                                                        |
| 13 | 13 | exit; // Exit if accessed directly  | 
                                                        
| 14 | 14 | }  | 
                                                        
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_License' ) ) :  | 
                                                        |
| 16 | +if ( ! class_exists('Give_Settings_License')) : | 
                                                        |
| 17 | 17 | |
| 18 | 18 | /**  | 
                                                        
| 19 | 19 | * Give_Settings_License.  | 
                                                        
@@ -43,11 +43,11 @@ discard block  | 
                                                    ||
| 43 | 43 | */  | 
                                                        
| 44 | 44 |  		public function __construct() { | 
                                                        
| 45 | 45 | $this->id = 'licenses';  | 
                                                        
| 46 | - $this->label = esc_html__( 'Licenses', 'give' );  | 
                                                        |
| 46 | +			$this->label = esc_html__('Licenses', 'give'); | 
                                                        |
| 47 | 47 | |
| 48 | - add_filter( 'give-settings_tabs_array', array( $this, 'add_settings_page' ), 20 );  | 
                                                        |
| 49 | -			add_action( "give-settings_settings_{$this->id}_page", array( $this, 'output' ) ); | 
                                                        |
| 50 | -			add_action( "give-settings_save_{$this->id}", array( $this, 'save' ) ); | 
                                                        |
| 48 | +			add_filter('give-settings_tabs_array', array($this, 'add_settings_page'), 20); | 
                                                        |
| 49 | +			add_action("give-settings_settings_{$this->id}_page", array($this, 'output')); | 
                                                        |
| 50 | +			add_action("give-settings_save_{$this->id}", array($this, 'save')); | 
                                                        |
| 51 | 51 | }  | 
                                                        
| 52 | 52 | |
| 53 | 53 | /**  | 
                                                        
@@ -57,11 +57,11 @@ discard block  | 
                                                    ||
| 57 | 57 | * @param array $pages Lst of pages.  | 
                                                        
| 58 | 58 | * @return array  | 
                                                        
| 59 | 59 | */  | 
                                                        
| 60 | -		public function add_settings_page( $pages ) { | 
                                                        |
| 60 | +		public function add_settings_page($pages) { | 
                                                        |
| 61 | 61 | $setting = $this->get_settings();  | 
                                                        
| 62 | 62 | // Bailout: Do not add licenses setting tab if it does not contain any setting fields.  | 
                                                        
| 63 | -			if( ! empty( $setting ) ) { | 
                                                        |
| 64 | - $pages[ $this->id ] = $this->label;  | 
                                                        |
| 63 | +			if ( ! empty($setting)) { | 
                                                        |
| 64 | + $pages[$this->id] = $this->label;  | 
                                                        |
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | 67 | return $pages;  | 
                                                        
@@ -80,7 +80,7 @@ discard block  | 
                                                    ||
| 80 | 80 | * Filter the licenses settings.  | 
                                                        
| 81 | 81 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8  | 
                                                        
| 82 | 82 | */  | 
                                                        
| 83 | - $settings = apply_filters( 'give_settings_licenses', $settings );  | 
                                                        |
| 83 | +			$settings = apply_filters('give_settings_licenses', $settings); | 
                                                        |
| 84 | 84 | |
| 85 | 85 | /**  | 
                                                        
| 86 | 86 | * Filter the settings.  | 
                                                        
@@ -88,7 +88,7 @@ discard block  | 
                                                    ||
| 88 | 88 | * @since 1.8  | 
                                                        
| 89 | 89 | * @param array $settings  | 
                                                        
| 90 | 90 | */  | 
                                                        
| 91 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );  | 
                                                        |
| 91 | +			$settings = apply_filters('give_get_settings_'.$this->id, $settings); | 
                                                        |
| 92 | 92 | |
| 93 | 93 | // Output.  | 
                                                        
| 94 | 94 | return $settings;  | 
                                                        
@@ -103,7 +103,7 @@ discard block  | 
                                                    ||
| 103 | 103 |  		public function output() { | 
                                                        
| 104 | 104 | $settings = $this->get_settings();  | 
                                                        
| 105 | 105 | |
| 106 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' );  | 
                                                        |
| 106 | + Give_Admin_Settings::output_fields($settings, 'give_settings');  | 
                                                        |
| 107 | 107 | }  | 
                                                        
| 108 | 108 | |
| 109 | 109 | /**  | 
                                                        
@@ -116,14 +116,14 @@ discard block  | 
                                                    ||
| 116 | 116 | $settings = $this->get_settings();  | 
                                                        
| 117 | 117 | $current_section = give_get_current_setting_section();  | 
                                                        
| 118 | 118 | |
| 119 | - Give_Admin_Settings::save_fields( $settings, 'give_settings' );  | 
                                                        |
| 119 | + Give_Admin_Settings::save_fields($settings, 'give_settings');  | 
                                                        |
| 120 | 120 | |
| 121 | 121 | /**  | 
                                                        
| 122 | 122 | * Trigger Action  | 
                                                        
| 123 | 123 | *  | 
                                                        
| 124 | 124 | * @since 1.8  | 
                                                        
| 125 | 125 | */  | 
                                                        
| 126 | - do_action( 'give_update_options_' . $this->id . '_' . $current_section );  | 
                                                        |
| 126 | +			do_action('give_update_options_'.$this->id.'_'.$current_section); | 
                                                        |
| 127 | 127 | }  | 
                                                        
| 128 | 128 | }  | 
                                                        
| 129 | 129 | |
@@ -65,23 +65,23 @@ discard block  | 
                                                    ||
| 65 | 65 | *  | 
                                                        
| 66 | 66 | * @param $args  | 
                                                        
| 67 | 67 | */  | 
                                                        
| 68 | -	public function __construct( $args ) { | 
                                                        |
| 68 | +	public function __construct($args) { | 
                                                        |
| 69 | 69 | |
| 70 | 70 | // Only for admins.  | 
                                                        
| 71 | -		if ( ! is_admin() ) { | 
                                                        |
| 71 | +		if ( ! is_admin()) { | 
                                                        |
| 72 | 72 | return;  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | 74 | |
| 75 | 75 | // This plugin is en_US native.  | 
                                                        
| 76 | 76 | $this->locale = get_locale();  | 
                                                        
| 77 | -		if ( 'en_US' === $this->locale ) { | 
                                                        |
| 77 | +		if ('en_US' === $this->locale) { | 
                                                        |
| 78 | 78 | return;  | 
                                                        
| 79 | 79 | }  | 
                                                        
| 80 | 80 | |
| 81 | - $this->init( $args );  | 
                                                        |
| 81 | + $this->init($args);  | 
                                                        |
| 82 | 82 | |
| 83 | -		if ( ! $this->hide_promo() ) { | 
                                                        |
| 84 | - add_action( $this->hook, array( $this, 'promo' ) );  | 
                                                        |
| 83 | +		if ( ! $this->hide_promo()) { | 
                                                        |
| 84 | + add_action($this->hook, array($this, 'promo'));  | 
                                                        |
| 85 | 85 | }  | 
                                                        
| 86 | 86 | }  | 
                                                        
| 87 | 87 | |
@@ -92,8 +92,8 @@ discard block  | 
                                                    ||
| 92 | 92 | *  | 
                                                        
| 93 | 93 | * @param array $args  | 
                                                        
| 94 | 94 | */  | 
                                                        
| 95 | -	private function init( $args ) { | 
                                                        |
| 96 | -		foreach ( $args as $key => $arg ) { | 
                                                        |
| 95 | +	private function init($args) { | 
                                                        |
| 96 | +		foreach ($args as $key => $arg) { | 
                                                        |
| 97 | 97 | $this->$key = $arg;  | 
                                                        
| 98 | 98 | }  | 
                                                        
| 99 | 99 | |
@@ -107,11 +107,11 @@ discard block  | 
                                                    ||
| 107 | 107 | * @return bool  | 
                                                        
| 108 | 108 | */  | 
                                                        
| 109 | 109 |  	private function hide_promo() { | 
                                                        
| 110 | - $hide_promo = get_transient( 'give_i18n_give_promo_hide' );  | 
                                                        |
| 111 | -		if ( ! $hide_promo ) { | 
                                                        |
| 112 | -			if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { | 
                                                        |
| 110 | +		$hide_promo = get_transient('give_i18n_give_promo_hide'); | 
                                                        |
| 111 | +		if ( ! $hide_promo) { | 
                                                        |
| 112 | +			if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { | 
                                                        |
| 113 | 113 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.  | 
                                                        
| 114 | - set_transient( 'give_i18n_give_promo_hide', true );  | 
                                                        |
| 114 | +				set_transient('give_i18n_give_promo_hide', true); | 
                                                        |
| 115 | 115 | $hide_promo = true;  | 
                                                        
| 116 | 116 | }  | 
                                                        
| 117 | 117 | }  | 
                                                        
@@ -130,20 +130,20 @@ discard block  | 
                                                    ||
| 130 | 130 | $message = false;  | 
                                                        
| 131 | 131 | |
| 132 | 132 | // Using a translation less than 90% complete.  | 
                                                        
| 133 | -		if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { | 
                                                        |
| 134 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' );  | 
                                                        |
| 135 | -		} elseif ( ! $this->translation_loaded && $this->translation_exists ) { | 
                                                        |
| 136 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' );  | 
                                                        |
| 137 | -		} elseif ( ! $this->translation_exists ) { | 
                                                        |
| 138 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' );  | 
                                                        |
| 133 | +		if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { | 
                                                        |
| 134 | +			$message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); | 
                                                        |
| 135 | +		} elseif ( ! $this->translation_loaded && $this->translation_exists) { | 
                                                        |
| 136 | +			$message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); | 
                                                        |
| 137 | +		} elseif ( ! $this->translation_exists) { | 
                                                        |
| 138 | +			$message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); | 
                                                        |
| 139 | 139 | }  | 
                                                        
| 140 | 140 | |
| 141 | 141 | // Links.  | 
                                                        
| 142 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) );  | 
                                                        |
| 143 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) );  | 
                                                        |
| 142 | +		$registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); | 
                                                        |
| 143 | +		$translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); | 
                                                        |
| 144 | 144 | |
| 145 | 145 | // Message.  | 
                                                        
| 146 | - $message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link );  | 
                                                        |
| 146 | + $message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link);  | 
                                                        |
| 147 | 147 | |
| 148 | 148 | return $message;  | 
                                                        
| 149 | 149 | |
@@ -157,7 +157,7 @@ discard block  | 
                                                    ||
| 157 | 157 | $this->translation_details();  | 
                                                        
| 158 | 158 | $message = $this->promo_message();  | 
                                                        
| 159 | 159 | |
| 160 | -		if ( $message ) { ?> | 
                                                        |
| 160 | +		if ($message) { ?> | 
                                                        |
| 161 | 161 | |
| 162 | 162 | <style>  | 
                                                        
| 163 | 163 | /* Banner specific styles */  | 
                                                        
@@ -220,12 +220,12 @@ discard block  | 
                                                    ||
| 220 | 220 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a>  | 
                                                        
| 221 | 221 | |
| 222 | 222 | <div class="give-i18n-notice-content">  | 
                                                        
| 223 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>  | 
                                                        |
| 223 | +					<a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> | 
                                                        |
| 224 | 224 | |
| 225 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2>  | 
                                                        |
| 225 | +					<h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> | 
                                                        |
| 226 | 226 | <p><?php echo $message; ?></p>  | 
                                                        
| 227 | 227 | <p>  | 
                                                        
| 228 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a>  | 
                                                        |
| 228 | +						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> | 
                                                        |
| 229 | 229 | </p>  | 
                                                        
| 230 | 230 | </div>  | 
                                                        
| 231 | 231 | </div>  | 
                                                        
@@ -242,11 +242,11 @@ discard block  | 
                                                    ||
| 242 | 242 | */  | 
                                                        
| 243 | 243 |  	private function find_or_initialize_translation_details() { | 
                                                        
| 244 | 244 | |
| 245 | - $set = get_transient( 'give_i18n_give_' . $this->locale );  | 
                                                        |
| 245 | +		$set = get_transient('give_i18n_give_'.$this->locale); | 
                                                        |
| 246 | 246 | |
| 247 | -		if ( ! $set ) { | 
                                                        |
| 247 | +		if ( ! $set) { | 
                                                        |
| 248 | 248 | $set = $this->retrieve_translation_details();  | 
                                                        
| 249 | - set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS );  | 
                                                        |
| 249 | +			set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS); | 
                                                        |
| 250 | 250 | }  | 
                                                        
| 251 | 251 | |
| 252 | 252 | return $set;  | 
                                                        
@@ -260,10 +260,10 @@ discard block  | 
                                                    ||
| 260 | 260 |  	private function translation_details() { | 
                                                        
| 261 | 261 | $set = $this->find_or_initialize_translation_details();  | 
                                                        
| 262 | 262 | |
| 263 | - $this->translation_exists = ! is_null( $set );  | 
                                                        |
| 264 | - $this->translation_loaded = is_textdomain_loaded( 'give' );  | 
                                                        |
| 263 | + $this->translation_exists = ! is_null($set);  | 
                                                        |
| 264 | +		$this->translation_loaded = is_textdomain_loaded('give'); | 
                                                        |
| 265 | 265 | |
| 266 | - $this->parse_translation_set( $set );  | 
                                                        |
| 266 | + $this->parse_translation_set($set);  | 
                                                        |
| 267 | 267 | }  | 
                                                        
| 268 | 268 | |
| 269 | 269 | /**  | 
                                                        
@@ -275,26 +275,26 @@ discard block  | 
                                                    ||
| 275 | 275 | */  | 
                                                        
| 276 | 276 |  	private function retrieve_translation_details() { | 
                                                        
| 277 | 277 | |
| 278 | - $api_url = trailingslashit( $this->glotpress_url );  | 
                                                        |
| 278 | + $api_url = trailingslashit($this->glotpress_url);  | 
                                                        |
| 279 | 279 | |
| 280 | - $resp = wp_remote_get( $api_url );  | 
                                                        |
| 280 | + $resp = wp_remote_get($api_url);  | 
                                                        |
| 281 | 281 | |
| 282 | -		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { | 
                                                        |
| 282 | +		if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { | 
                                                        |
| 283 | 283 | return null;  | 
                                                        
| 284 | 284 | }  | 
                                                        
| 285 | 285 | |
| 286 | - $body = wp_remote_retrieve_body( $resp );  | 
                                                        |
| 287 | - unset( $resp );  | 
                                                        |
| 286 | + $body = wp_remote_retrieve_body($resp);  | 
                                                        |
| 287 | + unset($resp);  | 
                                                        |
| 288 | 288 | |
| 289 | -		if ( $body ) { | 
                                                        |
| 290 | - $body = json_decode( $body );  | 
                                                        |
| 289 | +		if ($body) { | 
                                                        |
| 290 | + $body = json_decode($body);  | 
                                                        |
| 291 | 291 | |
| 292 | -			foreach ( $body->translation_sets as $set ) { | 
                                                        |
| 293 | -				if ( ! property_exists( $set, 'wp_locale' ) ) { | 
                                                        |
| 292 | +			foreach ($body->translation_sets as $set) { | 
                                                        |
| 293 | +				if ( ! property_exists($set, 'wp_locale')) { | 
                                                        |
| 294 | 294 | continue;  | 
                                                        
| 295 | 295 | }  | 
                                                        
| 296 | 296 | |
| 297 | -				if ( $this->locale == $set->wp_locale ) { | 
                                                        |
| 297 | +				if ($this->locale == $set->wp_locale) { | 
                                                        |
| 298 | 298 | return $set;  | 
                                                        
| 299 | 299 | }  | 
                                                        
| 300 | 300 | }  | 
                                                        
@@ -310,8 +310,8 @@ discard block  | 
                                                    ||
| 310 | 310 | *  | 
                                                        
| 311 | 311 | * @access private  | 
                                                        
| 312 | 312 | */  | 
                                                        
| 313 | -	private function parse_translation_set( $set ) { | 
                                                        |
| 314 | -		if ( $this->translation_exists && is_object( $set ) ) { | 
                                                        |
| 313 | +	private function parse_translation_set($set) { | 
                                                        |
| 314 | +		if ($this->translation_exists && is_object($set)) { | 
                                                        |
| 315 | 315 | $this->locale_name = $set->name;  | 
                                                        
| 316 | 316 | $this->percent_translated = $set->percent_translated;  | 
                                                        
| 317 | 317 |  		} else { | 
                                                        
@@ -12,7 +12,7 @@ discard block  | 
                                                    ||
| 12 | 12 | */  | 
                                                        
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly.  | 
                                                        
| 15 | -if ( ! defined( 'ABSPATH' ) ) { | 
                                                        |
| 15 | +if ( ! defined('ABSPATH')) { | 
                                                        |
| 16 | 16 | exit;  | 
                                                        
| 17 | 17 | }  | 
                                                        
| 18 | 18 | |
@@ -30,36 +30,36 @@ discard block  | 
                                                    ||
| 30 | 30 | *  | 
                                                        
| 31 | 31 | * @return bool|object List of all user donations  | 
                                                        
| 32 | 32 | */  | 
                                                        
| 33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { | 
                                                        |
| 33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { | 
                                                        |
| 34 | 34 | |
| 35 | -	if ( empty( $user ) ) { | 
                                                        |
| 35 | +	if (empty($user)) { | 
                                                        |
| 36 | 36 | $user = get_current_user_id();  | 
                                                        
| 37 | 37 | }  | 
                                                        
| 38 | 38 | |
| 39 | -	if ( 0 === $user && ! Give()->email_access->token_exists ) { | 
                                                        |
| 39 | +	if (0 === $user && ! Give()->email_access->token_exists) { | 
                                                        |
| 40 | 40 | return false;  | 
                                                        
| 41 | 41 | }  | 
                                                        
| 42 | 42 | |
| 43 | 43 | $status = $status === 'complete' ? 'publish' : $status;  | 
                                                        
| 44 | 44 | |
| 45 | -	if ( $pagination ) { | 
                                                        |
| 46 | -		if ( get_query_var( 'paged' ) ) { | 
                                                        |
| 47 | - $paged = get_query_var( 'paged' );  | 
                                                        |
| 48 | -		} elseif ( get_query_var( 'page' ) ) { | 
                                                        |
| 49 | - $paged = get_query_var( 'page' );  | 
                                                        |
| 45 | +	if ($pagination) { | 
                                                        |
| 46 | +		if (get_query_var('paged')) { | 
                                                        |
| 47 | +			$paged = get_query_var('paged'); | 
                                                        |
| 48 | +		} elseif (get_query_var('page')) { | 
                                                        |
| 49 | +			$paged = get_query_var('page'); | 
                                                        |
| 50 | 50 |  		} else { | 
                                                        
| 51 | 51 | $paged = 1;  | 
                                                        
| 52 | 52 | }  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | |
| 55 | - $args = apply_filters( 'give_get_users_donations_args', array(  | 
                                                        |
| 55 | +	$args = apply_filters('give_get_users_donations_args', array( | 
                                                        |
| 56 | 56 | 'user' => $user,  | 
                                                        
| 57 | 57 | 'number' => $number,  | 
                                                        
| 58 | 58 | 'status' => $status,  | 
                                                        
| 59 | 59 | 'orderby' => 'date',  | 
                                                        
| 60 | - ) );  | 
                                                        |
| 60 | + ));  | 
                                                        |
| 61 | 61 | |
| 62 | -	if ( $pagination ) { | 
                                                        |
| 62 | +	if ($pagination) { | 
                                                        |
| 63 | 63 | |
| 64 | 64 | $args['page'] = $paged;  | 
                                                        
| 65 | 65 | |
@@ -69,20 +69,20 @@ discard block  | 
                                                    ||
| 69 | 69 | |
| 70 | 70 | }  | 
                                                        
| 71 | 71 | |
| 72 | - $by_user_id = is_numeric( $user ) ? true : false;  | 
                                                        |
| 73 | - $customer = new Give_Customer( $user, $by_user_id );  | 
                                                        |
| 72 | + $by_user_id = is_numeric($user) ? true : false;  | 
                                                        |
| 73 | + $customer = new Give_Customer($user, $by_user_id);  | 
                                                        |
| 74 | 74 | |
| 75 | -	if ( ! empty( $customer->payment_ids ) ) { | 
                                                        |
| 75 | +	if ( ! empty($customer->payment_ids)) { | 
                                                        |
| 76 | 76 | |
| 77 | - unset( $args['user'] );  | 
                                                        |
| 78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) );  | 
                                                        |
| 77 | + unset($args['user']);  | 
                                                        |
| 78 | +		$args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); | 
                                                        |
| 79 | 79 | |
| 80 | 80 | }  | 
                                                        
| 81 | 81 | |
| 82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );  | 
                                                        |
| 82 | +	$purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); | 
                                                        |
| 83 | 83 | |
| 84 | 84 | // No donations  | 
                                                        
| 85 | -	if ( ! $purchases ) { | 
                                                        |
| 85 | +	if ( ! $purchases) { | 
                                                        |
| 86 | 86 | return false;  | 
                                                        
| 87 | 87 | }  | 
                                                        
| 88 | 88 | |
@@ -101,65 +101,65 @@ discard block  | 
                                                    ||
| 101 | 101 | *  | 
                                                        
| 102 | 102 | * @return bool|object List of unique forms donated by user  | 
                                                        
| 103 | 103 | */  | 
                                                        
| 104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { | 
                                                        |
| 105 | -	if ( empty( $user ) ) { | 
                                                        |
| 104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { | 
                                                        |
| 105 | +	if (empty($user)) { | 
                                                        |
| 106 | 106 | $user = get_current_user_id();  | 
                                                        
| 107 | 107 | }  | 
                                                        
| 108 | 108 | |
| 109 | -	if ( empty( $user ) ) { | 
                                                        |
| 109 | +	if (empty($user)) { | 
                                                        |
| 110 | 110 | return false;  | 
                                                        
| 111 | 111 | }  | 
                                                        
| 112 | 112 | |
| 113 | - $by_user_id = is_numeric( $user ) ? true : false;  | 
                                                        |
| 113 | + $by_user_id = is_numeric($user) ? true : false;  | 
                                                        |
| 114 | 114 | |
| 115 | - $customer = new Give_Customer( $user, $by_user_id );  | 
                                                        |
| 115 | + $customer = new Give_Customer($user, $by_user_id);  | 
                                                        |
| 116 | 116 | |
| 117 | -	if ( empty( $customer->payment_ids ) ) { | 
                                                        |
| 117 | +	if (empty($customer->payment_ids)) { | 
                                                        |
| 118 | 118 | return false;  | 
                                                        
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
| 121 | 121 | // Get all the items donated  | 
                                                        
| 122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) );  | 
                                                        |
| 123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );  | 
                                                        |
| 124 | -	if ( ! empty( $limit_payments ) ) { | 
                                                        |
| 125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments );  | 
                                                        |
| 122 | +	$payment_ids    = array_reverse(explode(',', $customer->payment_ids)); | 
                                                        |
| 123 | +	$limit_payments = apply_filters('give_users_completed_donations_payments', 50); | 
                                                        |
| 124 | +	if ( ! empty($limit_payments)) { | 
                                                        |
| 125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments);  | 
                                                        |
| 126 | 126 | }  | 
                                                        
| 127 | 127 | $donation_data = array();  | 
                                                        
| 128 | -	foreach ( $payment_ids as $payment_id ) { | 
                                                        |
| 129 | - $donation_data[] = give_get_payment_meta( $payment_id );  | 
                                                        |
| 128 | +	foreach ($payment_ids as $payment_id) { | 
                                                        |
| 129 | + $donation_data[] = give_get_payment_meta($payment_id);  | 
                                                        |
| 130 | 130 | }  | 
                                                        
| 131 | 131 | |
| 132 | -	if ( empty( $donation_data ) ) { | 
                                                        |
| 132 | +	if (empty($donation_data)) { | 
                                                        |
| 133 | 133 | return false;  | 
                                                        
| 134 | 134 | }  | 
                                                        
| 135 | 135 | |
| 136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order  | 
                                                        
| 137 | 137 | $completed_donations_ids = array();  | 
                                                        
| 138 | -	foreach ( $donation_data as $purchase_meta ) { | 
                                                        |
| 139 | - $completed_donations_ids[] = isset( $purchase_meta['form_id'] ) ? $purchase_meta['form_id'] : '';  | 
                                                        |
| 138 | +	foreach ($donation_data as $purchase_meta) { | 
                                                        |
| 139 | + $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : '';  | 
                                                        |
| 140 | 140 | }  | 
                                                        
| 141 | 141 | |
| 142 | -	if ( empty( $completed_donations_ids ) ) { | 
                                                        |
| 142 | +	if (empty($completed_donations_ids)) { | 
                                                        |
| 143 | 143 | return false;  | 
                                                        
| 144 | 144 | }  | 
                                                        
| 145 | 145 | |
| 146 | 146 | // Only include each donation once  | 
                                                        
| 147 | - $form_ids = array_unique( $completed_donations_ids );  | 
                                                        |
| 147 | + $form_ids = array_unique($completed_donations_ids);  | 
                                                        |
| 148 | 148 | |
| 149 | 149 | // Make sure we still have some products and a first item  | 
                                                        
| 150 | -	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { | 
                                                        |
| 150 | +	if (empty($form_ids) || ! isset($form_ids[0])) { | 
                                                        |
| 151 | 151 | return false;  | 
                                                        
| 152 | 152 | }  | 
                                                        
| 153 | 153 | |
| 154 | - $post_type = get_post_type( $form_ids[0] );  | 
                                                        |
| 154 | + $post_type = get_post_type($form_ids[0]);  | 
                                                        |
| 155 | 155 | |
| 156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array(  | 
                                                        |
| 156 | +	$args = apply_filters('give_get_users_completed_donations_args', array( | 
                                                        |
| 157 | 157 | 'include' => $form_ids,  | 
                                                        
| 158 | 158 | 'post_type' => $post_type,  | 
                                                        
| 159 | - 'posts_per_page' => - 1,  | 
                                                        |
| 160 | - ) );  | 
                                                        |
| 159 | + 'posts_per_page' => -1,  | 
                                                        |
| 160 | + ));  | 
                                                        |
| 161 | 161 | |
| 162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );  | 
                                                        |
| 162 | +	return apply_filters('give_users_completed_donations_list', get_posts($args)); | 
                                                        |
| 163 | 163 | }  | 
                                                        
| 164 | 164 | |
| 165 | 165 | |
@@ -175,12 +175,12 @@ discard block  | 
                                                    ||
| 175 | 175 | *  | 
                                                        
| 176 | 176 | * @return bool True if has donated, false other wise.  | 
                                                        
| 177 | 177 | */  | 
                                                        
| 178 | -function give_has_purchases( $user_id = null ) { | 
                                                        |
| 179 | -	if ( empty( $user_id ) ) { | 
                                                        |
| 178 | +function give_has_purchases($user_id = null) { | 
                                                        |
| 179 | +	if (empty($user_id)) { | 
                                                        |
| 180 | 180 | $user_id = get_current_user_id();  | 
                                                        
| 181 | 181 | }  | 
                                                        
| 182 | 182 | |
| 183 | -	if ( give_get_users_purchases( $user_id, 1 ) ) { | 
                                                        |
| 183 | +	if (give_get_users_purchases($user_id, 1)) { | 
                                                        |
| 184 | 184 | return true; // User has at least one donation  | 
                                                        
| 185 | 185 | }  | 
                                                        
| 186 | 186 | |
@@ -200,27 +200,27 @@ discard block  | 
                                                    ||
| 200 | 200 | *  | 
                                                        
| 201 | 201 | * @return array  | 
                                                        
| 202 | 202 | */  | 
                                                        
| 203 | -function give_get_purchase_stats_by_user( $user = '' ) { | 
                                                        |
| 203 | +function give_get_purchase_stats_by_user($user = '') { | 
                                                        |
| 204 | 204 | |
| 205 | -	if ( is_email( $user ) ) { | 
                                                        |
| 205 | +	if (is_email($user)) { | 
                                                        |
| 206 | 206 | |
| 207 | 207 | $field = 'email';  | 
                                                        
| 208 | 208 | |
| 209 | -	} elseif ( is_numeric( $user ) ) { | 
                                                        |
| 209 | +	} elseif (is_numeric($user)) { | 
                                                        |
| 210 | 210 | |
| 211 | 211 | $field = 'user_id';  | 
                                                        
| 212 | 212 | |
| 213 | 213 | }  | 
                                                        
| 214 | 214 | |
| 215 | 215 | $stats = array();  | 
                                                        
| 216 | - $customer = Give()->customers->get_customer_by( $field, $user );  | 
                                                        |
| 216 | + $customer = Give()->customers->get_customer_by($field, $user);  | 
                                                        |
| 217 | 217 | |
| 218 | -	if ( $customer ) { | 
                                                        |
| 218 | +	if ($customer) { | 
                                                        |
| 219 | 219 | |
| 220 | - $customer = new Give_Customer( $customer->id );  | 
                                                        |
| 220 | + $customer = new Give_Customer($customer->id);  | 
                                                        |
| 221 | 221 | |
| 222 | - $stats['purchases'] = absint( $customer->purchase_count );  | 
                                                        |
| 223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value );  | 
                                                        |
| 222 | + $stats['purchases'] = absint($customer->purchase_count);  | 
                                                        |
| 223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value);  | 
                                                        |
| 224 | 224 | |
| 225 | 225 | }  | 
                                                        
| 226 | 226 | |
@@ -229,7 +229,7 @@ discard block  | 
                                                    ||
| 229 | 229 | *  | 
                                                        
| 230 | 230 | * @since 1.7  | 
                                                        
| 231 | 231 | */  | 
                                                        
| 232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );  | 
                                                        |
| 232 | +	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); | 
                                                        |
| 233 | 233 | |
| 234 | 234 | return $stats;  | 
                                                        
| 235 | 235 | }  | 
                                                        
@@ -247,21 +247,21 @@ discard block  | 
                                                    ||
| 247 | 247 | *  | 
                                                        
| 248 | 248 | * @return int The total number of donations  | 
                                                        
| 249 | 249 | */  | 
                                                        
| 250 | -function give_count_purchases_of_customer( $user = null ) { | 
                                                        |
| 250 | +function give_count_purchases_of_customer($user = null) { | 
                                                        |
| 251 | 251 | |
| 252 | 252 | // Logged in?  | 
                                                        
| 253 | -	if ( empty( $user ) ) { | 
                                                        |
| 253 | +	if (empty($user)) { | 
                                                        |
| 254 | 254 | $user = get_current_user_id();  | 
                                                        
| 255 | 255 | }  | 
                                                        
| 256 | 256 | |
| 257 | 257 | // Email access?  | 
                                                        
| 258 | -	if ( empty( $user ) && Give()->email_access->token_email ) { | 
                                                        |
| 258 | +	if (empty($user) && Give()->email_access->token_email) { | 
                                                        |
| 259 | 259 | $user = Give()->email_access->token_email;  | 
                                                        
| 260 | 260 | }  | 
                                                        
| 261 | 261 | |
| 262 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false;  | 
                                                        |
| 262 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false;  | 
                                                        |
| 263 | 263 | |
| 264 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;  | 
                                                        |
| 264 | + return isset($stats['purchases']) ? $stats['purchases'] : 0;  | 
                                                        |
| 265 | 265 | }  | 
                                                        
| 266 | 266 | |
| 267 | 267 | /**  | 
                                                        
@@ -274,9 +274,9 @@ discard block  | 
                                                    ||
| 274 | 274 | *  | 
                                                        
| 275 | 275 | * @return float The total amount the user has spent  | 
                                                        
| 276 | 276 | */  | 
                                                        
| 277 | -function give_purchase_total_of_user( $user = null ) { | 
                                                        |
| 277 | +function give_purchase_total_of_user($user = null) { | 
                                                        |
| 278 | 278 | |
| 279 | - $stats = give_get_purchase_stats_by_user( $user );  | 
                                                        |
| 279 | + $stats = give_get_purchase_stats_by_user($user);  | 
                                                        |
| 280 | 280 | |
| 281 | 281 | return $stats['total_spent'];  | 
                                                        
| 282 | 282 | }  | 
                                                        
@@ -292,40 +292,40 @@ discard block  | 
                                                    ||
| 292 | 292 | *  | 
                                                        
| 293 | 293 | * @return bool  | 
                                                        
| 294 | 294 | */  | 
                                                        
| 295 | -function give_validate_username( $username, $form_id = 0 ) { | 
                                                        |
| 295 | +function give_validate_username($username, $form_id = 0) { | 
                                                        |
| 296 | 296 | $valid = true;  | 
                                                        
| 297 | 297 | |
| 298 | 298 | // Validate username.  | 
                                                        
| 299 | -	if ( ! empty( $username ) ) { | 
                                                        |
| 299 | +	if ( ! empty($username)) { | 
                                                        |
| 300 | 300 | |
| 301 | 301 | // Sanitize username.  | 
                                                        
| 302 | - $sanitized_user_name = sanitize_user( $username, false );  | 
                                                        |
| 302 | + $sanitized_user_name = sanitize_user($username, false);  | 
                                                        |
| 303 | 303 | |
| 304 | 304 | // We have an user name, check if it already exists.  | 
                                                        
| 305 | -		if ( username_exists( $username ) ) { | 
                                                        |
| 305 | +		if (username_exists($username)) { | 
                                                        |
| 306 | 306 | // Username already registered.  | 
                                                        
| 307 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );  | 
                                                        |
| 307 | +			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); | 
                                                        |
| 308 | 308 | $valid = false;  | 
                                                        
| 309 | 309 | |
| 310 | 310 | // Check if it's valid.  | 
                                                        
| 311 | -		} elseif ( $sanitized_user_name !== $username ) { | 
                                                        |
| 311 | +		} elseif ($sanitized_user_name !== $username) { | 
                                                        |
| 312 | 312 | // Invalid username.  | 
                                                        
| 313 | -			if ( is_multisite() ) { | 
                                                        |
| 314 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );  | 
                                                        |
| 313 | +			if (is_multisite()) { | 
                                                        |
| 314 | +				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); | 
                                                        |
| 315 | 315 | $valid = false;  | 
                                                        
| 316 | 316 |  			} else { | 
                                                        
| 317 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );  | 
                                                        |
| 317 | +				give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); | 
                                                        |
| 318 | 318 | $valid = false;  | 
                                                        
| 319 | 319 | }  | 
                                                        
| 320 | 320 | }  | 
                                                        
| 321 | 321 |  	} else { | 
                                                        
| 322 | 322 | // Username is empty.  | 
                                                        
| 323 | - give_set_error( 'username_empty', esc_html__( 'Enter a username.', 'give' ) );  | 
                                                        |
| 323 | +		give_set_error('username_empty', esc_html__('Enter a username.', 'give')); | 
                                                        |
| 324 | 324 | $valid = false;  | 
                                                        
| 325 | 325 | |
| 326 | 326 | // Check if guest checkout is disable for form.  | 
                                                        
| 327 | -		if ( $form_id && give_logged_in_only( $form_id ) ) { | 
                                                        |
| 328 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );  | 
                                                        |
| 327 | +		if ($form_id && give_logged_in_only($form_id)) { | 
                                                        |
| 328 | +			give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); | 
                                                        |
| 329 | 329 | $valid = false;  | 
                                                        
| 330 | 330 | }  | 
                                                        
| 331 | 331 | }  | 
                                                        
@@ -339,7 +339,7 @@ discard block  | 
                                                    ||
| 339 | 339 | * @param string $username  | 
                                                        
| 340 | 340 | * @param bool $form_id  | 
                                                        
| 341 | 341 | */  | 
                                                        
| 342 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );  | 
                                                        |
| 342 | +	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); | 
                                                        |
| 343 | 343 | |
| 344 | 344 | return $valid;  | 
                                                        
| 345 | 345 | }  | 
                                                        
@@ -355,22 +355,22 @@ discard block  | 
                                                    ||
| 355 | 355 | *  | 
                                                        
| 356 | 356 | * @return bool  | 
                                                        
| 357 | 357 | */  | 
                                                        
| 358 | -function give_validate_user_email( $email, $registering_new_user = false ) { | 
                                                        |
| 358 | +function give_validate_user_email($email, $registering_new_user = false) { | 
                                                        |
| 359 | 359 | $valid = true;  | 
                                                        
| 360 | 360 | |
| 361 | -	if ( empty( $email ) ) { | 
                                                        |
| 361 | +	if (empty($email)) { | 
                                                        |
| 362 | 362 | // No email.  | 
                                                        
| 363 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );  | 
                                                        |
| 363 | +		give_set_error('email_empty', esc_html__('Enter an email.', 'give')); | 
                                                        |
| 364 | 364 | $valid = false;  | 
                                                        
| 365 | 365 | |
| 366 | -	} elseif ( ! is_email( $email ) ) { | 
                                                        |
| 366 | +	} elseif ( ! is_email($email)) { | 
                                                        |
| 367 | 367 | // Validate email.  | 
                                                        
| 368 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );  | 
                                                        |
| 368 | +		give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); | 
                                                        |
| 369 | 369 | $valid = false;  | 
                                                        
| 370 | 370 | |
| 371 | -	} elseif ( $registering_new_user && email_exists( $email ) ) { | 
                                                        |
| 371 | +	} elseif ($registering_new_user && email_exists($email)) { | 
                                                        |
| 372 | 372 | // Check if email exists.  | 
                                                        
| 373 | - give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );  | 
                                                        |
| 373 | +		give_set_error('email_used', esc_html__('The email already active for another user.', 'give')); | 
                                                        |
| 374 | 374 | $valid = false;  | 
                                                        
| 375 | 375 | }  | 
                                                        
| 376 | 376 | |
@@ -383,7 +383,7 @@ discard block  | 
                                                    ||
| 383 | 383 | * @param string $email  | 
                                                        
| 384 | 384 | * @param bool $registering_new_user  | 
                                                        
| 385 | 385 | */  | 
                                                        
| 386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );  | 
                                                        |
| 386 | +	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); | 
                                                        |
| 387 | 387 | |
| 388 | 388 | return $valid;  | 
                                                        
| 389 | 389 | }  | 
                                                        
@@ -399,25 +399,25 @@ discard block  | 
                                                    ||
| 399 | 399 | *  | 
                                                        
| 400 | 400 | * @return bool  | 
                                                        
| 401 | 401 | */  | 
                                                        
| 402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { | 
                                                        |
| 402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { | 
                                                        |
| 403 | 403 | $valid = true;  | 
                                                        
| 404 | 404 | |
| 405 | -	if ( $password && $confirm_password ) { | 
                                                        |
| 405 | +	if ($password && $confirm_password) { | 
                                                        |
| 406 | 406 | // Verify confirmation matches.  | 
                                                        
| 407 | -		if ( $password != $confirm_password ) { | 
                                                        |
| 407 | +		if ($password != $confirm_password) { | 
                                                        |
| 408 | 408 | // Passwords do not match  | 
                                                        
| 409 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );  | 
                                                        |
| 409 | +			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); | 
                                                        |
| 410 | 410 | $valid = false;  | 
                                                        
| 411 | 411 | }  | 
                                                        
| 412 | -	} elseif ( $registering_new_user ) { | 
                                                        |
| 412 | +	} elseif ($registering_new_user) { | 
                                                        |
| 413 | 413 | // Password or confirmation missing.  | 
                                                        
| 414 | -		if ( ! $password ) { | 
                                                        |
| 414 | +		if ( ! $password) { | 
                                                        |
| 415 | 415 | // The password is invalid.  | 
                                                        
| 416 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );  | 
                                                        |
| 416 | +			give_set_error('password_empty', esc_html__('Enter a password.', 'give')); | 
                                                        |
| 417 | 417 | $valid = false;  | 
                                                        
| 418 | -		} elseif ( ! $confirm_password ) { | 
                                                        |
| 418 | +		} elseif ( ! $confirm_password) { | 
                                                        |
| 419 | 419 | // Confirmation password is invalid.  | 
                                                        
| 420 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );  | 
                                                        |
| 420 | +			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); | 
                                                        |
| 421 | 421 | $valid = false;  | 
                                                        
| 422 | 422 | }  | 
                                                        
| 423 | 423 | }  | 
                                                        
@@ -432,7 +432,7 @@ discard block  | 
                                                    ||
| 432 | 432 | * @param string $confirm_password  | 
                                                        
| 433 | 433 | * @param bool $registering_new_user  | 
                                                        
| 434 | 434 | */  | 
                                                        
| 435 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );  | 
                                                        |
| 435 | +	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); | 
                                                        |
| 436 | 436 | |
| 437 | 437 | return $valid;  | 
                                                        
| 438 | 438 | }  | 
                                                        
@@ -451,32 +451,32 @@ discard block  | 
                                                    ||
| 451 | 451 | *  | 
                                                        
| 452 | 452 | * @return void  | 
                                                        
| 453 | 453 | */  | 
                                                        
| 454 | -function give_add_past_purchases_to_new_user( $user_id ) { | 
                                                        |
| 454 | +function give_add_past_purchases_to_new_user($user_id) { | 
                                                        |
| 455 | 455 | |
| 456 | - $email = get_the_author_meta( 'user_email', $user_id );  | 
                                                        |
| 456 | +	$email = get_the_author_meta('user_email', $user_id); | 
                                                        |
| 457 | 457 | |
| 458 | - $payments = give_get_payments( array( 's' => $email ) );  | 
                                                        |
| 458 | +	$payments = give_get_payments(array('s' => $email)); | 
                                                        |
| 459 | 459 | |
| 460 | -	if ( $payments ) { | 
                                                        |
| 461 | -		foreach ( $payments as $payment ) { | 
                                                        |
| 462 | -			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { | 
                                                        |
| 460 | +	if ($payments) { | 
                                                        |
| 461 | +		foreach ($payments as $payment) { | 
                                                        |
| 462 | +			if (intval(give_get_payment_user_id($payment->ID)) > 0) { | 
                                                        |
| 463 | 463 | continue;  | 
                                                        
| 464 | 464 | } // This payment already associated with an account  | 
                                                        
| 465 | 465 | |
| 466 | - $meta = give_get_payment_meta( $payment->ID );  | 
                                                        |
| 467 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] );  | 
                                                        |
| 466 | + $meta = give_get_payment_meta($payment->ID);  | 
                                                        |
| 467 | + $meta['user_info'] = maybe_unserialize($meta['user_info']);  | 
                                                        |
| 468 | 468 | $meta['user_info']['id'] = $user_id;  | 
                                                        
| 469 | 469 | $meta['user_info'] = $meta['user_info'];  | 
                                                        
| 470 | 470 | |
| 471 | 471 | // Store the updated user ID in the payment meta  | 
                                                        
| 472 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );  | 
                                                        |
| 473 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );  | 
                                                        |
| 472 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);  | 
                                                        |
| 473 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);  | 
                                                        |
| 474 | 474 | }  | 
                                                        
| 475 | 475 | }  | 
                                                        
| 476 | 476 | |
| 477 | 477 | }  | 
                                                        
| 478 | 478 | |
| 479 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' );  | 
                                                        |
| 479 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); | 
                                                        |
| 480 | 480 | |
| 481 | 481 | |
| 482 | 482 | /**  | 
                                                        
@@ -502,34 +502,34 @@ discard block  | 
                                                    ||
| 502 | 502 | *  | 
                                                        
| 503 | 503 | * @return array The donor's address, if any  | 
                                                        
| 504 | 504 | */  | 
                                                        
| 505 | -function give_get_donor_address( $user_id = 0 ) { | 
                                                        |
| 506 | -	if ( empty( $user_id ) ) { | 
                                                        |
| 505 | +function give_get_donor_address($user_id = 0) { | 
                                                        |
| 506 | +	if (empty($user_id)) { | 
                                                        |
| 507 | 507 | $user_id = get_current_user_id();  | 
                                                        
| 508 | 508 | }  | 
                                                        
| 509 | 509 | |
| 510 | - $address = get_user_meta( $user_id, '_give_user_address', true );  | 
                                                        |
| 510 | + $address = get_user_meta($user_id, '_give_user_address', true);  | 
                                                        |
| 511 | 511 | |
| 512 | -	if ( ! isset( $address['line1'] ) ) { | 
                                                        |
| 512 | +	if ( ! isset($address['line1'])) { | 
                                                        |
| 513 | 513 | $address['line1'] = '';  | 
                                                        
| 514 | 514 | }  | 
                                                        
| 515 | 515 | |
| 516 | -	if ( ! isset( $address['line2'] ) ) { | 
                                                        |
| 516 | +	if ( ! isset($address['line2'])) { | 
                                                        |
| 517 | 517 | $address['line2'] = '';  | 
                                                        
| 518 | 518 | }  | 
                                                        
| 519 | 519 | |
| 520 | -	if ( ! isset( $address['city'] ) ) { | 
                                                        |
| 520 | +	if ( ! isset($address['city'])) { | 
                                                        |
| 521 | 521 | $address['city'] = '';  | 
                                                        
| 522 | 522 | }  | 
                                                        
| 523 | 523 | |
| 524 | -	if ( ! isset( $address['zip'] ) ) { | 
                                                        |
| 524 | +	if ( ! isset($address['zip'])) { | 
                                                        |
| 525 | 525 | $address['zip'] = '';  | 
                                                        
| 526 | 526 | }  | 
                                                        
| 527 | 527 | |
| 528 | -	if ( ! isset( $address['country'] ) ) { | 
                                                        |
| 528 | +	if ( ! isset($address['country'])) { | 
                                                        |
| 529 | 529 | $address['country'] = '';  | 
                                                        
| 530 | 530 | }  | 
                                                        
| 531 | 531 | |
| 532 | -	if ( ! isset( $address['state'] ) ) { | 
                                                        |
| 532 | +	if ( ! isset($address['state'])) { | 
                                                        |
| 533 | 533 | $address['state'] = '';  | 
                                                        
| 534 | 534 | }  | 
                                                        
| 535 | 535 | |
@@ -549,42 +549,42 @@ discard block  | 
                                                    ||
| 549 | 549 | *  | 
                                                        
| 550 | 550 | * @return void  | 
                                                        
| 551 | 551 | */  | 
                                                        
| 552 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { | 
                                                        |
| 552 | +function give_new_user_notification($user_id = 0, $user_data = array()) { | 
                                                        |
| 553 | 553 | |
| 554 | -	if ( empty( $user_id ) || empty( $user_data ) ) { | 
                                                        |
| 554 | +	if (empty($user_id) || empty($user_data)) { | 
                                                        |
| 555 | 555 | return;  | 
                                                        
| 556 | 556 | }  | 
                                                        
| 557 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );  | 
                                                        |
| 557 | +	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); | 
                                                        |
| 558 | 558 | |
| 559 | 559 | /* translators: %s: site name */  | 
                                                        
| 560 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n";  | 
                                                        |
| 560 | +	$message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; | 
                                                        |
| 561 | 561 | /* translators: %s: user login */  | 
                                                        
| 562 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n";  | 
                                                        |
| 562 | +	$message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; | 
                                                        |
| 563 | 563 | /* translators: %s: user email */  | 
                                                        
| 564 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n";  | 
                                                        |
| 564 | +	$message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; | 
                                                        |
| 565 | 565 | |
| 566 | 566 | @wp_mail(  | 
                                                        
| 567 | - get_option( 'admin_email' ),  | 
                                                        |
| 567 | +		get_option('admin_email'), | 
                                                        |
| 568 | 568 | sprintf(  | 
                                                        
| 569 | 569 | /* translators: %s: site name */  | 
                                                        
| 570 | - esc_attr__( '[%s] New User Registration', 'give' ),  | 
                                                        |
| 570 | +			esc_attr__('[%s] New User Registration', 'give'), | 
                                                        |
| 571 | 571 | $blogname  | 
                                                        
| 572 | 572 | ),  | 
                                                        
| 573 | 573 | $message  | 
                                                        
| 574 | 574 | );  | 
                                                        
| 575 | 575 | |
| 576 | 576 | /* translators: %s: user login */  | 
                                                        
| 577 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n";  | 
                                                        |
| 577 | +	$message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; | 
                                                        |
| 578 | 578 | /* translators: %s: paswword */  | 
                                                        
| 579 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n";  | 
                                                        |
| 579 | +	$message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; | 
                                                        |
| 580 | 580 | |
| 581 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n";  | 
                                                        |
| 581 | +	$message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; | 
                                                        |
| 582 | 582 | |
| 583 | 583 | wp_mail(  | 
                                                        
| 584 | 584 | $user_data['user_email'],  | 
                                                        
| 585 | 585 | sprintf(  | 
                                                        
| 586 | 586 | /* translators: %s: site name */  | 
                                                        
| 587 | - esc_attr__( '[%s] Your username and password', 'give' ),  | 
                                                        |
| 587 | +			esc_attr__('[%s] Your username and password', 'give'), | 
                                                        |
| 588 | 588 | $blogname  | 
                                                        
| 589 | 589 | ),  | 
                                                        
| 590 | 590 | $message  | 
                                                        
@@ -592,4 +592,4 @@ discard block  | 
                                                    ||
| 592 | 592 | |
| 593 | 593 | }  | 
                                                        
| 594 | 594 | |
| 595 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );  | 
                                                        |
| 595 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); | 
                                                        |
@@ -10,7 +10,7 @@ discard block  | 
                                                    ||
| 10 | 10 | */  | 
                                                        
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly.  | 
                                                        
| 13 | -if ( ! defined( 'ABSPATH' ) ) { | 
                                                        |
| 13 | +if ( ! defined('ABSPATH')) { | 
                                                        |
| 14 | 14 | exit;  | 
                                                        
| 15 | 15 | }  | 
                                                        
| 16 | 16 | |
@@ -30,7 +30,7 @@ discard block  | 
                                                    ||
| 30 | 30 | *  | 
                                                        
| 31 | 31 | * @since 1.0  | 
                                                        
| 32 | 32 | */  | 
                                                        
| 33 | - do_action( 'give_pre_process_donation' );  | 
                                                        |
| 33 | +	do_action('give_pre_process_donation'); | 
                                                        |
| 34 | 34 | |
| 35 | 35 | // Validate the form $_POST data  | 
                                                        
| 36 | 36 | $valid_data = give_purchase_form_validate_fields();  | 
                                                        
@@ -45,26 +45,26 @@ discard block  | 
                                                    ||
| 45 | 45 | * @param bool|array $valid_data Validate fields.  | 
                                                        
| 46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST.  | 
                                                        
| 47 | 47 | */  | 
                                                        
| 48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST );  | 
                                                        |
| 48 | +	do_action('give_checkout_error_checks', $valid_data, $_POST); | 
                                                        |
| 49 | 49 | |
| 50 | - $is_ajax = isset( $_POST['give_ajax'] );  | 
                                                        |
| 50 | + $is_ajax = isset($_POST['give_ajax']);  | 
                                                        |
| 51 | 51 | |
| 52 | 52 | // Process the login form  | 
                                                        
| 53 | -	if ( isset( $_POST['give_login_submit'] ) ) { | 
                                                        |
| 53 | +	if (isset($_POST['give_login_submit'])) { | 
                                                        |
| 54 | 54 | give_process_form_login();  | 
                                                        
| 55 | 55 | }  | 
                                                        
| 56 | 56 | |
| 57 | 57 | // Validate the user  | 
                                                        
| 58 | - $user = give_get_purchase_form_user( $valid_data );  | 
                                                        |
| 58 | + $user = give_get_purchase_form_user($valid_data);  | 
                                                        |
| 59 | 59 | |
| 60 | -	if ( false === $valid_data || give_get_errors() || ! $user ) { | 
                                                        |
| 61 | -		if ( $is_ajax ) { | 
                                                        |
| 60 | +	if (false === $valid_data || give_get_errors() || ! $user) { | 
                                                        |
| 61 | +		if ($is_ajax) { | 
                                                        |
| 62 | 62 | /**  | 
                                                        
| 63 | 63 | * Fires when AJAX sends back errors from the donation form.  | 
                                                        
| 64 | 64 | *  | 
                                                        
| 65 | 65 | * @since 1.0  | 
                                                        
| 66 | 66 | */  | 
                                                        
| 67 | - do_action( 'give_ajax_donation_errors' );  | 
                                                        |
| 67 | +			do_action('give_ajax_donation_errors'); | 
                                                        |
| 68 | 68 | give_die();  | 
                                                        
| 69 | 69 |  		} else { | 
                                                        
| 70 | 70 | return false;  | 
                                                        
@@ -72,17 +72,17 @@ discard block  | 
                                                    ||
| 72 | 72 | }  | 
                                                        
| 73 | 73 | |
| 74 | 74 | // If AJAX send back success to proceed with form submission  | 
                                                        
| 75 | -	if ( $is_ajax ) { | 
                                                        |
| 75 | +	if ($is_ajax) { | 
                                                        |
| 76 | 76 | echo 'success';  | 
                                                        
| 77 | 77 | give_die();  | 
                                                        
| 78 | 78 | }  | 
                                                        
| 79 | 79 | |
| 80 | 80 | // After AJAX: Setup session if not using php_sessions  | 
                                                        
| 81 | -	if ( ! Give()->session->use_php_sessions() ) { | 
                                                        |
| 81 | +	if ( ! Give()->session->use_php_sessions()) { | 
                                                        |
| 82 | 82 | // Double-check that set_cookie is publicly accessible;  | 
                                                        
| 83 | 83 | // we're using a slightly modified class-wp-sessions.php  | 
                                                        
| 84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );  | 
                                                        |
| 85 | -		if ( $session_reflection->isPublic() ) { | 
                                                        |
| 84 | +		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); | 
                                                        |
| 85 | +		if ($session_reflection->isPublic()) { | 
                                                        |
| 86 | 86 | // Manually set the cookie.  | 
                                                        
| 87 | 87 | Give()->session->init()->set_cookie();  | 
                                                        
| 88 | 88 | }  | 
                                                        
@@ -97,18 +97,18 @@ discard block  | 
                                                    ||
| 97 | 97 | 'address' => $user['address'],  | 
                                                        
| 98 | 98 | );  | 
                                                        
| 99 | 99 | |
| 100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';  | 
                                                        |
| 100 | +	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; | 
                                                        |
| 101 | 101 | |
| 102 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';  | 
                                                        |
| 103 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  | 
                                                        |
| 102 | +	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; | 
                                                        |
| 103 | +	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); | 
                                                        |
| 104 | 104 | |
| 105 | 105 | // Setup donation information  | 
                                                        
| 106 | 106 | $purchase_data = array(  | 
                                                        
| 107 | 107 | 'price' => $price,  | 
                                                        
| 108 | 108 | 'purchase_key' => $purchase_key,  | 
                                                        
| 109 | 109 | 'user_email' => $user['user_email'],  | 
                                                        
| 110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),  | 
                                                        |
| 111 | - 'user_info' => stripslashes_deep( $user_info ),  | 
                                                        |
| 110 | +		'date'         => date('Y-m-d H:i:s', current_time('timestamp')), | 
                                                        |
| 111 | + 'user_info' => stripslashes_deep($user_info),  | 
                                                        |
| 112 | 112 | 'post_data' => $_POST,  | 
                                                        
| 113 | 113 | 'gateway' => $valid_data['gateway'],  | 
                                                        
| 114 | 114 | 'card_info' => $valid_data['cc_info'],  | 
                                                        
@@ -128,10 +128,10 @@ discard block  | 
                                                    ||
| 128 | 128 | * @param array $user_info Array containing basic user information.  | 
                                                        
| 129 | 129 | * @param bool|array $valid_data Validate fields.  | 
                                                        
| 130 | 130 | */  | 
                                                        
| 131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );  | 
                                                        |
| 131 | +	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); | 
                                                        |
| 132 | 132 | |
| 133 | 133 | // Sanity check for price  | 
                                                        
| 134 | -	if ( ! $purchase_data['price'] ) { | 
                                                        |
| 134 | +	if ( ! $purchase_data['price']) { | 
                                                        |
| 135 | 135 | // Revert to manual  | 
                                                        
| 136 | 136 | $purchase_data['gateway'] = 'manual';  | 
                                                        
| 137 | 137 | $_POST['give-gateway'] = 'manual';  | 
                                                        
@@ -142,27 +142,27 @@ discard block  | 
                                                    ||
| 142 | 142 | *  | 
                                                        
| 143 | 143 | * @since 1.7  | 
                                                        
| 144 | 144 | */  | 
                                                        
| 145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data );  | 
                                                        |
| 145 | +	$purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); | 
                                                        |
| 146 | 146 | |
| 147 | 147 | // Setup the data we're storing in the donation session  | 
                                                        
| 148 | 148 | $session_data = $purchase_data;  | 
                                                        
| 149 | 149 | |
| 150 | 150 | // Make sure credit card numbers are never stored in sessions  | 
                                                        
| 151 | - unset( $session_data['card_info']['card_number'] );  | 
                                                        |
| 152 | - unset( $session_data['post_data']['card_number'] );  | 
                                                        |
| 151 | + unset($session_data['card_info']['card_number']);  | 
                                                        |
| 152 | + unset($session_data['post_data']['card_number']);  | 
                                                        |
| 153 | 153 | |
| 154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data.  | 
                                                        
| 155 | - give_set_purchase_session( $session_data );  | 
                                                        |
| 155 | + give_set_purchase_session($session_data);  | 
                                                        |
| 156 | 156 | |
| 157 | 157 | // Send info to the gateway for payment processing  | 
                                                        
| 158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data );  | 
                                                        |
| 158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data);  | 
                                                        |
| 159 | 159 | give_die();  | 
                                                        
| 160 | 160 | |
| 161 | 161 | }  | 
                                                        
| 162 | 162 | |
| 163 | -add_action( 'give_purchase', 'give_process_donation_form' );  | 
                                                        |
| 164 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );  | 
                                                        |
| 165 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );  | 
                                                        |
| 163 | +add_action('give_purchase', 'give_process_donation_form'); | 
                                                        |
| 164 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); | 
                                                        |
| 165 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); | 
                                                        |
| 166 | 166 | |
| 167 | 167 | |
| 168 | 168 | /**  | 
                                                        
@@ -175,26 +175,26 @@ discard block  | 
                                                    ||
| 175 | 175 | *  | 
                                                        
| 176 | 176 | * @return void  | 
                                                        
| 177 | 177 | */  | 
                                                        
| 178 | -function give_checkout_check_existing_email( $valid_data, $post ) { | 
                                                        |
| 178 | +function give_checkout_check_existing_email($valid_data, $post) { | 
                                                        |
| 179 | 179 | |
| 180 | 180 | // Verify that the email address belongs to this customer.  | 
                                                        
| 181 | -	if ( is_user_logged_in() ) { | 
                                                        |
| 181 | +	if (is_user_logged_in()) { | 
                                                        |
| 182 | 182 | |
| 183 | 183 | $email = $valid_data['logged_in_user']['user_email'];  | 
                                                        
| 184 | - $customer = new Give_Customer( get_current_user_id(), true );  | 
                                                        |
| 184 | + $customer = new Give_Customer(get_current_user_id(), true);  | 
                                                        |
| 185 | 185 | |
| 186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer  | 
                                                        
| 187 | -		if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { | 
                                                        |
| 188 | - $found_customer = new Give_Customer( $email );  | 
                                                        |
| 187 | +		if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { | 
                                                        |
| 188 | + $found_customer = new Give_Customer($email);  | 
                                                        |
| 189 | 189 | |
| 190 | -			if ( $found_customer->id > 0 ) { | 
                                                        |
| 191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) );  | 
                                                        |
| 190 | +			if ($found_customer->id > 0) { | 
                                                        |
| 191 | +				give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); | 
                                                        |
| 192 | 192 | }  | 
                                                        
| 193 | 193 | }  | 
                                                        
| 194 | 194 | }  | 
                                                        
| 195 | 195 | }  | 
                                                        
| 196 | 196 | |
| 197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 );  | 
                                                        |
| 197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); | 
                                                        |
| 198 | 198 | |
| 199 | 199 | /**  | 
                                                        
| 200 | 200 | * Process the checkout login form  | 
                                                        
@@ -205,37 +205,37 @@ discard block  | 
                                                    ||
| 205 | 205 | */  | 
                                                        
| 206 | 206 |  function give_process_form_login() { | 
                                                        
| 207 | 207 | |
| 208 | - $is_ajax = isset( $_POST['give_ajax'] );  | 
                                                        |
| 208 | + $is_ajax = isset($_POST['give_ajax']);  | 
                                                        |
| 209 | 209 | |
| 210 | 210 | $user_data = give_purchase_form_validate_user_login();  | 
                                                        
| 211 | 211 | |
| 212 | -	if ( give_get_errors() || $user_data['user_id'] < 1 ) { | 
                                                        |
| 213 | -		if ( $is_ajax ) { | 
                                                        |
| 212 | +	if (give_get_errors() || $user_data['user_id'] < 1) { | 
                                                        |
| 213 | +		if ($is_ajax) { | 
                                                        |
| 214 | 214 | /**  | 
                                                        
| 215 | 215 | * Fires when AJAX sends back errors from the donation form.  | 
                                                        
| 216 | 216 | *  | 
                                                        
| 217 | 217 | * @since 1.0  | 
                                                        
| 218 | 218 | */  | 
                                                        
| 219 | - do_action( 'give_ajax_donation_errors' );  | 
                                                        |
| 219 | +			do_action('give_ajax_donation_errors'); | 
                                                        |
| 220 | 220 | give_die();  | 
                                                        
| 221 | 221 |  		} else { | 
                                                        
| 222 | - wp_redirect( $_SERVER['HTTP_REFERER'] );  | 
                                                        |
| 222 | + wp_redirect($_SERVER['HTTP_REFERER']);  | 
                                                        |
| 223 | 223 | exit;  | 
                                                        
| 224 | 224 | }  | 
                                                        
| 225 | 225 | }  | 
                                                        
| 226 | 226 | |
| 227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );  | 
                                                        |
| 227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);  | 
                                                        |
| 228 | 228 | |
| 229 | -	if ( $is_ajax ) { | 
                                                        |
| 229 | +	if ($is_ajax) { | 
                                                        |
| 230 | 230 | echo 'success';  | 
                                                        
| 231 | 231 | give_die();  | 
                                                        
| 232 | 232 |  	} else { | 
                                                        
| 233 | - wp_redirect( $_SERVER['HTTP_REFERER'] );  | 
                                                        |
| 233 | + wp_redirect($_SERVER['HTTP_REFERER']);  | 
                                                        |
| 234 | 234 | }  | 
                                                        
| 235 | 235 | }  | 
                                                        
| 236 | 236 | |
| 237 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );  | 
                                                        |
| 238 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );  | 
                                                        |
| 237 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); | 
                                                        |
| 238 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); | 
                                                        |
| 239 | 239 | |
| 240 | 240 | /**  | 
                                                        
| 241 | 241 | * Donation Form Validate Fields  | 
                                                        
@@ -247,55 +247,55 @@ discard block  | 
                                                    ||
| 247 | 247 |  function give_purchase_form_validate_fields() { | 
                                                        
| 248 | 248 | |
| 249 | 249 | // Check if there is $_POST  | 
                                                        
| 250 | -	if ( empty( $_POST ) ) { | 
                                                        |
| 250 | +	if (empty($_POST)) { | 
                                                        |
| 251 | 251 | return false;  | 
                                                        
| 252 | 252 | }  | 
                                                        
| 253 | 253 | |
| 254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';  | 
                                                        |
| 254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';  | 
                                                        |
| 255 | 255 | |
| 256 | 256 | // Start an array to collect valid data  | 
                                                        
| 257 | 257 | $valid_data = array(  | 
                                                        
| 258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)  | 
                                                        
| 259 | - 'need_new_user' => false, // New user flag  | 
                                                        |
| 260 | - 'need_user_login' => false, // Login user flag  | 
                                                        |
| 261 | - 'logged_user_data' => array(), // Logged user collected data  | 
                                                        |
| 262 | - 'new_user_data' => array(), // New user collected data  | 
                                                        |
| 263 | - 'login_user_data' => array(), // Login user collected data  | 
                                                        |
| 264 | - 'guest_user_data' => array(), // Guest user collected data  | 
                                                        |
| 265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info  | 
                                                        |
| 259 | + 'need_new_user' => false, // New user flag  | 
                                                        |
| 260 | + 'need_user_login' => false, // Login user flag  | 
                                                        |
| 261 | + 'logged_user_data' => array(), // Logged user collected data  | 
                                                        |
| 262 | + 'new_user_data' => array(), // New user collected data  | 
                                                        |
| 263 | + 'login_user_data' => array(), // Login user collected data  | 
                                                        |
| 264 | + 'guest_user_data' => array(), // Guest user collected data  | 
                                                        |
| 265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info  | 
                                                        |
| 266 | 266 | );  | 
                                                        
| 267 | 267 | |
| 268 | 268 | // Validate Honeypot First  | 
                                                        
| 269 | -	if ( ! empty( $_POST['give-honeypot'] ) ) { | 
                                                        |
| 270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );  | 
                                                        |
| 269 | +	if ( ! empty($_POST['give-honeypot'])) { | 
                                                        |
| 270 | +		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); | 
                                                        |
| 271 | 271 | }  | 
                                                        
| 272 | 272 | |
| 273 | 273 | // Validate agree to terms  | 
                                                        
| 274 | -	if ( give_is_terms_enabled( $form_id ) ) { | 
                                                        |
| 274 | +	if (give_is_terms_enabled($form_id)) { | 
                                                        |
| 275 | 275 | give_purchase_form_validate_agree_to_terms();  | 
                                                        
| 276 | 276 | }  | 
                                                        
| 277 | 277 | |
| 278 | 278 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout.  | 
                                                        
| 279 | 279 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout.  | 
                                                        
| 280 | 280 | if (  | 
                                                        
| 281 | - ! give_logged_in_only( $form_id )  | 
                                                        |
| 282 | - && isset( $_POST['give-purchase-var'] )  | 
                                                        |
| 281 | + ! give_logged_in_only($form_id)  | 
                                                        |
| 282 | + && isset($_POST['give-purchase-var'])  | 
                                                        |
| 283 | 283 | && $_POST['give-purchase-var'] == 'needs-to-register'  | 
                                                        
| 284 | - && empty( $_POST['give_user_login'] )  | 
                                                        |
| 284 | + && empty($_POST['give_user_login'])  | 
                                                        |
| 285 | 285 |  	) { | 
                                                        
| 286 | - unset( $_POST['give-purchase-var'] );  | 
                                                        |
| 286 | + unset($_POST['give-purchase-var']);  | 
                                                        |
| 287 | 287 | }  | 
                                                        
| 288 | 288 | |
| 289 | -	if ( is_user_logged_in() ) { | 
                                                        |
| 289 | +	if (is_user_logged_in()) { | 
                                                        |
| 290 | 290 | // Collect logged in user data  | 
                                                        
| 291 | 291 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();  | 
                                                        
| 292 | -	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { | 
                                                        |
| 292 | +	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { | 
                                                        |
| 293 | 293 | // Set new user registration as required  | 
                                                        
| 294 | 294 | $valid_data['need_new_user'] = true;  | 
                                                        
| 295 | 295 | // Validate new user data  | 
                                                        
| 296 | 296 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user();  | 
                                                        
| 297 | 297 | // Check if login validation is needed  | 
                                                        
| 298 | -	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { | 
                                                        |
| 298 | +	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { | 
                                                        |
| 299 | 299 | // Set user login as required  | 
                                                        
| 300 | 300 | $valid_data['need_user_login'] = true;  | 
                                                        
| 301 | 301 | // Validate users login info  | 
                                                        
@@ -320,41 +320,41 @@ discard block  | 
                                                    ||
| 320 | 320 | */  | 
                                                        
| 321 | 321 |  function give_purchase_form_validate_gateway() { | 
                                                        
| 322 | 322 | |
| 323 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;  | 
                                                        |
| 324 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;  | 
                                                        |
| 325 | - $gateway = give_get_default_gateway( $form_id );  | 
                                                        |
| 323 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;  | 
                                                        |
| 324 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;  | 
                                                        |
| 325 | + $gateway = give_get_default_gateway($form_id);  | 
                                                        |
| 326 | 326 | |
| 327 | 327 | // Check if a gateway value is present  | 
                                                        
| 328 | -	if ( ! empty( $_REQUEST['give-gateway'] ) ) { | 
                                                        |
| 328 | +	if ( ! empty($_REQUEST['give-gateway'])) { | 
                                                        |
| 329 | 329 | |
| 330 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] );  | 
                                                        |
| 330 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']);  | 
                                                        |
| 331 | 331 | |
| 332 | 332 | // Is amount being donated in LIVE mode 0.00? If so, error:  | 
                                                        
| 333 | -		if ( $amount == 0 && ! give_is_test_mode() ) { | 
                                                        |
| 333 | +		if ($amount == 0 && ! give_is_test_mode()) { | 
                                                        |
| 334 | 334 | |
| 335 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );  | 
                                                        |
| 335 | +			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); | 
                                                        |
| 336 | 336 | |
| 337 | 337 | } //Check for a minimum custom amount  | 
                                                        
| 338 | -		elseif ( ! give_verify_minimum_price() ) { | 
                                                        |
| 338 | +		elseif ( ! give_verify_minimum_price()) { | 
                                                        |
| 339 | 339 | // translators: %s: minimum donation amount.  | 
                                                        
| 340 | 340 | give_set_error(  | 
                                                        
| 341 | 341 | 'invalid_donation_minimum',  | 
                                                        
| 342 | 342 | sprintf(  | 
                                                        
| 343 | 343 | /* translators: %s: minimum donation amount */  | 
                                                        
| 344 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),  | 
                                                        |
| 345 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )  | 
                                                        |
| 344 | +					esc_html__('This form has a minimum donation amount of %s.', 'give'), | 
                                                        |
| 345 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))  | 
                                                        |
| 346 | 346 | )  | 
                                                        
| 347 | 347 | );  | 
                                                        
| 348 | 348 | |
| 349 | 349 | } //Is this test mode zero donation? Let it through but set to manual gateway.  | 
                                                        
| 350 | -		elseif ( $amount == 0 && give_is_test_mode() ) { | 
                                                        |
| 350 | +		elseif ($amount == 0 && give_is_test_mode()) { | 
                                                        |
| 351 | 351 | |
| 352 | 352 | $gateway = 'manual';  | 
                                                        
| 353 | 353 | |
| 354 | 354 | } //Check if this gateway is active.  | 
                                                        
| 355 | -		elseif ( ! give_is_gateway_active( $gateway ) ) { | 
                                                        |
| 355 | +		elseif ( ! give_is_gateway_active($gateway)) { | 
                                                        |
| 356 | 356 | |
| 357 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );  | 
                                                        |
| 357 | +			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); | 
                                                        |
| 358 | 358 | |
| 359 | 359 | }  | 
                                                        
| 360 | 360 | }  | 
                                                        
@@ -372,23 +372,23 @@ discard block  | 
                                                    ||
| 372 | 372 | */  | 
                                                        
| 373 | 373 |  function give_verify_minimum_price() { | 
                                                        
| 374 | 374 | |
| 375 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] );  | 
                                                        |
| 376 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;  | 
                                                        |
| 377 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;  | 
                                                        |
| 378 | - $variable_prices = give_has_variable_prices( $form_id );  | 
                                                        |
| 375 | + $amount = give_sanitize_amount($_REQUEST['give-amount']);  | 
                                                        |
| 376 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;  | 
                                                        |
| 377 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;  | 
                                                        |
| 378 | + $variable_prices = give_has_variable_prices($form_id);  | 
                                                        |
| 379 | 379 | |
| 380 | -	if ( $variable_prices && ! empty( $price_id ) ) { | 
                                                        |
| 380 | +	if ($variable_prices && ! empty($price_id)) { | 
                                                        |
| 381 | 381 | |
| 382 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id );  | 
                                                        |
| 382 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id);  | 
                                                        |
| 383 | 383 | |
| 384 | -		if ( $price_level_amount == $amount ) { | 
                                                        |
| 384 | +		if ($price_level_amount == $amount) { | 
                                                        |
| 385 | 385 | return true;  | 
                                                        
| 386 | 386 | }  | 
                                                        
| 387 | 387 | }  | 
                                                        
| 388 | 388 | |
| 389 | - $minimum = give_get_form_minimum_price( $form_id );  | 
                                                        |
| 389 | + $minimum = give_get_form_minimum_price($form_id);  | 
                                                        |
| 390 | 390 | |
| 391 | -	if ( $minimum > $amount ) { | 
                                                        |
| 391 | +	if ($minimum > $amount) { | 
                                                        |
| 392 | 392 | return false;  | 
                                                        
| 393 | 393 | }  | 
                                                        
| 394 | 394 | |
@@ -404,9 +404,9 @@ discard block  | 
                                                    ||
| 404 | 404 | */  | 
                                                        
| 405 | 405 |  function give_purchase_form_validate_agree_to_terms() { | 
                                                        
| 406 | 406 | // Validate agree to terms.  | 
                                                        
| 407 | -	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { | 
                                                        |
| 407 | +	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { | 
                                                        |
| 408 | 408 | // User did not agree.  | 
                                                        
| 409 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) );  | 
                                                        |
| 409 | +		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); | 
                                                        |
| 410 | 410 | }  | 
                                                        
| 411 | 411 | }  | 
                                                        
| 412 | 412 | |
@@ -420,43 +420,43 @@ discard block  | 
                                                    ||
| 420 | 420 | *  | 
                                                        
| 421 | 421 | * @return array  | 
                                                        
| 422 | 422 | */  | 
                                                        
| 423 | -function give_get_required_fields( $form_id ) { | 
                                                        |
| 423 | +function give_get_required_fields($form_id) { | 
                                                        |
| 424 | 424 | |
| 425 | - $payment_mode = give_get_chosen_gateway( $form_id );  | 
                                                        |
| 425 | + $payment_mode = give_get_chosen_gateway($form_id);  | 
                                                        |
| 426 | 426 | |
| 427 | 427 | $required_fields = array(  | 
                                                        
| 428 | 428 | 'give_email' => array(  | 
                                                        
| 429 | 429 | 'error_id' => 'invalid_email',  | 
                                                        
| 430 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ),  | 
                                                        |
| 430 | +			'error_message' => esc_html__('Please enter a valid email address.', 'give'), | 
                                                        |
| 431 | 431 | ),  | 
                                                        
| 432 | 432 | 'give_first' => array(  | 
                                                        
| 433 | 433 | 'error_id' => 'invalid_first_name',  | 
                                                        
| 434 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ),  | 
                                                        |
| 434 | +			'error_message' => esc_html__('Please enter your first name.', 'give'), | 
                                                        |
| 435 | 435 | ),  | 
                                                        
| 436 | 436 | );  | 
                                                        
| 437 | 437 | |
| 438 | - $require_address = give_require_billing_address( $payment_mode );  | 
                                                        |
| 438 | + $require_address = give_require_billing_address($payment_mode);  | 
                                                        |
| 439 | 439 | |
| 440 | -	if ( $require_address ) { | 
                                                        |
| 441 | - $required_fields['card_address'] = array(  | 
                                                        |
| 440 | +	if ($require_address) { | 
                                                        |
| 441 | + $required_fields['card_address'] = array(  | 
                                                        |
| 442 | 442 | 'error_id' => 'invalid_card_address',  | 
                                                        
| 443 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ),  | 
                                                        |
| 443 | +			'error_message' => esc_html__('Please enter your primary billing address.', 'give'), | 
                                                        |
| 444 | 444 | );  | 
                                                        
| 445 | - $required_fields['card_zip'] = array(  | 
                                                        |
| 445 | + $required_fields['card_zip'] = array(  | 
                                                        |
| 446 | 446 | 'error_id' => 'invalid_zip_code',  | 
                                                        
| 447 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ),  | 
                                                        |
| 447 | +			'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), | 
                                                        |
| 448 | 448 | );  | 
                                                        
| 449 | - $required_fields['card_city'] = array(  | 
                                                        |
| 449 | + $required_fields['card_city'] = array(  | 
                                                        |
| 450 | 450 | 'error_id' => 'invalid_city',  | 
                                                        
| 451 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ),  | 
                                                        |
| 451 | +			'error_message' => esc_html__('Please enter your billing city.', 'give'), | 
                                                        |
| 452 | 452 | );  | 
                                                        
| 453 | 453 | $required_fields['billing_country'] = array(  | 
                                                        
| 454 | 454 | 'error_id' => 'invalid_country',  | 
                                                        
| 455 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ),  | 
                                                        |
| 455 | +			'error_message' => esc_html__('Please select your billing country.', 'give'), | 
                                                        |
| 456 | 456 | );  | 
                                                        
| 457 | - $required_fields['card_state'] = array(  | 
                                                        |
| 457 | + $required_fields['card_state'] = array(  | 
                                                        |
| 458 | 458 | 'error_id' => 'invalid_state',  | 
                                                        
| 459 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ),  | 
                                                        |
| 459 | +			'error_message' => esc_html__('Please enter billing state / province.', 'give'), | 
                                                        |
| 460 | 460 | );  | 
                                                        
| 461 | 461 | }  | 
                                                        
| 462 | 462 | |
@@ -465,7 +465,7 @@ discard block  | 
                                                    ||
| 465 | 465 | *  | 
                                                        
| 466 | 466 | * @since 1.7  | 
                                                        
| 467 | 467 | */  | 
                                                        
| 468 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );  | 
                                                        |
| 468 | +	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); | 
                                                        |
| 469 | 469 | |
| 470 | 470 | return $required_fields;  | 
                                                        
| 471 | 471 | |
@@ -480,16 +480,16 @@ discard block  | 
                                                    ||
| 480 | 480 | *  | 
                                                        
| 481 | 481 | * @return mixed|void  | 
                                                        
| 482 | 482 | */  | 
                                                        
| 483 | -function give_require_billing_address( $payment_mode ) { | 
                                                        |
| 483 | +function give_require_billing_address($payment_mode) { | 
                                                        |
| 484 | 484 | |
| 485 | 485 | $return = false;  | 
                                                        
| 486 | 486 | |
| 487 | -	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { | 
                                                        |
| 487 | +	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { | 
                                                        |
| 488 | 488 | $return = true;  | 
                                                        
| 489 | 489 | }  | 
                                                        
| 490 | 490 | |
| 491 | 491 | // Let payment gateways and other extensions determine if address fields should be required.  | 
                                                        
| 492 | - return apply_filters( 'give_require_billing_address', $return );  | 
                                                        |
| 492 | +	return apply_filters('give_require_billing_address', $return); | 
                                                        |
| 493 | 493 | |
| 494 | 494 | }  | 
                                                        
| 495 | 495 | |
@@ -503,42 +503,42 @@ discard block  | 
                                                    ||
| 503 | 503 |  function give_purchase_form_validate_logged_in_user() { | 
                                                        
| 504 | 504 | global $user_ID;  | 
                                                        
| 505 | 505 | |
| 506 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';  | 
                                                        |
| 506 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';  | 
                                                        |
| 507 | 507 | |
| 508 | 508 | // Start empty array to collect valid user data.  | 
                                                        
| 509 | 509 | $valid_user_data = array(  | 
                                                        
| 510 | 510 | // Assume there will be errors.  | 
                                                        
| 511 | - 'user_id' => - 1,  | 
                                                        |
| 511 | + 'user_id' => -1,  | 
                                                        |
| 512 | 512 | );  | 
                                                        
| 513 | 513 | |
| 514 | 514 | // Verify there is a user_ID.  | 
                                                        
| 515 | -	if ( $user_ID > 0 ) { | 
                                                        |
| 515 | +	if ($user_ID > 0) { | 
                                                        |
| 516 | 516 | // Get the logged in user data.  | 
                                                        
| 517 | - $user_data = get_userdata( $user_ID );  | 
                                                        |
| 517 | + $user_data = get_userdata($user_ID);  | 
                                                        |
| 518 | 518 | |
| 519 | 519 | // Loop through required fields and show error messages.  | 
                                                        
| 520 | -		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { | 
                                                        |
| 521 | -			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { | 
                                                        |
| 522 | - give_set_error( $value['error_id'], $value['error_message'] );  | 
                                                        |
| 520 | +		foreach (give_get_required_fields($form_id) as $field_name => $value) { | 
                                                        |
| 521 | +			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { | 
                                                        |
| 522 | + give_set_error($value['error_id'], $value['error_message']);  | 
                                                        |
| 523 | 523 | }  | 
                                                        
| 524 | 524 | }  | 
                                                        
| 525 | 525 | |
| 526 | 526 | // Verify data.  | 
                                                        
| 527 | -		if ( $user_data ) { | 
                                                        |
| 527 | +		if ($user_data) { | 
                                                        |
| 528 | 528 | // Collected logged in user data.  | 
                                                        
| 529 | 529 | $valid_user_data = array(  | 
                                                        
| 530 | 530 | 'user_id' => $user_ID,  | 
                                                        
| 531 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,  | 
                                                        |
| 532 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,  | 
                                                        |
| 533 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,  | 
                                                        |
| 531 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,  | 
                                                        |
| 532 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,  | 
                                                        |
| 533 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,  | 
                                                        |
| 534 | 534 | );  | 
                                                        
| 535 | 535 | |
| 536 | -			if ( ! is_email( $valid_user_data['user_email'] ) ) { | 
                                                        |
| 537 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );  | 
                                                        |
| 536 | +			if ( ! is_email($valid_user_data['user_email'])) { | 
                                                        |
| 537 | +				give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); | 
                                                        |
| 538 | 538 | }  | 
                                                        
| 539 | 539 |  		} else { | 
                                                        
| 540 | 540 | // Set invalid user error.  | 
                                                        
| 541 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );  | 
                                                        |
| 541 | +			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); | 
                                                        |
| 542 | 542 | }  | 
                                                        
| 543 | 543 | }  | 
                                                        
| 544 | 544 | |
@@ -557,7 +557,7 @@ discard block  | 
                                                    ||
| 557 | 557 | // Default user data.  | 
                                                        
| 558 | 558 | $default_user_data = array(  | 
                                                        
| 559 | 559 | 'give-form-id' => '',  | 
                                                        
| 560 | - 'user_id' => - 1, // Assume there will be errors.  | 
                                                        |
| 560 | + 'user_id' => -1, // Assume there will be errors.  | 
                                                        |
| 561 | 561 | 'user_first' => '',  | 
                                                        
| 562 | 562 | 'user_last' => '',  | 
                                                        
| 563 | 563 | 'give_user_login' => false,  | 
                                                        
@@ -567,14 +567,14 @@ discard block  | 
                                                    ||
| 567 | 567 | );  | 
                                                        
| 568 | 568 | |
| 569 | 569 | // Get user data.  | 
                                                        
| 570 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );  | 
                                                        |
| 570 | +	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); | 
                                                        |
| 571 | 571 | $registering_new_user = false;  | 
                                                        
| 572 | - $form_id = absint( $user_data['give-form-id'] );  | 
                                                        |
| 572 | + $form_id = absint($user_data['give-form-id']);  | 
                                                        |
| 573 | 573 | |
| 574 | 574 | // Start an empty array to collect valid user data.  | 
                                                        
| 575 | 575 | $valid_user_data = array(  | 
                                                        
| 576 | 576 | // Assume there will be errors.  | 
                                                        
| 577 | - 'user_id' => - 1,  | 
                                                        |
| 577 | + 'user_id' => -1,  | 
                                                        |
| 578 | 578 | |
| 579 | 579 | // Get first name.  | 
                                                        
| 580 | 580 | 'user_first' => $user_data['give_first'],  | 
                                                        
@@ -584,25 +584,25 @@ discard block  | 
                                                    ||
| 584 | 584 | );  | 
                                                        
| 585 | 585 | |
| 586 | 586 | // Loop through required fields and show error messages.  | 
                                                        
| 587 | -	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { | 
                                                        |
| 588 | -		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { | 
                                                        |
| 589 | - give_set_error( $value['error_id'], $value['error_message'] );  | 
                                                        |
| 587 | +	foreach (give_get_required_fields($form_id) as $field_name => $value) { | 
                                                        |
| 588 | +		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { | 
                                                        |
| 589 | + give_set_error($value['error_id'], $value['error_message']);  | 
                                                        |
| 590 | 590 | }  | 
                                                        
| 591 | 591 | }  | 
                                                        
| 592 | 592 | |
| 593 | 593 | // Check if we have an username to register.  | 
                                                        
| 594 | -	if ( give_validate_username( $user_data['give_user_login'] ) ) { | 
                                                        |
| 594 | +	if (give_validate_username($user_data['give_user_login'])) { | 
                                                        |
| 595 | 595 | $registering_new_user = true;  | 
                                                        
| 596 | 596 | $valid_user_data['user_login'] = $user_data['give_user_login'];  | 
                                                        
| 597 | 597 | }  | 
                                                        
| 598 | 598 | |
| 599 | 599 | // Check if we have an email to verify.  | 
                                                        
| 600 | -	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { | 
                                                        |
| 600 | +	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { | 
                                                        |
| 601 | 601 | $valid_user_data['user_email'] = $user_data['give_email'];  | 
                                                        
| 602 | 602 | }  | 
                                                        
| 603 | 603 | |
| 604 | 604 | // Check password.  | 
                                                        
| 605 | -	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { | 
                                                        |
| 605 | +	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { | 
                                                        |
| 606 | 606 | // All is good to go.  | 
                                                        
| 607 | 607 | $valid_user_data['user_pass'] = $user_data['give_user_pass'];  | 
                                                        
| 608 | 608 | }  | 
                                                        
@@ -622,36 +622,36 @@ discard block  | 
                                                    ||
| 622 | 622 | // Start an array to collect valid user data.  | 
                                                        
| 623 | 623 | $valid_user_data = array(  | 
                                                        
| 624 | 624 | // Assume there will be errors  | 
                                                        
| 625 | - 'user_id' => - 1,  | 
                                                        |
| 625 | + 'user_id' => -1,  | 
                                                        |
| 626 | 626 | );  | 
                                                        
| 627 | 627 | |
| 628 | 628 | // Username.  | 
                                                        
| 629 | -	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { | 
                                                        |
| 630 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );  | 
                                                        |
| 629 | +	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { | 
                                                        |
| 630 | +		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); | 
                                                        |
| 631 | 631 | |
| 632 | 632 | return $valid_user_data;  | 
                                                        
| 633 | 633 | }  | 
                                                        
| 634 | 634 | |
| 635 | 635 | // Get the user by login.  | 
                                                        
| 636 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );  | 
                                                        |
| 636 | +	$user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); | 
                                                        |
| 637 | 637 | |
| 638 | 638 | // Check if user exists.  | 
                                                        
| 639 | -	if ( $user_data ) { | 
                                                        |
| 639 | +	if ($user_data) { | 
                                                        |
| 640 | 640 | // Get password.  | 
                                                        
| 641 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;  | 
                                                        |
| 641 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;  | 
                                                        |
| 642 | 642 | |
| 643 | 643 | // Check user_pass.  | 
                                                        
| 644 | -		if ( $user_pass ) { | 
                                                        |
| 644 | +		if ($user_pass) { | 
                                                        |
| 645 | 645 | // Check if password is valid.  | 
                                                        
| 646 | -			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { | 
                                                        |
| 646 | +			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { | 
                                                        |
| 647 | 647 | // Incorrect password.  | 
                                                        
| 648 | 648 | give_set_error(  | 
                                                        
| 649 | 649 | 'password_incorrect',  | 
                                                        
| 650 | 650 | sprintf(  | 
                                                        
| 651 | 651 | '%1$s <a href="%2$s">%3$s</a>',  | 
                                                        
| 652 | - esc_html__( 'The password you entered is incorrect.', 'give' ),  | 
                                                        |
| 653 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),  | 
                                                        |
| 654 | - esc_html__( 'Reset Password', 'give' )  | 
                                                        |
| 652 | +						esc_html__('The password you entered is incorrect.', 'give'), | 
                                                        |
| 653 | +						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), | 
                                                        |
| 654 | +						esc_html__('Reset Password', 'give') | 
                                                        |
| 655 | 655 | )  | 
                                                        
| 656 | 656 | );  | 
                                                        
| 657 | 657 | // All is correct.  | 
                                                        
@@ -668,11 +668,11 @@ discard block  | 
                                                    ||
| 668 | 668 | }  | 
                                                        
| 669 | 669 |  		} else { | 
                                                        
| 670 | 670 | // Empty password.  | 
                                                        
| 671 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );  | 
                                                        |
| 671 | +			give_set_error('password_empty', esc_html__('Enter a password.', 'give')); | 
                                                        |
| 672 | 672 | }  | 
                                                        
| 673 | 673 |  	} else { | 
                                                        
| 674 | 674 | // No username.  | 
                                                        
| 675 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );  | 
                                                        |
| 675 | +		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); | 
                                                        |
| 676 | 676 | }  | 
                                                        
| 677 | 677 | |
| 678 | 678 | return $valid_user_data;  | 
                                                        
@@ -687,7 +687,7 @@ discard block  | 
                                                    ||
| 687 | 687 | */  | 
                                                        
| 688 | 688 |  function give_purchase_form_validate_guest_user() { | 
                                                        
| 689 | 689 | |
| 690 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';  | 
                                                        |
| 690 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';  | 
                                                        |
| 691 | 691 | |
| 692 | 692 | // Start an array to collect valid user data.  | 
                                                        
| 693 | 693 | $valid_user_data = array(  | 
                                                        
@@ -696,38 +696,38 @@ discard block  | 
                                                    ||
| 696 | 696 | );  | 
                                                        
| 697 | 697 | |
| 698 | 698 | // Show error message if user must be logged in.  | 
                                                        
| 699 | -	if ( give_logged_in_only( $form_id ) ) { | 
                                                        |
| 700 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );  | 
                                                        |
| 699 | +	if (give_logged_in_only($form_id)) { | 
                                                        |
| 700 | +		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); | 
                                                        |
| 701 | 701 | }  | 
                                                        
| 702 | 702 | |
| 703 | 703 | // Get the guest email.  | 
                                                        
| 704 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;  | 
                                                        |
| 704 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;  | 
                                                        |
| 705 | 705 | |
| 706 | 706 | // Check email.  | 
                                                        
| 707 | -	if ( $guest_email && strlen( $guest_email ) > 0 ) { | 
                                                        |
| 707 | +	if ($guest_email && strlen($guest_email) > 0) { | 
                                                        |
| 708 | 708 | // Validate email.  | 
                                                        
| 709 | -		if ( ! is_email( $guest_email ) ) { | 
                                                        |
| 709 | +		if ( ! is_email($guest_email)) { | 
                                                        |
| 710 | 710 | // Invalid email.  | 
                                                        
| 711 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );  | 
                                                        |
| 711 | +			give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); | 
                                                        |
| 712 | 712 |  		} else { | 
                                                        
| 713 | 713 | // All is good to go.  | 
                                                        
| 714 | 714 | $valid_user_data['user_email'] = $guest_email;  | 
                                                        
| 715 | 715 | |
| 716 | 716 | // Get user_id from donor if exist.  | 
                                                        
| 717 | - $donor = new Give_Customer( $guest_email );  | 
                                                        |
| 718 | -			if ( $donor->id && $donor->user_id ) { | 
                                                        |
| 717 | + $donor = new Give_Customer($guest_email);  | 
                                                        |
| 718 | +			if ($donor->id && $donor->user_id) { | 
                                                        |
| 719 | 719 | $valid_user_data['user_id'] = $donor->user_id;  | 
                                                        
| 720 | 720 | }  | 
                                                        
| 721 | 721 | }  | 
                                                        
| 722 | 722 |  	} else { | 
                                                        
| 723 | 723 | // No email.  | 
                                                        
| 724 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );  | 
                                                        |
| 724 | +		give_set_error('email_empty', esc_html__('Enter an email.', 'give')); | 
                                                        |
| 725 | 725 | }  | 
                                                        
| 726 | 726 | |
| 727 | 727 | // Loop through required fields and show error messages.  | 
                                                        
| 728 | -	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { | 
                                                        |
| 729 | -		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { | 
                                                        |
| 730 | - give_set_error( $value['error_id'], $value['error_message'] );  | 
                                                        |
| 728 | +	foreach (give_get_required_fields($form_id) as $field_name => $value) { | 
                                                        |
| 729 | +		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { | 
                                                        |
| 730 | + give_set_error($value['error_id'], $value['error_message']);  | 
                                                        |
| 731 | 731 | }  | 
                                                        
| 732 | 732 | }  | 
                                                        
| 733 | 733 | |
@@ -743,36 +743,36 @@ discard block  | 
                                                    ||
| 743 | 743 | * @since 1.0  | 
                                                        
| 744 | 744 | * @return integer  | 
                                                        
| 745 | 745 | */  | 
                                                        
| 746 | -function give_register_and_login_new_user( $user_data = array() ) { | 
                                                        |
| 746 | +function give_register_and_login_new_user($user_data = array()) { | 
                                                        |
| 747 | 747 | // Verify the array.  | 
                                                        
| 748 | -	if ( empty( $user_data ) ) { | 
                                                        |
| 749 | - return - 1;  | 
                                                        |
| 748 | +	if (empty($user_data)) { | 
                                                        |
| 749 | + return -1;  | 
                                                        |
| 750 | 750 | }  | 
                                                        
| 751 | 751 | |
| 752 | -	if ( give_get_errors() ) { | 
                                                        |
| 753 | - return - 1;  | 
                                                        |
| 752 | +	if (give_get_errors()) { | 
                                                        |
| 753 | + return -1;  | 
                                                        |
| 754 | 754 | }  | 
                                                        
| 755 | 755 | |
| 756 | - $user_args = apply_filters( 'give_insert_user_args', array(  | 
                                                        |
| 757 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',  | 
                                                        |
| 758 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',  | 
                                                        |
| 759 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',  | 
                                                        |
| 760 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',  | 
                                                        |
| 761 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',  | 
                                                        |
| 762 | - 'user_registered' => date( 'Y-m-d H:i:s' ),  | 
                                                        |
| 763 | - 'role' => get_option( 'default_role' ),  | 
                                                        |
| 764 | - ), $user_data );  | 
                                                        |
| 756 | +	$user_args = apply_filters('give_insert_user_args', array( | 
                                                        |
| 757 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '',  | 
                                                        |
| 758 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',  | 
                                                        |
| 759 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '',  | 
                                                        |
| 760 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '',  | 
                                                        |
| 761 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '',  | 
                                                        |
| 762 | +		'user_registered' => date('Y-m-d H:i:s'), | 
                                                        |
| 763 | +		'role'            => get_option('default_role'), | 
                                                        |
| 764 | + ), $user_data);  | 
                                                        |
| 765 | 765 | |
| 766 | 766 | // Insert new user.  | 
                                                        
| 767 | - $user_id = wp_insert_user( $user_args );  | 
                                                        |
| 767 | + $user_id = wp_insert_user($user_args);  | 
                                                        |
| 768 | 768 | |
| 769 | 769 | // Validate inserted user.  | 
                                                        
| 770 | -	if ( is_wp_error( $user_id ) ) { | 
                                                        |
| 771 | - return - 1;  | 
                                                        |
| 770 | +	if (is_wp_error($user_id)) { | 
                                                        |
| 771 | + return -1;  | 
                                                        |
| 772 | 772 | }  | 
                                                        
| 773 | 773 | |
| 774 | 774 | // Allow themes and plugins to filter the user data.  | 
                                                        
| 775 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );  | 
                                                        |
| 775 | +	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args); | 
                                                        |
| 776 | 776 | |
| 777 | 777 | /**  | 
                                                        
| 778 | 778 | * Fires after inserting user.  | 
                                                        
@@ -782,10 +782,10 @@ discard block  | 
                                                    ||
| 782 | 782 | * @param int $user_id User id.  | 
                                                        
| 783 | 783 | * @param array $user_data Array containing user data.  | 
                                                        
| 784 | 784 | */  | 
                                                        
| 785 | - do_action( 'give_insert_user', $user_id, $user_data );  | 
                                                        |
| 785 | +	do_action('give_insert_user', $user_id, $user_data); | 
                                                        |
| 786 | 786 | |
| 787 | 787 | // Login new user.  | 
                                                        
| 788 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );  | 
                                                        |
| 788 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);  | 
                                                        |
| 789 | 789 | |
| 790 | 790 | // Return user id.  | 
                                                        
| 791 | 791 | return $user_id;  | 
                                                        
@@ -800,27 +800,27 @@ discard block  | 
                                                    ||
| 800 | 800 | * @since 1.0  | 
                                                        
| 801 | 801 | * @return array  | 
                                                        
| 802 | 802 | */  | 
                                                        
| 803 | -function give_get_purchase_form_user( $valid_data = array() ) { | 
                                                        |
| 803 | +function give_get_purchase_form_user($valid_data = array()) { | 
                                                        |
| 804 | 804 | |
| 805 | 805 | // Initialize user.  | 
                                                        
| 806 | 806 | $user = false;  | 
                                                        
| 807 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;  | 
                                                        |
| 807 | +	$is_ajax = defined('DOING_AJAX') && DOING_AJAX; | 
                                                        |
| 808 | 808 | |
| 809 | -	if ( $is_ajax ) { | 
                                                        |
| 809 | +	if ($is_ajax) { | 
                                                        |
| 810 | 810 | // Do not create or login the user during the ajax submission (check for errors only).  | 
                                                        
| 811 | 811 | return true;  | 
                                                        
| 812 | -	} elseif ( is_user_logged_in() ) { | 
                                                        |
| 812 | +	} elseif (is_user_logged_in()) { | 
                                                        |
| 813 | 813 | // Set the valid user as the logged in collected data.  | 
                                                        
| 814 | 814 | $user = $valid_data['logged_in_user'];  | 
                                                        
| 815 | -	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { | 
                                                        |
| 815 | +	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { | 
                                                        |
| 816 | 816 | // New user registration.  | 
                                                        
| 817 | -		if ( $valid_data['need_new_user'] === true ) { | 
                                                        |
| 817 | +		if ($valid_data['need_new_user'] === true) { | 
                                                        |
| 818 | 818 | // Set user.  | 
                                                        
| 819 | 819 | $user = $valid_data['new_user_data'];  | 
                                                        
| 820 | 820 | // Register and login new user.  | 
                                                        
| 821 | - $user['user_id'] = give_register_and_login_new_user( $user );  | 
                                                        |
| 821 | + $user['user_id'] = give_register_and_login_new_user($user);  | 
                                                        |
| 822 | 822 | // User login  | 
                                                        
| 823 | -		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { | 
                                                        |
| 823 | +		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { | 
                                                        |
| 824 | 824 | |
| 825 | 825 | /*  | 
                                                        
| 826 | 826 | * The login form is now processed in the give_process_purchase_login() function.  | 
                                                        
@@ -833,48 +833,48 @@ discard block  | 
                                                    ||
| 833 | 833 | // Set user.  | 
                                                        
| 834 | 834 | $user = $valid_data['login_user_data'];  | 
                                                        
| 835 | 835 | // Login user.  | 
                                                        
| 836 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );  | 
                                                        |
| 836 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);  | 
                                                        |
| 837 | 837 | }  | 
                                                        
| 838 | 838 | }  | 
                                                        
| 839 | 839 | |
| 840 | 840 | // Check guest checkout.  | 
                                                        
| 841 | -	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { | 
                                                        |
| 841 | +	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { | 
                                                        |
| 842 | 842 | // Set user  | 
                                                        
| 843 | 843 | $user = $valid_data['guest_user_data'];  | 
                                                        
| 844 | 844 | }  | 
                                                        
| 845 | 845 | |
| 846 | 846 | // Verify we have an user.  | 
                                                        
| 847 | -	if ( false === $user || empty( $user ) ) { | 
                                                        |
| 847 | +	if (false === $user || empty($user)) { | 
                                                        |
| 848 | 848 | // Return false.  | 
                                                        
| 849 | 849 | return false;  | 
                                                        
| 850 | 850 | }  | 
                                                        
| 851 | 851 | |
| 852 | 852 | // Get user first name.  | 
                                                        
| 853 | -	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { | 
                                                        |
| 854 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';  | 
                                                        |
| 853 | +	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { | 
                                                        |
| 854 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';  | 
                                                        |
| 855 | 855 | }  | 
                                                        
| 856 | 856 | |
| 857 | 857 | // Get user last name.  | 
                                                        
| 858 | -	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { | 
                                                        |
| 859 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';  | 
                                                        |
| 858 | +	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { | 
                                                        |
| 859 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';  | 
                                                        |
| 860 | 860 | }  | 
                                                        
| 861 | 861 | |
| 862 | 862 | // Get the user's billing address details.  | 
                                                        
| 863 | 863 | $user['address'] = array();  | 
                                                        
| 864 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;  | 
                                                        |
| 865 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;  | 
                                                        |
| 866 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;  | 
                                                        |
| 867 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;  | 
                                                        |
| 868 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;  | 
                                                        |
| 869 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;  | 
                                                        |
| 870 | -  | 
                                                        |
| 871 | -	if ( empty( $user['address']['country'] ) ) { | 
                                                        |
| 864 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;  | 
                                                        |
| 865 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;  | 
                                                        |
| 866 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;  | 
                                                        |
| 867 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;  | 
                                                        |
| 868 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;  | 
                                                        |
| 869 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;  | 
                                                        |
| 870 | +  | 
                                                        |
| 871 | +	if (empty($user['address']['country'])) { | 
                                                        |
| 872 | 872 | $user['address'] = false;  | 
                                                        
| 873 | 873 | } // Country will always be set if address fields are present.  | 
                                                        
| 874 | 874 | |
| 875 | -	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { | 
                                                        |
| 875 | +	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { | 
                                                        |
| 876 | 876 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases.  | 
                                                        
| 877 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );  | 
                                                        |
| 877 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']);  | 
                                                        |
| 878 | 878 | }  | 
                                                        
| 879 | 879 | |
| 880 | 880 | // Return valid user.  | 
                                                        
@@ -893,16 +893,16 @@ discard block  | 
                                                    ||
| 893 | 893 | $card_data = give_get_purchase_cc_info();  | 
                                                        
| 894 | 894 | |
| 895 | 895 | // Validate the card zip.  | 
                                                        
| 896 | -	if ( ! empty( $card_data['card_zip'] ) ) { | 
                                                        |
| 897 | -		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { | 
                                                        |
| 898 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );  | 
                                                        |
| 896 | +	if ( ! empty($card_data['card_zip'])) { | 
                                                        |
| 897 | +		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { | 
                                                        |
| 898 | +			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); | 
                                                        |
| 899 | 899 | }  | 
                                                        
| 900 | 900 | }  | 
                                                        
| 901 | 901 | |
| 902 | 902 | // Ensure no spaces.  | 
                                                        
| 903 | -	if ( ! empty( $card_data['card_number'] ) ) { | 
                                                        |
| 904 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs  | 
                                                        |
| 905 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces  | 
                                                        |
| 903 | +	if ( ! empty($card_data['card_number'])) { | 
                                                        |
| 904 | +		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs | 
                                                        |
| 905 | +		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces | 
                                                        |
| 906 | 906 | }  | 
                                                        
| 907 | 907 | |
| 908 | 908 | // This should validate card numbers at some point too.  | 
                                                        
@@ -918,17 +918,17 @@ discard block  | 
                                                    ||
| 918 | 918 | */  | 
                                                        
| 919 | 919 |  function give_get_purchase_cc_info() { | 
                                                        
| 920 | 920 | $cc_info = array();  | 
                                                        
| 921 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';  | 
                                                        |
| 922 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';  | 
                                                        |
| 923 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';  | 
                                                        |
| 924 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';  | 
                                                        |
| 925 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';  | 
                                                        |
| 926 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';  | 
                                                        |
| 927 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';  | 
                                                        |
| 928 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';  | 
                                                        |
| 929 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';  | 
                                                        |
| 930 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';  | 
                                                        |
| 931 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';  | 
                                                        |
| 921 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';  | 
                                                        |
| 922 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';  | 
                                                        |
| 923 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';  | 
                                                        |
| 924 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';  | 
                                                        |
| 925 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';  | 
                                                        |
| 926 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';  | 
                                                        |
| 927 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';  | 
                                                        |
| 928 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';  | 
                                                        |
| 929 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';  | 
                                                        |
| 930 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';  | 
                                                        |
| 931 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';  | 
                                                        |
| 932 | 932 | |
| 933 | 933 | // Return cc info  | 
                                                        
| 934 | 934 | return $cc_info;  | 
                                                        
@@ -944,14 +944,14 @@ discard block  | 
                                                    ||
| 944 | 944 | *  | 
                                                        
| 945 | 945 | * @return bool|mixed|void  | 
                                                        
| 946 | 946 | */  | 
                                                        
| 947 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { | 
                                                        |
| 947 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { | 
                                                        |
| 948 | 948 | $ret = false;  | 
                                                        
| 949 | 949 | |
| 950 | -	if ( empty( $zip ) || empty( $country_code ) ) { | 
                                                        |
| 950 | +	if (empty($zip) || empty($country_code)) { | 
                                                        |
| 951 | 951 | return $ret;  | 
                                                        
| 952 | 952 | }  | 
                                                        
| 953 | 953 | |
| 954 | - $country_code = strtoupper( $country_code );  | 
                                                        |
| 954 | + $country_code = strtoupper($country_code);  | 
                                                        |
| 955 | 955 | |
| 956 | 956 | $zip_regex = array(  | 
                                                        
| 957 | 957 |  		'AD' => 'AD\d{3}', | 
                                                        
@@ -1111,11 +1111,11 @@ discard block  | 
                                                    ||
| 1111 | 1111 |  		'ZM' => '\d{5}', | 
                                                        
| 1112 | 1112 | );  | 
                                                        
| 1113 | 1113 | |
| 1114 | -	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { | 
                                                        |
| 1114 | +	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { | 
                                                        |
| 1115 | 1115 | $ret = true;  | 
                                                        
| 1116 | 1116 | }  | 
                                                        
| 1117 | 1117 | |
| 1118 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );  | 
                                                        |
| 1118 | +	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); | 
                                                        |
| 1119 | 1119 | }  | 
                                                        
| 1120 | 1120 | |
| 1121 | 1121 | |
@@ -1129,36 +1129,36 @@ discard block  | 
                                                    ||
| 1129 | 1129 | *  | 
                                                        
| 1130 | 1130 | * @return bool  | 
                                                        
| 1131 | 1131 | */  | 
                                                        
| 1132 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { | 
                                                        |
| 1132 | +function give_validate_multi_donation_form_level($valid_data, $data) { | 
                                                        |
| 1133 | 1133 | /* @var Give_Donate_Form $form */  | 
                                                        
| 1134 | - $form = new Give_Donate_Form( $data['give-form-id'] );  | 
                                                        |
| 1134 | + $form = new Give_Donate_Form($data['give-form-id']);  | 
                                                        |
| 1135 | 1135 | |
| 1136 | 1136 | $donation_level_matched = false;  | 
                                                        
| 1137 | 1137 | |
| 1138 | -	if ( $form->is_multi_type_donation_form() ) { | 
                                                        |
| 1138 | +	if ($form->is_multi_type_donation_form()) { | 
                                                        |
| 1139 | 1139 | |
| 1140 | 1140 | // Bailout.  | 
                                                        
| 1141 | -		if ( ! ( $variable_prices = $form->get_prices() ) ) { | 
                                                        |
| 1141 | +		if ( ! ($variable_prices = $form->get_prices())) { | 
                                                        |
| 1142 | 1142 | return false;  | 
                                                        
| 1143 | 1143 | }  | 
                                                        
| 1144 | 1144 | |
| 1145 | 1145 | // Sanitize donation amount.  | 
                                                        
| 1146 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] );  | 
                                                        |
| 1146 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']);  | 
                                                        |
| 1147 | 1147 | |
| 1148 | 1148 | // Get number of decimals.  | 
                                                        
| 1149 | 1149 | $default_decimals = give_get_price_decimals();  | 
                                                        
| 1150 | 1150 | |
| 1151 | -		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { | 
                                                        |
| 1151 | +		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { | 
                                                        |
| 1152 | 1152 | return true;  | 
                                                        
| 1153 | 1153 | }  | 
                                                        
| 1154 | 1154 | |
| 1155 | 1155 | // Find correct donation level from all donation levels.  | 
                                                        
| 1156 | -		foreach ( $variable_prices as $variable_price ) { | 
                                                        |
| 1156 | +		foreach ($variable_prices as $variable_price) { | 
                                                        |
| 1157 | 1157 | // Sanitize level amount.  | 
                                                        
| 1158 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );  | 
                                                        |
| 1158 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);  | 
                                                        |
| 1159 | 1159 | |
| 1160 | 1160 | // Set first match donation level ID.  | 
                                                        
| 1161 | -			if ( $data['give-amount'] === $variable_price['_give_amount'] ) { | 
                                                        |
| 1161 | +			if ($data['give-amount'] === $variable_price['_give_amount']) { | 
                                                        |
| 1162 | 1162 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id'];  | 
                                                        
| 1163 | 1163 | $donation_level_matched = true;  | 
                                                        
| 1164 | 1164 | break;  | 
                                                        
@@ -1169,19 +1169,19 @@ discard block  | 
                                                    ||
| 1169 | 1169 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any).  | 
                                                        
| 1170 | 1170 | if (  | 
                                                        
| 1171 | 1171 | ! $donation_level_matched  | 
                                                        
| 1172 | - && ( give_is_setting_enabled( get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )  | 
                                                        |
| 1172 | + && (give_is_setting_enabled(get_post_meta($data['give-form-id'], '_give_custom_amount', true)))  | 
                                                        |
| 1173 | 1173 |  		) { | 
                                                        
| 1174 | 1174 | // Sanitize custom minimum amount.  | 
                                                        
| 1175 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );  | 
                                                        |
| 1175 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);  | 
                                                        |
| 1176 | 1176 | |
| 1177 | -			if ( $data['give-amount'] >= $custom_minimum_amount ) { | 
                                                        |
| 1177 | +			if ($data['give-amount'] >= $custom_minimum_amount) { | 
                                                        |
| 1178 | 1178 | $_POST['give-price-id'] = 'custom';  | 
                                                        
| 1179 | 1179 | $donation_level_matched = true;  | 
                                                        
| 1180 | 1180 | }  | 
                                                        
| 1181 | 1181 | }  | 
                                                        
| 1182 | 1182 | }  | 
                                                        
| 1183 | 1183 | |
| 1184 | - return ( $donation_level_matched ? true : false );  | 
                                                        |
| 1184 | + return ($donation_level_matched ? true : false);  | 
                                                        |
| 1185 | 1185 | }  | 
                                                        
| 1186 | 1186 | |
| 1187 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );  | 
                                                        |
| 1187 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); | 
                                                        |