@@ -8,11 +8,11 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | // Exit if accessed directly |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -if ( ! class_exists( 'Give_License' ) ) : |
|
| 15 | +if ( ! class_exists('Give_License')) : |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Give_License Class |
@@ -38,16 +38,16 @@ discard block |
||
| 38 | 38 | * @param string $_optname |
| 39 | 39 | * @param string $_api_url |
| 40 | 40 | */ |
| 41 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) { |
|
| 41 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null) { |
|
| 42 | 42 | global $give_options; |
| 43 | 43 | |
| 44 | 44 | $this->file = $_file; |
| 45 | 45 | $this->item_name = $_item_name; |
| 46 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
| 46 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
| 47 | 47 | $this->version = $_version; |
| 48 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
| 48 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
| 49 | 49 | $this->author = $_author; |
| 50 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
| 50 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | // Setup hooks |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @return void |
| 64 | 64 | */ |
| 65 | 65 | private function includes() { |
| 66 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 66 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
| 67 | 67 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | private function hooks() { |
| 78 | 78 | |
| 79 | 79 | // Register settings |
| 80 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
| 80 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
| 81 | 81 | |
| 82 | 82 | // Activate license key on settings save |
| 83 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
| 83 | + add_action('admin_init', array($this, 'activate_license')); |
|
| 84 | 84 | |
| 85 | 85 | // Deactivate license key |
| 86 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
| 86 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
| 87 | 87 | |
| 88 | 88 | // Updater |
| 89 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
| 89 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
| 90 | 90 | |
| 91 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
| 91 | + add_action('admin_notices', array($this, 'notices')); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function auto_updater() { |
| 102 | 102 | |
| 103 | - if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) ) { |
|
| 103 | + if ('valid' !== get_option($this->item_shortname.'_license_active')) { |
|
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return array |
| 129 | 129 | */ |
| 130 | - public function settings( $settings ) { |
|
| 130 | + public function settings($settings) { |
|
| 131 | 131 | |
| 132 | 132 | $give_license_settings = array( |
| 133 | 133 | array( |
| 134 | 134 | 'name' => $this->item_name, |
| 135 | - 'id' => $this->item_shortname . '_license_key', |
|
| 135 | + 'id' => $this->item_shortname.'_license_key', |
|
| 136 | 136 | 'desc' => '', |
| 137 | 137 | 'type' => 'license_key', |
| 138 | - 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ), |
|
| 138 | + 'options' => array('is_valid_license_option' => $this->item_shortname.'_license_active'), |
|
| 139 | 139 | 'size' => 'regular' |
| 140 | 140 | ) |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - return array_merge( $settings, $give_license_settings ); |
|
| 143 | + return array_merge($settings, $give_license_settings); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -152,18 +152,18 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return array |
| 154 | 154 | */ |
| 155 | - public function license_settings_content( $settings ) { |
|
| 155 | + public function license_settings_content($settings) { |
|
| 156 | 156 | |
| 157 | 157 | $give_license_settings = array( |
| 158 | 158 | array( |
| 159 | - 'name' => esc_html( 'Add-on Licenses', 'give' ), |
|
| 159 | + 'name' => esc_html('Add-on Licenses', 'give'), |
|
| 160 | 160 | 'desc' => '<hr>', |
| 161 | 161 | 'type' => 'give_title', |
| 162 | 162 | 'id' => 'give_title' |
| 163 | 163 | ), |
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | - return array_merge( $settings, $give_license_settings ); |
|
| 166 | + return array_merge($settings, $give_license_settings); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | |
@@ -175,34 +175,34 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function activate_license() { |
| 177 | 177 | |
| 178 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 178 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 179 | 179 | return; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - foreach ( $_POST as $key => $value ) { |
|
| 183 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
| 182 | + foreach ($_POST as $key => $value) { |
|
| 183 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
| 184 | 184 | // Don't activate a key when deactivating a different key |
| 185 | 185 | return; |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
| 189 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
| 190 | 190 | |
| 191 | - wp_die( esc_html( 'Nonce verification failed.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 191 | + wp_die(esc_html('Nonce verification failed.', 'give'), esc_html('Error', 'give'), array('response' => 403)); |
|
| 192 | 192 | |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 195 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) { |
|
| 199 | + if ('valid' === get_option($this->item_shortname.'_license_active')) { |
|
| 200 | 200 | return; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
| 203 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
| 204 | 204 | |
| 205 | - if ( empty( $license ) ) { |
|
| 205 | + if (empty($license)) { |
|
| 206 | 206 | return; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $api_params = array( |
| 211 | 211 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
| 212 | 212 | 'license' => $license, |
| 213 | - 'item_name' => urlencode( $this->item_name ), |
|
| 213 | + 'item_name' => urlencode($this->item_name), |
|
| 214 | 214 | 'url' => home_url() |
| 215 | 215 | ); |
| 216 | 216 | |
@@ -225,22 +225,22 @@ discard block |
||
| 225 | 225 | ); |
| 226 | 226 | |
| 227 | 227 | // Make sure there are no errors |
| 228 | - if ( is_wp_error( $response ) ) { |
|
| 228 | + if (is_wp_error($response)) { |
|
| 229 | 229 | return; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Tell WordPress to look for updates |
| 233 | - set_site_transient( 'update_plugins', null ); |
|
| 233 | + set_site_transient('update_plugins', null); |
|
| 234 | 234 | |
| 235 | 235 | // Decode license data |
| 236 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 236 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 237 | 237 | |
| 238 | - update_option( $this->item_shortname . '_license_active', $license_data->license ); |
|
| 238 | + update_option($this->item_shortname.'_license_active', $license_data->license); |
|
| 239 | 239 | |
| 240 | - if ( ! (bool) $license_data->success ) { |
|
| 241 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
| 240 | + if ( ! (bool) $license_data->success) { |
|
| 241 | + set_transient('give_license_error', $license_data, 1000); |
|
| 242 | 242 | } else { |
| 243 | - delete_transient( 'give_license_error' ); |
|
| 243 | + delete_transient('give_license_error'); |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
@@ -253,28 +253,28 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function deactivate_license() { |
| 255 | 255 | |
| 256 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 256 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 257 | 257 | return; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
| 260 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
| 261 | 261 | |
| 262 | - wp_die( esc_html( 'Nonce verification failed.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 262 | + wp_die(esc_html('Nonce verification failed.', 'give'), esc_html('Error', 'give'), array('response' => 403)); |
|
| 263 | 263 | |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 266 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 267 | 267 | return; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Run on deactivate button press |
| 271 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
| 271 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
| 272 | 272 | |
| 273 | 273 | // Data to send to the API |
| 274 | 274 | $api_params = array( |
| 275 | 275 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
| 276 | 276 | 'license' => $this->license, |
| 277 | - 'item_name' => urlencode( $this->item_name ), |
|
| 277 | + 'item_name' => urlencode($this->item_name), |
|
| 278 | 278 | 'url' => home_url() |
| 279 | 279 | ); |
| 280 | 280 | |
@@ -290,19 +290,19 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | // Make sure there are no errors |
| 293 | - if ( is_wp_error( $response ) ) { |
|
| 293 | + if (is_wp_error($response)) { |
|
| 294 | 294 | return; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | // Decode the license data |
| 298 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 298 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 299 | 299 | |
| 300 | - delete_option( $this->item_shortname . '_license_active' ); |
|
| 300 | + delete_option($this->item_shortname.'_license_active'); |
|
| 301 | 301 | |
| 302 | - if ( ! (bool) $license_data->success ) { |
|
| 303 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
| 302 | + if ( ! (bool) $license_data->success) { |
|
| 303 | + set_transient('give_license_error', $license_data, 1000); |
|
| 304 | 304 | } else { |
| 305 | - delete_transient( 'give_license_error' ); |
|
| 305 | + delete_transient('give_license_error'); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -316,44 +316,44 @@ discard block |
||
| 316 | 316 | */ |
| 317 | 317 | public function notices() { |
| 318 | 318 | |
| 319 | - if ( ! isset( $_GET['page'] ) || 'give-settings' !== $_GET['page'] ) { |
|
| 319 | + if ( ! isset($_GET['page']) || 'give-settings' !== $_GET['page']) { |
|
| 320 | 320 | return; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( ! isset( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) { |
|
| 323 | + if ( ! isset($_GET['tab']) || 'licenses' !== $_GET['tab']) { |
|
| 324 | 324 | return; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - $license_error = get_transient( 'give_license_error' ); |
|
| 327 | + $license_error = get_transient('give_license_error'); |
|
| 328 | 328 | |
| 329 | - if ( false === $license_error ) { |
|
| 329 | + if (false === $license_error) { |
|
| 330 | 330 | return; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if ( ! empty( $license_error->error ) ) { |
|
| 333 | + if ( ! empty($license_error->error)) { |
|
| 334 | 334 | |
| 335 | - switch ( $license_error->error ) { |
|
| 335 | + switch ($license_error->error) { |
|
| 336 | 336 | |
| 337 | 337 | case 'item_name_mismatch' : |
| 338 | 338 | |
| 339 | - $message = esc_html( 'This license does not belong to the product you have entered it for.', 'give' ); |
|
| 339 | + $message = esc_html('This license does not belong to the product you have entered it for.', 'give'); |
|
| 340 | 340 | break; |
| 341 | 341 | |
| 342 | 342 | case 'no_activations_left' : |
| 343 | 343 | |
| 344 | - $message = esc_html( 'This license does not have any activations left.', 'give' ); |
|
| 344 | + $message = esc_html('This license does not have any activations left.', 'give'); |
|
| 345 | 345 | break; |
| 346 | 346 | |
| 347 | 347 | case 'expired' : |
| 348 | 348 | |
| 349 | - $message = esc_html( 'This license key is expired. Please renew it.', 'give' ); |
|
| 349 | + $message = esc_html('This license key is expired. Please renew it.', 'give'); |
|
| 350 | 350 | break; |
| 351 | 351 | |
| 352 | 352 | default : |
| 353 | 353 | |
| 354 | 354 | $message = sprintf( |
| 355 | 355 | /* translators: %s: license error */ |
| 356 | - esc_html( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'give' ), |
|
| 356 | + esc_html('There was a problem activating your license key, please try again or contact support. Error code: %s', 'give'), |
|
| 357 | 357 | $license_error->error |
| 358 | 358 | ); |
| 359 | 359 | break; |
@@ -362,15 +362,15 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if ( ! empty( $message ) ) { |
|
| 365 | + if ( ! empty($message)) { |
|
| 366 | 366 | |
| 367 | 367 | echo '<div class="error">'; |
| 368 | - echo '<p>' . $message . '</p>'; |
|
| 368 | + echo '<p>'.$message.'</p>'; |
|
| 369 | 369 | echo '</div>'; |
| 370 | 370 | |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - delete_transient( 'give_license_error' ); |
|
| 373 | + delete_transient('give_license_error'); |
|
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | 23 | function give_get_templates_dir() { |
| 24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
| 24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function give_get_templates_url() { |
| 34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
| 34 | + return GIVE_PLUGIN_URL.'templates'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -51,23 +51,23 @@ discard block |
||
| 51 | 51 | * @uses load_template() |
| 52 | 52 | * @uses get_template_part() |
| 53 | 53 | */ |
| 54 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
| 54 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
| 55 | 55 | |
| 56 | 56 | // Execute code for this part |
| 57 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 57 | + do_action('get_template_part_'.$slug, $slug, $name); |
|
| 58 | 58 | |
| 59 | 59 | // Setup possible parts |
| 60 | 60 | $templates = array(); |
| 61 | - if ( isset( $name ) ) { |
|
| 62 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 61 | + if (isset($name)) { |
|
| 62 | + $templates[] = $slug.'-'.$name.'.php'; |
|
| 63 | 63 | } |
| 64 | - $templates[] = $slug . '.php'; |
|
| 64 | + $templates[] = $slug.'.php'; |
|
| 65 | 65 | |
| 66 | 66 | // Allow template parts to be filtered |
| 67 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
| 67 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
| 68 | 68 | |
| 69 | 69 | // Return the part that is found |
| 70 | - return give_locate_template( $templates, $load, false ); |
|
| 70 | + return give_locate_template($templates, $load, false); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -88,37 +88,37 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string The template filename if one is located. |
| 90 | 90 | */ |
| 91 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
| 91 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
| 92 | 92 | // No file found yet |
| 93 | 93 | $located = false; |
| 94 | 94 | |
| 95 | 95 | // Try to find a template file |
| 96 | - foreach ( (array) $template_names as $template_name ) { |
|
| 96 | + foreach ((array) $template_names as $template_name) { |
|
| 97 | 97 | |
| 98 | 98 | // Continue if template is empty |
| 99 | - if ( empty( $template_name ) ) { |
|
| 99 | + if (empty($template_name)) { |
|
| 100 | 100 | continue; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Trim off any slashes from the template name |
| 104 | - $template_name = ltrim( $template_name, '/' ); |
|
| 104 | + $template_name = ltrim($template_name, '/'); |
|
| 105 | 105 | |
| 106 | 106 | // try locating this template file by looping through the template paths |
| 107 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
| 107 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
| 108 | 108 | |
| 109 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 110 | - $located = $template_path . $template_name; |
|
| 109 | + if (file_exists($template_path.$template_name)) { |
|
| 110 | + $located = $template_path.$template_name; |
|
| 111 | 111 | break; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( $located ) { |
|
| 115 | + if ($located) { |
|
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 121 | - load_template( $located, $require_once ); |
|
| 120 | + if ((true == $load) && ! empty($located)) { |
|
| 121 | + load_template($located, $require_once); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $located; |
@@ -135,17 +135,17 @@ discard block |
||
| 135 | 135 | $template_dir = give_get_theme_template_dir_name(); |
| 136 | 136 | |
| 137 | 137 | $file_paths = array( |
| 138 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 139 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 138 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
| 139 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
| 140 | 140 | 100 => give_get_templates_dir() |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
| 143 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
| 144 | 144 | |
| 145 | 145 | // sort the file paths based on priority |
| 146 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 146 | + ksort($file_paths, SORT_NUMERIC); |
|
| 147 | 147 | |
| 148 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 148 | + return array_map('trailingslashit', $file_paths); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @return string |
| 158 | 158 | */ |
| 159 | 159 | function give_get_theme_template_dir_name() { |
| 160 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
| 160 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -167,10 +167,10 @@ discard block |
||
| 167 | 167 | * @return void |
| 168 | 168 | */ |
| 169 | 169 | function give_version_in_header() { |
| 170 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
| 170 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
| 173 | +add_action('wp_head', 'give_version_in_header'); |
|
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Determines if we're currently on the Donations History page. |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | function give_is_donation_history_page() { |
| 182 | 182 | |
| 183 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
| 183 | + $ret = is_page(give_get_option('history_page')); |
|
| 184 | 184 | |
| 185 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
| 185 | + return apply_filters('give_is_donation_history_page', $ret); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -194,25 +194,25 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return array Modified array of classes |
| 196 | 196 | */ |
| 197 | -function give_add_body_classes( $class ) { |
|
| 197 | +function give_add_body_classes($class) { |
|
| 198 | 198 | $classes = (array) $class; |
| 199 | 199 | |
| 200 | - if ( give_is_success_page() ) { |
|
| 200 | + if (give_is_success_page()) { |
|
| 201 | 201 | $classes[] = 'give-success'; |
| 202 | 202 | $classes[] = 'give-page'; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if ( give_is_failed_transaction_page() ) { |
|
| 205 | + if (give_is_failed_transaction_page()) { |
|
| 206 | 206 | $classes[] = 'give-failed-transaction'; |
| 207 | 207 | $classes[] = 'give-page'; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if ( give_is_donation_history_page() ) { |
|
| 210 | + if (give_is_donation_history_page()) { |
|
| 211 | 211 | $classes[] = 'give-donation-history'; |
| 212 | 212 | $classes[] = 'give-page'; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( give_is_test_mode() ) { |
|
| 215 | + if (give_is_test_mode()) { |
|
| 216 | 216 | $classes[] = 'give-test-mode'; |
| 217 | 217 | $classes[] = 'give-page'; |
| 218 | 218 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | //Theme-specific Classes used to prevent conflicts via CSS |
| 221 | 221 | $current_theme = wp_get_theme(); |
| 222 | 222 | |
| 223 | - switch ( $current_theme->template ) { |
|
| 223 | + switch ($current_theme->template) { |
|
| 224 | 224 | |
| 225 | 225 | case 'Divi': |
| 226 | 226 | $classes[] = 'give-divi'; |
@@ -234,10 +234,10 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - return array_unique( $classes ); |
|
| 237 | + return array_unique($classes); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
| 240 | +add_filter('body_class', 'give_add_body_classes'); |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -253,22 +253,22 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return array |
| 255 | 255 | */ |
| 256 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
| 257 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
| 256 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
| 257 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
| 258 | 258 | return $classes; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
| 262 | 262 | |
| 263 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
| 264 | - unset( $classes[ $key ] ); |
|
| 263 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
| 264 | + unset($classes[$key]); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | return $classes; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
| 271 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
| 271 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * Get the placeholder image URL for forms etc |
@@ -278,84 +278,84 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | function give_get_placeholder_img_src() { |
| 280 | 280 | |
| 281 | - $placeholder_url = 'http://placehold.it/600x600&text=' . urlencode( esc_attr( 'Give Placeholder Image', 'give' ) ); |
|
| 281 | + $placeholder_url = 'http://placehold.it/600x600&text='.urlencode(esc_attr('Give Placeholder Image', 'give')); |
|
| 282 | 282 | |
| 283 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
| 283 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
| 287 | 287 | /** |
| 288 | 288 | * Global |
| 289 | 289 | */ |
| 290 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
| 290 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | 293 | * Output the start of the page wrapper. |
| 294 | 294 | */ |
| 295 | 295 | function give_output_content_wrapper() { |
| 296 | - give_get_template_part( 'global/wrapper-start' ); |
|
| 296 | + give_get_template_part('global/wrapper-start'); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
| 299 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * Output the end of the page wrapper. |
| 303 | 303 | */ |
| 304 | 304 | function give_output_content_wrapper_end() { |
| 305 | - give_get_template_part( 'global/wrapper-end' ); |
|
| 305 | + give_get_template_part('global/wrapper-end'); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * Single Give Form |
| 311 | 311 | */ |
| 312 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
| 312 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
| 313 | 313 | function give_left_sidebar_pre_wrap() { |
| 314 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
| 314 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
| 318 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
| 319 | 319 | function give_left_sidebar_post_wrap() { |
| 320 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
| 320 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
| 324 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
| 325 | 325 | function give_get_forms_sidebar() { |
| 326 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
| 326 | + give_get_template_part('single-give-form/sidebar'); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
| 330 | +if ( ! function_exists('give_show_form_images')) { |
|
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | 333 | * Output the product image before the single product summary. |
| 334 | 334 | */ |
| 335 | 335 | function give_show_form_images() { |
| 336 | - $featured_image_option = give_get_option( 'disable_form_featured_img' ); |
|
| 337 | - if ( $featured_image_option !== 'on' ) { |
|
| 338 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
| 336 | + $featured_image_option = give_get_option('disable_form_featured_img'); |
|
| 337 | + if ($featured_image_option !== 'on') { |
|
| 338 | + give_get_template_part('single-give-form/featured-image'); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
| 343 | +if ( ! function_exists('give_template_single_title')) { |
|
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | 346 | * Output the product title. |
| 347 | 347 | */ |
| 348 | 348 | function give_template_single_title() { |
| 349 | - give_get_template_part( 'single-give-form/title' ); |
|
| 349 | + give_get_template_part('single-give-form/title'); |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
| 353 | +if ( ! function_exists('give_show_avatars')) { |
|
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | 356 | * Output the product title. |
| 357 | 357 | */ |
| 358 | 358 | function give_show_avatars() { |
| 359 | - echo do_shortcode( '[give_donators_gravatars]' ); |
|
| 359 | + echo do_shortcode('[give_donators_gravatars]'); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | \ No newline at end of file |
@@ -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 | |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return string Login form |
| 27 | 27 | */ |
| 28 | -function give_login_form( $redirect = '' ) { |
|
| 28 | +function give_login_form($redirect = '') { |
|
| 29 | 29 | global $give_login_redirect; |
| 30 | 30 | |
| 31 | - if ( empty( $redirect ) ) { |
|
| 31 | + if (empty($redirect)) { |
|
| 32 | 32 | $redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | ob_start(); |
| 38 | 38 | |
| 39 | - give_get_template_part( 'shortcode', 'login' ); |
|
| 39 | + give_get_template_part('shortcode', 'login'); |
|
| 40 | 40 | |
| 41 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
| 41 | + return apply_filters('give_login_form', ob_get_clean()); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string Register form |
| 54 | 54 | */ |
| 55 | -function give_register_form( $redirect = '' ) { |
|
| 55 | +function give_register_form($redirect = '') { |
|
| 56 | 56 | global $give_options, $give_register_redirect; |
| 57 | 57 | |
| 58 | - if ( empty( $redirect ) ) { |
|
| 58 | + if (empty($redirect)) { |
|
| 59 | 59 | $redirect = give_get_current_page_url(); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | ob_start(); |
| 65 | 65 | |
| 66 | - if ( ! is_user_logged_in() ) { |
|
| 67 | - give_get_template_part( 'shortcode', 'register' ); |
|
| 66 | + if ( ! is_user_logged_in()) { |
|
| 67 | + give_get_template_part('shortcode', 'register'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
| 70 | + return apply_filters('give_register_form', ob_get_clean()); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,34 +79,34 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return void |
| 81 | 81 | */ |
| 82 | -function give_process_login_form( $data ) { |
|
| 83 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
| 84 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
| 85 | - if ( ! $user_data ) { |
|
| 86 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
| 82 | +function give_process_login_form($data) { |
|
| 83 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
| 84 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
| 85 | + if ( ! $user_data) { |
|
| 86 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
| 87 | 87 | } |
| 88 | - if ( $user_data ) { |
|
| 88 | + if ($user_data) { |
|
| 89 | 89 | $user_ID = $user_data->ID; |
| 90 | 90 | $user_email = $user_data->user_email; |
| 91 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
| 92 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
| 91 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
| 92 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
| 93 | 93 | } else { |
| 94 | - give_set_error( 'password_incorrect', esc_html( 'The password you entered is incorrect.', 'give' ) ); |
|
| 94 | + give_set_error('password_incorrect', esc_html('The password you entered is incorrect.', 'give')); |
|
| 95 | 95 | } |
| 96 | 96 | } else { |
| 97 | - give_set_error( 'username_incorrect', esc_html( 'The username you entered does not exist.', 'give' ) ); |
|
| 97 | + give_set_error('username_incorrect', esc_html('The username you entered does not exist.', 'give')); |
|
| 98 | 98 | } |
| 99 | 99 | // Check for errors and redirect if none present |
| 100 | 100 | $errors = give_get_errors(); |
| 101 | - if ( ! $errors ) { |
|
| 102 | - $redirect = apply_filters( 'give_login_redirect', $data['give_redirect'], $user_ID ); |
|
| 103 | - wp_redirect( $redirect ); |
|
| 101 | + if ( ! $errors) { |
|
| 102 | + $redirect = apply_filters('give_login_redirect', $data['give_redirect'], $user_ID); |
|
| 103 | + wp_redirect($redirect); |
|
| 104 | 104 | give_die(); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
| 109 | +add_action('give_user_login', 'give_process_login_form'); |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Log User In |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return void |
| 121 | 121 | */ |
| 122 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
| 123 | - if ( $user_id < 1 ) { |
|
| 122 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
| 123 | + if ($user_id < 1) { |
|
| 124 | 124 | return; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - wp_set_auth_cookie( $user_id ); |
|
| 128 | - wp_set_current_user( $user_id, $user_login ); |
|
| 129 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
| 130 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
| 127 | + wp_set_auth_cookie($user_id); |
|
| 128 | + wp_set_current_user($user_id, $user_login); |
|
| 129 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
| 130 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -140,70 +140,70 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | -function give_process_register_form( $data ) { |
|
| 143 | +function give_process_register_form($data) { |
|
| 144 | 144 | |
| 145 | - if ( is_user_logged_in() ) { |
|
| 145 | + if (is_user_logged_in()) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
| 149 | + if (empty($_POST['give_register_submit'])) { |
|
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - do_action( 'give_pre_process_register_form' ); |
|
| 153 | + do_action('give_pre_process_register_form'); |
|
| 154 | 154 | |
| 155 | - if ( empty( $data['give_user_login'] ) ) { |
|
| 156 | - give_set_error( 'empty_username', esc_html( 'Invalid username.', 'give' ) ); |
|
| 155 | + if (empty($data['give_user_login'])) { |
|
| 156 | + give_set_error('empty_username', esc_html('Invalid username.', 'give')); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
| 160 | - give_set_error( 'username_unavailable', esc_html( 'Username already taken.', 'give' ) ); |
|
| 159 | + if (username_exists($data['give_user_login'])) { |
|
| 160 | + give_set_error('username_unavailable', esc_html('Username already taken.', 'give')); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
| 164 | - give_set_error( 'username_invalid', esc_html( 'Invalid username.', 'give' ) ); |
|
| 163 | + if ( ! validate_username($data['give_user_login'])) { |
|
| 164 | + give_set_error('username_invalid', esc_html('Invalid username.', 'give')); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
| 168 | - give_set_error( 'email_unavailable', esc_html( 'Email address already taken.', 'give' ) ); |
|
| 167 | + if (email_exists($data['give_user_email'])) { |
|
| 168 | + give_set_error('email_unavailable', esc_html('Email address already taken.', 'give')); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
| 172 | - give_set_error( 'email_invalid', esc_html( 'Invalid email.', 'give' ) ); |
|
| 171 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
| 172 | + give_set_error('email_invalid', esc_html('Invalid email.', 'give')); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
| 176 | - give_set_error( 'payment_email_invalid', esc_html( 'Invalid payment email.', 'give' ) ); |
|
| 175 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
| 176 | + give_set_error('payment_email_invalid', esc_html('Invalid payment email.', 'give')); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
| 180 | - give_set_error( 'empty_password', esc_html( 'Please enter a password.', 'give' ) ); |
|
| 179 | + if (empty($_POST['give_user_pass'])) { |
|
| 180 | + give_set_error('empty_password', esc_html('Please enter a password.', 'give')); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
| 184 | - give_set_error( 'password_mismatch', esc_html( 'Passwords don\'t match.', 'give' ) ); |
|
| 183 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
| 184 | + give_set_error('password_mismatch', esc_html('Passwords don\'t match.', 'give')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - do_action( 'give_process_register_form' ); |
|
| 187 | + do_action('give_process_register_form'); |
|
| 188 | 188 | |
| 189 | 189 | // Check for errors and redirect if none present |
| 190 | 190 | $errors = give_get_errors(); |
| 191 | 191 | |
| 192 | - if ( empty( $errors ) ) { |
|
| 192 | + if (empty($errors)) { |
|
| 193 | 193 | |
| 194 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
| 194 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
| 195 | 195 | |
| 196 | - give_register_and_login_new_user( array( |
|
| 196 | + give_register_and_login_new_user(array( |
|
| 197 | 197 | 'user_login' => $data['give_user_login'], |
| 198 | 198 | 'user_pass' => $data['give_user_pass'], |
| 199 | 199 | 'user_email' => $data['give_user_email'], |
| 200 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 201 | - 'role' => get_option( 'default_role' ) |
|
| 202 | - ) ); |
|
| 200 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 201 | + 'role' => get_option('default_role') |
|
| 202 | + )); |
|
| 203 | 203 | |
| 204 | - wp_redirect( $redirect ); |
|
| 204 | + wp_redirect($redirect); |
|
| 205 | 205 | give_die(); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
| 210 | 209 | \ No newline at end of file |
| 210 | +add_action('give_user_register', 'give_process_register_form'); |
|
| 211 | 211 | \ No newline at end of file |
@@ -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 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return string $output Give forms dropdown |
| 35 | 35 | */ |
| 36 | - public function forms_dropdown( $args = array() ) { |
|
| 36 | + public function forms_dropdown($args = array()) { |
|
| 37 | 37 | |
| 38 | 38 | $defaults = array( |
| 39 | 39 | 'name' => 'forms', |
@@ -44,47 +44,47 @@ discard block |
||
| 44 | 44 | 'chosen' => false, |
| 45 | 45 | 'number' => 30, |
| 46 | 46 | /* translators: %s: form singular label */ |
| 47 | - 'placeholder' => sprintf( esc_attr( 'Select a %s', 'give' ), give_get_forms_label_singular() ) |
|
| 47 | + 'placeholder' => sprintf(esc_attr('Select a %s', 'give'), give_get_forms_label_singular()) |
|
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - $args = wp_parse_args( $args, $defaults ); |
|
| 50 | + $args = wp_parse_args($args, $defaults); |
|
| 51 | 51 | |
| 52 | - $forms = get_posts( array( |
|
| 52 | + $forms = get_posts(array( |
|
| 53 | 53 | 'post_type' => 'give_forms', |
| 54 | 54 | 'orderby' => 'title', |
| 55 | 55 | 'order' => 'ASC', |
| 56 | 56 | 'posts_per_page' => $args['number'] |
| 57 | - ) ); |
|
| 57 | + )); |
|
| 58 | 58 | |
| 59 | 59 | $options = array(); |
| 60 | 60 | |
| 61 | - if ( $forms ) { |
|
| 61 | + if ($forms) { |
|
| 62 | 62 | $options[0] = sprintf( |
| 63 | 63 | /* translators: %s: form singular label */ |
| 64 | - esc_html( 'Select a %s', 'give' ), |
|
| 64 | + esc_html('Select a %s', 'give'), |
|
| 65 | 65 | give_get_forms_label_singular() |
| 66 | 66 | ); |
| 67 | - foreach ( $forms as $form ) { |
|
| 68 | - $options[ absint( $form->ID ) ] = esc_html( $form->post_title ); |
|
| 67 | + foreach ($forms as $form) { |
|
| 68 | + $options[absint($form->ID)] = esc_html($form->post_title); |
|
| 69 | 69 | } |
| 70 | 70 | } else { |
| 71 | - $options[0] = esc_html( 'No Give Forms Found', 'give' ); |
|
| 71 | + $options[0] = esc_html('No Give Forms Found', 'give'); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // This ensures that any selected forms are included in the drop down |
| 75 | - if ( is_array( $args['selected'] ) ) { |
|
| 76 | - foreach ( $args['selected'] as $item ) { |
|
| 77 | - if ( ! in_array( $item, $options ) ) { |
|
| 78 | - $options[ $item ] = get_the_title( $item ); |
|
| 75 | + if (is_array($args['selected'])) { |
|
| 76 | + foreach ($args['selected'] as $item) { |
|
| 77 | + if ( ! in_array($item, $options)) { |
|
| 78 | + $options[$item] = get_the_title($item); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 82 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 83 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
| 81 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 82 | + if ( ! in_array($args['selected'], $options)) { |
|
| 83 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $output = $this->select( array( |
|
| 87 | + $output = $this->select(array( |
|
| 88 | 88 | 'name' => $args['name'], |
| 89 | 89 | 'selected' => $args['selected'], |
| 90 | 90 | 'id' => $args['id'], |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | 'placeholder' => $args['placeholder'], |
| 96 | 96 | 'show_option_all' => false, |
| 97 | 97 | 'show_option_none' => false |
| 98 | - ) ); |
|
| 98 | + )); |
|
| 99 | 99 | |
| 100 | 100 | return $output; |
| 101 | 101 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return string $output Donor dropdown |
| 112 | 112 | */ |
| 113 | - public function donor_dropdown( $args = array() ) { |
|
| 113 | + public function donor_dropdown($args = array()) { |
|
| 114 | 114 | |
| 115 | 115 | $defaults = array( |
| 116 | 116 | 'name' => 'customers', |
@@ -119,38 +119,38 @@ discard block |
||
| 119 | 119 | 'multiple' => false, |
| 120 | 120 | 'selected' => 0, |
| 121 | 121 | 'chosen' => true, |
| 122 | - 'placeholder' => esc_attr( 'Select a Donor', 'give' ), |
|
| 122 | + 'placeholder' => esc_attr('Select a Donor', 'give'), |
|
| 123 | 123 | 'number' => 30 |
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - $args = wp_parse_args( $args, $defaults ); |
|
| 126 | + $args = wp_parse_args($args, $defaults); |
|
| 127 | 127 | |
| 128 | - $customers = Give()->customers->get_customers( array( |
|
| 128 | + $customers = Give()->customers->get_customers(array( |
|
| 129 | 129 | 'number' => $args['number'] |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | |
| 132 | 132 | $options = array(); |
| 133 | 133 | |
| 134 | - if ( $customers ) { |
|
| 135 | - $options[0] = esc_html( 'No donor attached', 'give' ); |
|
| 136 | - foreach ( $customers as $customer ) { |
|
| 137 | - $options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
| 134 | + if ($customers) { |
|
| 135 | + $options[0] = esc_html('No donor attached', 'give'); |
|
| 136 | + foreach ($customers as $customer) { |
|
| 137 | + $options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')'); |
|
| 138 | 138 | } |
| 139 | 139 | } else { |
| 140 | - $options[0] = esc_html( 'No donors found', 'give' ); |
|
| 140 | + $options[0] = esc_html('No donors found', 'give'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if ( ! empty( $args['selected'] ) ) { |
|
| 143 | + if ( ! empty($args['selected'])) { |
|
| 144 | 144 | |
| 145 | 145 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed |
| 146 | 146 | |
| 147 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
| 147 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
| 148 | 148 | |
| 149 | - $customer = new Give_Customer( $args['selected'] ); |
|
| 149 | + $customer = new Give_Customer($args['selected']); |
|
| 150 | 150 | |
| 151 | - if ( $customer ) { |
|
| 151 | + if ($customer) { |
|
| 152 | 152 | |
| 153 | - $options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
| 153 | + $options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')'); |
|
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | |
@@ -158,17 +158,17 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $output = $this->select( array( |
|
| 161 | + $output = $this->select(array( |
|
| 162 | 162 | 'name' => $args['name'], |
| 163 | 163 | 'selected' => $args['selected'], |
| 164 | 164 | 'id' => $args['id'], |
| 165 | - 'class' => $args['class'] . ' give-customer-select', |
|
| 165 | + 'class' => $args['class'].' give-customer-select', |
|
| 166 | 166 | 'options' => $options, |
| 167 | 167 | 'multiple' => $args['multiple'], |
| 168 | 168 | 'chosen' => $args['chosen'], |
| 169 | 169 | 'show_option_all' => false, |
| 170 | 170 | 'show_option_none' => false |
| 171 | - ) ); |
|
| 171 | + )); |
|
| 172 | 172 | |
| 173 | 173 | return $output; |
| 174 | 174 | } |
@@ -185,21 +185,21 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return string $output Category dropdown |
| 187 | 187 | */ |
| 188 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0 ) { |
|
| 189 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
| 188 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0) { |
|
| 189 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
| 190 | 190 | $options = array(); |
| 191 | 191 | |
| 192 | - foreach ( $categories as $category ) { |
|
| 193 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
| 192 | + foreach ($categories as $category) { |
|
| 193 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $output = $this->select( array( |
|
| 196 | + $output = $this->select(array( |
|
| 197 | 197 | 'name' => $name, |
| 198 | 198 | 'selected' => $selected, |
| 199 | 199 | 'options' => $options, |
| 200 | - 'show_option_all' => esc_html( 'All Categories', 'give' ), |
|
| 200 | + 'show_option_all' => esc_html('All Categories', 'give'), |
|
| 201 | 201 | 'show_option_none' => false |
| 202 | - ) ); |
|
| 202 | + )); |
|
| 203 | 203 | |
| 204 | 204 | return $output; |
| 205 | 205 | } |
@@ -217,25 +217,25 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @return string $output Year dropdown |
| 219 | 219 | */ |
| 220 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 221 | - $current = date( 'Y' ); |
|
| 222 | - $start_year = $current - absint( $years_before ); |
|
| 223 | - $end_year = $current + absint( $years_after ); |
|
| 224 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 220 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 221 | + $current = date('Y'); |
|
| 222 | + $start_year = $current - absint($years_before); |
|
| 223 | + $end_year = $current + absint($years_after); |
|
| 224 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 225 | 225 | $options = array(); |
| 226 | 226 | |
| 227 | - while ( $start_year <= $end_year ) { |
|
| 228 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 229 | - $start_year ++; |
|
| 227 | + while ($start_year <= $end_year) { |
|
| 228 | + $options[absint($start_year)] = $start_year; |
|
| 229 | + $start_year++; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - $output = $this->select( array( |
|
| 232 | + $output = $this->select(array( |
|
| 233 | 233 | 'name' => $name, |
| 234 | 234 | 'selected' => $selected, |
| 235 | 235 | 'options' => $options, |
| 236 | 236 | 'show_option_all' => false, |
| 237 | 237 | 'show_option_none' => false |
| 238 | - ) ); |
|
| 238 | + )); |
|
| 239 | 239 | |
| 240 | 240 | return $output; |
| 241 | 241 | } |
@@ -252,23 +252,23 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return string $output Month dropdown |
| 254 | 254 | */ |
| 255 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 255 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
| 256 | 256 | $month = 1; |
| 257 | 257 | $options = array(); |
| 258 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 258 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 259 | 259 | |
| 260 | - while ( $month <= 12 ) { |
|
| 261 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
| 262 | - $month ++; |
|
| 260 | + while ($month <= 12) { |
|
| 261 | + $options[absint($month)] = give_month_num_to_name($month); |
|
| 262 | + $month++; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - $output = $this->select( array( |
|
| 265 | + $output = $this->select(array( |
|
| 266 | 266 | 'name' => $name, |
| 267 | 267 | 'selected' => $selected, |
| 268 | 268 | 'options' => $options, |
| 269 | 269 | 'show_option_all' => false, |
| 270 | 270 | 'show_option_none' => false |
| 271 | - ) ); |
|
| 271 | + )); |
|
| 272 | 272 | |
| 273 | 273 | return $output; |
| 274 | 274 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @return string |
| 284 | 284 | */ |
| 285 | - public function select( $args = array() ) { |
|
| 285 | + public function select($args = array()) { |
|
| 286 | 286 | $defaults = array( |
| 287 | 287 | 'options' => array(), |
| 288 | 288 | 'name' => null, |
@@ -292,60 +292,60 @@ discard block |
||
| 292 | 292 | 'chosen' => false, |
| 293 | 293 | 'placeholder' => null, |
| 294 | 294 | 'multiple' => false, |
| 295 | - 'show_option_all' => esc_html( 'All', 'give' ), |
|
| 296 | - 'show_option_none' => esc_html( 'None', 'give' ) |
|
| 295 | + 'show_option_all' => esc_html('All', 'give'), |
|
| 296 | + 'show_option_none' => esc_html('None', 'give') |
|
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | - $args = wp_parse_args( $args, $defaults ); |
|
| 299 | + $args = wp_parse_args($args, $defaults); |
|
| 300 | 300 | |
| 301 | 301 | |
| 302 | - if ( $args['multiple'] ) { |
|
| 302 | + if ($args['multiple']) { |
|
| 303 | 303 | $multiple = ' MULTIPLE'; |
| 304 | 304 | } else { |
| 305 | 305 | $multiple = ''; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if ( $args['chosen'] ) { |
|
| 308 | + if ($args['chosen']) { |
|
| 309 | 309 | $args['class'] .= ' give-select-chosen'; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( $args['placeholder'] ) { |
|
| 312 | + if ($args['placeholder']) { |
|
| 313 | 313 | $placeholder = $args['placeholder']; |
| 314 | 314 | } else { |
| 315 | 315 | $placeholder = ''; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' data-placeholder="' . $placeholder . '">'; |
|
| 318 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' data-placeholder="'.$placeholder.'">'; |
|
| 319 | 319 | |
| 320 | - if ( $args['show_option_all'] ) { |
|
| 321 | - if ( $args['multiple'] ) { |
|
| 322 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 320 | + if ($args['show_option_all']) { |
|
| 321 | + if ($args['multiple']) { |
|
| 322 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 323 | 323 | } else { |
| 324 | - $selected = selected( $args['selected'], 0, false ); |
|
| 324 | + $selected = selected($args['selected'], 0, false); |
|
| 325 | 325 | } |
| 326 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 326 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( ! empty( $args['options'] ) ) { |
|
| 329 | + if ( ! empty($args['options'])) { |
|
| 330 | 330 | |
| 331 | - if ( $args['show_option_none'] ) { |
|
| 332 | - if ( $args['multiple'] ) { |
|
| 333 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
| 331 | + if ($args['show_option_none']) { |
|
| 332 | + if ($args['multiple']) { |
|
| 333 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
| 334 | 334 | } else { |
| 335 | - $selected = selected( $args['selected'], - 1, false ); |
|
| 335 | + $selected = selected($args['selected'], - 1, false); |
|
| 336 | 336 | } |
| 337 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 337 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - foreach ( $args['options'] as $key => $option ) { |
|
| 340 | + foreach ($args['options'] as $key => $option) { |
|
| 341 | 341 | |
| 342 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 343 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
| 342 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 343 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
| 344 | 344 | } else { |
| 345 | - $selected = selected( $args['selected'], $key, false ); |
|
| 345 | + $selected = selected($args['selected'], $key, false); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 348 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * |
| 364 | 364 | * @return string |
| 365 | 365 | */ |
| 366 | - public function checkbox( $args = array() ) { |
|
| 366 | + public function checkbox($args = array()) { |
|
| 367 | 367 | $defaults = array( |
| 368 | 368 | 'name' => null, |
| 369 | 369 | 'current' => null, |
@@ -374,16 +374,16 @@ discard block |
||
| 374 | 374 | ) |
| 375 | 375 | ); |
| 376 | 376 | |
| 377 | - $args = wp_parse_args( $args, $defaults ); |
|
| 377 | + $args = wp_parse_args($args, $defaults); |
|
| 378 | 378 | |
| 379 | 379 | $options = ''; |
| 380 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 380 | + if ( ! empty($args['options']['disabled'])) { |
|
| 381 | 381 | $options .= ' disabled="disabled"'; |
| 382 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 382 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
| 383 | 383 | $options .= ' readonly'; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 386 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
| 387 | 387 | |
| 388 | 388 | return $output; |
| 389 | 389 | } |
@@ -397,22 +397,22 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @return string Text field |
| 399 | 399 | */ |
| 400 | - public function text( $args = array() ) { |
|
| 400 | + public function text($args = array()) { |
|
| 401 | 401 | // Backwards compatabliity |
| 402 | - if ( func_num_args() > 1 ) { |
|
| 402 | + if (func_num_args() > 1) { |
|
| 403 | 403 | $args = func_get_args(); |
| 404 | 404 | |
| 405 | 405 | $name = $args[0]; |
| 406 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 407 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 408 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 406 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 407 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 408 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $defaults = array( |
| 412 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 413 | - 'value' => isset( $value ) ? $value : null, |
|
| 414 | - 'label' => isset( $label ) ? $label : null, |
|
| 415 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 412 | + 'name' => isset($name) ? $name : 'text', |
|
| 413 | + 'value' => isset($value) ? $value : null, |
|
| 414 | + 'label' => isset($label) ? $label : null, |
|
| 415 | + 'desc' => isset($desc) ? $desc : null, |
|
| 416 | 416 | 'placeholder' => '', |
| 417 | 417 | 'class' => 'regular-text', |
| 418 | 418 | 'disabled' => false, |
@@ -420,29 +420,29 @@ discard block |
||
| 420 | 420 | 'data' => false |
| 421 | 421 | ); |
| 422 | 422 | |
| 423 | - $args = wp_parse_args( $args, $defaults ); |
|
| 423 | + $args = wp_parse_args($args, $defaults); |
|
| 424 | 424 | |
| 425 | 425 | $disabled = ''; |
| 426 | - if ( $args['disabled'] ) { |
|
| 426 | + if ($args['disabled']) { |
|
| 427 | 427 | $disabled = ' disabled="disabled"'; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | $data = ''; |
| 431 | - if ( ! empty( $args['data'] ) ) { |
|
| 432 | - foreach ( $args['data'] as $key => $value ) { |
|
| 433 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
| 431 | + if ( ! empty($args['data'])) { |
|
| 432 | + foreach ($args['data'] as $key => $value) { |
|
| 433 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 437 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
| 438 | 438 | |
| 439 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 439 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
| 440 | 440 | |
| 441 | - if ( ! empty( $args['desc'] ) ) { |
|
| 442 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 441 | + if ( ! empty($args['desc'])) { |
|
| 442 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
| 445 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
| 446 | 446 | |
| 447 | 447 | $output .= '</span>'; |
| 448 | 448 | |
@@ -458,15 +458,15 @@ discard block |
||
| 458 | 458 | * |
| 459 | 459 | * @return string Datepicker field |
| 460 | 460 | */ |
| 461 | - public function date_field( $args = array() ) { |
|
| 461 | + public function date_field($args = array()) { |
|
| 462 | 462 | |
| 463 | - if ( empty( $args['class'] ) ) { |
|
| 463 | + if (empty($args['class'])) { |
|
| 464 | 464 | $args['class'] = 'give_datepicker'; |
| 465 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
| 465 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
| 466 | 466 | $args['class'] .= ' give_datepicker'; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - return $this->text( $args ); |
|
| 469 | + return $this->text($args); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * |
| 480 | 480 | * @return string textarea |
| 481 | 481 | */ |
| 482 | - public function textarea( $args = array() ) { |
|
| 482 | + public function textarea($args = array()) { |
|
| 483 | 483 | $defaults = array( |
| 484 | 484 | 'name' => 'textarea', |
| 485 | 485 | 'value' => null, |
@@ -489,21 +489,21 @@ discard block |
||
| 489 | 489 | 'disabled' => false |
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | - $args = wp_parse_args( $args, $defaults ); |
|
| 492 | + $args = wp_parse_args($args, $defaults); |
|
| 493 | 493 | |
| 494 | 494 | $disabled = ''; |
| 495 | - if ( $args['disabled'] ) { |
|
| 495 | + if ($args['disabled']) { |
|
| 496 | 496 | $disabled = ' disabled="disabled"'; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 499 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
| 500 | 500 | |
| 501 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 501 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
| 502 | 502 | |
| 503 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_html( $args['value'] ) . '</textarea>'; |
|
| 503 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_html($args['value']).'</textarea>'; |
|
| 504 | 504 | |
| 505 | - if ( ! empty( $args['desc'] ) ) { |
|
| 506 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 505 | + if ( ! empty($args['desc'])) { |
|
| 506 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | $output .= '</span>'; |
@@ -520,12 +520,12 @@ discard block |
||
| 520 | 520 | * |
| 521 | 521 | * @return string text field with ajax search |
| 522 | 522 | */ |
| 523 | - public function ajax_user_search( $args = array() ) { |
|
| 523 | + public function ajax_user_search($args = array()) { |
|
| 524 | 524 | |
| 525 | 525 | $defaults = array( |
| 526 | 526 | 'name' => 'user_id', |
| 527 | 527 | 'value' => null, |
| 528 | - 'placeholder' => esc_attr( 'Enter username', 'give' ), |
|
| 528 | + 'placeholder' => esc_attr('Enter username', 'give'), |
|
| 529 | 529 | 'label' => null, |
| 530 | 530 | 'desc' => null, |
| 531 | 531 | 'class' => '', |
@@ -534,13 +534,13 @@ discard block |
||
| 534 | 534 | 'data' => false |
| 535 | 535 | ); |
| 536 | 536 | |
| 537 | - $args = wp_parse_args( $args, $defaults ); |
|
| 537 | + $args = wp_parse_args($args, $defaults); |
|
| 538 | 538 | |
| 539 | - $args['class'] = 'give-ajax-user-search ' . $args['class']; |
|
| 539 | + $args['class'] = 'give-ajax-user-search '.$args['class']; |
|
| 540 | 540 | |
| 541 | 541 | $output = '<span class="give_user_search_wrap">'; |
| 542 | - $output .= $this->text( $args ); |
|
| 543 | - $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" title="' . esc_attr( 'Cancel', 'give' ) . '" aria-label="' . esc_attr( 'Cancel', 'give' ) . '" href="#">x</a><span></span></span>'; |
|
| 542 | + $output .= $this->text($args); |
|
| 543 | + $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" title="'.esc_attr('Cancel', 'give').'" aria-label="'.esc_attr('Cancel', 'give').'" href="#">x</a><span></span></span>'; |
|
| 544 | 544 | $output .= '</span>'; |
| 545 | 545 | |
| 546 | 546 | return $output; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -defined( 'ABSPATH' ) or exit; |
|
| 13 | +defined('ABSPATH') or exit; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Give Form widget |
@@ -31,18 +31,18 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function __construct() |
| 33 | 33 | { |
| 34 | - $this->self = get_class( $this ); |
|
| 34 | + $this->self = get_class($this); |
|
| 35 | 35 | |
| 36 | 36 | parent::__construct( |
| 37 | - strtolower( $this->self ), |
|
| 38 | - esc_html( 'Give - Donation Form', 'give' ), |
|
| 37 | + strtolower($this->self), |
|
| 38 | + esc_html('Give - Donation Form', 'give'), |
|
| 39 | 39 | array( |
| 40 | - 'description' => esc_html( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
| 40 | + 'description' => esc_html('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
| 45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
| 44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
| 45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | - public function admin_widget_scripts( $hook ) |
|
| 55 | + public function admin_widget_scripts($hook) |
|
| 56 | 56 | { |
| 57 | 57 | // Directories of assets |
| 58 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
| 59 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 60 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
| 58 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
| 59 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 60 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
| 61 | 61 | |
| 62 | 62 | // Use minified libraries if SCRIPT_DEBUG is turned off |
| 63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 64 | 64 | |
| 65 | 65 | // Widget Script |
| 66 | - if ( $hook == 'widgets.php' ) { |
|
| 66 | + if ($hook == 'widgets.php') { |
|
| 67 | 67 | |
| 68 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
| 68 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
| 69 | 69 | |
| 70 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
| 70 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
| 71 | 71 | |
| 72 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 72 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -80,24 +80,24 @@ discard block |
||
| 80 | 80 | * before_widget, and after_widget. |
| 81 | 81 | * @param array $instance The settings for the particular instance of the widget. |
| 82 | 82 | */ |
| 83 | - public function widget( $args, $instance ) |
|
| 83 | + public function widget($args, $instance) |
|
| 84 | 84 | { |
| 85 | - extract( $args ); |
|
| 85 | + extract($args); |
|
| 86 | 86 | |
| 87 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
| 88 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 87 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 88 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
| 89 | 89 | |
| 90 | 90 | echo $before_widget; |
| 91 | 91 | |
| 92 | - do_action( 'give_before_forms_widget' ); |
|
| 92 | + do_action('give_before_forms_widget'); |
|
| 93 | 93 | |
| 94 | - echo $title ? $before_title . $title . $after_title : ''; |
|
| 94 | + echo $title ? $before_title.$title.$after_title : ''; |
|
| 95 | 95 | |
| 96 | - give_get_donation_form( $instance ); |
|
| 96 | + give_get_donation_form($instance); |
|
| 97 | 97 | |
| 98 | 98 | echo $after_widget; |
| 99 | 99 | |
| 100 | - do_action( 'give_after_forms_widget' ); |
|
| 100 | + do_action('give_after_forms_widget'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | - public function form( $instance ) |
|
| 110 | + public function form($instance) |
|
| 111 | 111 | { |
| 112 | 112 | $defaults = array( |
| 113 | 113 | 'title' => '', |
@@ -115,61 +115,61 @@ discard block |
||
| 115 | 115 | 'float_labels' => '', |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 118 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 119 | 119 | |
| 120 | - extract( $instance ); |
|
| 120 | + extract($instance); |
|
| 121 | 121 | |
| 122 | 122 | // Query Give Forms |
| 123 | 123 | |
| 124 | 124 | $args = array( |
| 125 | 125 | 'post_type' => 'give_forms', |
| 126 | - 'posts_per_page' => - 1, |
|
| 126 | + 'posts_per_page' => -1, |
|
| 127 | 127 | 'post_status' => 'publish', |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - $give_forms = get_posts( $args ); |
|
| 130 | + $give_forms = get_posts($args); |
|
| 131 | 131 | |
| 132 | 132 | // Widget: Title |
| 133 | 133 | |
| 134 | 134 | ?><p> |
| 135 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
| 136 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $title ); ?>" /><br> |
|
| 137 | - <small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
| 135 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
| 136 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($title); ?>" /><br> |
|
| 137 | + <small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
| 138 | 138 | </p><?php |
| 139 | 139 | |
| 140 | 140 | // Widget: Give Form |
| 141 | 141 | |
| 142 | 142 | ?><p> |
| 143 | - <label for="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"><?php |
|
| 143 | + <label for="<?php esc_attr_e($this->get_field_id('id')); ?>"><?php |
|
| 144 | 144 | printf( |
| 145 | 145 | /* translators: %s: form singular label */ |
| 146 | - esc_html( 'Give %s:', 'give' ), |
|
| 146 | + esc_html('Give %s:', 'give'), |
|
| 147 | 147 | give_get_forms_label_singular() |
| 148 | 148 | ); |
| 149 | 149 | ?></label> |
| 150 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'id' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"> |
|
| 151 | - <option value="current"><?php esc_html_e( '— Select —', 'give' ); ?></option> |
|
| 152 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
| 153 | - <option <?php selected( absint( $id ), $give_form->ID ); ?> value="<?php esc_attr_e( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 150 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('id')); ?>" id="<?php esc_attr_e($this->get_field_id('id')); ?>"> |
|
| 151 | + <option value="current"><?php esc_html_e('— Select —', 'give'); ?></option> |
|
| 152 | + <?php foreach ($give_forms as $give_form) { ?> |
|
| 153 | + <option <?php selected(absint($id), $give_form->ID); ?> value="<?php esc_attr_e($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
| 154 | 154 | <?php } ?> |
| 155 | 155 | </select><br> |
| 156 | - <small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
| 156 | + <small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
| 157 | 157 | </p><?php |
| 158 | 158 | |
| 159 | 159 | // Widget: Floating Labels |
| 160 | 160 | |
| 161 | 161 | ?><p> |
| 162 | - <label for="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label> |
|
| 163 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"> |
|
| 164 | - <option value="" <?php selected( esc_attr( $float_labels ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
| 165 | - <option value="enabled" <?php selected( esc_attr( $float_labels ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option> |
|
| 166 | - <option value="disabled" <?php selected( esc_attr( $float_labels ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option> |
|
| 162 | + <label for="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label> |
|
| 163 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('float_labels')); ?>" id="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"> |
|
| 164 | + <option value="" <?php selected(esc_attr($float_labels), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option> |
|
| 165 | + <option value="enabled" <?php selected(esc_attr($float_labels), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option> |
|
| 166 | + <option value="disabled" <?php selected(esc_attr($float_labels), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option> |
|
| 167 | 167 | </select><br> |
| 168 | 168 | <small><?php |
| 169 | 169 | printf( |
| 170 | 170 | /* translators: %s: http://bradfrost.com/blog/post/float-label-pattern/ */ |
| 171 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
| 172 | - esc_url( 'http://bradfrost.com/blog/post/float-label-pattern/' ) |
|
| 171 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
| 172 | + esc_url('http://bradfrost.com/blog/post/float-label-pattern/') |
|
| 173 | 173 | ); |
| 174 | 174 | ?></small> |
| 175 | 175 | </p><?php |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function widget_init() |
| 184 | 184 | { |
| 185 | - register_widget( $this->self ); |
|
| 185 | + register_widget($this->self); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @return array |
| 195 | 195 | */ |
| 196 | - public function update( $new_instance, $old_instance ) |
|
| 196 | + public function update($new_instance, $old_instance) |
|
| 197 | 197 | { |
| 198 | 198 | $this->flush_widget_cache(); |
| 199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function flush_widget_cache() |
| 209 | 209 | { |
| 210 | - wp_cache_delete( $this->self, 'widget' ); |
|
| 210 | + wp_cache_delete($this->self, 'widget'); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @since 1.4 |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -defined( 'ABSPATH' ) or exit; |
|
| 13 | +defined('ABSPATH') or exit; |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Class Give_Email_Access |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | function __construct() { |
| 31 | 31 | |
| 32 | 32 | // get it started |
| 33 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 33 | + add_action('init', array($this, 'init')); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -39,30 +39,30 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function init() { |
| 41 | 41 | |
| 42 | - $is_enabled = give_get_option( 'email_access' ); |
|
| 42 | + $is_enabled = give_get_option('email_access'); |
|
| 43 | 43 | |
| 44 | 44 | //Non-logged in users only |
| 45 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
| 45 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | //Are db columns setup? |
| 50 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
| 51 | - if ( empty( $is_setup ) ) { |
|
| 50 | + $is_setup = give_get_option('email_access_installed'); |
|
| 51 | + if (empty($is_setup)) { |
|
| 52 | 52 | $this->create_columns(); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Timeouts |
| 56 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
| 57 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
| 56 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
| 57 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
| 58 | 58 | |
| 59 | 59 | // Setup login |
| 60 | 60 | $this->check_for_token(); |
| 61 | 61 | |
| 62 | - if ( $this->token_exists ) { |
|
| 63 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
| 64 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
| 65 | - add_filter( 'give_get_users_purchases_args', array( $this, 'users_purchases_args' ) ); |
|
| 62 | + if ($this->token_exists) { |
|
| 63 | + add_filter('give_can_view_receipt', '__return_true'); |
|
| 64 | + add_filter('give_user_pending_verification', '__return_false'); |
|
| 65 | + add_filter('give_get_users_purchases_args', array($this, 'users_purchases_args')); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -73,24 +73,24 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return bool |
| 75 | 75 | */ |
| 76 | - function can_send_email( $customer_id ) { |
|
| 76 | + function can_send_email($customer_id) { |
|
| 77 | 77 | global $wpdb; |
| 78 | 78 | |
| 79 | 79 | // Prevent multiple emails within X minutes |
| 80 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
| 80 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
| 81 | 81 | |
| 82 | 82 | // Does a user row exist? |
| 83 | 83 | $exists = (int) $wpdb->get_var( |
| 84 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
| 84 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | - if ( 0 < $exists ) { |
|
| 87 | + if (0 < $exists) { |
|
| 88 | 88 | $row_id = (int) $wpdb->get_var( |
| 89 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
| 89 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | - if ( $row_id < 1 ) { |
|
| 93 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
| 92 | + if ($row_id < 1) { |
|
| 93 | + give_set_error('give_email_access_attempts_exhausted', esc_html('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
| 94 | 94 | |
| 95 | 95 | return false; |
| 96 | 96 | } |
@@ -106,38 +106,38 @@ discard block |
||
| 106 | 106 | * @param $customer_id |
| 107 | 107 | * @param $email |
| 108 | 108 | */ |
| 109 | - function send_email( $customer_id, $email ) { |
|
| 109 | + function send_email($customer_id, $email) { |
|
| 110 | 110 | |
| 111 | - $verify_key = wp_generate_password( 20, false ); |
|
| 111 | + $verify_key = wp_generate_password(20, false); |
|
| 112 | 112 | |
| 113 | 113 | // Generate a new verify key |
| 114 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
| 114 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
| 115 | 115 | |
| 116 | 116 | // Get the purchase history URL |
| 117 | - $page_id = give_get_option( 'history_page' ); |
|
| 117 | + $page_id = give_get_option('history_page'); |
|
| 118 | 118 | |
| 119 | - $access_url = add_query_arg( array( |
|
| 119 | + $access_url = add_query_arg(array( |
|
| 120 | 120 | 'give_nl' => $verify_key, |
| 121 | - ), get_permalink( $page_id ) ); |
|
| 121 | + ), get_permalink($page_id)); |
|
| 122 | 122 | |
| 123 | 123 | //Nice subject and message |
| 124 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
| 124 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
| 125 | 125 | |
| 126 | - $message = esc_html( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
| 126 | + $message = esc_html('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
| 127 | 127 | |
| 128 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html( 'Access My Donation Details', 'give' ) . ' »</a>'; |
|
| 128 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html('Access My Donation Details', 'give').' »</a>'; |
|
| 129 | 129 | |
| 130 | 130 | $message .= "\n\n"; |
| 131 | 131 | $message .= "\n\n"; |
| 132 | - $message .= esc_html( 'Sincerely,', 'give' ); |
|
| 133 | - $message .= "\n" . get_bloginfo( 'name' ) . "\n"; |
|
| 132 | + $message .= esc_html('Sincerely,', 'give'); |
|
| 133 | + $message .= "\n".get_bloginfo('name')."\n"; |
|
| 134 | 134 | |
| 135 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
| 135 | + $message = apply_filters('give_email_access_token_message', $message); |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | // Send the email |
| 139 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html( 'Your Access Link', 'give' ) ) ); |
|
| 140 | - Give()->emails->send( $email, $subject, $message ); |
|
| 139 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html('Your Access Link', 'give'))); |
|
| 140 | + Give()->emails->send($email, $subject, $message); |
|
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | |
@@ -147,24 +147,24 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function check_for_token() { |
| 149 | 149 | |
| 150 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
| 150 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
| 151 | 151 | |
| 152 | 152 | // Check for cookie |
| 153 | - if ( empty( $token ) ) { |
|
| 154 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
| 153 | + if (empty($token)) { |
|
| 154 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( ! empty( $token ) ) { |
|
| 158 | - if ( ! $this->is_valid_token( $token ) ) { |
|
| 159 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
| 157 | + if ( ! empty($token)) { |
|
| 158 | + if ( ! $this->is_valid_token($token)) { |
|
| 159 | + if ( ! $this->is_valid_verify_key($token)) { |
|
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $this->token_exists = true; |
| 165 | 165 | // Set cookie |
| 166 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
| 167 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
| 166 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
| 167 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -175,18 +175,18 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return bool |
| 177 | 177 | */ |
| 178 | - function is_valid_token( $token ) { |
|
| 178 | + function is_valid_token($token) { |
|
| 179 | 179 | |
| 180 | 180 | global $wpdb; |
| 181 | 181 | |
| 182 | 182 | // Make sure token isn't expired |
| 183 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
| 183 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
| 184 | 184 | |
| 185 | 185 | $email = $wpdb->get_var( |
| 186 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
| 186 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | - if ( ! empty( $email ) ) { |
|
| 189 | + if ( ! empty($email)) { |
|
| 190 | 190 | $this->token_email = $email; |
| 191 | 191 | $this->token = $token; |
| 192 | 192 | |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | //Set error only if email access form isn't being submitted |
| 197 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
| 198 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give' ) ); |
|
| 197 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
| 198 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give')); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -210,25 +210,25 @@ discard block |
||
| 210 | 210 | * @param $email |
| 211 | 211 | * @param $verify_key |
| 212 | 212 | */ |
| 213 | - function set_verify_key( $customer_id, $email, $verify_key ) { |
|
| 213 | + function set_verify_key($customer_id, $email, $verify_key) { |
|
| 214 | 214 | global $wpdb; |
| 215 | 215 | |
| 216 | - $now = date( 'Y-m-d H:i:s' ); |
|
| 216 | + $now = date('Y-m-d H:i:s'); |
|
| 217 | 217 | |
| 218 | 218 | // Insert or update? |
| 219 | 219 | $row_id = (int) $wpdb->get_var( |
| 220 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
| 220 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
| 221 | 221 | ); |
| 222 | 222 | |
| 223 | 223 | // Update |
| 224 | - if ( ! empty( $row_id ) ) { |
|
| 224 | + if ( ! empty($row_id)) { |
|
| 225 | 225 | $wpdb->query( |
| 226 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
| 226 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
| 227 | 227 | ); |
| 228 | 228 | } // Insert |
| 229 | 229 | else { |
| 230 | 230 | $wpdb->query( |
| 231 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
| 231 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
| 232 | 232 | ); |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -240,20 +240,20 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return bool |
| 242 | 242 | */ |
| 243 | - function is_valid_verify_key( $token ) { |
|
| 243 | + function is_valid_verify_key($token) { |
|
| 244 | 244 | global $wpdb; |
| 245 | 245 | |
| 246 | 246 | // See if the verify_key exists |
| 247 | 247 | $row = $wpdb->get_row( |
| 248 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
| 248 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - $now = date( 'Y-m-d H:i:s' ); |
|
| 251 | + $now = date('Y-m-d H:i:s'); |
|
| 252 | 252 | |
| 253 | 253 | // Set token |
| 254 | - if ( ! empty( $row ) ) { |
|
| 254 | + if ( ! empty($row)) { |
|
| 255 | 255 | $wpdb->query( |
| 256 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
| 256 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
| 257 | 257 | ); |
| 258 | 258 | |
| 259 | 259 | $this->token_email = $row->email; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return mixed |
| 274 | 274 | */ |
| 275 | - function users_purchases_args( $args ) { |
|
| 275 | + function users_purchases_args($args) { |
|
| 276 | 276 | $args['user'] = $this->token_email; |
| 277 | 277 | |
| 278 | 278 | return $args; |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | global $wpdb; |
| 290 | 290 | |
| 291 | 291 | //Create columns in customers table |
| 292 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
| 292 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
| 293 | 293 | |
| 294 | 294 | //Columns added properly |
| 295 | - if ( $query ) { |
|
| 296 | - give_update_option( 'email_access_installed', 1 ); |
|
| 295 | + if ($query) { |
|
| 296 | + give_update_option('email_access_installed', 1); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @access private |
| 22 | 22 | * @since 1.0 |
| 23 | 23 | */ |
| 24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
| 24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
| 35 | +function give_process_paypal_purchase($purchase_data) { |
|
| 36 | 36 | |
| 37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 38 | - wp_die( esc_html( 'Nonce verification has failed.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 38 | + wp_die(esc_html('Nonce verification has failed.', 'give'), esc_html('Error', 'give'), array('response' => 403)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
| 41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
| 42 | 42 | $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
| 43 | 43 | |
| 44 | 44 | // Collect payment data |
@@ -57,67 +57,67 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | // Record the pending payment |
| 60 | - $payment = give_insert_payment( $payment_data ); |
|
| 60 | + $payment = give_insert_payment($payment_data); |
|
| 61 | 61 | |
| 62 | 62 | // Check payment |
| 63 | - if ( ! $payment ) { |
|
| 63 | + if ( ! $payment) { |
|
| 64 | 64 | // Record the error |
| 65 | 65 | give_record_gateway_error( |
| 66 | - esc_html( 'Payment Error', 'give' ), |
|
| 66 | + esc_html('Payment Error', 'give'), |
|
| 67 | 67 | sprintf( |
| 68 | 68 | /* translators: %s: payment data */ |
| 69 | - esc_html( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), |
|
| 70 | - json_encode( $payment_data ) |
|
| 69 | + esc_html('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), |
|
| 70 | + json_encode($payment_data) |
|
| 71 | 71 | ), |
| 72 | 72 | $payment |
| 73 | 73 | ); |
| 74 | 74 | // Problems? send back |
| 75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 76 | 76 | } else { |
| 77 | 77 | // Only send to PayPal if the pending payment is created successfully |
| 78 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
| 78 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
| 79 | 79 | |
| 80 | 80 | // Get the success url |
| 81 | - $return_url = add_query_arg( array( |
|
| 81 | + $return_url = add_query_arg(array( |
|
| 82 | 82 | 'payment-confirmation' => 'paypal', |
| 83 | 83 | 'payment-id' => $payment |
| 84 | 84 | |
| 85 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
| 85 | + ), get_permalink(give_get_option('success_page'))); |
|
| 86 | 86 | |
| 87 | 87 | // Get the PayPal redirect uri |
| 88 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
| 88 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
| 89 | 89 | |
| 90 | 90 | //Item name - pass level name if variable priced |
| 91 | 91 | $item_name = $purchase_data['post_data']['give-form-title']; |
| 92 | 92 | |
| 93 | 93 | //Verify has variable prices |
| 94 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
| 94 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
| 95 | 95 | |
| 96 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 96 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 97 | 97 | |
| 98 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
| 98 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
| 99 | 99 | |
| 100 | 100 | //Donation given doesn't match selected level (must be a custom amount) |
| 101 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 102 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 101 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
| 102 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 103 | 103 | //user custom amount text if any, fallback to default if not |
| 104 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html( 'Custom Amount', 'give' ) ); |
|
| 104 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html('Custom Amount', 'give')); |
|
| 105 | 105 | |
| 106 | 106 | } //Is there any donation level text? |
| 107 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
| 108 | - $item_name .= ' - ' . $item_price_level_text; |
|
| 107 | + elseif ( ! empty($item_price_level_text)) { |
|
| 108 | + $item_name .= ' - '.$item_price_level_text; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | } //Single donation: Custom Amount |
| 112 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
| 113 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 112 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
| 113 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 114 | 114 | //user custom amount text if any, fallback to default if not |
| 115 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html( 'Custom Amount', 'give' ) ); |
|
| 115 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html('Custom Amount', 'give')); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Setup PayPal arguments |
| 119 | 119 | $paypal_args = array( |
| 120 | - 'business' => give_get_option( 'paypal_email', false ), |
|
| 120 | + 'business' => give_get_option('paypal_email', false), |
|
| 121 | 121 | 'email' => $purchase_data['user_email'], |
| 122 | 122 | 'invoice' => $purchase_data['purchase_key'], |
| 123 | 123 | 'amount' => $purchase_data['price'], |
@@ -128,25 +128,25 @@ discard block |
||
| 128 | 128 | 'shipping' => '0', |
| 129 | 129 | 'no_note' => '1', |
| 130 | 130 | 'currency_code' => give_get_currency(), |
| 131 | - 'charset' => get_bloginfo( 'charset' ), |
|
| 131 | + 'charset' => get_bloginfo('charset'), |
|
| 132 | 132 | 'custom' => $payment, |
| 133 | 133 | 'rm' => '2', |
| 134 | 134 | 'return' => $return_url, |
| 135 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
| 135 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
| 136 | 136 | 'notify_url' => $listener_url, |
| 137 | 137 | 'page_style' => give_get_paypal_page_style(), |
| 138 | - 'cbt' => get_bloginfo( 'name' ), |
|
| 138 | + 'cbt' => get_bloginfo('name'), |
|
| 139 | 139 | 'bn' => 'givewp_SP' |
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
| 142 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
| 143 | 143 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
| 144 | 144 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
| 145 | 145 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
| 146 | 146 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
| 149 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
| 150 | 150 | $paypal_extra_args = array( |
| 151 | 151 | 'cmd' => '_xclick', |
| 152 | 152 | ); |
@@ -156,23 +156,23 @@ discard block |
||
| 156 | 156 | ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
| 160 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
| 159 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
| 160 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
| 161 | 161 | |
| 162 | 162 | // Build query |
| 163 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
| 163 | + $paypal_redirect .= http_build_query($paypal_args); |
|
| 164 | 164 | |
| 165 | 165 | // Fix for some sites that encode the entities |
| 166 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
| 166 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
| 167 | 167 | |
| 168 | 168 | // Redirect to PayPal |
| 169 | - wp_redirect( $paypal_redirect ); |
|
| 169 | + wp_redirect($paypal_redirect); |
|
| 170 | 170 | exit; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
| 175 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -182,12 +182,12 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | function give_listen_for_paypal_ipn() { |
| 184 | 184 | // Regular PayPal IPN |
| 185 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
| 186 | - do_action( 'give_verify_paypal_ipn' ); |
|
| 185 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
| 186 | + do_action('give_verify_paypal_ipn'); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
| 190 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | 193 | * Process PayPal IPN |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | function give_process_paypal_ipn() { |
| 199 | 199 | |
| 200 | 200 | // Check the request method is POST |
| 201 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 201 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | $post_data = ''; |
| 207 | 207 | |
| 208 | 208 | // Fallback just in case post_max_size is lower than needed |
| 209 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 210 | - $post_data = file_get_contents( 'php://input' ); |
|
| 209 | + if (ini_get('allow_url_fopen')) { |
|
| 210 | + $post_data = file_get_contents('php://input'); |
|
| 211 | 211 | } else { |
| 212 | 212 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
| 213 | - ini_set( 'post_max_size', '12M' ); |
|
| 213 | + ini_set('post_max_size', '12M'); |
|
| 214 | 214 | } |
| 215 | 215 | // Start the encoded data collection with notification command |
| 216 | 216 | $encoded_data = 'cmd=_notify-validate'; |
@@ -219,40 +219,40 @@ discard block |
||
| 219 | 219 | $arg_separator = give_get_php_arg_separator_output(); |
| 220 | 220 | |
| 221 | 221 | // Verify there is a post_data |
| 222 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 222 | + if ($post_data || strlen($post_data) > 0) { |
|
| 223 | 223 | // Append the data |
| 224 | - $encoded_data .= $arg_separator . $post_data; |
|
| 224 | + $encoded_data .= $arg_separator.$post_data; |
|
| 225 | 225 | } else { |
| 226 | 226 | // Check if POST is empty |
| 227 | - if ( empty( $_POST ) ) { |
|
| 227 | + if (empty($_POST)) { |
|
| 228 | 228 | // Nothing to do |
| 229 | 229 | return; |
| 230 | 230 | } else { |
| 231 | 231 | // Loop through each POST |
| 232 | - foreach ( $_POST as $key => $value ) { |
|
| 232 | + foreach ($_POST as $key => $value) { |
|
| 233 | 233 | // Encode the value and append the data |
| 234 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 234 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Convert collected post data to an array |
| 240 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 240 | + parse_str($encoded_data, $encoded_data_array); |
|
| 241 | 241 | |
| 242 | - foreach ( $encoded_data_array as $key => $value ) { |
|
| 242 | + foreach ($encoded_data_array as $key => $value) { |
|
| 243 | 243 | |
| 244 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 245 | - $new_key = str_replace( '&', '&', $key ); |
|
| 246 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
| 244 | + if (false !== strpos($key, 'amp;')) { |
|
| 245 | + $new_key = str_replace('&', '&', $key); |
|
| 246 | + $new_key = str_replace('amp;', '&', $new_key); |
|
| 247 | 247 | |
| 248 | - unset( $encoded_data_array[ $key ] ); |
|
| 249 | - $encoded_data_array[ $new_key ] = $value; |
|
| 248 | + unset($encoded_data_array[$key]); |
|
| 249 | + $encoded_data_array[$new_key] = $value; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
| 255 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
| 255 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
| 256 | 256 | |
| 257 | 257 | $remote_post_vars = array( |
| 258 | 258 | 'method' => 'POST', |
@@ -272,27 +272,27 @@ discard block |
||
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | 274 | // Validate the IPN |
| 275 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
| 275 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
| 276 | 276 | |
| 277 | - if ( is_wp_error( $api_response ) ) { |
|
| 277 | + if (is_wp_error($api_response)) { |
|
| 278 | 278 | give_record_gateway_error( |
| 279 | - esc_html( 'IPN Error', 'give' ), |
|
| 279 | + esc_html('IPN Error', 'give'), |
|
| 280 | 280 | sprintf( |
| 281 | 281 | /* translators: %s: Paypal IPN response */ |
| 282 | - esc_html( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 283 | - json_encode( $api_response ) |
|
| 282 | + esc_html('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 283 | + json_encode($api_response) |
|
| 284 | 284 | ) |
| 285 | 285 | ); |
| 286 | 286 | return; // Something went wrong |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
| 289 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
| 290 | 290 | give_record_gateway_error( |
| 291 | - esc_html( 'IPN Error', 'give' ), |
|
| 291 | + esc_html('IPN Error', 'give'), |
|
| 292 | 292 | sprintf( |
| 293 | 293 | /* translators: %s: Paypal IPN response */ |
| 294 | - esc_html( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
| 295 | - json_encode( $api_response ) |
|
| 294 | + esc_html('Invalid IPN verification response. IPN data: %s', 'give'), |
|
| 295 | + json_encode($api_response) |
|
| 296 | 296 | ) |
| 297 | 297 | ); |
| 298 | 298 | return; // Response not okay |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // Check if $post_data_array has been populated |
| 304 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
| 304 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
| 305 | 305 | return; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -310,21 +310,21 @@ discard block |
||
| 310 | 310 | 'payment_status' => '' |
| 311 | 311 | ); |
| 312 | 312 | |
| 313 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 313 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
| 314 | 314 | |
| 315 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 315 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
| 316 | 316 | |
| 317 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
| 317 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
| 318 | 318 | // Allow PayPal IPN types to be processed separately |
| 319 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
| 319 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
| 320 | 320 | } else { |
| 321 | 321 | // Fallback to web accept just in case the txn_type isn't present |
| 322 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
| 322 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
| 323 | 323 | } |
| 324 | 324 | exit; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
| 327 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | 330 | * Process web accept (one time) payment IPNs |
@@ -335,224 +335,224 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return void |
| 337 | 337 | */ |
| 338 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
| 338 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
| 339 | 339 | |
| 340 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
| 340 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
| 341 | 341 | return; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if ( empty( $payment_id ) ) { |
|
| 344 | + if (empty($payment_id)) { |
|
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Collect payment details |
| 349 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
| 349 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
| 350 | 350 | $paypal_amount = $data['mc_gross']; |
| 351 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 352 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 353 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 354 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 351 | + $payment_status = strtolower($data['payment_status']); |
|
| 352 | + $currency_code = strtolower($data['mc_currency']); |
|
| 353 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
| 354 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 355 | 355 | |
| 356 | 356 | |
| 357 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
| 357 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
| 358 | 358 | return; // this isn't a PayPal standard IPN |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | // Verify payment recipient |
| 362 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
| 362 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
| 363 | 363 | |
| 364 | 364 | give_record_gateway_error( |
| 365 | - esc_html( 'IPN Error', 'give' ), |
|
| 365 | + esc_html('IPN Error', 'give'), |
|
| 366 | 366 | sprintf( |
| 367 | 367 | /* translators: %s: Paypal IPN response */ |
| 368 | - esc_html( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
| 369 | - json_encode( $data ) |
|
| 368 | + esc_html('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
| 369 | + json_encode($data) |
|
| 370 | 370 | ), |
| 371 | 371 | $payment_id |
| 372 | 372 | ); |
| 373 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 374 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
| 373 | + give_update_payment_status($payment_id, 'failed'); |
|
| 374 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid PayPal business email.', 'give')); |
|
| 375 | 375 | |
| 376 | 376 | return; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Verify payment currency |
| 380 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
| 380 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
| 381 | 381 | |
| 382 | 382 | give_record_gateway_error( |
| 383 | - esc_html( 'IPN Error', 'give' ), |
|
| 383 | + esc_html('IPN Error', 'give'), |
|
| 384 | 384 | sprintf( |
| 385 | 385 | /* translators: %s: Paypal IPN response */ |
| 386 | - esc_html( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
| 387 | - json_encode( $data ) |
|
| 386 | + esc_html('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
| 387 | + json_encode($data) |
|
| 388 | 388 | ), |
| 389 | 389 | $payment_id |
| 390 | 390 | ); |
| 391 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 392 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
| 391 | + give_update_payment_status($payment_id, 'failed'); |
|
| 392 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
| 393 | 393 | |
| 394 | 394 | return; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
| 397 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
| 398 | 398 | |
| 399 | 399 | // No email associated with purchase, so store from PayPal |
| 400 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
| 400 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
| 401 | 401 | |
| 402 | 402 | // Setup and store the donors's details |
| 403 | 403 | $address = array(); |
| 404 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
| 405 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
| 406 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
| 407 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
| 408 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
| 404 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
| 405 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
| 406 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
| 407 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
| 408 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
| 409 | 409 | |
| 410 | 410 | $user_info = array( |
| 411 | 411 | 'id' => '-1', |
| 412 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
| 413 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
| 414 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
| 412 | + 'email' => sanitize_text_field($data['payer_email']), |
|
| 413 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
| 414 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
| 415 | 415 | 'discount' => '', |
| 416 | 416 | 'address' => $address |
| 417 | 417 | ); |
| 418 | 418 | |
| 419 | 419 | $payment_meta['user_info'] = $user_info; |
| 420 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
| 420 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 423 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
| 424 | 424 | |
| 425 | 425 | // Process a refund |
| 426 | - give_process_paypal_refund( $data, $payment_id ); |
|
| 426 | + give_process_paypal_refund($data, $payment_id); |
|
| 427 | 427 | |
| 428 | 428 | } else { |
| 429 | 429 | |
| 430 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
| 430 | + if (get_post_status($payment_id) == 'publish') { |
|
| 431 | 431 | return; // Only complete payments once |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // Retrieve the total purchase amount (before PayPal) |
| 435 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 435 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 436 | 436 | |
| 437 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 437 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 438 | 438 | // The prices don't match |
| 439 | 439 | give_record_gateway_error( |
| 440 | - esc_html( 'IPN Error', 'give' ), |
|
| 440 | + esc_html('IPN Error', 'give'), |
|
| 441 | 441 | sprintf( |
| 442 | 442 | /* translators: %s: Paypal IPN response */ |
| 443 | - esc_html( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
| 444 | - json_encode( $data ) |
|
| 443 | + esc_html('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
| 444 | + json_encode($data) |
|
| 445 | 445 | ), |
| 446 | 446 | $payment_id |
| 447 | 447 | ); |
| 448 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 449 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
| 448 | + give_update_payment_status($payment_id, 'failed'); |
|
| 449 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
| 450 | 450 | |
| 451 | 451 | return; |
| 452 | 452 | } |
| 453 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
| 453 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
| 454 | 454 | // Purchase keys don't match |
| 455 | 455 | give_record_gateway_error( |
| 456 | - esc_html( 'IPN Error', 'give' ), |
|
| 456 | + esc_html('IPN Error', 'give'), |
|
| 457 | 457 | sprintf( |
| 458 | 458 | /* translators: %s: Paypal IPN response */ |
| 459 | - esc_html( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), |
|
| 460 | - json_encode( $data ) |
|
| 459 | + esc_html('Invalid purchase key in IPN response. IPN data: %s', 'give'), |
|
| 460 | + json_encode($data) |
|
| 461 | 461 | ), |
| 462 | 462 | $payment_id |
| 463 | 463 | ); |
| 464 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 465 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
| 464 | + give_update_payment_status($payment_id, 'failed'); |
|
| 465 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
| 466 | 466 | |
| 467 | 467 | return; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
| 470 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
| 471 | 471 | give_insert_payment_note( |
| 472 | 472 | $payment_id, |
| 473 | 473 | sprintf( |
| 474 | 474 | /* translators: %s: Paypal transaction ID */ |
| 475 | - esc_html( 'PayPal Transaction ID: %s', 'give' ), |
|
| 475 | + esc_html('PayPal Transaction ID: %s', 'give'), |
|
| 476 | 476 | $data['txn_id'] |
| 477 | 477 | ) |
| 478 | 478 | ); |
| 479 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
| 480 | - give_update_payment_status( $payment_id, 'publish' ); |
|
| 481 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 479 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
| 480 | + give_update_payment_status($payment_id, 'publish'); |
|
| 481 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
| 482 | 482 | |
| 483 | 483 | // Look for possible pending reasons, such as an echeck |
| 484 | 484 | |
| 485 | 485 | $note = ''; |
| 486 | 486 | |
| 487 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
| 487 | + switch (strtolower($data['pending_reason'])) { |
|
| 488 | 488 | |
| 489 | 489 | case 'echeck' : |
| 490 | 490 | |
| 491 | - $note = esc_html( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
| 491 | + $note = esc_html('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
| 492 | 492 | |
| 493 | 493 | break; |
| 494 | 494 | |
| 495 | 495 | case 'address' : |
| 496 | 496 | |
| 497 | - $note = esc_html( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
| 497 | + $note = esc_html('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
| 498 | 498 | |
| 499 | 499 | break; |
| 500 | 500 | |
| 501 | 501 | case 'intl' : |
| 502 | 502 | |
| 503 | - $note = esc_html( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
| 503 | + $note = esc_html('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
| 504 | 504 | |
| 505 | 505 | break; |
| 506 | 506 | |
| 507 | 507 | case 'multi-currency' : |
| 508 | 508 | |
| 509 | - $note = esc_html( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
| 509 | + $note = esc_html('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
| 510 | 510 | |
| 511 | 511 | break; |
| 512 | 512 | |
| 513 | 513 | case 'paymentreview' : |
| 514 | 514 | case 'regulatory_review' : |
| 515 | 515 | |
| 516 | - $note = esc_html( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
| 516 | + $note = esc_html('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
| 517 | 517 | |
| 518 | 518 | break; |
| 519 | 519 | |
| 520 | 520 | case 'unilateral' : |
| 521 | 521 | |
| 522 | - $note = esc_html( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
| 522 | + $note = esc_html('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
| 523 | 523 | |
| 524 | 524 | break; |
| 525 | 525 | |
| 526 | 526 | case 'upgrade' : |
| 527 | 527 | |
| 528 | - $note = esc_html( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
| 528 | + $note = esc_html('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
| 529 | 529 | |
| 530 | 530 | break; |
| 531 | 531 | |
| 532 | 532 | case 'verify' : |
| 533 | 533 | |
| 534 | - $note = esc_html( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' ); |
|
| 534 | + $note = esc_html('PayPal account is not verified. Verify account in order to accept this payment.', 'give'); |
|
| 535 | 535 | |
| 536 | 536 | break; |
| 537 | 537 | |
| 538 | 538 | case 'other' : |
| 539 | 539 | |
| 540 | - $note = esc_html( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
| 540 | + $note = esc_html('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
| 541 | 541 | |
| 542 | 542 | break; |
| 543 | 543 | |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - if ( ! empty( $note ) ) { |
|
| 546 | + if ( ! empty($note)) { |
|
| 547 | 547 | |
| 548 | - give_insert_payment_note( $payment_id, $note ); |
|
| 548 | + give_insert_payment_note($payment_id, $note); |
|
| 549 | 549 | |
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
| 555 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | 558 | * Process PayPal IPN Refunds |
@@ -563,28 +563,28 @@ discard block |
||
| 563 | 563 | * |
| 564 | 564 | * @return void |
| 565 | 565 | */ |
| 566 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
| 566 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
| 567 | 567 | |
| 568 | 568 | // Collect payment details |
| 569 | 569 | |
| 570 | - if ( empty( $payment_id ) ) { |
|
| 570 | + if (empty($payment_id)) { |
|
| 571 | 571 | return; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
| 574 | + if (get_post_status($payment_id) == 'refunded') { |
|
| 575 | 575 | return; // Only refund payments once |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 578 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 579 | 579 | $refund_amount = $data['payment_gross'] * - 1; |
| 580 | 580 | |
| 581 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 581 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 582 | 582 | |
| 583 | 583 | give_insert_payment_note( |
| 584 | 584 | $payment_id, |
| 585 | 585 | sprintf( |
| 586 | 586 | /* translators: %s: Paypal parent transaction ID */ |
| 587 | - esc_html( 'Partial PayPal refund processed: %s', 'give' ), |
|
| 587 | + esc_html('Partial PayPal refund processed: %s', 'give'), |
|
| 588 | 588 | $data['parent_txn_id'] |
| 589 | 589 | ) |
| 590 | 590 | ); |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | $payment_id, |
| 598 | 598 | sprintf( |
| 599 | 599 | /* translators: %s: Paypal parent transaction ID */ |
| 600 | - esc_html( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), |
|
| 600 | + esc_html('PayPal Payment #%s Refunded for reason: %s', 'give'), |
|
| 601 | 601 | $data['parent_txn_id'], $data['reason_code'] |
| 602 | 602 | ) |
| 603 | 603 | ); |
@@ -605,11 +605,11 @@ discard block |
||
| 605 | 605 | $payment_id, |
| 606 | 606 | sprintf( |
| 607 | 607 | /* translators: %s: Paypal transaction ID */ |
| 608 | - esc_html( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
| 608 | + esc_html('PayPal Refund Transaction ID: %s', 'give'), |
|
| 609 | 609 | $data['txn_id'] |
| 610 | 610 | ) |
| 611 | 611 | ); |
| 612 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
| 612 | + give_update_payment_status($payment_id, 'refunded'); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -621,24 +621,24 @@ discard block |
||
| 621 | 621 | * |
| 622 | 622 | * @return string |
| 623 | 623 | */ |
| 624 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
| 624 | +function give_get_paypal_redirect($ssl_check = false) { |
|
| 625 | 625 | |
| 626 | - if ( is_ssl() || ! $ssl_check ) { |
|
| 626 | + if (is_ssl() || ! $ssl_check) { |
|
| 627 | 627 | $protocal = 'https://'; |
| 628 | 628 | } else { |
| 629 | 629 | $protocal = 'http://'; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Check the current payment mode |
| 633 | - if ( give_is_test_mode() ) { |
|
| 633 | + if (give_is_test_mode()) { |
|
| 634 | 634 | // Test mode |
| 635 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 635 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 636 | 636 | } else { |
| 637 | 637 | // Live mode |
| 638 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
| 638 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
| 641 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -648,8 +648,8 @@ discard block |
||
| 648 | 648 | * @return string |
| 649 | 649 | */ |
| 650 | 650 | function give_get_paypal_page_style() { |
| 651 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
| 652 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
| 651 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
| 652 | + return apply_filters('give_paypal_page_style', $page_style); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | /** |
@@ -664,27 +664,27 @@ discard block |
||
| 664 | 664 | * @return string |
| 665 | 665 | * |
| 666 | 666 | */ |
| 667 | -function give_paypal_success_page_content( $content ) { |
|
| 667 | +function give_paypal_success_page_content($content) { |
|
| 668 | 668 | |
| 669 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
| 669 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
| 670 | 670 | return $content; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
| 673 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
| 674 | 674 | |
| 675 | - if ( ! $payment_id ) { |
|
| 675 | + if ( ! $payment_id) { |
|
| 676 | 676 | $session = give_get_purchase_session(); |
| 677 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
| 677 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - $payment = get_post( $payment_id ); |
|
| 680 | + $payment = get_post($payment_id); |
|
| 681 | 681 | |
| 682 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
| 682 | + if ($payment && 'pending' == $payment->post_status) { |
|
| 683 | 683 | |
| 684 | 684 | // Payment is still pending so show processing indicator to fix the Race Condition |
| 685 | 685 | ob_start(); |
| 686 | 686 | |
| 687 | - give_get_template_part( 'payment', 'processing' ); |
|
| 687 | + give_get_template_part('payment', 'processing'); |
|
| 688 | 688 | |
| 689 | 689 | $content = ob_get_clean(); |
| 690 | 690 | |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
| 697 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
| 698 | 698 | |
| 699 | 699 | /** |
| 700 | 700 | * Given a Payment ID, extract the transaction ID |
@@ -705,22 +705,22 @@ discard block |
||
| 705 | 705 | * |
| 706 | 706 | * @return string Transaction ID |
| 707 | 707 | */ |
| 708 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
| 708 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
| 709 | 709 | |
| 710 | 710 | $transaction_id = ''; |
| 711 | - $notes = give_get_payment_notes( $payment_id ); |
|
| 711 | + $notes = give_get_payment_notes($payment_id); |
|
| 712 | 712 | |
| 713 | - foreach ( $notes as $note ) { |
|
| 714 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
| 713 | + foreach ($notes as $note) { |
|
| 714 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
| 715 | 715 | $transaction_id = $match[1]; |
| 716 | 716 | continue; |
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 720 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
| 723 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | 726 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -732,13 +732,13 @@ discard block |
||
| 732 | 732 | * |
| 733 | 733 | * @return string A link to the PayPal transaction details |
| 734 | 734 | */ |
| 735 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
| 735 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
| 736 | 736 | |
| 737 | 737 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
| 738 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
| 738 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
| 739 | 739 | |
| 740 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
| 740 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
| 741 | 741 | |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
| 744 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 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 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @since 1.0 |
| 21 | 21 | * @return void |
| 22 | 22 | */ |
| 23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
| 23 | +add_action('give_manual_cc_form', '__return_false'); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | -function give_manual_payment( $purchase_data ) { |
|
| 35 | +function give_manual_payment($purchase_data) { |
|
| 36 | 36 | |
| 37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
| 38 | - wp_die( esc_html( 'Nonce verification has failed', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
| 38 | + wp_die(esc_html('Nonce verification has failed', 'give'), esc_html('Error', 'give'), array('response' => 403)); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | //Create payment_data array |
| 42 | 42 | $payment_data = array( |
| 43 | 43 | 'price' => $purchase_data['price'], |
| 44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
| 45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
| 45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
| 46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
| 47 | 47 | 'date' => $purchase_data['date'], |
| 48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | 'status' => 'pending' |
| 53 | 53 | ); |
| 54 | 54 | // Record the pending payment |
| 55 | - $payment = give_insert_payment( $payment_data ); |
|
| 55 | + $payment = give_insert_payment($payment_data); |
|
| 56 | 56 | |
| 57 | - if ( $payment ) { |
|
| 58 | - give_update_payment_status( $payment, 'publish' ); |
|
| 57 | + if ($payment) { |
|
| 58 | + give_update_payment_status($payment, 'publish'); |
|
| 59 | 59 | give_send_to_success_page(); |
| 60 | 60 | } else { |
| 61 | 61 | give_record_gateway_error( |
| 62 | - esc_html( 'Payment Error', 'give' ), |
|
| 62 | + esc_html('Payment Error', 'give'), |
|
| 63 | 63 | sprintf( |
| 64 | 64 | /* translators: %s: payment data */ |
| 65 | - esc_html( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
| 66 | - json_encode( $payment_data ) |
|
| 65 | + esc_html('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
| 66 | + json_encode($payment_data) |
|
| 67 | 67 | ), |
| 68 | 68 | $payment |
| 69 | 69 | ); |
| 70 | 70 | // If errors are present, send the user back to the purchase page so they can be corrected |
| 71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
| 75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
|
@@ -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 | |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param $data |
| 23 | 23 | */ |
| 24 | -function give_process_gateway_select( $data ) { |
|
| 25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
| 26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
| 24 | +function give_process_gateway_select($data) { |
|
| 25 | + if (isset($_POST['gateway_submit'])) { |
|
| 26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
| 27 | 27 | exit; |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
| 31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Loads a payment gateway via AJAX |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * @return void |
| 38 | 38 | */ |
| 39 | 39 | function give_load_ajax_gateway() { |
| 40 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
| 41 | - do_action( 'give_purchase_form', $_POST['give_form_id'] ); |
|
| 40 | + if (isset($_POST['give_payment_mode'])) { |
|
| 41 | + do_action('give_purchase_form', $_POST['give_form_id']); |
|
| 42 | 42 | exit(); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 47 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 46 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 47 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * Sets an error on checkout if no gateways are enabled |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | function give_no_gateway_error() { |
| 56 | 56 | $gateways = give_get_enabled_payment_gateways(); |
| 57 | 57 | |
| 58 | - if ( empty( $gateways ) ) { |
|
| 59 | - give_set_error( 'no_gateways', esc_html( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
| 58 | + if (empty($gateways)) { |
|
| 59 | + give_set_error('no_gateways', esc_html('You must enable a payment gateway to use Give.', 'give')); |
|
| 60 | 60 | } else { |
| 61 | - give_unset_error( 'no_gateways' ); |
|
| 61 | + give_unset_error('no_gateways'); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -add_action( 'init', 'give_no_gateway_error' ); |
|
| 66 | 65 | \ No newline at end of file |
| 66 | +add_action('init', 'give_no_gateway_error'); |
|
| 67 | 67 | \ No newline at end of file |