@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @since 1.0 |
| 21 | 21 | */ |
| 22 | -class Give_Forms_Widget extends WP_Widget{ |
|
| 22 | +class Give_Forms_Widget extends WP_Widget { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * The widget class name |
@@ -31,19 +31,19 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * Instantiate the class |
| 33 | 33 | */ |
| 34 | - public function __construct(){ |
|
| 35 | - $this->self = get_class( $this ); |
|
| 34 | + public function __construct() { |
|
| 35 | + $this->self = get_class($this); |
|
| 36 | 36 | |
| 37 | 37 | parent::__construct( |
| 38 | - strtolower( $this->self ), |
|
| 39 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
| 38 | + strtolower($this->self), |
|
| 39 | + esc_html__('Give - Donation Form', 'give'), |
|
| 40 | 40 | array( |
| 41 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
| 41 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
| 42 | 42 | ) |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
| 46 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
| 45 | + add_action('widgets_init', array($this, 'widget_init')); |
|
| 46 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -53,19 +53,19 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return void |
| 55 | 55 | */ |
| 56 | - public function admin_widget_scripts( $hook ){ |
|
| 56 | + public function admin_widget_scripts($hook) { |
|
| 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 ( 'widgets.php' === $hook ) { |
|
| 66 | + if ('widgets.php' === $hook) { |
|
| 67 | 67 | |
| 68 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 68 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * before_widget, and after_widget. |
| 77 | 77 | * @param array $instance The settings for the particular instance of the widget. |
| 78 | 78 | */ |
| 79 | - public function widget( $args, $instance ){ |
|
| 80 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
| 81 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 79 | + public function widget($args, $instance) { |
|
| 80 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 81 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
| 82 | 82 | |
| 83 | 83 | echo $args['before_widget']; |
| 84 | 84 | |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @since 1.0 |
| 89 | 89 | */ |
| 90 | - do_action( 'give_before_forms_widget' ); |
|
| 90 | + do_action('give_before_forms_widget'); |
|
| 91 | 91 | |
| 92 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
| 92 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
| 93 | 93 | |
| 94 | - give_get_donation_form( $instance ); |
|
| 94 | + give_get_donation_form($instance); |
|
| 95 | 95 | |
| 96 | 96 | echo $args['after_widget']; |
| 97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @since 1.0 |
| 102 | 102 | */ |
| 103 | - do_action( 'give_after_forms_widget' ); |
|
| 103 | + do_action('give_after_forms_widget'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public function form( $instance ){ |
|
| 113 | + public function form($instance) { |
|
| 114 | 114 | $defaults = array( |
| 115 | 115 | 'title' => '', |
| 116 | 116 | 'id' => '', |
@@ -120,84 +120,84 @@ discard block |
||
| 120 | 120 | 'continue_button_title' => '', |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 123 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 124 | 124 | |
| 125 | 125 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
| 126 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
| 126 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
| 127 | 127 | |
| 128 | 128 | // Query Give Forms |
| 129 | 129 | $args = array( |
| 130 | 130 | 'post_type' => 'give_forms', |
| 131 | - 'posts_per_page' => - 1, |
|
| 131 | + 'posts_per_page' => -1, |
|
| 132 | 132 | 'post_status' => 'publish', |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - $give_forms = get_posts( $args ); |
|
| 135 | + $give_forms = get_posts($args); |
|
| 136 | 136 | ?> |
| 137 | 137 | <div class="give_forms_widget_container"> |
| 138 | 138 | |
| 139 | 139 | <?php // Widget: widget Title. ?> |
| 140 | 140 | <p> |
| 141 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
| 142 | - <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( $instance['title'] ); ?>" /><br> |
|
| 143 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
| 141 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
| 142 | + <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($instance['title']); ?>" /><br> |
|
| 143 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
| 144 | 144 | </p> |
| 145 | 145 | |
| 146 | 146 | <?php // Widget: Give Form?> |
| 147 | 147 | <p> |
| 148 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
| 149 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
| 150 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
| 151 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
| 152 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
| 153 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option> |
|
| 148 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
| 149 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
| 150 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
| 151 | + <?php foreach ($give_forms as $give_form) { ?> |
|
| 152 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
| 153 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option> |
|
| 154 | 154 | <?php } ?> |
| 155 | 155 | </select><br> |
| 156 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
| 156 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
| 157 | 157 | </p> |
| 158 | 158 | |
| 159 | 159 | <?php // Widget: Display Style ?> |
| 160 | 160 | <p class="give_forms_display_style_setting_row"> |
| 161 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
| 162 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
| 163 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
| 164 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
| 165 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
| 161 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
| 162 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
| 163 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
| 164 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
| 165 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
| 166 | 166 | <small class="give-field-description"> |
| 167 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
| 167 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
| 168 | 168 | </small> |
| 169 | 169 | </p> |
| 170 | 170 | |
| 171 | 171 | <?php // Widget: Continue Button Title. ?> |
| 172 | 172 | <p class="give_forms_continue_button_title_setting_row"> |
| 173 | - <label for="<?php echo $this->get_field_id( 'continue_button_title' ); ?>"><?php esc_html_e( 'Button Text:', 'give' ); ?></label> |
|
| 174 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'continue_button_title' ); ?>" name="<?php echo $this->get_field_name( 'continue_button_title' ); ?>" value="<?php esc_attr_e( $instance['continue_button_title'] ); ?>" /><br> |
|
| 175 | - <small class="give-field-description"><?php esc_html_e( 'The button label for displaying the additional payment fields.', 'give' ); ?></small> |
|
| 173 | + <label for="<?php echo $this->get_field_id('continue_button_title'); ?>"><?php esc_html_e('Button Text:', 'give'); ?></label> |
|
| 174 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('continue_button_title'); ?>" name="<?php echo $this->get_field_name('continue_button_title'); ?>" value="<?php esc_attr_e($instance['continue_button_title']); ?>" /><br> |
|
| 175 | + <small class="give-field-description"><?php esc_html_e('The button label for displaying the additional payment fields.', 'give'); ?></small> |
|
| 176 | 176 | </p> |
| 177 | 177 | |
| 178 | 178 | <?php // Widget: Floating Labels ?> |
| 179 | 179 | <p> |
| 180 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
| 181 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
| 182 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
| 183 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
| 180 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
| 181 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
| 182 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
| 183 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
| 184 | 184 | <small class="give-field-description"> |
| 185 | 185 | <?php |
| 186 | 186 | printf( |
| 187 | 187 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
| 188 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
| 189 | - esc_url( 'http://docs.givewp.com/form-floating-labels' ) |
|
| 188 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
| 189 | + esc_url('http://docs.givewp.com/form-floating-labels') |
|
| 190 | 190 | ); |
| 191 | 191 | ?></small> |
| 192 | 192 | </p> |
| 193 | 193 | |
| 194 | 194 | <?php // Widget: Display Content ?> |
| 195 | 195 | <p> |
| 196 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
| 197 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
| 198 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
| 199 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
| 200 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
| 196 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
| 197 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
| 198 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
| 199 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
| 200 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
| 201 | 201 | </div> |
| 202 | 202 | <?php |
| 203 | 203 | } |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return void |
| 209 | 209 | */ |
| 210 | - function widget_init(){ |
|
| 211 | - register_widget( $this->self ); |
|
| 210 | + function widget_init() { |
|
| 211 | + register_widget($this->self); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return array |
| 221 | 221 | */ |
| 222 | - public function update( $new_instance, $old_instance ){ |
|
| 222 | + public function update($new_instance, $old_instance) { |
|
| 223 | 223 | $this->flush_widget_cache(); |
| 224 | 224 | |
| 225 | 225 | return $new_instance; |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | * |
| 231 | 231 | * @return void |
| 232 | 232 | */ |
| 233 | - public function flush_widget_cache(){ |
|
| 234 | - wp_cache_delete( $this->self, 'widget' ); |
|
| 233 | + public function flush_widget_cache() { |
|
| 234 | + wp_cache_delete($this->self, 'widget'); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @category Class |
| 12 | 12 | * @author WordImpress |
| 13 | 13 | */ |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | * Updater will still run via cron job if this fails for any reason. |
| 32 | 32 | */ |
| 33 | 33 | public function dispatch() { |
| 34 | - if ( give_test_ajax_works() ) { |
|
| 34 | + if (give_test_ajax_works()) { |
|
| 35 | 35 | parent::dispatch(); |
| 36 | - } elseif ( wp_doing_ajax() ) { |
|
| 36 | + } elseif (wp_doing_ajax()) { |
|
| 37 | 37 | $this->maybe_handle(); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | 60 | public function has_queue() { |
| 61 | - return ( ! parent::is_queue_empty() ); |
|
| 61 | + return ( ! parent::is_queue_empty()); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | protected function lock_process() { |
| 76 | 76 | // Check if admin want to pause upgrade. |
| 77 | - if( get_option('give_pause_upgrade') ) { |
|
| 77 | + if (get_option('give_pause_upgrade')) { |
|
| 78 | 78 | self::flush_cache(); |
| 79 | 79 | |
| 80 | - delete_option( 'give_paused_batches' ); |
|
| 80 | + delete_option('give_paused_batches'); |
|
| 81 | 81 | |
| 82 | - Give_Updates::get_instance()->__pause_db_update( true ); |
|
| 82 | + Give_Updates::get_instance()->__pause_db_update(true); |
|
| 83 | 83 | |
| 84 | 84 | delete_option('give_pause_upgrade'); |
| 85 | 85 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @since 2.0.1 |
| 90 | 90 | */ |
| 91 | - do_action( 'give_pause_db_upgrade', Give_Updates::get_instance() ); |
|
| 91 | + do_action('give_pause_db_upgrade', Give_Updates::get_instance()); |
|
| 92 | 92 | |
| 93 | 93 | wp_die(); |
| 94 | 94 | } |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $this->start_time = time(); // Set start time of current process. |
| 98 | 98 | |
| 99 | - $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute |
|
| 100 | - $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); |
|
| 99 | + $lock_duration = (property_exists($this, 'queue_lock_time')) ? $this->queue_lock_time : 60; // 1 minute |
|
| 100 | + $lock_duration = apply_filters($this->identifier.'_queue_lock_time', $lock_duration); |
|
| 101 | 101 | |
| 102 | - set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); |
|
| 102 | + set_site_transient($this->identifier.'_process_lock', microtime(), $lock_duration); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | * and data exists in the queue. |
| 110 | 110 | */ |
| 111 | 111 | public function handle_cron_healthcheck() { |
| 112 | - if ( $this->is_process_running() || $this->is_paused_process() ) { |
|
| 112 | + if ($this->is_process_running() || $this->is_paused_process()) { |
|
| 113 | 113 | // Background process already running. |
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $this->is_queue_empty() ) { |
|
| 117 | + if ($this->is_queue_empty()) { |
|
| 118 | 118 | // No data to process. |
| 119 | 119 | $this->clear_scheduled_event(); |
| 120 | 120 | |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | * Schedule fallback event. |
| 129 | 129 | */ |
| 130 | 130 | protected function schedule_event() { |
| 131 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) && ! $this->is_paused_process() ) { |
|
| 132 | - wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
| 131 | + if ( ! wp_next_scheduled($this->cron_hook_identifier) && ! $this->is_paused_process()) { |
|
| 132 | + wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -145,13 +145,13 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return mixed |
| 147 | 147 | */ |
| 148 | - protected function task( $update ) { |
|
| 148 | + protected function task($update) { |
|
| 149 | 149 | // Pause upgrade immediately if admin pausing upgrades. |
| 150 | - if( $this->is_paused_process() ) { |
|
| 150 | + if ($this->is_paused_process()) { |
|
| 151 | 151 | wp_die(); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ( empty( $update ) ) { |
|
| 154 | + if (empty($update)) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | 'update_info' => $update, |
| 169 | 169 | 'step' => 1, |
| 170 | 170 | 'update' => 1, |
| 171 | - 'heading' => sprintf( 'Update %s of {update_count}', 1 ), |
|
| 171 | + 'heading' => sprintf('Update %s of {update_count}', 1), |
|
| 172 | 172 | 'percentage' => $give_updates->percentage, |
| 173 | 173 | 'total_percentage' => 0, |
| 174 | 174 | ) |
@@ -177,22 +177,22 @@ discard block |
||
| 177 | 177 | // Continuously skip update if previous update does not complete yet. |
| 178 | 178 | if ( |
| 179 | 179 | $resume_update['update_info']['id'] !== $update['id'] && |
| 180 | - ! give_has_upgrade_completed( $resume_update['update_info']['id'] ) |
|
| 180 | + ! give_has_upgrade_completed($resume_update['update_info']['id']) |
|
| 181 | 181 | ) { |
| 182 | 182 | return $update; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Set params. |
| 186 | 186 | $resume_update['update_info'] = $update; |
| 187 | - $give_updates->step = absint( $resume_update['step'] ); |
|
| 188 | - $give_updates->update = absint( $resume_update['update'] ); |
|
| 189 | - $is_parent_update_completed = $give_updates->is_parent_updates_completed( $update ); |
|
| 187 | + $give_updates->step = absint($resume_update['step']); |
|
| 188 | + $give_updates->update = absint($resume_update['update']); |
|
| 189 | + $is_parent_update_completed = $give_updates->is_parent_updates_completed($update); |
|
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | // Skip update if dependency update does not complete yet. |
| 193 | - if ( empty( $is_parent_update_completed ) ) { |
|
| 193 | + if (empty($is_parent_update_completed)) { |
|
| 194 | 194 | // @todo: set error when you have only one update with invalid dependency |
| 195 | - if ( ! is_null( $is_parent_update_completed ) ) { |
|
| 195 | + if ( ! is_null($is_parent_update_completed)) { |
|
| 196 | 196 | return $update; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -203,23 +203,23 @@ discard block |
||
| 203 | 203 | // Pause upgrade immediately if found following: |
| 204 | 204 | // 1. Running update number greater then total update count |
| 205 | 205 | // 2. Processing percentage greater then 100% |
| 206 | - if( ( |
|
| 206 | + if (( |
|
| 207 | 207 | 101 < $resume_update['total_percentage'] ) || |
| 208 | - ( $give_updates->get_total_db_update_count() < $resume_update['update'] ) || |
|
| 209 | - ! in_array( $resume_update['update_info']['id'], $give_updates->get_update_ids() ) |
|
| 208 | + ($give_updates->get_total_db_update_count() < $resume_update['update']) || |
|
| 209 | + ! in_array($resume_update['update_info']['id'], $give_updates->get_update_ids()) |
|
| 210 | 210 | ) { |
| 211 | - if( ! $this->is_paused_process() ){ |
|
| 211 | + if ( ! $this->is_paused_process()) { |
|
| 212 | 212 | $give_updates->__pause_db_update(true); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - update_option( 'give_upgrade_error', 1, false ); |
|
| 215 | + update_option('give_upgrade_error', 1, false); |
|
| 216 | 216 | |
| 217 | - $log_data = 'Update Task' . "\n"; |
|
| 217 | + $log_data = 'Update Task'."\n"; |
|
| 218 | 218 | $log_data .= "Total update count: {$give_updates->get_total_db_update_count()}\n"; |
| 219 | - $log_data .= 'Update IDs: ' . print_r( $give_updates->get_update_ids() , true ); |
|
| 220 | - $log_data .= 'Update: ' . print_r( $resume_update , true ); |
|
| 219 | + $log_data .= 'Update IDs: '.print_r($give_updates->get_update_ids(), true); |
|
| 220 | + $log_data .= 'Update: '.print_r($resume_update, true); |
|
| 221 | 221 | |
| 222 | - Give()->logs->add( 'Update Error', $log_data, 0, 'update' ); |
|
| 222 | + Give()->logs->add('Update Error', $log_data, 0, 'update'); |
|
| 223 | 223 | |
| 224 | 224 | wp_die(); |
| 225 | 225 | } |
@@ -227,25 +227,25 @@ discard block |
||
| 227 | 227 | // Disable cache. |
| 228 | 228 | Give_Cache::disable(); |
| 229 | 229 | |
| 230 | - try{ |
|
| 230 | + try { |
|
| 231 | 231 | // Run update. |
| 232 | - if ( is_array( $update['callback'] ) ) { |
|
| 232 | + if (is_array($update['callback'])) { |
|
| 233 | 233 | $update['callback'][0]->$update['callback'][1](); |
| 234 | 234 | } else { |
| 235 | 235 | $update['callback'](); |
| 236 | 236 | } |
| 237 | - } catch ( Exception $e ){ |
|
| 237 | + } catch (Exception $e) { |
|
| 238 | 238 | |
| 239 | - if( ! $this->is_paused_process() ){ |
|
| 239 | + if ( ! $this->is_paused_process()) { |
|
| 240 | 240 | $give_updates->__pause_db_update(true); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $log_data = 'Update Task' . "\n"; |
|
| 244 | - $log_data .= print_r( $resume_update, true ) . "\n\n"; |
|
| 243 | + $log_data = 'Update Task'."\n"; |
|
| 244 | + $log_data .= print_r($resume_update, true)."\n\n"; |
|
| 245 | 245 | $log_data .= "Error\n {$e->getMessage()}"; |
| 246 | 246 | |
| 247 | - Give()->logs->add( 'Update Error', $log_data, 0, 'update' ); |
|
| 248 | - update_option( 'give_upgrade_error', 1, false ); |
|
| 247 | + Give()->logs->add('Update Error', $log_data, 0, 'update'); |
|
| 248 | + update_option('give_upgrade_error', 1, false); |
|
| 249 | 249 | |
| 250 | 250 | wp_die(); |
| 251 | 251 | } |
@@ -253,21 +253,21 @@ discard block |
||
| 253 | 253 | // Set update info. |
| 254 | 254 | $doing_upgrade_args = array( |
| 255 | 255 | 'update_info' => $update, |
| 256 | - 'step' => ++ $give_updates->step, |
|
| 256 | + 'step' => ++$give_updates->step, |
|
| 257 | 257 | 'update' => $give_updates->update, |
| 258 | - 'heading' => sprintf( 'Update %s of %s', $give_updates->update, get_option( 'give_db_update_count' ) ), |
|
| 258 | + 'heading' => sprintf('Update %s of %s', $give_updates->update, get_option('give_db_update_count')), |
|
| 259 | 259 | 'percentage' => $give_updates->percentage, |
| 260 | 260 | 'total_percentage' => $give_updates->get_db_update_processing_percentage(), |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | 263 | // Cache upgrade. |
| 264 | - update_option( 'give_doing_upgrade', $doing_upgrade_args, false ); |
|
| 264 | + update_option('give_doing_upgrade', $doing_upgrade_args, false); |
|
| 265 | 265 | |
| 266 | 266 | // Enable cache. |
| 267 | 267 | Give_Cache::enable(); |
| 268 | 268 | |
| 269 | 269 | // Check if current update completed or not. |
| 270 | - if ( give_has_upgrade_completed( $update['id'] ) ) { |
|
| 270 | + if (give_has_upgrade_completed($update['id'])) { |
|
| 271 | 271 | return false; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -281,23 +281,23 @@ discard block |
||
| 281 | 281 | * performed, or, call parent::complete(). |
| 282 | 282 | */ |
| 283 | 283 | public function complete() { |
| 284 | - if ( $this->is_paused_process() ) { |
|
| 284 | + if ($this->is_paused_process()) { |
|
| 285 | 285 | return false; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | parent::complete(); |
| 289 | 289 | |
| 290 | - delete_option( 'give_pause_upgrade' ); |
|
| 291 | - delete_option( 'give_upgrade_error' ); |
|
| 292 | - delete_option( 'give_db_update_count' ); |
|
| 293 | - delete_option( 'give_doing_upgrade' ); |
|
| 294 | - add_option( 'give_show_db_upgrade_complete_notice', 1, '', false ); |
|
| 290 | + delete_option('give_pause_upgrade'); |
|
| 291 | + delete_option('give_upgrade_error'); |
|
| 292 | + delete_option('give_db_update_count'); |
|
| 293 | + delete_option('give_doing_upgrade'); |
|
| 294 | + add_option('give_show_db_upgrade_complete_notice', 1, '', false); |
|
| 295 | 295 | |
| 296 | 296 | // Flush cache. |
| 297 | - Give_Cache::flush_cache( true ); |
|
| 297 | + Give_Cache::flush_cache(true); |
|
| 298 | 298 | |
| 299 | - if ( $cache_keys = Give_Cache::get_options_like( '' ) ) { |
|
| 300 | - Give_Cache::delete( $cache_keys ); |
|
| 299 | + if ($cache_keys = Give_Cache::get_options_like('')) { |
|
| 300 | + Give_Cache::delete($cache_keys); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
@@ -307,19 +307,19 @@ discard block |
||
| 307 | 307 | * @return int |
| 308 | 308 | */ |
| 309 | 309 | protected function get_memory_limit() { |
| 310 | - if ( function_exists( 'ini_get' ) ) { |
|
| 311 | - $memory_limit = ini_get( 'memory_limit' ); |
|
| 310 | + if (function_exists('ini_get')) { |
|
| 311 | + $memory_limit = ini_get('memory_limit'); |
|
| 312 | 312 | } else { |
| 313 | 313 | // Sensible default. |
| 314 | 314 | $memory_limit = '128M'; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - if ( ! $memory_limit || '-1' === $memory_limit ) { |
|
| 317 | + if ( ! $memory_limit || '-1' === $memory_limit) { |
|
| 318 | 318 | // Unlimited, set to 32GB. |
| 319 | 319 | $memory_limit = '32000M'; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - return intval( $memory_limit ) * 1024 * 1024; |
|
| 322 | + return intval($memory_limit) * 1024 * 1024; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -332,17 +332,17 @@ discard block |
||
| 332 | 332 | // Don't lock up other requests while processing |
| 333 | 333 | session_write_close(); |
| 334 | 334 | |
| 335 | - if ( $this->is_process_running() || $this->is_paused_process() ) { |
|
| 335 | + if ($this->is_process_running() || $this->is_paused_process()) { |
|
| 336 | 336 | // Background process already running. |
| 337 | 337 | wp_die(); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( $this->is_queue_empty() ) { |
|
| 340 | + if ($this->is_queue_empty()) { |
|
| 341 | 341 | // No data to process. |
| 342 | 342 | wp_die(); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 345 | + check_ajax_referer($this->identifier, 'nonce'); |
|
| 346 | 346 | |
| 347 | 347 | $this->handle(); |
| 348 | 348 | |
@@ -361,36 +361,36 @@ discard block |
||
| 361 | 361 | do { |
| 362 | 362 | $batch = $this->get_batch(); |
| 363 | 363 | |
| 364 | - foreach ( $batch->data as $key => $value ) { |
|
| 365 | - $task = $this->task( $value ); |
|
| 364 | + foreach ($batch->data as $key => $value) { |
|
| 365 | + $task = $this->task($value); |
|
| 366 | 366 | |
| 367 | - if ( false !== $task ) { |
|
| 368 | - $batch->data[ $key ] = $task; |
|
| 367 | + if (false !== $task) { |
|
| 368 | + $batch->data[$key] = $task; |
|
| 369 | 369 | } else { |
| 370 | - unset( $batch->data[ $key ] ); |
|
| 370 | + unset($batch->data[$key]); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if ( $this->time_exceeded() || $this->memory_exceeded() ) { |
|
| 373 | + if ($this->time_exceeded() || $this->memory_exceeded()) { |
|
| 374 | 374 | // Batch limits reached. |
| 375 | 375 | break; |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Update or delete current batch. |
| 380 | - if ( ! empty( $batch->data ) ) { |
|
| 381 | - $this->update( $batch->key, $batch->data ); |
|
| 380 | + if ( ! empty($batch->data)) { |
|
| 381 | + $this->update($batch->key, $batch->data); |
|
| 382 | 382 | } else { |
| 383 | - $this->delete( $batch->key ); |
|
| 383 | + $this->delete($batch->key); |
|
| 384 | 384 | } |
| 385 | - } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); |
|
| 385 | + } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty()); |
|
| 386 | 386 | |
| 387 | 387 | $this->unlock_process(); |
| 388 | 388 | |
| 389 | 389 | // Start next batch or complete process. |
| 390 | - if ( ! $this->is_queue_empty() ) { |
|
| 390 | + if ( ! $this->is_queue_empty()) { |
|
| 391 | 391 | |
| 392 | 392 | // Dispatch only if ajax works. |
| 393 | - if( give_test_ajax_works() ) { |
|
| 393 | + if (give_test_ajax_works()) { |
|
| 394 | 394 | $this->dispatch(); |
| 395 | 395 | } |
| 396 | 396 | } else { |
@@ -408,13 +408,13 @@ discard block |
||
| 408 | 408 | * @access public |
| 409 | 409 | * @return bool |
| 410 | 410 | */ |
| 411 | - public function is_paused_process(){ |
|
| 411 | + public function is_paused_process() { |
|
| 412 | 412 | // Delete cache. |
| 413 | - wp_cache_delete( 'give_paused_batches', 'options' ); |
|
| 413 | + wp_cache_delete('give_paused_batches', 'options'); |
|
| 414 | 414 | |
| 415 | 415 | $paused_batches = get_option('give_paused_batches'); |
| 416 | 416 | |
| 417 | - return ! empty( $paused_batches ); |
|
| 417 | + return ! empty($paused_batches); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | |
@@ -460,8 +460,8 @@ discard block |
||
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | 462 | |
| 463 | - foreach ( $options as $option ) { |
|
| 464 | - wp_cache_delete( $option, 'options' ); |
|
| 463 | + foreach ($options as $option) { |
|
| 464 | + wp_cache_delete($option, 'options'); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | } |
@@ -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 | |
@@ -53,21 +53,21 @@ discard block |
||
| 53 | 53 | * @since 1.8.9 |
| 54 | 54 | */ |
| 55 | 55 | public function __construct() { |
| 56 | - add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 ); |
|
| 57 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
| 56 | + add_action('admin_notices', array($this, 'render_admin_notices'), 999); |
|
| 57 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
| 58 | 58 | |
| 59 | - add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 ); |
|
| 60 | - add_action( 'give_pre_form_output', array( $this, 'render_frontend_form_notices' ), 10, 1 ); |
|
| 61 | - add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) ); |
|
| 59 | + add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999); |
|
| 60 | + add_action('give_pre_form_output', array($this, 'render_frontend_form_notices'), 10, 1); |
|
| 61 | + add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices')); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Backward compatibility for deprecated params. |
| 65 | 65 | * |
| 66 | 66 | * @since 1.8.14 |
| 67 | 67 | */ |
| 68 | - add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 69 | - add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 70 | - add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) ); |
|
| 68 | + add_filter('give_register_notice_args', array($this, 'bc_deprecated_params')); |
|
| 69 | + add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params')); |
|
| 70 | + add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params')); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | - public function bc_deprecated_params( $args ) { |
|
| 83 | + public function bc_deprecated_params($args) { |
|
| 84 | 84 | /** |
| 85 | 85 | * Param: auto_dismissible |
| 86 | 86 | * deprecated in 1.8.14 |
| 87 | 87 | * |
| 88 | 88 | * Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto |
| 89 | 89 | */ |
| 90 | - if ( isset( $args['auto_dismissible'] ) ) { |
|
| 91 | - if ( ! empty( $args['auto_dismissible'] ) ) { |
|
| 90 | + if (isset($args['auto_dismissible'])) { |
|
| 91 | + if ( ! empty($args['auto_dismissible'])) { |
|
| 92 | 92 | $args['dismissible'] = 'auto'; |
| 93 | 93 | } |
| 94 | 94 | // unset auto_dismissible as it has been deprecated. |
| 95 | - unset( $args['auto_dismissible'] ); |
|
| 95 | + unset($args['auto_dismissible']); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return $args; |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return bool |
| 110 | 110 | */ |
| 111 | - public function register_notice( $notice_args ) { |
|
| 111 | + public function register_notice($notice_args) { |
|
| 112 | 112 | // Bailout. |
| 113 | - if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) { |
|
| 113 | + if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) { |
|
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -159,39 +159,39 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @since 1.8.14 |
| 161 | 161 | */ |
| 162 | - $notice_args = apply_filters( 'give_register_notice_args', $notice_args ); |
|
| 162 | + $notice_args = apply_filters('give_register_notice_args', $notice_args); |
|
| 163 | 163 | |
| 164 | 164 | // Set extra dismiss links if any. |
| 165 | - if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) { |
|
| 165 | + if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) { |
|
| 166 | 166 | |
| 167 | - preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link ); |
|
| 167 | + preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link); |
|
| 168 | 168 | |
| 169 | - if ( ! empty( $extra_notice_dismiss_link ) ) { |
|
| 170 | - $extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 ); |
|
| 171 | - foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) { |
|
| 169 | + if ( ! empty($extra_notice_dismiss_link)) { |
|
| 170 | + $extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3); |
|
| 171 | + foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) { |
|
| 172 | 172 | // Create array og key ==> value by parsing query string created after renaming data attributes. |
| 173 | - $data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array( |
|
| 173 | + $data_attribute_query_str = str_replace(array('data-', '-', '"'), array( |
|
| 174 | 174 | '', |
| 175 | 175 | '_', |
| 176 | 176 | '', |
| 177 | - ), implode( '&', $extra_notice_dismiss_link ) ); |
|
| 177 | + ), implode('&', $extra_notice_dismiss_link)); |
|
| 178 | 178 | |
| 179 | - $notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str ); |
|
| 179 | + $notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
| 185 | - self::$notices[ $notice_args['id'] ] = $notice_args; |
|
| 185 | + self::$notices[$notice_args['id']] = $notice_args; |
|
| 186 | 186 | |
| 187 | 187 | // Auto set show param if not already set. |
| 188 | - if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) { |
|
| 189 | - self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true; |
|
| 188 | + if ( ! isset(self::$notices[$notice_args['id']]['show'])) { |
|
| 189 | + self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Auto set time interval for shortly. |
| 193 | - if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) { |
|
| 194 | - self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
| 193 | + if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) { |
|
| 194 | + self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return true; |
@@ -205,51 +205,51 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function render_admin_notices() { |
| 207 | 207 | // Bailout. |
| 208 | - if ( empty( self::$notices ) ) { |
|
| 208 | + if (empty(self::$notices)) { |
|
| 209 | 209 | return; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | $output = ''; |
| 213 | 213 | |
| 214 | - foreach ( self::$notices as $notice_id => $notice ) { |
|
| 214 | + foreach (self::$notices as $notice_id => $notice) { |
|
| 215 | 215 | // Check flag set to true to show notice. |
| 216 | - if ( ! $notice['show'] ) { |
|
| 216 | + if ( ! $notice['show']) { |
|
| 217 | 217 | continue; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | // Render custom html. |
| 222 | - if( ! empty( $notice['description_html'] ) ) { |
|
| 222 | + if ( ! empty($notice['description_html'])) { |
|
| 223 | 223 | $output .= "{$notice['description_html']} \n"; |
| 224 | 224 | continue; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Check if notice dismissible or not. |
| 228 | - if ( ! self::$has_auto_dismissible_notice ) { |
|
| 229 | - self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] ); |
|
| 228 | + if ( ! self::$has_auto_dismissible_notice) { |
|
| 229 | + self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Check if notice dismissible or not. |
| 233 | - if ( ! self::$has_dismiss_interval_notice ) { |
|
| 233 | + if ( ! self::$has_dismiss_interval_notice) { |
|
| 234 | 234 | self::$has_dismiss_interval_notice = $notice['dismiss_interval']; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] ); |
|
| 237 | + $css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']); |
|
| 238 | 238 | |
| 239 | - $css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
| 240 | - $output .= sprintf( |
|
| 241 | - '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n", |
|
| 239 | + $css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}"; |
|
| 240 | + $output .= sprintf( |
|
| 241 | + '<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n", |
|
| 242 | 242 | $css_id, |
| 243 | 243 | $css_class, |
| 244 | - give_clean( $notice['dismissible'] ), |
|
| 244 | + give_clean($notice['dismissible']), |
|
| 245 | 245 | $notice['dismissible_type'], |
| 246 | 246 | $notice['dismiss_interval'], |
| 247 | 247 | $notice['id'], |
| 248 | - empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ), |
|
| 248 | + empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"), |
|
| 249 | 249 | $notice['dismiss_interval_time'] |
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | - $output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" ); |
|
| 252 | + $output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>"); |
|
| 253 | 253 | $output .= "</div> \n"; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @param int $form_id |
| 269 | 269 | */ |
| 270 | - public function render_frontend_notices( $form_id = 0 ) { |
|
| 270 | + public function render_frontend_notices($form_id = 0) { |
|
| 271 | 271 | $errors = give_get_errors(); |
| 272 | 272 | |
| 273 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0; |
|
| 273 | + $request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0; |
|
| 274 | 274 | |
| 275 | 275 | // Sanity checks first: Ensure that gateway returned errors display on the appropriate form. |
| 276 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
| 276 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( $errors ) { |
|
| 281 | - self::print_frontend_errors( $errors ); |
|
| 280 | + if ($errors) { |
|
| 281 | + self::print_frontend_errors($errors); |
|
| 282 | 282 | |
| 283 | 283 | give_clear_errors(); |
| 284 | 284 | } |
@@ -295,13 +295,13 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return void |
| 297 | 297 | */ |
| 298 | - public function render_frontend_form_notices( $form_id ) { |
|
| 299 | - $display_option = give_get_meta( $form_id, '_give_payment_display', true ); |
|
| 298 | + public function render_frontend_form_notices($form_id) { |
|
| 299 | + $display_option = give_get_meta($form_id, '_give_payment_display', true); |
|
| 300 | 300 | |
| 301 | - if ( 'modal' === $display_option ) { |
|
| 302 | - add_action( 'give_payment_mode_top', array( $this, 'render_frontend_notices' ) ); |
|
| 301 | + if ('modal' === $display_option) { |
|
| 302 | + add_action('give_payment_mode_top', array($this, 'render_frontend_notices')); |
|
| 303 | 303 | } else { |
| 304 | - add_action( 'give_pre_form', array( $this, 'render_frontend_notices' ), 11 ); |
|
| 304 | + add_action('give_pre_form', array($this, 'render_frontend_notices'), 11); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @access private |
| 313 | 313 | */ |
| 314 | 314 | private function print_js() { |
| 315 | - if ( self::$has_auto_dismissible_notice ) : |
|
| 315 | + if (self::$has_auto_dismissible_notice) : |
|
| 316 | 316 | ?> |
| 317 | 317 | <script> |
| 318 | 318 | jQuery(document).ready(function () { |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | <?php |
| 329 | 329 | endif; |
| 330 | 330 | |
| 331 | - if ( self::$has_dismiss_interval_notice ) : |
|
| 331 | + if (self::$has_dismiss_interval_notice) : |
|
| 332 | 332 | ?> |
| 333 | 333 | <script> |
| 334 | 334 | jQuery(document).ready(function () { |
@@ -407,36 +407,36 @@ discard block |
||
| 407 | 407 | * @access public |
| 408 | 408 | */ |
| 409 | 409 | public function dismiss_notices() { |
| 410 | - $_post = give_clean( $_POST ); |
|
| 411 | - $notice_id = esc_attr( $_post['notice_id'] ); |
|
| 410 | + $_post = give_clean($_POST); |
|
| 411 | + $notice_id = esc_attr($_post['notice_id']); |
|
| 412 | 412 | |
| 413 | 413 | // Bailout. |
| 414 | 414 | if ( |
| 415 | - empty( $notice_id ) || |
|
| 416 | - empty( $_post['dismissible_type'] ) || |
|
| 417 | - empty( $_post['dismiss_interval'] ) || |
|
| 418 | - ! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' ) |
|
| 415 | + empty($notice_id) || |
|
| 416 | + empty($_post['dismissible_type']) || |
|
| 417 | + empty($_post['dismiss_interval']) || |
|
| 418 | + ! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce') |
|
| 419 | 419 | ) { |
| 420 | 420 | wp_send_json_error(); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] ); |
|
| 424 | - if ( 'user' === $_post['dismissible_type'] ) { |
|
| 423 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']); |
|
| 424 | + if ('user' === $_post['dismissible_type']) { |
|
| 425 | 425 | $current_user = wp_get_current_user(); |
| 426 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID ); |
|
| 426 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - $notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null; |
|
| 429 | + $notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null; |
|
| 430 | 430 | |
| 431 | 431 | // Save option to hide notice. |
| 432 | - Give_Cache::set( $notice_key, true, $notice_dismiss_time, true ); |
|
| 432 | + Give_Cache::set($notice_key, true, $notice_dismiss_time, true); |
|
| 433 | 433 | |
| 434 | 434 | /** |
| 435 | 435 | * Fire the action when notice dismissed |
| 436 | 436 | * |
| 437 | 437 | * @since 2.0 |
| 438 | 438 | */ |
| 439 | - do_action( 'give_dismiss_notices', $_post ); |
|
| 439 | + do_action('give_dismiss_notices', $_post); |
|
| 440 | 440 | |
| 441 | 441 | wp_send_json_success(); |
| 442 | 442 | } |
@@ -454,18 +454,18 @@ discard block |
||
| 454 | 454 | * |
| 455 | 455 | * @return string |
| 456 | 456 | */ |
| 457 | - public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) { |
|
| 457 | + public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) { |
|
| 458 | 458 | $notice_key = "_give_notice_{$notice_id}"; |
| 459 | 459 | |
| 460 | - if ( ! empty( $dismiss_interval ) ) { |
|
| 460 | + if ( ! empty($dismiss_interval)) { |
|
| 461 | 461 | $notice_key .= "_{$dismiss_interval}"; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if ( $user_id ) { |
|
| 464 | + if ($user_id) { |
|
| 465 | 465 | $notice_key .= "_{$user_id}"; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $notice_key = sanitize_key( $notice_key ); |
|
| 468 | + $notice_key = sanitize_key($notice_key); |
|
| 469 | 469 | |
| 470 | 470 | return $notice_key; |
| 471 | 471 | } |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | * |
| 479 | 479 | * @return string |
| 480 | 480 | */ |
| 481 | - public function get_dismiss_link( $notice_args ) { |
|
| 481 | + public function get_dismiss_link($notice_args) { |
|
| 482 | 482 | $notice_args = wp_parse_args( |
| 483 | 483 | $notice_args, |
| 484 | 484 | array( |
| 485 | - 'title' => __( 'Click here', 'give' ), |
|
| 485 | + 'title' => __('Click here', 'give'), |
|
| 486 | 486 | 'dismissible_type' => '', |
| 487 | 487 | 'dismiss_interval' => '', |
| 488 | 488 | 'dismiss_interval_time' => null, |
@@ -509,31 +509,31 @@ discard block |
||
| 509 | 509 | * |
| 510 | 510 | * @return bool|null |
| 511 | 511 | */ |
| 512 | - public function is_notice_dismissed( $notice ) { |
|
| 513 | - $notice_key = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] ); |
|
| 512 | + public function is_notice_dismissed($notice) { |
|
| 513 | + $notice_key = $this->get_notice_key($notice['id'], $notice['dismiss_interval']); |
|
| 514 | 514 | $is_notice_dismissed = false; |
| 515 | 515 | |
| 516 | - if ( 'user' === $notice['dismissible_type'] ) { |
|
| 516 | + if ('user' === $notice['dismissible_type']) { |
|
| 517 | 517 | $current_user = wp_get_current_user(); |
| 518 | - $notice_key = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID ); |
|
| 518 | + $notice_key = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - $notice_data = Give_Cache::get( $notice_key, true ); |
|
| 521 | + $notice_data = Give_Cache::get($notice_key, true); |
|
| 522 | 522 | |
| 523 | 523 | // Find notice dismiss link status if notice has extra dismissible links. |
| 524 | - if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) { |
|
| 524 | + if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) { |
|
| 525 | 525 | |
| 526 | - foreach ( $notice['extra_links'] as $extra_link ) { |
|
| 527 | - $new_notice_data = wp_parse_args( $extra_link, $notice ); |
|
| 528 | - unset( $new_notice_data['extra_links'] ); |
|
| 526 | + foreach ($notice['extra_links'] as $extra_link) { |
|
| 527 | + $new_notice_data = wp_parse_args($extra_link, $notice); |
|
| 528 | + unset($new_notice_data['extra_links']); |
|
| 529 | 529 | |
| 530 | - if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) { |
|
| 530 | + if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) { |
|
| 531 | 531 | return $is_notice_dismissed; |
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - $is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data ); |
|
| 536 | + $is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data); |
|
| 537 | 537 | |
| 538 | 538 | return $is_notice_dismissed; |
| 539 | 539 | } |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | * |
| 548 | 548 | * @param array $errors |
| 549 | 549 | */ |
| 550 | - public static function print_frontend_errors( $errors ) { |
|
| 550 | + public static function print_frontend_errors($errors) { |
|
| 551 | 551 | // Bailout. |
| 552 | - if ( ! $errors ) { |
|
| 552 | + if ( ! $errors) { |
|
| 553 | 553 | return; |
| 554 | 554 | } |
| 555 | 555 | |
@@ -564,37 +564,37 @@ discard block |
||
| 564 | 564 | ); |
| 565 | 565 | |
| 566 | 566 | // Note: we will remove give_errors class in future. |
| 567 | - $classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) ); |
|
| 567 | + $classes = apply_filters('give_error_class', array('give_notices', 'give_errors')); |
|
| 568 | 568 | |
| 569 | - echo sprintf( '<div class="%s">', implode( ' ', $classes ) ); |
|
| 569 | + echo sprintf('<div class="%s">', implode(' ', $classes)); |
|
| 570 | 570 | |
| 571 | 571 | // Loop error codes and display errors. |
| 572 | - foreach ( $errors as $error_id => $error ) { |
|
| 572 | + foreach ($errors as $error_id => $error) { |
|
| 573 | 573 | // Backward compatibility v<1.8.11 |
| 574 | - if ( is_string( $error ) ) { |
|
| 574 | + if (is_string($error)) { |
|
| 575 | 575 | $error = array( |
| 576 | 576 | 'message' => $error, |
| 577 | 577 | 'notice_args' => array(), |
| 578 | 578 | ); |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - $notice_args = wp_parse_args( $error['notice_args'], $default_notice_args ); |
|
| 581 | + $notice_args = wp_parse_args($error['notice_args'], $default_notice_args); |
|
| 582 | 582 | |
| 583 | 583 | /** |
| 584 | 584 | * Filter to modify Frontend Errors args before errors is display. |
| 585 | 585 | * |
| 586 | 586 | * @since 1.8.14 |
| 587 | 587 | */ |
| 588 | - $notice_args = apply_filters( 'give_frontend_errors_args', $notice_args ); |
|
| 588 | + $notice_args = apply_filters('give_frontend_errors_args', $notice_args); |
|
| 589 | 589 | |
| 590 | 590 | echo sprintf( |
| 591 | 591 | '<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d"> |
| 592 | 592 | <p><strong>%4$s</strong>: %5$s</p> |
| 593 | 593 | </div>', |
| 594 | 594 | $error_id, |
| 595 | - give_clean( $notice_args['dismissible'] ), |
|
| 596 | - absint( $notice_args['dismiss_interval'] ), |
|
| 597 | - esc_html__( 'Error', 'give' ), |
|
| 595 | + give_clean($notice_args['dismissible']), |
|
| 596 | + absint($notice_args['dismiss_interval']), |
|
| 597 | + esc_html__('Error', 'give'), |
|
| 598 | 598 | $error['message'] |
| 599 | 599 | ); |
| 600 | 600 | } |
@@ -616,8 +616,8 @@ discard block |
||
| 616 | 616 | * |
| 617 | 617 | * @return string |
| 618 | 618 | */ |
| 619 | - public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) { |
|
| 620 | - if ( empty( $message ) ) { |
|
| 619 | + public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) { |
|
| 620 | + if (empty($message)) { |
|
| 621 | 621 | return ''; |
| 622 | 622 | } |
| 623 | 623 | |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | 'dismiss_interval' => 5000, |
| 633 | 633 | ); |
| 634 | 634 | |
| 635 | - $notice_args = wp_parse_args( $notice_args, $default_notice_args ); |
|
| 635 | + $notice_args = wp_parse_args($notice_args, $default_notice_args); |
|
| 636 | 636 | |
| 637 | 637 | // Notice dismissible must be true for dismiss type. |
| 638 | 638 | $notice_args['dismiss_type'] = ! $notice_args['dismissible'] ? '' : $notice_args['dismiss_type']; |
@@ -642,15 +642,14 @@ discard block |
||
| 642 | 642 | * |
| 643 | 643 | * @since 1.8.14 |
| 644 | 644 | */ |
| 645 | - $notice_args = apply_filters( 'give_frontend_notice_args', $notice_args ); |
|
| 645 | + $notice_args = apply_filters('give_frontend_notice_args', $notice_args); |
|
| 646 | 646 | |
| 647 | 647 | $close_icon = 'manual' === $notice_args['dismiss_type'] ? |
| 648 | 648 | sprintf( |
| 649 | 649 | '<img class="notice-dismiss give-notice-close" src="%s" />', |
| 650 | - esc_url( GIVE_PLUGIN_URL . 'assets/dist/images/close.svg' ) |
|
| 650 | + esc_url(GIVE_PLUGIN_URL.'assets/dist/images/close.svg') |
|
| 651 | 651 | |
| 652 | - ) : |
|
| 653 | - ''; |
|
| 652 | + ) : ''; |
|
| 654 | 653 | |
| 655 | 654 | // Note: we will remove give_errors class in future. |
| 656 | 655 | $error = sprintf( |
@@ -661,15 +660,15 @@ discard block |
||
| 661 | 660 | %6$s |
| 662 | 661 | </div>', |
| 663 | 662 | $notice_type, |
| 664 | - give_clean( $notice_args['dismissible'] ), |
|
| 665 | - absint( $notice_args['dismiss_interval'] ), |
|
| 666 | - give_clean( $notice_args['dismiss_type'] ), |
|
| 663 | + give_clean($notice_args['dismissible']), |
|
| 664 | + absint($notice_args['dismiss_interval']), |
|
| 665 | + give_clean($notice_args['dismiss_type']), |
|
| 667 | 666 | $message, |
| 668 | 667 | $close_icon |
| 669 | 668 | |
| 670 | 669 | ); |
| 671 | 670 | |
| 672 | - if ( ! $echo ) { |
|
| 671 | + if ( ! $echo) { |
|
| 673 | 672 | return $error; |
| 674 | 673 | } |
| 675 | 674 | |
@@ -689,24 +688,24 @@ discard block |
||
| 689 | 688 | * |
| 690 | 689 | * @return string |
| 691 | 690 | */ |
| 692 | - public function print_admin_notices( $notice_args = array() ) { |
|
| 691 | + public function print_admin_notices($notice_args = array()) { |
|
| 693 | 692 | // Bailout. |
| 694 | - if ( empty( $notice_args['description'] ) ) { |
|
| 693 | + if (empty($notice_args['description'])) { |
|
| 695 | 694 | return ''; |
| 696 | 695 | } |
| 697 | 696 | |
| 698 | - $defaults = array( |
|
| 697 | + $defaults = array( |
|
| 699 | 698 | 'id' => '', |
| 700 | 699 | 'echo' => true, |
| 701 | 700 | 'notice_type' => 'warning', |
| 702 | 701 | 'dismissible' => true, |
| 703 | 702 | ); |
| 704 | - $notice_args = wp_parse_args( $notice_args, $defaults ); |
|
| 703 | + $notice_args = wp_parse_args($notice_args, $defaults); |
|
| 705 | 704 | |
| 706 | 705 | $output = ''; |
| 707 | - $css_id = ! empty( $notice_args['id'] ) ? $notice_args['id'] : uniqid( 'give-inline-notice-' ); |
|
| 706 | + $css_id = ! empty($notice_args['id']) ? $notice_args['id'] : uniqid('give-inline-notice-'); |
|
| 708 | 707 | $css_class = "notice-{$notice_args['notice_type']} give-notice notice inline"; |
| 709 | - $css_class .= ( $notice_args['dismissible'] ) ? ' is-dismissible' : ''; |
|
| 708 | + $css_class .= ($notice_args['dismissible']) ? ' is-dismissible' : ''; |
|
| 710 | 709 | $output .= sprintf( |
| 711 | 710 | '<div id="%1$s" class="%2$s"><p>%3$s</p></div>', |
| 712 | 711 | $css_id, |
@@ -714,7 +713,7 @@ discard block |
||
| 714 | 713 | $notice_args['description'] |
| 715 | 714 | ); |
| 716 | 715 | |
| 717 | - if ( ! $notice_args['echo'] ) { |
|
| 716 | + if ( ! $notice_args['echo']) { |
|
| 718 | 717 | return $output; |
| 719 | 718 | } |
| 720 | 719 | |
@@ -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.8.13 |
| 21 | 21 | */ |
| 22 | 22 | function give_import_donation_report() { |
| 23 | - return get_option( 'give_import_donation_report', array() ); |
|
| 23 | + return get_option('give_import_donation_report', array()); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @since 1.8.13 |
| 31 | 31 | */ |
| 32 | -function give_import_donation_report_update( $value = array() ) { |
|
| 33 | - update_option( 'give_import_donation_report', $value, false ); |
|
| 32 | +function give_import_donation_report_update($value = array()) { |
|
| 33 | + update_option('give_import_donation_report', $value, false); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @since 1.8.13 |
| 40 | 40 | */ |
| 41 | 41 | function give_import_donation_report_reset() { |
| 42 | - update_option( 'give_import_donation_report', array(), false ); |
|
| 42 | + update_option('give_import_donation_report', array(), false); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return array|bool|Give_Donate_Form|int|null|WP_Post |
| 53 | 53 | */ |
| 54 | -function give_import_get_form_data_from_csv( $data, $import_setting = array() ) { |
|
| 54 | +function give_import_get_form_data_from_csv($data, $import_setting = array()) { |
|
| 55 | 55 | $new_form = false; |
| 56 | - $dry_run = isset( $import_setting['dry_run'] ) ? $import_setting['dry_run'] : false; |
|
| 56 | + $dry_run = isset($import_setting['dry_run']) ? $import_setting['dry_run'] : false; |
|
| 57 | 57 | |
| 58 | 58 | // Get the import report |
| 59 | 59 | $report = give_import_donation_report(); |
@@ -61,25 +61,25 @@ discard block |
||
| 61 | 61 | $form = false; |
| 62 | 62 | $meta = array(); |
| 63 | 63 | |
| 64 | - if ( ! empty( $data['form_id'] ) ) { |
|
| 65 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
| 64 | + if ( ! empty($data['form_id'])) { |
|
| 65 | + $form = new Give_Donate_Form($data['form_id']); |
|
| 66 | 66 | // Add support to older php version. |
| 67 | 67 | $form_id = $form->get_ID(); |
| 68 | - if ( empty( $form_id ) ) { |
|
| 68 | + if (empty($form_id)) { |
|
| 69 | 69 | $form = false; |
| 70 | 70 | } else { |
| 71 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
| 71 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ( false === $form && ! empty( $data['form_title'] ) ) { |
|
| 76 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
| 75 | + if (false === $form && ! empty($data['form_title'])) { |
|
| 76 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
| 77 | 77 | |
| 78 | - if ( ! empty( $form->ID ) ) { |
|
| 78 | + if ( ! empty($form->ID)) { |
|
| 79 | 79 | |
| 80 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
| 80 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
| 81 | 81 | |
| 82 | - $form = new Give_Donate_Form( $form->ID ); |
|
| 82 | + $form = new Give_Donate_Form($form->ID); |
|
| 83 | 83 | } else { |
| 84 | 84 | $form = new Give_Donate_Form(); |
| 85 | 85 | $args = array( |
@@ -87,43 +87,43 @@ discard block |
||
| 87 | 87 | 'post_status' => 'publish', |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - if ( empty( $dry_run ) ) { |
|
| 91 | - $form = $form->create( $args ); |
|
| 90 | + if (empty($dry_run)) { |
|
| 91 | + $form = $form->create($args); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 ); |
|
| 94 | + $report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1); |
|
| 95 | 95 | $new_form = true; |
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' ); |
|
| 100 | - if ( ! empty( $form->ID ) ) { |
|
| 101 | - $form = new Give_Donate_Form( $form->ID ); |
|
| 99 | + $form = get_page_by_title($data['form_title'], OBJECT, 'give_forms'); |
|
| 100 | + if ( ! empty($form->ID)) { |
|
| 101 | + $form = new Give_Donate_Form($form->ID); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( ! empty( $form ) && $form->get_ID() && ! empty( $data['form_level'] ) && empty( $dry_run ) ) { |
|
| 105 | + if ( ! empty($form) && $form->get_ID() && ! empty($data['form_level']) && empty($dry_run)) { |
|
| 106 | 106 | |
| 107 | 107 | $price_option = 'set'; |
| 108 | - $form_level = strtolower( preg_replace( '/\s+/', '', $data['form_level'] ) ); |
|
| 108 | + $form_level = strtolower(preg_replace('/\s+/', '', $data['form_level'])); |
|
| 109 | 109 | |
| 110 | - if ( 'custom' !== $form_level ) { |
|
| 110 | + if ('custom' !== $form_level) { |
|
| 111 | 111 | $prices = (array) $form->get_prices(); |
| 112 | 112 | $price_text = array(); |
| 113 | - foreach ( $prices as $key => $price ) { |
|
| 114 | - if ( isset( $price['_give_id']['level_id'] ) ) { |
|
| 115 | - $price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? strtolower( preg_replace( '/\s+/', '', $price['_give_text'] ) ) : '' ); |
|
| 113 | + foreach ($prices as $key => $price) { |
|
| 114 | + if (isset($price['_give_id']['level_id'])) { |
|
| 115 | + $price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? strtolower(preg_replace('/\s+/', '', $price['_give_text'])) : ''); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( ! in_array( $form_level, $price_text ) ) { |
|
| 119 | + if ( ! in_array($form_level, $price_text)) { |
|
| 120 | 120 | |
| 121 | 121 | // For generating unquiet level id. |
| 122 | 122 | $count = 1; |
| 123 | - $new_level = count( $prices ) + $count; |
|
| 124 | - while ( array_key_exists( $new_level, $price_text ) ) { |
|
| 125 | - $count ++; |
|
| 126 | - $new_level = count( $prices ) + $count; |
|
| 123 | + $new_level = count($prices) + $count; |
|
| 124 | + while (array_key_exists($new_level, $price_text)) { |
|
| 125 | + $count++; |
|
| 126 | + $new_level = count($prices) + $count; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $multi_level_donations = array( |
@@ -131,42 +131,42 @@ discard block |
||
| 131 | 131 | '_give_id' => array( |
| 132 | 132 | 'level_id' => $new_level, |
| 133 | 133 | ), |
| 134 | - '_give_amount' => give_sanitize_amount_for_db( $data['amount'] ), |
|
| 134 | + '_give_amount' => give_sanitize_amount_for_db($data['amount']), |
|
| 135 | 135 | '_give_text' => $data['form_level'], |
| 136 | 136 | ), |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | - $price_text[ $new_level ] = strtolower( preg_replace( '/\s+/', '', $data['form_level'] ) ); |
|
| 139 | + $price_text[$new_level] = strtolower(preg_replace('/\s+/', '', $data['form_level'])); |
|
| 140 | 140 | |
| 141 | - if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) { |
|
| 142 | - $prices = wp_parse_args( $multi_level_donations, $prices ); |
|
| 141 | + if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) { |
|
| 142 | + $prices = wp_parse_args($multi_level_donations, $prices); |
|
| 143 | 143 | |
| 144 | 144 | // Sort $prices by amount in ascending order. |
| 145 | - $prices = wp_list_sort( $prices, '_give_amount', 'ASC' ); |
|
| 145 | + $prices = wp_list_sort($prices, '_give_amount', 'ASC'); |
|
| 146 | 146 | } else { |
| 147 | 147 | $prices = $multi_level_donations; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Unset _give_default key from $prices. |
| 151 | - foreach ( $prices as $key => $price ) { |
|
| 152 | - if ( isset( $prices[ $key ]['_give_default'] ) ) { |
|
| 153 | - unset( $prices[ $key ]['_give_default'] ); |
|
| 151 | + foreach ($prices as $key => $price) { |
|
| 152 | + if (isset($prices[$key]['_give_default'])) { |
|
| 153 | + unset($prices[$key]['_give_default']); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Set the first $price of the $prices as default. |
| 158 | 158 | $prices[0]['_give_default'] = 'default'; |
| 159 | 159 | } |
| 160 | - $form->price_id = array_search( $form_level, $price_text ); |
|
| 160 | + $form->price_id = array_search($form_level, $price_text); |
|
| 161 | 161 | |
| 162 | - $donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' ); |
|
| 163 | - $min_amount = min( $donation_levels_amounts ); |
|
| 164 | - $max_amount = max( $donation_levels_amounts ); |
|
| 162 | + $donation_levels_amounts = wp_list_pluck($prices, '_give_amount'); |
|
| 163 | + $min_amount = min($donation_levels_amounts); |
|
| 164 | + $max_amount = max($donation_levels_amounts); |
|
| 165 | 165 | |
| 166 | 166 | $meta = array( |
| 167 | 167 | '_give_levels_minimum_amount' => $min_amount, |
| 168 | 168 | '_give_levels_maximum_amount' => $max_amount, |
| 169 | - '_give_donation_levels' => array_values( $prices ), |
|
| 169 | + '_give_donation_levels' => array_values($prices), |
|
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | $price_option = 'multi'; |
@@ -175,13 +175,13 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $defaults = array( |
| 178 | - '_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ), |
|
| 178 | + '_give_set_price' => give_sanitize_amount_for_db($data['amount']), |
|
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | 181 | // If new form is created. |
| 182 | - if ( ! empty( $new_form ) ) { |
|
| 182 | + if ( ! empty($new_form)) { |
|
| 183 | 183 | $new_form = array( |
| 184 | - '_give_custom_amount_text' => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'custom' ), |
|
| 184 | + '_give_custom_amount_text' => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'custom'), |
|
| 185 | 185 | '_give_logged_in_only' => 'enabled', |
| 186 | 186 | '_give_custom_amount' => 'enabled', |
| 187 | 187 | '_give_payment_import' => true, |
@@ -194,18 +194,18 @@ discard block |
||
| 194 | 194 | '_give_show_register_form' => 'both', |
| 195 | 195 | '_give_price_option' => $price_option, |
| 196 | 196 | ); |
| 197 | - $defaults = wp_parse_args( $defaults, $new_form ); |
|
| 197 | + $defaults = wp_parse_args($defaults, $new_form); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - $meta = wp_parse_args( $meta, $defaults ); |
|
| 200 | + $meta = wp_parse_args($meta, $defaults); |
|
| 201 | 201 | |
| 202 | - foreach ( $meta as $key => $value ) { |
|
| 203 | - give_update_meta( $form->get_ID(), $key, $value ); |
|
| 202 | + foreach ($meta as $key => $value) { |
|
| 203 | + give_update_meta($form->get_ID(), $key, $value); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // update the report |
| 208 | - give_import_donation_report_update( $report ); |
|
| 208 | + give_import_donation_report_update($report); |
|
| 209 | 209 | |
| 210 | 210 | return $form; |
| 211 | 211 | } |
@@ -219,36 +219,36 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return bool|false|WP_User |
| 221 | 221 | */ |
| 222 | -function give_import_get_user_from_csv( $data, $import_setting = array() ) { |
|
| 222 | +function give_import_get_user_from_csv($data, $import_setting = array()) { |
|
| 223 | 223 | $report = give_import_donation_report(); |
| 224 | - $dry_run = isset( $import_setting['dry_run'] ) ? $import_setting['dry_run'] : false; |
|
| 224 | + $dry_run = isset($import_setting['dry_run']) ? $import_setting['dry_run'] : false; |
|
| 225 | 225 | $dry_run_donor_create = false; |
| 226 | 226 | $donor_data = array(); |
| 227 | 227 | $donor_id = false; |
| 228 | 228 | |
| 229 | 229 | // check if donor id is not empty |
| 230 | - if ( ! empty( $data['donor_id'] ) ) { |
|
| 231 | - $donor_data = new Give_Donor( (int) $data['donor_id'] ); |
|
| 232 | - if ( ! empty( $donor_data->id ) ) { |
|
| 233 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 230 | + if ( ! empty($data['donor_id'])) { |
|
| 231 | + $donor_data = new Give_Donor((int) $data['donor_id']); |
|
| 232 | + if ( ! empty($donor_data->id)) { |
|
| 233 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) { |
|
| 237 | + if (empty($donor_data->id) && ! empty($data['user_id'])) { |
|
| 238 | 238 | $user_id = (int) $data['user_id']; |
| 239 | - $donor_data = new Give_Donor( $user_id, true ); |
|
| 239 | + $donor_data = new Give_Donor($user_id, true); |
|
| 240 | 240 | |
| 241 | 241 | |
| 242 | - if ( empty( $donor_data->id ) ) { |
|
| 243 | - $donor_data = get_user_by( 'id', $user_id ); |
|
| 242 | + if (empty($donor_data->id)) { |
|
| 243 | + $donor_data = get_user_by('id', $user_id); |
|
| 244 | 244 | |
| 245 | 245 | // if no wp user is found then no donor is create with that user id |
| 246 | - if ( ! empty( $donor_data->ID ) ) { |
|
| 246 | + if ( ! empty($donor_data->ID)) { |
|
| 247 | 247 | |
| 248 | - if ( empty( $dry_run ) ) { |
|
| 249 | - $first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename ); |
|
| 250 | - $last_name = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) ); |
|
| 251 | - $name = $first_name . ' ' . $last_name; |
|
| 248 | + if (empty($dry_run)) { |
|
| 249 | + $first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename); |
|
| 250 | + $last_name = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : '')); |
|
| 251 | + $name = $first_name.' '.$last_name; |
|
| 252 | 252 | $user_email = $donor_data->user_email; |
| 253 | 253 | $donor_args = array( |
| 254 | 254 | 'name' => $name, |
@@ -257,51 +257,51 @@ discard block |
||
| 257 | 257 | ); |
| 258 | 258 | |
| 259 | 259 | $donor_data = new Give_Donor(); |
| 260 | - $donor_data->create( $donor_args ); |
|
| 260 | + $donor_data->create($donor_args); |
|
| 261 | 261 | |
| 262 | 262 | // Adding notes that donor is being imported from CSV. |
| 263 | 263 | $current_user = wp_get_current_user(); |
| 264 | - $donor_data->add_note( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ); |
|
| 264 | + $donor_data->add_note(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email)); |
|
| 265 | 265 | |
| 266 | 266 | // Add is used to ensure duplicate emails are not added |
| 267 | - if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) { |
|
| 268 | - $donor_data->add_meta( 'additional_email', $data['email'] ); |
|
| 267 | + if ($user_email != $data['email'] && ! empty($data['email'])) { |
|
| 268 | + $donor_data->add_meta('additional_email', $data['email']); |
|
| 269 | 269 | } |
| 270 | 270 | } else { |
| 271 | 271 | $dry_run_donor_create = true; |
| 272 | - $donor_data = array( 'id' => 1 ); |
|
| 272 | + $donor_data = array('id' => 1); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
| 276 | - } elseif ( $dry_run ) { |
|
| 275 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
| 276 | + } elseif ($dry_run) { |
|
| 277 | 277 | $donor_data = array(); |
| 278 | 278 | } |
| 279 | 279 | } else { |
| 280 | 280 | // Add is used to ensure duplicate emails are not added |
| 281 | - if ( $donor_data->email != $data['email'] && empty( $dry_run ) ) { |
|
| 282 | - $donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) ); |
|
| 281 | + if ($donor_data->email != $data['email'] && empty($dry_run)) { |
|
| 282 | + $donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email)); |
|
| 283 | 283 | } |
| 284 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 284 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( empty( $donor_data->id ) && ! empty( $data['email'] ) && empty( $dry_run_donor_create ) ) { |
|
| 288 | + if (empty($donor_data->id) && ! empty($data['email']) && empty($dry_run_donor_create)) { |
|
| 289 | 289 | |
| 290 | - $donor_data = new Give_Donor( $data['email'] ); |
|
| 291 | - if ( empty( $donor_data->id ) ) { |
|
| 292 | - $donor_data = get_user_by( 'email', $data['email'] ); |
|
| 290 | + $donor_data = new Give_Donor($data['email']); |
|
| 291 | + if (empty($donor_data->id)) { |
|
| 292 | + $donor_data = get_user_by('email', $data['email']); |
|
| 293 | 293 | |
| 294 | - if ( empty( $donor_data->ID ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) { |
|
| 295 | - $data['first_name'] = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $data['email'] ); |
|
| 296 | - $data['last_name'] = ( ! empty( $data['last_name'] ) ? $data['last_name'] : '' ); |
|
| 297 | - $give_role = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) ); |
|
| 294 | + if (empty($donor_data->ID) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) { |
|
| 295 | + $data['first_name'] = ( ! empty($data['first_name']) ? $data['first_name'] : $data['email']); |
|
| 296 | + $data['last_name'] = ( ! empty($data['last_name']) ? $data['last_name'] : ''); |
|
| 297 | + $give_role = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber'))); |
|
| 298 | 298 | $donor_args = array( |
| 299 | 299 | 'user_login' => $data['email'], |
| 300 | 300 | 'user_email' => $data['email'], |
| 301 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 301 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 302 | 302 | 'user_first' => $data['first_name'], |
| 303 | 303 | 'user_last' => $data['last_name'], |
| 304 | - 'user_pass' => wp_generate_password( 8, true ), |
|
| 304 | + 'user_pass' => wp_generate_password(8, true), |
|
| 305 | 305 | 'role' => $give_role, |
| 306 | 306 | ); |
| 307 | 307 | |
@@ -310,64 +310,64 @@ discard block |
||
| 310 | 310 | * |
| 311 | 311 | * @since 1.8.13 |
| 312 | 312 | */ |
| 313 | - $donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting ); |
|
| 313 | + $donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting); |
|
| 314 | 314 | |
| 315 | - if ( empty( $dry_run ) ) { |
|
| 315 | + if (empty($dry_run)) { |
|
| 316 | 316 | |
| 317 | 317 | // This action was added to remove the login when using the give register function. |
| 318 | - add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
| 319 | - $donor_id = give_register_and_login_new_user( $donor_args ); |
|
| 320 | - remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 ); |
|
| 318 | + add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
| 319 | + $donor_id = give_register_and_login_new_user($donor_args); |
|
| 320 | + remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11); |
|
| 321 | 321 | |
| 322 | - $donor_data = new Give_Donor( $donor_id, true ); |
|
| 323 | - $donor_data->update_meta( '_give_payment_import', true ); |
|
| 322 | + $donor_data = new Give_Donor($donor_id, true); |
|
| 323 | + $donor_data->update_meta('_give_payment_import', true); |
|
| 324 | 324 | |
| 325 | 325 | } else { |
| 326 | 326 | $dry_run_donor_create = true; |
| 327 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
| 327 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
| 328 | 328 | } |
| 329 | 329 | } else { |
| 330 | - $donor_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false ); |
|
| 330 | + $donor_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if ( empty( $dry_run_donor_create ) && ( ! empty( $donor_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) ) { |
|
| 334 | - $donor_data = new Give_Donor( $donor_id, true ); |
|
| 333 | + if (empty($dry_run_donor_create) && ( ! empty($donor_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user'])))) { |
|
| 334 | + $donor_data = new Give_Donor($donor_id, true); |
|
| 335 | 335 | |
| 336 | - if ( empty( $donor_data->id ) ) { |
|
| 336 | + if (empty($donor_data->id)) { |
|
| 337 | 337 | |
| 338 | - if ( ! empty( $data['form_id'] ) ) { |
|
| 339 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
| 338 | + if ( ! empty($data['form_id'])) { |
|
| 339 | + $form = new Give_Donate_Form($data['form_id']); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if ( empty( $dry_run ) ) { |
|
| 343 | - $payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : __( 'New Form', 'give' ) ) ); |
|
| 342 | + if (empty($dry_run)) { |
|
| 343 | + $payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : __('New Form', 'give'))); |
|
| 344 | 344 | $donor_args = array( |
| 345 | - 'name' => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '', |
|
| 345 | + 'name' => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '', |
|
| 346 | 346 | 'email' => $data['email'], |
| 347 | 347 | ); |
| 348 | - if ( ! empty( $donor_id ) ) { |
|
| 348 | + if ( ! empty($donor_id)) { |
|
| 349 | 349 | $donor_args['user_id'] = $donor_id; |
| 350 | 350 | } |
| 351 | - $donor_data->create( $donor_args ); |
|
| 351 | + $donor_data->create($donor_args); |
|
| 352 | 352 | |
| 353 | 353 | // Adding notes that donor is being imported from CSV. |
| 354 | 354 | $current_user = wp_get_current_user(); |
| 355 | - $donor_data->add_note( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) ); |
|
| 355 | + $donor_data->add_note(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email)); |
|
| 356 | 356 | } else { |
| 357 | 357 | $dry_run_donor_create = true; |
| 358 | 358 | } |
| 359 | - $report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 ); |
|
| 359 | + $report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1); |
|
| 360 | 360 | } else { |
| 361 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 361 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } else { |
| 365 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 365 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | // update the report |
| 370 | - give_import_donation_report_update( $report ); |
|
| 370 | + give_import_donation_report_update($report); |
|
| 371 | 371 | |
| 372 | 372 | return $donor_data; |
| 373 | 373 | } |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | * |
| 386 | 386 | * @return array |
| 387 | 387 | */ |
| 388 | - return (array) apply_filters( 'give_import_default_options', array( |
|
| 389 | - '' => __( 'Do not import', 'give' ), |
|
| 390 | - ) ); |
|
| 388 | + return (array) apply_filters('give_import_default_options', array( |
|
| 389 | + '' => __('Do not import', 'give'), |
|
| 390 | + )); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -403,93 +403,93 @@ discard block |
||
| 403 | 403 | * |
| 404 | 404 | * @return array |
| 405 | 405 | */ |
| 406 | - return (array) apply_filters( 'give_import_donations_options', array( |
|
| 407 | - 'id' => __( 'Donation ID', 'give' ), |
|
| 406 | + return (array) apply_filters('give_import_donations_options', array( |
|
| 407 | + 'id' => __('Donation ID', 'give'), |
|
| 408 | 408 | 'amount' => array( |
| 409 | - __( 'Donation Amount', 'give' ), |
|
| 410 | - __( 'Amount', 'give' ), |
|
| 411 | - __( 'Donation Total', 'give' ), |
|
| 412 | - __( 'Total', 'give' ), |
|
| 409 | + __('Donation Amount', 'give'), |
|
| 410 | + __('Amount', 'give'), |
|
| 411 | + __('Donation Total', 'give'), |
|
| 412 | + __('Total', 'give'), |
|
| 413 | 413 | ), |
| 414 | 414 | 'currency' => array( |
| 415 | - __( 'Donation Currencies', 'give' ), |
|
| 416 | - __( 'Currencies', 'give' ), |
|
| 417 | - __( 'Currencies Code', 'give' ), |
|
| 418 | - __( 'Currency Code', 'give' ), |
|
| 419 | - __( 'Code', 'give' ), |
|
| 415 | + __('Donation Currencies', 'give'), |
|
| 416 | + __('Currencies', 'give'), |
|
| 417 | + __('Currencies Code', 'give'), |
|
| 418 | + __('Currency Code', 'give'), |
|
| 419 | + __('Code', 'give'), |
|
| 420 | 420 | ), |
| 421 | 421 | 'post_date' => array( |
| 422 | - __( 'Donation Date', 'give' ), |
|
| 423 | - __( 'Date', 'give' ), |
|
| 422 | + __('Donation Date', 'give'), |
|
| 423 | + __('Date', 'give'), |
|
| 424 | 424 | ), |
| 425 | 425 | 'post_time' => array( |
| 426 | - __( 'Donation Time', 'give' ), |
|
| 427 | - __( 'Time', 'give' ), |
|
| 426 | + __('Donation Time', 'give'), |
|
| 427 | + __('Time', 'give'), |
|
| 428 | 428 | ), |
| 429 | 429 | 'title_prefix' => array( |
| 430 | - __( 'Title Prefix', 'give' ), |
|
| 431 | - __( 'Prefix', 'give' ), |
|
| 430 | + __('Title Prefix', 'give'), |
|
| 431 | + __('Prefix', 'give'), |
|
| 432 | 432 | ), |
| 433 | 433 | 'first_name' => array( |
| 434 | - __( 'Donor First Name', 'give' ), |
|
| 435 | - __( 'First Name', 'give' ), |
|
| 436 | - __( 'Name', 'give' ), |
|
| 437 | - __( 'First', 'give' ), |
|
| 434 | + __('Donor First Name', 'give'), |
|
| 435 | + __('First Name', 'give'), |
|
| 436 | + __('Name', 'give'), |
|
| 437 | + __('First', 'give'), |
|
| 438 | 438 | ), |
| 439 | 439 | 'last_name' => array( |
| 440 | - __( 'Donor Last Name', 'give' ), |
|
| 441 | - __( 'Last Name', 'give' ), |
|
| 442 | - __( 'Last', 'give' ), |
|
| 440 | + __('Donor Last Name', 'give'), |
|
| 441 | + __('Last Name', 'give'), |
|
| 442 | + __('Last', 'give'), |
|
| 443 | 443 | ), |
| 444 | 444 | 'company_name' => array( |
| 445 | - __( 'Company Name', 'give' ), |
|
| 446 | - __( 'Donor Company Name', 'give' ), |
|
| 447 | - __( 'Donor Company', 'give' ), |
|
| 448 | - __( 'Company', 'give' ), |
|
| 445 | + __('Company Name', 'give'), |
|
| 446 | + __('Donor Company Name', 'give'), |
|
| 447 | + __('Donor Company', 'give'), |
|
| 448 | + __('Company', 'give'), |
|
| 449 | 449 | ), |
| 450 | 450 | 'line1' => array( |
| 451 | - __( 'Address 1', 'give' ), |
|
| 452 | - __( 'Address', 'give' ), |
|
| 451 | + __('Address 1', 'give'), |
|
| 452 | + __('Address', 'give'), |
|
| 453 | 453 | ), |
| 454 | - 'line2' => __( 'Address 2', 'give' ), |
|
| 455 | - 'city' => __( 'City', 'give' ), |
|
| 454 | + 'line2' => __('Address 2', 'give'), |
|
| 455 | + 'city' => __('City', 'give'), |
|
| 456 | 456 | 'state' => array( |
| 457 | - __( 'State', 'give' ), |
|
| 458 | - __( 'Province', 'give' ), |
|
| 459 | - __( 'County', 'give' ), |
|
| 460 | - __( 'Region', 'give' ), |
|
| 457 | + __('State', 'give'), |
|
| 458 | + __('Province', 'give'), |
|
| 459 | + __('County', 'give'), |
|
| 460 | + __('Region', 'give'), |
|
| 461 | 461 | ), |
| 462 | - 'country' => __( 'Country', 'give' ), |
|
| 462 | + 'country' => __('Country', 'give'), |
|
| 463 | 463 | 'zip' => array( |
| 464 | - __( 'Zip Code', 'give' ), |
|
| 465 | - __( 'Zip', 'give' ), |
|
| 466 | - __( 'zipcode', 'give' ), |
|
| 467 | - __( 'Postal Code', 'give' ), |
|
| 468 | - __( 'Postal', 'give' ), |
|
| 464 | + __('Zip Code', 'give'), |
|
| 465 | + __('Zip', 'give'), |
|
| 466 | + __('zipcode', 'give'), |
|
| 467 | + __('Postal Code', 'give'), |
|
| 468 | + __('Postal', 'give'), |
|
| 469 | 469 | ), |
| 470 | 470 | 'email' => array( |
| 471 | - __( 'Donor Email', 'give' ), |
|
| 472 | - __( 'Email', 'give' ), |
|
| 473 | - __( 'Email Address', 'give' ), |
|
| 471 | + __('Donor Email', 'give'), |
|
| 472 | + __('Email', 'give'), |
|
| 473 | + __('Email Address', 'give'), |
|
| 474 | 474 | ), |
| 475 | 475 | 'post_status' => array( |
| 476 | - __( 'Donation Status', 'give' ), |
|
| 477 | - __( 'Status', 'give' ), |
|
| 476 | + __('Donation Status', 'give'), |
|
| 477 | + __('Status', 'give'), |
|
| 478 | 478 | ), |
| 479 | 479 | 'gateway' => array( |
| 480 | - __( 'Payment Method', 'give' ), |
|
| 481 | - __( 'Method', 'give' ), |
|
| 482 | - __( 'Payment Gateway', 'give' ), |
|
| 483 | - __( 'Gateway', 'give' ), |
|
| 480 | + __('Payment Method', 'give'), |
|
| 481 | + __('Method', 'give'), |
|
| 482 | + __('Payment Gateway', 'give'), |
|
| 483 | + __('Gateway', 'give'), |
|
| 484 | 484 | ), |
| 485 | - 'notes' => __( 'Notes', 'give' ), |
|
| 485 | + 'notes' => __('Notes', 'give'), |
|
| 486 | 486 | 'mode' => array( |
| 487 | - __( 'Payment Mode', 'give' ), |
|
| 488 | - __( 'Mode', 'give' ), |
|
| 489 | - __( 'Test Mode', 'give' ), |
|
| 487 | + __('Payment Mode', 'give'), |
|
| 488 | + __('Mode', 'give'), |
|
| 489 | + __('Test Mode', 'give'), |
|
| 490 | 490 | ), |
| 491 | - 'post_meta' => __( 'Import as Meta', 'give' ), |
|
| 492 | - ) ); |
|
| 491 | + 'post_meta' => __('Import as Meta', 'give'), |
|
| 492 | + )); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -505,10 +505,10 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return array |
| 507 | 507 | */ |
| 508 | - return (array) apply_filters( 'give_import_donor_options', array( |
|
| 509 | - 'donor_id' => __( 'Donor ID', 'give' ), |
|
| 510 | - 'user_id' => __( 'User ID', 'give' ), |
|
| 511 | - ) ); |
|
| 508 | + return (array) apply_filters('give_import_donor_options', array( |
|
| 509 | + 'donor_id' => __('Donor ID', 'give'), |
|
| 510 | + 'user_id' => __('User ID', 'give'), |
|
| 511 | + )); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -524,29 +524,29 @@ discard block |
||
| 524 | 524 | * |
| 525 | 525 | * @return array |
| 526 | 526 | */ |
| 527 | - return (array) apply_filters( 'give_import_donation_form_options', array( |
|
| 527 | + return (array) apply_filters('give_import_donation_form_options', array( |
|
| 528 | 528 | 'form_title' => array( |
| 529 | - __( 'Donation Form Title', 'give' ), |
|
| 530 | - __( 'Donation Form', 'give' ), |
|
| 531 | - __( 'Form Name', 'give' ), |
|
| 532 | - __( 'Title', 'give' ), |
|
| 533 | - __( 'Form Title', 'give' ), |
|
| 529 | + __('Donation Form Title', 'give'), |
|
| 530 | + __('Donation Form', 'give'), |
|
| 531 | + __('Form Name', 'give'), |
|
| 532 | + __('Title', 'give'), |
|
| 533 | + __('Form Title', 'give'), |
|
| 534 | 534 | 'ignore' => array( |
| 535 | - __( 'Title Prefix', 'give' ), |
|
| 536 | - __( 'Prefix', 'give' ), |
|
| 535 | + __('Title Prefix', 'give'), |
|
| 536 | + __('Prefix', 'give'), |
|
| 537 | 537 | ), |
| 538 | 538 | ), |
| 539 | 539 | 'form_id' => array( |
| 540 | - __( 'Donation Form ID', 'give' ), |
|
| 541 | - __( 'Form ID', 'give' ), |
|
| 540 | + __('Donation Form ID', 'give'), |
|
| 541 | + __('Form ID', 'give'), |
|
| 542 | 542 | ), |
| 543 | 543 | 'form_level' => array( |
| 544 | - __( 'Donation Level', 'give' ), |
|
| 545 | - __( 'Level', 'give' ), |
|
| 546 | - __( 'Level Title', 'give' ), |
|
| 544 | + __('Donation Level', 'give'), |
|
| 545 | + __('Level', 'give'), |
|
| 546 | + __('Level Title', 'give'), |
|
| 547 | 547 | ), |
| 548 | - 'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ), |
|
| 549 | - ) ); |
|
| 548 | + 'form_custom_amount_text' => __('Custom Amount Text', 'give'), |
|
| 549 | + )); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | * |
| 560 | 560 | * @return array |
| 561 | 561 | */ |
| 562 | -function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) { |
|
| 562 | +function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') { |
|
| 563 | 563 | /** |
| 564 | 564 | * Filter to modify delimiter of Import |
| 565 | 565 | * |
@@ -569,11 +569,11 @@ discard block |
||
| 569 | 569 | * |
| 570 | 570 | * @return string $delimiter |
| 571 | 571 | */ |
| 572 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
| 572 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
| 573 | 573 | |
| 574 | - $file_dir = give_get_file_data_by_file_id( $file_id ); |
|
| 574 | + $file_dir = give_get_file_data_by_file_id($file_id); |
|
| 575 | 575 | |
| 576 | - return give_get_raw_data_from_file( $file_dir, $start, $end, $delimiter ); |
|
| 576 | + return give_get_raw_data_from_file($file_dir, $start, $end, $delimiter); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /** |
@@ -588,18 +588,18 @@ discard block |
||
| 588 | 588 | * |
| 589 | 589 | * @return array |
| 590 | 590 | */ |
| 591 | -function give_get_raw_data_from_file( $file_dir, $start, $end, $delimiter ) { |
|
| 591 | +function give_get_raw_data_from_file($file_dir, $start, $end, $delimiter) { |
|
| 592 | 592 | $raw_data = array(); |
| 593 | 593 | |
| 594 | 594 | $count = 0; |
| 595 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
| 596 | - while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) { |
|
| 597 | - if ( $count >= $start && $count <= $end ) { |
|
| 595 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
| 596 | + while (false !== ($row = fgetcsv($handle, 0, $delimiter))) { |
|
| 597 | + if ($count >= $start && $count <= $end) { |
|
| 598 | 598 | $raw_data[] = $row; |
| 599 | 599 | } |
| 600 | - $count ++; |
|
| 600 | + $count++; |
|
| 601 | 601 | } |
| 602 | - fclose( $handle ); |
|
| 602 | + fclose($handle); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | return $raw_data; |
@@ -614,8 +614,8 @@ discard block |
||
| 614 | 614 | * |
| 615 | 615 | * @return false|string file content |
| 616 | 616 | */ |
| 617 | -function give_get_file_data_by_file_id( $file_id ) { |
|
| 618 | - return get_attached_file( $file_id ); |
|
| 617 | +function give_get_file_data_by_file_id($file_id) { |
|
| 618 | + return get_attached_file($file_id); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | * |
| 629 | 629 | * @return bool |
| 630 | 630 | */ |
| 631 | -function give_log_user_in_on_register_callback( $value ) { |
|
| 631 | +function give_log_user_in_on_register_callback($value) { |
|
| 632 | 632 | return false; |
| 633 | 633 | } |
| 634 | 634 | |
@@ -644,87 +644,87 @@ discard block |
||
| 644 | 644 | * |
| 645 | 645 | * @return bool |
| 646 | 646 | */ |
| 647 | -function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) { |
|
| 648 | - $data = array_combine( $raw_key, $row_data ); |
|
| 647 | +function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) { |
|
| 648 | + $data = array_combine($raw_key, $row_data); |
|
| 649 | 649 | $price_id = false; |
| 650 | 650 | $donor_id = 0; |
| 651 | 651 | $donor_data = array(); |
| 652 | 652 | $form = array(); |
| 653 | - $import_setting['create_user'] = isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1; |
|
| 654 | - $dry_run = isset( $import_setting['dry_run'] ) ? $import_setting['dry_run'] : false; |
|
| 653 | + $import_setting['create_user'] = isset($import_setting['create_user']) ? $import_setting['create_user'] : 1; |
|
| 654 | + $dry_run = isset($import_setting['dry_run']) ? $import_setting['dry_run'] : false; |
|
| 655 | 655 | $_dry_run_is_duplicate = false; |
| 656 | 656 | $dry_run_duplicate_form = false; |
| 657 | 657 | $dry_run_duplicate_donor = false; |
| 658 | - $donation_key = empty( $import_setting['donation_key'] ) ? 1 : (int) $import_setting['donation_key']; |
|
| 658 | + $donation_key = empty($import_setting['donation_key']) ? 1 : (int) $import_setting['donation_key']; |
|
| 659 | 659 | $payment_id = false; |
| 660 | 660 | |
| 661 | - $data = (array) apply_filters( 'give_save_import_donation_to_db', $data ); |
|
| 661 | + $data = (array) apply_filters('give_save_import_donation_to_db', $data); |
|
| 662 | 662 | |
| 663 | - $data['amount'] = give_maybe_sanitize_amount( $data['amount'] ); |
|
| 663 | + $data['amount'] = give_maybe_sanitize_amount($data['amount']); |
|
| 664 | 664 | $diff = array(); |
| 665 | 665 | |
| 666 | - if ( ! empty( $dry_run ) && 1 !== $donation_key ) { |
|
| 667 | - $csv_raw_data = empty( $import_setting['csv_raw_data'] ) ? array() : $import_setting['csv_raw_data']; |
|
| 668 | - $donors_list = empty( $import_setting['donors_list'] ) ? array() : $import_setting['donors_list']; |
|
| 666 | + if ( ! empty($dry_run) && 1 !== $donation_key) { |
|
| 667 | + $csv_raw_data = empty($import_setting['csv_raw_data']) ? array() : $import_setting['csv_raw_data']; |
|
| 668 | + $donors_list = empty($import_setting['donors_list']) ? array() : $import_setting['donors_list']; |
|
| 669 | 669 | $key = $donation_key - 1; |
| 670 | - for ( $i = 0; $i < $key; $i ++ ) { |
|
| 671 | - $csv_data = array_combine( $raw_key, $csv_raw_data[ $i ] ); |
|
| 672 | - $csv_data['amount'] = give_maybe_sanitize_amount( $csv_data['amount'] ); |
|
| 670 | + for ($i = 0; $i < $key; $i++) { |
|
| 671 | + $csv_data = array_combine($raw_key, $csv_raw_data[$i]); |
|
| 672 | + $csv_data['amount'] = give_maybe_sanitize_amount($csv_data['amount']); |
|
| 673 | 673 | // check for duplicate donations |
| 674 | - $diff = array_diff( $csv_data, $data ); |
|
| 675 | - if ( empty( $diff ) ) { |
|
| 674 | + $diff = array_diff($csv_data, $data); |
|
| 675 | + if (empty($diff)) { |
|
| 676 | 676 | $_dry_run_is_duplicate = true; |
| 677 | 677 | $dry_run_duplicate_form = true; |
| 678 | 678 | $dry_run_duplicate_donor = true; |
| 679 | 679 | } else { |
| 680 | 680 | // check for duplicate donation form with form id |
| 681 | - if ( ! empty( $csv_data['form_id'] ) && ! empty( $data['form_id'] ) && $csv_data['form_id'] === $data['form_id'] ) { |
|
| 682 | - $form = new Give_Donate_Form( $data['form_id'] ); |
|
| 681 | + if ( ! empty($csv_data['form_id']) && ! empty($data['form_id']) && $csv_data['form_id'] === $data['form_id']) { |
|
| 682 | + $form = new Give_Donate_Form($data['form_id']); |
|
| 683 | 683 | $form_id = $form->get_ID(); |
| 684 | - if ( ! empty( $form_id ) ) { |
|
| 684 | + if ( ! empty($form_id)) { |
|
| 685 | 685 | $dry_run_duplicate_form = true; |
| 686 | 686 | } |
| 687 | 687 | } |
| 688 | 688 | // check for duplicate donation form with form title |
| 689 | - if ( empty( $dry_run_duplicate_form ) && ! empty( $csv_data['form_title'] ) && ! empty( $data['form_title'] ) && $csv_data['form_title'] === $data['form_title'] ) { |
|
| 689 | + if (empty($dry_run_duplicate_form) && ! empty($csv_data['form_title']) && ! empty($data['form_title']) && $csv_data['form_title'] === $data['form_title']) { |
|
| 690 | 690 | $dry_run_duplicate_form = true; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | |
| 694 | 694 | // check for duplicate donor by donor id |
| 695 | - if ( ! empty( $csv_data['donor_id'] ) && ! empty( $data['donor_id'] ) && $csv_data['donor_id'] === $data['donor_id'] ) { |
|
| 696 | - $donor = array_search( (int) $data['donor_id'], array_column( 'id', $donors_list ) ); |
|
| 697 | - if ( ! empty( $donor ) ) { |
|
| 695 | + if ( ! empty($csv_data['donor_id']) && ! empty($data['donor_id']) && $csv_data['donor_id'] === $data['donor_id']) { |
|
| 696 | + $donor = array_search((int) $data['donor_id'], array_column('id', $donors_list)); |
|
| 697 | + if ( ! empty($donor)) { |
|
| 698 | 698 | $dry_run_duplicate_donor = true; |
| 699 | 699 | } |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | // check for duplicate donor by user id |
| 703 | - if ( empty( $dry_run_duplicate_donor ) && ! empty( $csv_data['user_id'] ) && ! empty( $data['user_id'] ) && $csv_data['user_id'] === $data['user_id'] ) { |
|
| 704 | - $donor = array_search( (int) $data['user_id'], array_column( 'user_id', $donors_list ) ); |
|
| 705 | - if ( ! empty( $donor ) ) { |
|
| 703 | + if (empty($dry_run_duplicate_donor) && ! empty($csv_data['user_id']) && ! empty($data['user_id']) && $csv_data['user_id'] === $data['user_id']) { |
|
| 704 | + $donor = array_search((int) $data['user_id'], array_column('user_id', $donors_list)); |
|
| 705 | + if ( ! empty($donor)) { |
|
| 706 | 706 | $dry_run_duplicate_donor = true; |
| 707 | 707 | } else { |
| 708 | - $donor = get_user_by( 'id', $csv_data['user_id'] ); |
|
| 709 | - if ( ! empty( $donor->ID ) ) { |
|
| 708 | + $donor = get_user_by('id', $csv_data['user_id']); |
|
| 709 | + if ( ! empty($donor->ID)) { |
|
| 710 | 710 | $dry_run_duplicate_donor = true; |
| 711 | 711 | } |
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | // check for duplicate donor by donor id |
| 716 | - if ( empty( $dry_run_duplicate_donor ) && ! empty( $csv_data['email'] ) && ! empty( $data['email'] ) && $csv_data['email'] === $data['email'] ) { |
|
| 716 | + if (empty($dry_run_duplicate_donor) && ! empty($csv_data['email']) && ! empty($data['email']) && $csv_data['email'] === $data['email']) { |
|
| 717 | 717 | $dry_run_duplicate_donor = true; |
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - if ( empty( $dry_run_duplicate_donor ) ) { |
|
| 723 | + if (empty($dry_run_duplicate_donor)) { |
|
| 724 | 724 | // Here come the login function. |
| 725 | - $donor_data = give_import_get_user_from_csv( $data, $import_setting ); |
|
| 726 | - if ( empty( $dry_run ) ) { |
|
| 727 | - if ( ! empty( $donor_data->id ) ) { |
|
| 725 | + $donor_data = give_import_get_user_from_csv($data, $import_setting); |
|
| 726 | + if (empty($dry_run)) { |
|
| 727 | + if ( ! empty($donor_data->id)) { |
|
| 728 | 728 | $donor_id = $donor_data->id; |
| 729 | 729 | } else { |
| 730 | 730 | return $payment_id; |
@@ -733,52 +733,52 @@ discard block |
||
| 733 | 733 | } else { |
| 734 | 734 | // Get the report |
| 735 | 735 | $report = give_import_donation_report(); |
| 736 | - $report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 ); |
|
| 736 | + $report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1); |
|
| 737 | 737 | // update the report |
| 738 | - give_import_donation_report_update( $report ); |
|
| 738 | + give_import_donation_report_update($report); |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - if ( empty( $dry_run_duplicate_form ) ) { |
|
| 741 | + if (empty($dry_run_duplicate_form)) { |
|
| 742 | 742 | // get form data or register a form data. |
| 743 | - $form = give_import_get_form_data_from_csv( $data, $import_setting ); |
|
| 744 | - if ( false == $form && empty( $dry_run ) ) { |
|
| 743 | + $form = give_import_get_form_data_from_csv($data, $import_setting); |
|
| 744 | + if (false == $form && empty($dry_run)) { |
|
| 745 | 745 | return $payment_id; |
| 746 | 746 | } else { |
| 747 | - $price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false; |
|
| 747 | + $price_id = ( ! empty($form->price_id)) ? $form->price_id : false; |
|
| 748 | 748 | } |
| 749 | 749 | } else { |
| 750 | 750 | // Get the report |
| 751 | 751 | $report = give_import_donation_report(); |
| 752 | - $report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 ); |
|
| 752 | + $report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1); |
|
| 753 | 753 | // update the report |
| 754 | - give_import_donation_report_update( $report ); |
|
| 754 | + give_import_donation_report_update($report); |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | // Get the report |
| 758 | 758 | $report = give_import_donation_report(); |
| 759 | 759 | |
| 760 | 760 | |
| 761 | - $status = give_import_donation_get_status( $data ); |
|
| 762 | - $country = ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' ); |
|
| 763 | - $state = ( ! empty( $data['state'] ) ? ( ( $state_code = array_search( $data['state'], give_get_states( $country ) ) ) ? $state_code : $data['state'] ) : '' ); |
|
| 761 | + $status = give_import_donation_get_status($data); |
|
| 762 | + $country = ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : ''); |
|
| 763 | + $state = ( ! empty($data['state']) ? (($state_code = array_search($data['state'], give_get_states($country))) ? $state_code : $data['state']) : ''); |
|
| 764 | 764 | |
| 765 | 765 | $address = array( |
| 766 | - 'line1' => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ), |
|
| 767 | - 'line2' => ( ! empty( $data['line2'] ) ? give_clean( $data['line2'] ) : '' ), |
|
| 768 | - 'city' => ( ! empty( $data['city'] ) ? give_clean( $data['city'] ) : '' ), |
|
| 769 | - 'zip' => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ), |
|
| 766 | + 'line1' => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''), |
|
| 767 | + 'line2' => ( ! empty($data['line2']) ? give_clean($data['line2']) : ''), |
|
| 768 | + 'city' => ( ! empty($data['city']) ? give_clean($data['city']) : ''), |
|
| 769 | + 'zip' => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''), |
|
| 770 | 770 | 'state' => $state, |
| 771 | 771 | 'country' => $country, |
| 772 | 772 | ); |
| 773 | 773 | |
| 774 | - $test_mode = array( 'test', 'true', ); |
|
| 775 | - $post_date = current_time( 'mysql' ); |
|
| 776 | - if ( ! empty( $data['post_date'] ) ) { |
|
| 777 | - if ( ! empty( $data['post_time'] ) ) { |
|
| 778 | - $post_date = mysql2date( 'Y-m-d', $data['post_date'] ); |
|
| 779 | - $post_date = mysql2date( 'Y-m-d H:i:s', $post_date . ' ' . $data['post_time'] ); |
|
| 774 | + $test_mode = array('test', 'true',); |
|
| 775 | + $post_date = current_time('mysql'); |
|
| 776 | + if ( ! empty($data['post_date'])) { |
|
| 777 | + if ( ! empty($data['post_time'])) { |
|
| 778 | + $post_date = mysql2date('Y-m-d', $data['post_date']); |
|
| 779 | + $post_date = mysql2date('Y-m-d H:i:s', $post_date.' '.$data['post_time']); |
|
| 780 | 780 | } else { |
| 781 | - $post_date = mysql2date( 'Y-m-d H:i:s', $data['post_date'] ); |
|
| 781 | + $post_date = mysql2date('Y-m-d H:i:s', $data['post_date']); |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
@@ -787,23 +787,23 @@ discard block |
||
| 787 | 787 | 'donor_id' => $donor_id, |
| 788 | 788 | 'price' => $data['amount'], |
| 789 | 789 | 'status' => $status, |
| 790 | - 'currency' => ! empty( $data['currency'] ) && array_key_exists( $data['currency'], give_get_currencies_list() ) ? $data['currency'] : give_get_currency(), |
|
| 790 | + 'currency' => ! empty($data['currency']) && array_key_exists($data['currency'], give_get_currencies_list()) ? $data['currency'] : give_get_currency(), |
|
| 791 | 791 | 'user_info' => array( |
| 792 | 792 | 'id' => $donor_id, |
| 793 | - 'email' => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ), |
|
| 794 | - 'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $donor_id ) && ( $first_name = get_user_meta( $donor_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ), |
|
| 795 | - 'last_name' => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $donor_id ) && ( $last_name = get_user_meta( $donor_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ), |
|
| 793 | + 'email' => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)), |
|
| 794 | + 'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($donor_id) && ($first_name = get_user_meta($donor_id, 'first_name', true)) ? $first_name : $donor_data->name)), |
|
| 795 | + 'last_name' => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($donor_id) && ($last_name = get_user_meta($donor_id, 'last_name', true)) ? $last_name : $donor_data->name)), |
|
| 796 | 796 | 'address' => $address, |
| 797 | - 'title' => ! empty( $data['title_prefix'] ) ? $data['title_prefix'] : '', |
|
| 797 | + 'title' => ! empty($data['title_prefix']) ? $data['title_prefix'] : '', |
|
| 798 | 798 | ), |
| 799 | - 'gateway' => ( ! empty( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ), |
|
| 800 | - 'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : ( method_exists( $form, 'get_name' ) ? $form->get_name() : '' ) ), |
|
| 801 | - 'give_form_id' => method_exists( $form, 'get_ID' ) ? $form->get_ID() : '', |
|
| 799 | + 'gateway' => ( ! empty($data['gateway']) ? strtolower($data['gateway']) : 'manual'), |
|
| 800 | + 'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : (method_exists($form, 'get_name') ? $form->get_name() : '')), |
|
| 801 | + 'give_form_id' => method_exists($form, 'get_ID') ? $form->get_ID() : '', |
|
| 802 | 802 | 'give_price_id' => $price_id, |
| 803 | - 'purchase_key' => strtolower( md5( uniqid() ) ), |
|
| 803 | + 'purchase_key' => strtolower(md5(uniqid())), |
|
| 804 | 804 | 'user_email' => $data['email'], |
| 805 | 805 | 'post_date' => $post_date, |
| 806 | - 'mode' => ( ! empty( $data['mode'] ) ? ( in_array( strtolower( $data['mode'] ), $test_mode ) ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ), |
|
| 806 | + 'mode' => ( ! empty($data['mode']) ? (in_array(strtolower($data['mode']), $test_mode) ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))), |
|
| 807 | 807 | ); |
| 808 | 808 | |
| 809 | 809 | /** |
@@ -818,74 +818,74 @@ discard block |
||
| 818 | 818 | * |
| 819 | 819 | * @return array $payment_data payment data |
| 820 | 820 | */ |
| 821 | - $payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form ); |
|
| 821 | + $payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form); |
|
| 822 | 822 | |
| 823 | 823 | // Get the report |
| 824 | 824 | $report = give_import_donation_report(); |
| 825 | 825 | |
| 826 | 826 | // Check for duplicate code. |
| 827 | - $donation_duplicate = give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ); |
|
| 828 | - if ( false !== $donation_duplicate || ! empty( $_dry_run_is_duplicate ) ) { |
|
| 829 | - $report['donation_details'][ $import_setting['donation_key'] ]['duplicate'] = $donation_duplicate; |
|
| 830 | - $report['duplicate_donation'] = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 ); |
|
| 827 | + $donation_duplicate = give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data); |
|
| 828 | + if (false !== $donation_duplicate || ! empty($_dry_run_is_duplicate)) { |
|
| 829 | + $report['donation_details'][$import_setting['donation_key']]['duplicate'] = $donation_duplicate; |
|
| 830 | + $report['duplicate_donation'] = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1); |
|
| 831 | 831 | } else { |
| 832 | 832 | |
| 833 | - if ( empty( $dry_run ) ) { |
|
| 834 | - add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 ); |
|
| 835 | - add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 ); |
|
| 836 | - add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 ); |
|
| 837 | - add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 ); |
|
| 833 | + if (empty($dry_run)) { |
|
| 834 | + add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1); |
|
| 835 | + add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2); |
|
| 836 | + add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3); |
|
| 837 | + add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2); |
|
| 838 | 838 | |
| 839 | 839 | // if it status is other then pending then first change the donation status to pending and after adding the payment meta update the donation status. |
| 840 | - if ( 'pending' !== $status ) { |
|
| 841 | - unset( $payment_data['status'] ); |
|
| 840 | + if ('pending' !== $status) { |
|
| 841 | + unset($payment_data['status']); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - $payment_id = give_insert_payment( $payment_data ); |
|
| 845 | - remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 ); |
|
| 846 | - remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 ); |
|
| 847 | - remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 ); |
|
| 848 | - remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 ); |
|
| 844 | + $payment_id = give_insert_payment($payment_data); |
|
| 845 | + remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1); |
|
| 846 | + remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11); |
|
| 847 | + remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11); |
|
| 848 | + remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11); |
|
| 849 | 849 | |
| 850 | - if ( $payment_id ) { |
|
| 850 | + if ($payment_id) { |
|
| 851 | 851 | |
| 852 | - $payment = new Give_Payment( $payment_id ); |
|
| 852 | + $payment = new Give_Payment($payment_id); |
|
| 853 | 853 | |
| 854 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
| 854 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
| 855 | 855 | |
| 856 | - $payment->update_meta( '_give_payment_import', true ); |
|
| 856 | + $payment->update_meta('_give_payment_import', true); |
|
| 857 | 857 | |
| 858 | - if ( ! empty( $import_setting['csv'] ) ) { |
|
| 859 | - $payment->update_meta( '_give_payment_import_id', $import_setting['csv'] ); |
|
| 858 | + if ( ! empty($import_setting['csv'])) { |
|
| 859 | + $payment->update_meta('_give_payment_import_id', $import_setting['csv']); |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | // Insert Company Name. |
| 863 | - if ( ! empty( $data['company_name'] ) ) { |
|
| 864 | - $payment->update_meta( '_give_donation_company', $data['company_name'] ); |
|
| 865 | - $donor_data->update_meta( '_give_donor_company', $data['company_name'] ); |
|
| 863 | + if ( ! empty($data['company_name'])) { |
|
| 864 | + $payment->update_meta('_give_donation_company', $data['company_name']); |
|
| 865 | + $donor_data->update_meta('_give_donor_company', $data['company_name']); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | // Insert Notes. |
| 869 | - if ( ! empty( $data['notes'] ) ) { |
|
| 870 | - $payment->add_note( $data['notes'] ); |
|
| 869 | + if ( ! empty($data['notes'])) { |
|
| 870 | + $payment->add_note($data['notes']); |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - $meta_exists = array_keys( $raw_key, 'post_meta' ); |
|
| 874 | - if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) { |
|
| 875 | - foreach ( $meta_exists as $meta_exist ) { |
|
| 876 | - if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) { |
|
| 877 | - $payment->update_meta( $main_key[ $meta_exist ], $row_data[ $meta_exist ] ); |
|
| 873 | + $meta_exists = array_keys($raw_key, 'post_meta'); |
|
| 874 | + if ( ! empty($main_key) && ! empty($meta_exists)) { |
|
| 875 | + foreach ($meta_exists as $meta_exist) { |
|
| 876 | + if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) { |
|
| 877 | + $payment->update_meta($main_key[$meta_exist], $row_data[$meta_exist]); |
|
| 878 | 878 | } |
| 879 | 879 | } |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | // update the donation status if it's other then pending |
| 883 | - if ( 'pending' !== $status ) { |
|
| 884 | - $payment->update_status( $status ); |
|
| 883 | + if ('pending' !== $status) { |
|
| 884 | + $payment->update_status($status); |
|
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | } else { |
| 888 | - $report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 ); |
|
| 888 | + $report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1); |
|
| 889 | 889 | $payment_id = false; |
| 890 | 890 | } |
| 891 | 891 | |
@@ -900,15 +900,15 @@ discard block |
||
| 900 | 900 | * @param array $donor_data donor data |
| 901 | 901 | * @param object $donor_data form object |
| 902 | 902 | */ |
| 903 | - do_action( 'give_import_after_import_payment', $payment, $payment_data, $data, $donor_data, $form ); |
|
| 903 | + do_action('give_import_after_import_payment', $payment, $payment_data, $data, $donor_data, $form); |
|
| 904 | 904 | } else { |
| 905 | - $report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 ); |
|
| 905 | + $report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1); |
|
| 906 | 906 | $payment_id = true; |
| 907 | 907 | } |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | // update the report |
| 911 | - give_import_donation_report_update( $report ); |
|
| 911 | + give_import_donation_report_update($report); |
|
| 912 | 912 | |
| 913 | 913 | return $payment_id; |
| 914 | 914 | } |
@@ -922,25 +922,25 @@ discard block |
||
| 922 | 922 | * |
| 923 | 923 | * @return string $status Donation status. |
| 924 | 924 | */ |
| 925 | -function give_import_donation_get_status( $data ) { |
|
| 926 | - if ( empty( $data['post_status'] ) ) { |
|
| 925 | +function give_import_donation_get_status($data) { |
|
| 926 | + if (empty($data['post_status'])) { |
|
| 927 | 927 | return 'publish'; |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | 930 | $status = 'publish'; |
| 931 | 931 | |
| 932 | - $donation_status = trim( $data['post_status'] ); |
|
| 933 | - $donation_status_key = strtolower( preg_replace( '/\s+/', '', $donation_status ) ); |
|
| 932 | + $donation_status = trim($data['post_status']); |
|
| 933 | + $donation_status_key = strtolower(preg_replace('/\s+/', '', $donation_status)); |
|
| 934 | 934 | |
| 935 | - foreach ( give_get_payment_statuses() as $key => $value ) { |
|
| 935 | + foreach (give_get_payment_statuses() as $key => $value) { |
|
| 936 | 936 | $match = false; |
| 937 | - if ( $key === $donation_status_key ) { |
|
| 937 | + if ($key === $donation_status_key) { |
|
| 938 | 938 | $match = true; |
| 939 | - } else if ( stristr( $donation_status, $value ) ) { |
|
| 939 | + } else if (stristr($donation_status, $value)) { |
|
| 940 | 940 | $match = true; |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - if ( ! empty( $match ) ) { |
|
| 943 | + if ( ! empty($match)) { |
|
| 944 | 944 | $status = $key; |
| 945 | 945 | break; |
| 946 | 946 | } |
@@ -960,12 +960,12 @@ discard block |
||
| 960 | 960 | * |
| 961 | 961 | * @return Give_Donor |
| 962 | 962 | */ |
| 963 | -function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) { |
|
| 963 | +function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) { |
|
| 964 | 964 | $old_donor = $donor; |
| 965 | - if ( ! empty( $payment_data['donor_id'] ) ) { |
|
| 966 | - $donor_id = absint( $payment_data['donor_id'] ); |
|
| 967 | - $donor = new Give_Donor( $donor_id ); |
|
| 968 | - if ( ! empty( $donor->id ) ) { |
|
| 965 | + if ( ! empty($payment_data['donor_id'])) { |
|
| 966 | + $donor_id = absint($payment_data['donor_id']); |
|
| 967 | + $donor = new Give_Donor($donor_id); |
|
| 968 | + if ( ! empty($donor->id)) { |
|
| 969 | 969 | return $donor; |
| 970 | 970 | } |
| 971 | 971 | } |
@@ -978,12 +978,12 @@ discard block |
||
| 978 | 978 | * |
| 979 | 979 | * @since 1.8.13 |
| 980 | 980 | */ |
| 981 | -function give_import_donation_insert_payment( $payment_id, $payment_data ) { |
|
| 981 | +function give_import_donation_insert_payment($payment_id, $payment_data) { |
|
| 982 | 982 | // Update Give Customers purchase_count |
| 983 | - if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) { |
|
| 984 | - $donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true ); |
|
| 985 | - if ( ! empty( $donor_id ) ) { |
|
| 986 | - $donor = new Give_Donor( $donor_id ); |
|
| 983 | + if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) { |
|
| 984 | + $donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true); |
|
| 985 | + if ( ! empty($donor_id)) { |
|
| 986 | + $donor = new Give_Donor($donor_id); |
|
| 987 | 987 | $donor->increase_purchase_count(); |
| 988 | 988 | } |
| 989 | 989 | } |
@@ -994,8 +994,8 @@ discard block |
||
| 994 | 994 | * |
| 995 | 995 | * @since 1.8.13 |
| 996 | 996 | */ |
| 997 | -function give_donation_import_give_insert_payment_args( $args, $payment_data ) { |
|
| 998 | - if ( ! empty( $payment_data['user_info']['id'] ) ) { |
|
| 997 | +function give_donation_import_give_insert_payment_args($args, $payment_data) { |
|
| 998 | + if ( ! empty($payment_data['user_info']['id'])) { |
|
| 999 | 999 | $args['post_author'] = (int) $payment_data['user_info']['id']; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
@@ -1007,11 +1007,11 @@ discard block |
||
| 1007 | 1007 | * |
| 1008 | 1008 | * @since 1.8.13 |
| 1009 | 1009 | */ |
| 1010 | -function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) { |
|
| 1010 | +function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) { |
|
| 1011 | 1011 | $return = false; |
| 1012 | - if ( ! empty( $data['post_date'] ) ) { |
|
| 1013 | - $post_date = mysql2date( 'Y-m-d-H-i-s', $payment_data['post_date'] ); |
|
| 1014 | - $post_date = explode( '-', $post_date ); |
|
| 1012 | + if ( ! empty($data['post_date'])) { |
|
| 1013 | + $post_date = mysql2date('Y-m-d-H-i-s', $payment_data['post_date']); |
|
| 1014 | + $post_date = explode('-', $post_date); |
|
| 1015 | 1015 | $args = array( |
| 1016 | 1016 | 'output' => 'post', |
| 1017 | 1017 | 'cache_results' => false, |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | 'meta_query' => array( |
| 1033 | 1033 | array( |
| 1034 | 1034 | 'key' => '_give_payment_total', |
| 1035 | - 'value' => preg_replace( '/[\$,]/', '', $payment_data['price'] ), |
|
| 1035 | + 'value' => preg_replace('/[\$,]/', '', $payment_data['price']), |
|
| 1036 | 1036 | 'compare' => 'LIKE', |
| 1037 | 1037 | ), |
| 1038 | 1038 | array( |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | ), |
| 1049 | 1049 | array( |
| 1050 | 1050 | 'key' => '_give_payment_donor_id', |
| 1051 | - 'value' => isset( $donor_data->id ) ? $donor_data->id : '', |
|
| 1051 | + 'value' => isset($donor_data->id) ? $donor_data->id : '', |
|
| 1052 | 1052 | 'compare' => '=', |
| 1053 | 1053 | ), |
| 1054 | 1054 | array( |
@@ -1059,9 +1059,9 @@ discard block |
||
| 1059 | 1059 | ), |
| 1060 | 1060 | ); |
| 1061 | 1061 | |
| 1062 | - $payments = new Give_Payments_Query( $args ); |
|
| 1062 | + $payments = new Give_Payments_Query($args); |
|
| 1063 | 1063 | $donations = $payments->get_payments(); |
| 1064 | - if ( ! empty( $donations ) ) { |
|
| 1064 | + if ( ! empty($donations)) { |
|
| 1065 | 1065 | $return = $donations; |
| 1066 | 1066 | } |
| 1067 | 1067 | } |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | * |
| 1072 | 1072 | * @since 1.8.18 |
| 1073 | 1073 | */ |
| 1074 | - return apply_filters( 'give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data ); |
|
| 1074 | + return apply_filters('give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data); |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1083,9 +1083,9 @@ discard block |
||
| 1083 | 1083 | * |
| 1084 | 1084 | * @return void |
| 1085 | 1085 | */ |
| 1086 | -function give_donation_import_insert_default_payment_note( $payment_id ) { |
|
| 1086 | +function give_donation_import_insert_default_payment_note($payment_id) { |
|
| 1087 | 1087 | $current_user = wp_get_current_user(); |
| 1088 | - give_insert_payment_note( $payment_id, wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) ); |
|
| 1088 | + give_insert_payment_note($payment_id, wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email)); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | /** |
@@ -1097,14 +1097,14 @@ discard block |
||
| 1097 | 1097 | * |
| 1098 | 1098 | * @return string URL |
| 1099 | 1099 | */ |
| 1100 | -function give_import_page_url( $parameter = array() ) { |
|
| 1100 | +function give_import_page_url($parameter = array()) { |
|
| 1101 | 1101 | $defalut_query_arg = array( |
| 1102 | 1102 | 'post_type' => 'give_forms', |
| 1103 | 1103 | 'page' => 'give-tools', |
| 1104 | 1104 | 'tab' => 'import', |
| 1105 | 1105 | 'importer-type' => 'import_donations', |
| 1106 | 1106 | ); |
| 1107 | - $import_query_arg = wp_parse_args( $parameter, $defalut_query_arg ); |
|
| 1107 | + $import_query_arg = wp_parse_args($parameter, $defalut_query_arg); |
|
| 1108 | 1108 | |
| 1109 | - return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) ); |
|
| 1109 | + return add_query_arg($import_query_arg, admin_url('edit.php')); |
|
| 1110 | 1110 | } |
@@ -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 | |
@@ -26,34 +26,34 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
| 29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
| 30 | 30 | // Bailout. |
| 31 | - if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) { |
|
| 31 | + if ( ! function_exists('give_v18_renamed_core_settings')) { |
|
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Get old setting names. |
| 36 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
| 36 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
| 37 | 37 | $update_setting = false; |
| 38 | 38 | |
| 39 | - foreach ( $settings as $key => $value ) { |
|
| 39 | + foreach ($settings as $key => $value) { |
|
| 40 | 40 | |
| 41 | 41 | // Check 1. Check if new option is really updated or not. |
| 42 | 42 | // Check 2. Continue if key is not renamed. |
| 43 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
| 43 | + if ( ! isset($old_settings[$key])) { |
|
| 44 | 44 | continue; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Set old setting. |
| 48 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
| 48 | + $settings[$old_settings[$key]] = 'on'; |
|
| 49 | 49 | |
| 50 | 50 | // Do not need to set old setting if new setting is not set. |
| 51 | 51 | if ( |
| 52 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
| 53 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
| 52 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
| 53 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
| 54 | 54 | |
| 55 | 55 | ) { |
| 56 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
| 56 | + unset($settings[$old_settings[$key]]); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Tell bot to update setting. |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Update setting if any old setting set. |
| 64 | - if ( $update_setting ) { |
|
| 65 | - update_option( 'give_settings', $settings, false ); |
|
| 64 | + if ($update_setting) { |
|
| 65 | + update_option('give_settings', $settings, false); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
| 69 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Check spam through Akismet. |
@@ -80,45 +80,45 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return bool|mixed |
| 82 | 82 | */ |
| 83 | -function give_akismet( $spam ) { |
|
| 83 | +function give_akismet($spam) { |
|
| 84 | 84 | |
| 85 | 85 | // Bail out, If spam. |
| 86 | - if ( $spam ) { |
|
| 86 | + if ($spam) { |
|
| 87 | 87 | return $spam; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Bail out, if Akismet key not exist. |
| 91 | - if ( ! give_check_akismet_key() ) { |
|
| 91 | + if ( ! give_check_akismet_key()) { |
|
| 92 | 92 | return false; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Build args array. |
| 96 | 96 | $args = array(); |
| 97 | 97 | |
| 98 | - $args['comment_author'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
| 99 | - $args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
| 100 | - $args['blog'] = get_option( 'home' ); |
|
| 98 | + $args['comment_author'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
| 99 | + $args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
| 100 | + $args['blog'] = get_option('home'); |
|
| 101 | 101 | $args['blog_lang'] = get_locale(); |
| 102 | - $args['blog_charset'] = get_option( 'blog_charset' ); |
|
| 102 | + $args['blog_charset'] = get_option('blog_charset'); |
|
| 103 | 103 | $args['user_ip'] = $_SERVER['REMOTE_ADDR']; |
| 104 | 104 | $args['user_agent'] = $_SERVER['HTTP_USER_AGENT']; |
| 105 | 105 | $args['referrer'] = $_SERVER['HTTP_REFERER']; |
| 106 | 106 | $args['comment_type'] = 'contact-form'; |
| 107 | 107 | |
| 108 | - $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ); |
|
| 108 | + $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'); |
|
| 109 | 109 | |
| 110 | - foreach ( $_SERVER as $key => $value ) { |
|
| 111 | - if ( ! in_array( $key, (array) $ignore ) ) { |
|
| 110 | + foreach ($_SERVER as $key => $value) { |
|
| 111 | + if ( ! in_array($key, (array) $ignore)) { |
|
| 112 | 112 | $args["$key"] = $value; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // It will return Akismet spam detect API response. |
| 117 | - return give_akismet_spam_check( $args ); |
|
| 117 | + return give_akismet_spam_check($args); |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -add_filter( 'give_spam', 'give_akismet' ); |
|
| 121 | +add_filter('give_spam', 'give_akismet'); |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * Check Akismet API Key. |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | * @return bool |
| 129 | 129 | */ |
| 130 | 130 | function give_check_akismet_key() { |
| 131 | - if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+ |
|
| 131 | + if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+ |
|
| 132 | 132 | return (bool) Akismet::get_api_key(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if ( function_exists( 'akismet_get_key' ) ) { |
|
| 135 | + if (function_exists('akismet_get_key')) { |
|
| 136 | 136 | return (bool) akismet_get_key(); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -148,26 +148,26 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return bool|mixed |
| 150 | 150 | */ |
| 151 | -function give_akismet_spam_check( $args ) { |
|
| 151 | +function give_akismet_spam_check($args) { |
|
| 152 | 152 | global $akismet_api_host, $akismet_api_port; |
| 153 | 153 | |
| 154 | 154 | $spam = false; |
| 155 | - $query_string = http_build_query( $args ); |
|
| 155 | + $query_string = http_build_query($args); |
|
| 156 | 156 | |
| 157 | - if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+ |
|
| 158 | - $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
| 157 | + if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+ |
|
| 158 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
| 159 | 159 | } else { |
| 160 | - $response = akismet_http_post( $query_string, $akismet_api_host, |
|
| 161 | - '/1.1/comment-check', $akismet_api_port ); |
|
| 160 | + $response = akismet_http_post($query_string, $akismet_api_host, |
|
| 161 | + '/1.1/comment-check', $akismet_api_port); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // It's spam if response status is true. |
| 165 | - if ( 'true' === $response[1] ) { |
|
| 165 | + if ('true' === $response[1]) { |
|
| 166 | 166 | $spam = true; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Allow developer to modified Akismet spam detection response. |
| 170 | - return apply_filters( 'give_akismet_spam_check', $spam, $args ); |
|
| 170 | + return apply_filters('give_akismet_spam_check', $spam, $args); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @return array |
| 182 | 182 | */ |
| 183 | -function give_bc_v1817_iranian_currency_code( $currencies ) { |
|
| 184 | - if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) { |
|
| 183 | +function give_bc_v1817_iranian_currency_code($currencies) { |
|
| 184 | + if ( ! give_has_upgrade_completed('v1817_update_donation_iranian_currency_code')) { |
|
| 185 | 185 | $currencies['RIAL'] = $currencies['IRR']; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | return $currencies; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | -add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 ); |
|
| 191 | +add_filter('give_currencies', 'give_bc_v1817_iranian_currency_code', 0); |
|
| 192 | 192 | |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -202,25 +202,23 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @return string |
| 204 | 204 | */ |
| 205 | -function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) { |
|
| 206 | - if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) { |
|
| 205 | +function give_format_price_for_right_to_left_supported_currency($formatted_amount, $currency_args, $price) { |
|
| 206 | + if ( ! give_is_right_to_left_supported_currency($currency_args['currency_code'])) { |
|
| 207 | 207 | return $formatted_amount; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | $formatted_amount = ( |
| 211 | 211 | 'before' === (string) $currency_args['position'] ? |
| 212 | - '‫' . $price . $currency_args['symbol'] . '‬' : |
|
| 213 | - '‪' . $price . $currency_args['symbol'] . '‬' |
|
| 212 | + '‫'.$price.$currency_args['symbol'].'‬' : '‪'.$price.$currency_args['symbol'].'‬' |
|
| 214 | 213 | ); |
| 215 | 214 | |
| 216 | 215 | $formatted_amount = $currency_args['decode_currency'] ? |
| 217 | - html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) : |
|
| 218 | - $formatted_amount; |
|
| 216 | + html_entity_decode($formatted_amount, ENT_COMPAT, 'UTF-8') : $formatted_amount; |
|
| 219 | 217 | |
| 220 | 218 | return $formatted_amount; |
| 221 | 219 | } |
| 222 | 220 | |
| 223 | -add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 ); |
|
| 221 | +add_filter('give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3); |
|
| 224 | 222 | |
| 225 | 223 | /** |
| 226 | 224 | * Validate active gateway value before returning result. |
@@ -231,31 +229,31 @@ discard block |
||
| 231 | 229 | * |
| 232 | 230 | * @return array |
| 233 | 231 | */ |
| 234 | -function __give_validate_active_gateways( $value ) { |
|
| 235 | - $gateways = array_keys( give_get_payment_gateways() ); |
|
| 236 | - $active_gateways = is_array( $value ) ? array_keys( $value ) : array(); |
|
| 232 | +function __give_validate_active_gateways($value) { |
|
| 233 | + $gateways = array_keys(give_get_payment_gateways()); |
|
| 234 | + $active_gateways = is_array($value) ? array_keys($value) : array(); |
|
| 237 | 235 | |
| 238 | 236 | // Remove deactivated payment gateways. |
| 239 | - if( ! empty( $active_gateways ) ) { |
|
| 240 | - foreach ( $active_gateways as $index => $gateway_id ) { |
|
| 241 | - if( ! in_array( $gateway_id, $gateways ) ) { |
|
| 242 | - unset( $value[$gateway_id] ); |
|
| 237 | + if ( ! empty($active_gateways)) { |
|
| 238 | + foreach ($active_gateways as $index => $gateway_id) { |
|
| 239 | + if ( ! in_array($gateway_id, $gateways)) { |
|
| 240 | + unset($value[$gateway_id]); |
|
| 243 | 241 | } |
| 244 | 242 | } |
| 245 | 243 | } |
| 246 | 244 | |
| 247 | - if ( empty( $value ) ) { |
|
| 245 | + if (empty($value)) { |
|
| 248 | 246 | /** |
| 249 | 247 | * Filter the default active gateway |
| 250 | 248 | * |
| 251 | 249 | * @since 2.1.0 |
| 252 | 250 | */ |
| 253 | - $value = apply_filters( 'give_default_active_gateways', array( |
|
| 251 | + $value = apply_filters('give_default_active_gateways', array( |
|
| 254 | 252 | 'manual' => 1, |
| 255 | - ) ); |
|
| 253 | + )); |
|
| 256 | 254 | } |
| 257 | 255 | |
| 258 | 256 | return $value; |
| 259 | 257 | } |
| 260 | 258 | |
| 261 | -add_filter( 'give_get_option_gateways', '__give_validate_active_gateways', 10, 1 ); |
|
| 259 | +add_filter('give_get_option_gateways', '__give_validate_active_gateways', 10, 1); |
|
@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return array |
| 20 | 20 | */ |
| 21 | -function give_offline_register_gateway( $gateways ) { |
|
| 21 | +function give_offline_register_gateway($gateways) { |
|
| 22 | 22 | // Format: ID => Name |
| 23 | 23 | $gateways['offline'] = array( |
| 24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
| 25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
| 24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
| 25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give'), |
|
| 26 | 26 | ); |
| 27 | 27 | |
| 28 | 28 | return $gateways; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
| 31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Add our payment instructions to the checkout |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return void |
| 41 | 41 | */ |
| 42 | -function give_offline_payment_cc_form( $form_id ) { |
|
| 42 | +function give_offline_payment_cc_form($form_id) { |
|
| 43 | 43 | // Get offline payment instruction. |
| 44 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
| 44 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
| 45 | 45 | |
| 46 | 46 | ob_start(); |
| 47 | 47 | |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param int $form_id Give form id. |
| 54 | 54 | */ |
| 55 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
| 55 | + do_action('give_before_offline_info_fields', $form_id); |
|
| 56 | 56 | ?> |
| 57 | 57 | <fieldset id="give_offline_payment_info"> |
| 58 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
| 58 | + <?php echo stripslashes($offline_instructions); ?> |
|
| 59 | 59 | </fieldset> |
| 60 | 60 | <?php |
| 61 | 61 | /** |
@@ -65,35 +65,35 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param int $form_id Give form id. |
| 67 | 67 | */ |
| 68 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
| 68 | + do_action('give_after_offline_info_fields', $form_id); |
|
| 69 | 69 | |
| 70 | 70 | echo ob_get_clean(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
| 73 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Give Offline Billing Field |
| 77 | 77 | * |
| 78 | 78 | * @param $form_id |
| 79 | 79 | */ |
| 80 | -function give_offline_billing_fields( $form_id ) { |
|
| 80 | +function give_offline_billing_fields($form_id) { |
|
| 81 | 81 | //Enable Default CC fields (billing info) |
| 82 | - $post_offline_cc_fields = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
| 83 | - $post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
| 82 | + $post_offline_cc_fields = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
| 83 | + $post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
| 84 | 84 | |
| 85 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
| 85 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
| 86 | 86 | |
| 87 | 87 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
| 88 | 88 | if ( |
| 89 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
| 90 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
| 89 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
| 90 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
| 91 | 91 | ) { |
| 92 | - give_default_cc_address_fields( $form_id ); |
|
| 92 | + give_default_cc_address_fields($form_id); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
| 96 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Process the payment |
@@ -104,18 +104,18 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | -function give_offline_process_payment( $purchase_data ) { |
|
| 107 | +function give_offline_process_payment($purchase_data) { |
|
| 108 | 108 | |
| 109 | 109 | // Setup the payment details. |
| 110 | 110 | $payment_data = array( |
| 111 | 111 | 'price' => $purchase_data['price'], |
| 112 | 112 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
| 113 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
| 114 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
| 113 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
| 114 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
| 115 | 115 | 'date' => $purchase_data['date'], |
| 116 | 116 | 'user_email' => $purchase_data['user_email'], |
| 117 | 117 | 'purchase_key' => $purchase_data['purchase_key'], |
| 118 | - 'currency' => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ), |
|
| 118 | + 'currency' => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data), |
|
| 119 | 119 | 'user_info' => $purchase_data['user_info'], |
| 120 | 120 | 'status' => 'pending', |
| 121 | 121 | 'gateway' => 'offline', |
@@ -123,18 +123,18 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | // record the pending payment |
| 126 | - $payment = give_insert_payment( $payment_data ); |
|
| 126 | + $payment = give_insert_payment($payment_data); |
|
| 127 | 127 | |
| 128 | - if ( $payment ) { |
|
| 128 | + if ($payment) { |
|
| 129 | 129 | give_send_to_success_page(); |
| 130 | 130 | } else { |
| 131 | 131 | // if errors are present, send the user back to the donation form so they can be corrected |
| 132 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
| 132 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
| 137 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -147,59 +147,59 @@ discard block |
||
| 147 | 147 | * @since 1.0 |
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
| 150 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
| 151 | 151 | |
| 152 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
| 153 | - $post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
| 152 | + $payment_data = give_get_payment_meta($payment_id); |
|
| 153 | + $post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
| 154 | 154 | |
| 155 | 155 | //Customize email content depending on whether the single form has been customized |
| 156 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
| 156 | + $email_content = give_get_option('global_offline_donation_email'); |
|
| 157 | 157 | |
| 158 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
| 159 | - $email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
| 158 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
| 159 | + $email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 162 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * Filters the from name. |
| 166 | 166 | * |
| 167 | 167 | * @since 1.7 |
| 168 | 168 | */ |
| 169 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
| 169 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
| 170 | 170 | |
| 171 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 171 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | 174 | * Filters the from email. |
| 175 | 175 | * |
| 176 | 176 | * @since 1.7 |
| 177 | 177 | */ |
| 178 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
| 178 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
| 179 | 179 | |
| 180 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
| 180 | + $to_email = give_get_payment_user_email($payment_id); |
|
| 181 | 181 | |
| 182 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
| 183 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
| 184 | - $subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
| 182 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
| 183 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
| 184 | + $subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
| 188 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
| 187 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
| 188 | + $subject = give_do_email_tags($subject, $payment_id); |
|
| 189 | 189 | |
| 190 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
| 191 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
| 190 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
| 191 | + $message = give_do_email_tags($email_content, $payment_id); |
|
| 192 | 192 | |
| 193 | 193 | $emails = Give()->emails; |
| 194 | 194 | |
| 195 | - $emails->__set( 'from_name', $from_name ); |
|
| 196 | - $emails->__set( 'from_email', $from_email ); |
|
| 197 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
| 195 | + $emails->__set('from_name', $from_name); |
|
| 196 | + $emails->__set('from_email', $from_email); |
|
| 197 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
| 198 | 198 | |
| 199 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
| 200 | - $emails->__set( 'headers', $headers ); |
|
| 199 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
| 200 | + $emails->__set('headers', $headers); |
|
| 201 | 201 | |
| 202 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
| 202 | + $emails->send($to_email, $subject, $message, $attachments); |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -216,54 +216,54 @@ discard block |
||
| 216 | 216 | * @return void |
| 217 | 217 | * |
| 218 | 218 | */ |
| 219 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
| 219 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
| 220 | 220 | |
| 221 | 221 | /* Send an email notification to the admin */ |
| 222 | 222 | $admin_email = give_get_admin_notice_emails(); |
| 223 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 223 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
| 224 | 224 | |
| 225 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
| 226 | - $user_data = get_userdata( $user_info['id'] ); |
|
| 225 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
| 226 | + $user_data = get_userdata($user_info['id']); |
|
| 227 | 227 | $name = $user_data->display_name; |
| 228 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
| 229 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 228 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
| 229 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 230 | 230 | } else { |
| 231 | 231 | $name = $user_info['email']; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $amount = give_donation_amount( $payment_id ); |
|
| 234 | + $amount = give_donation_amount($payment_id); |
|
| 235 | 235 | |
| 236 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
| 236 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
| 237 | 237 | |
| 238 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
| 239 | - $admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n"; |
|
| 240 | - $admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
| 238 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
| 239 | + $admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n"; |
|
| 240 | + $admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
| 244 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
| 243 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
| 244 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
| 245 | 245 | |
| 246 | 246 | $admin_message .= sprintf( |
| 247 | 247 | '<a href="%1$s">%2$s</a>', |
| 248 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
| 249 | - __( 'View Donation Details »', 'give' ) |
|
| 250 | - ) . "\n\n"; |
|
| 248 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id), |
|
| 249 | + __('View Donation Details »', 'give') |
|
| 250 | + )."\n\n"; |
|
| 251 | 251 | |
| 252 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
| 253 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
| 252 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
| 253 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
| 254 | 254 | |
| 255 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
| 256 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
| 255 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
| 256 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
| 257 | 257 | |
| 258 | 258 | //Send Email |
| 259 | 259 | $emails = Give()->emails; |
| 260 | - $emails->__set( 'heading', __( 'New Offline Donation', 'give' ) ); |
|
| 260 | + $emails->__set('heading', __('New Offline Donation', 'give')); |
|
| 261 | 261 | |
| 262 | - if ( ! empty( $admin_headers ) ) { |
|
| 263 | - $emails->__set( 'headers', $admin_headers ); |
|
| 262 | + if ( ! empty($admin_headers)) { |
|
| 263 | + $emails->__set('headers', $admin_headers); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
| 266 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
| 267 | 267 | |
| 268 | 268 | } |
| 269 | 269 | |
@@ -275,20 +275,20 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return array |
| 277 | 277 | */ |
| 278 | -function give_offline_add_settings( $settings ) { |
|
| 278 | +function give_offline_add_settings($settings) { |
|
| 279 | 279 | |
| 280 | 280 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
| 281 | - if ( in_array( 'offline', (array) give_get_option( 'gateways' ) ) ) { |
|
| 281 | + if (in_array('offline', (array) give_get_option('gateways'))) { |
|
| 282 | 282 | return $settings; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | //Vars |
| 286 | 286 | $prefix = '_give_'; |
| 287 | 287 | |
| 288 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
| 288 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
| 289 | 289 | |
| 290 | 290 | //this gateway isn't active |
| 291 | - if ( ! $is_gateway_active ) { |
|
| 291 | + if ( ! $is_gateway_active) { |
|
| 292 | 292 | //return settings and bounce |
| 293 | 293 | return $settings; |
| 294 | 294 | } |
@@ -297,34 +297,34 @@ discard block |
||
| 297 | 297 | $check_settings = array( |
| 298 | 298 | |
| 299 | 299 | array( |
| 300 | - 'name' => __( 'Offline Donations', 'give' ), |
|
| 301 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
| 302 | - 'id' => $prefix . 'customize_offline_donations', |
|
| 300 | + 'name' => __('Offline Donations', 'give'), |
|
| 301 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
| 302 | + 'id' => $prefix.'customize_offline_donations', |
|
| 303 | 303 | 'type' => 'radio_inline', |
| 304 | 304 | 'default' => 'global', |
| 305 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 306 | - 'global' => __( 'Global Option', 'give' ), |
|
| 307 | - 'enabled' => __( 'Customize', 'give' ), |
|
| 308 | - 'disabled' => __( 'Disable', 'give' ), |
|
| 305 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
| 306 | + 'global' => __('Global Option', 'give'), |
|
| 307 | + 'enabled' => __('Customize', 'give'), |
|
| 308 | + 'disabled' => __('Disable', 'give'), |
|
| 309 | 309 | ) |
| 310 | 310 | ), |
| 311 | 311 | ), |
| 312 | 312 | array( |
| 313 | - 'name' => __( 'Billing Fields', 'give' ), |
|
| 314 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
| 315 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
| 313 | + 'name' => __('Billing Fields', 'give'), |
|
| 314 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
| 315 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
| 316 | 316 | 'row_classes' => 'give-subfield give-hidden', |
| 317 | 317 | 'type' => 'radio_inline', |
| 318 | 318 | 'default' => 'disabled', |
| 319 | 319 | 'options' => array( |
| 320 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 321 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 320 | + 'enabled' => __('Enabled', 'give'), |
|
| 321 | + 'disabled' => __('Disabled', 'give'), |
|
| 322 | 322 | ), |
| 323 | 323 | ), |
| 324 | 324 | array( |
| 325 | - 'id' => $prefix . 'offline_checkout_notes', |
|
| 326 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
| 327 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
| 325 | + 'id' => $prefix.'offline_checkout_notes', |
|
| 326 | + 'name' => __('Donation Instructions', 'give'), |
|
| 327 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
| 328 | 328 | 'default' => give_get_default_offline_donation_content(), |
| 329 | 329 | 'type' => 'wysiwyg', |
| 330 | 330 | 'row_classes' => 'give-subfield give-hidden', |
@@ -336,14 +336,14 @@ discard block |
||
| 336 | 336 | 'name' => 'offline_docs', |
| 337 | 337 | 'type' => 'docs_link', |
| 338 | 338 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
| 339 | - 'title' => __( 'Offline Donations', 'give' ), |
|
| 339 | + 'title' => __('Offline Donations', 'give'), |
|
| 340 | 340 | ), |
| 341 | 341 | ); |
| 342 | 342 | |
| 343 | - return array_merge( $settings, $check_settings ); |
|
| 343 | + return array_merge($settings, $check_settings); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
| 346 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
| 347 | 347 | |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -354,24 +354,24 @@ discard block |
||
| 354 | 354 | * @return string |
| 355 | 355 | */ |
| 356 | 356 | function give_get_default_offline_donation_content() { |
| 357 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
| 357 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
| 358 | 358 | $default_text .= '<ol>'; |
| 359 | 359 | $default_text .= '<li>'; |
| 360 | 360 | $default_text .= sprintf( |
| 361 | 361 | /* translators: %s: site name */ |
| 362 | - __( 'Make a check payable to "{sitename}"', 'give' ) ); |
|
| 362 | + __('Make a check payable to "{sitename}"', 'give') ); |
|
| 363 | 363 | $default_text .= '</li>'; |
| 364 | 364 | $default_text .= '<li>'; |
| 365 | 365 | $default_text .= sprintf( |
| 366 | 366 | /* translators: %s: site name */ |
| 367 | - __( 'On the memo line of the check, please indicate that the donation is for "{sitename}"', 'give' ) ); |
|
| 367 | + __('On the memo line of the check, please indicate that the donation is for "{sitename}"', 'give') ); |
|
| 368 | 368 | $default_text .= '</li>'; |
| 369 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
| 369 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
| 370 | 370 | $default_text .= '</ol>'; |
| 371 | 371 | $default_text .= '{offline_mailing_address}<br>'; |
| 372 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
| 372 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
| 373 | 373 | |
| 374 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
| 374 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
| 375 | 375 | |
| 376 | 376 | } |
| 377 | 377 | |
@@ -383,28 +383,28 @@ discard block |
||
| 383 | 383 | * @return string |
| 384 | 384 | */ |
| 385 | 385 | function give_get_default_offline_donation_email_content() { |
| 386 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
| 387 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
| 386 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
| 387 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
| 388 | 388 | $default_text .= '<ol>'; |
| 389 | 389 | $default_text .= '<li>'; |
| 390 | 390 | $default_text .= sprintf( |
| 391 | 391 | /* translators: %s: site name */ |
| 392 | - __( 'Make a check payable to "{sitename}"', 'give' ) |
|
| 392 | + __('Make a check payable to "{sitename}"', 'give') |
|
| 393 | 393 | ); |
| 394 | 394 | $default_text .= '</li>'; |
| 395 | 395 | $default_text .= '<li>'; |
| 396 | 396 | $default_text .= sprintf( |
| 397 | - __( 'On the memo line of the check, please indicate that the donation is for "{sitename}"', 'give' ) |
|
| 397 | + __('On the memo line of the check, please indicate that the donation is for "{sitename}"', 'give') |
|
| 398 | 398 | ); |
| 399 | 399 | $default_text .= '</li>'; |
| 400 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
| 400 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
| 401 | 401 | $default_text .= '</ol>'; |
| 402 | 402 | $default_text .= '{offline_mailing_address}<br>'; |
| 403 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
| 404 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
| 403 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
| 404 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
| 405 | 405 | $default_text .= '<p>{sitename}</p>'; |
| 406 | 406 | |
| 407 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
| 407 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
| 408 | 408 | |
| 409 | 409 | } |
| 410 | 410 | |
@@ -418,35 +418,35 @@ discard block |
||
| 418 | 418 | * |
| 419 | 419 | * @return string |
| 420 | 420 | */ |
| 421 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
| 421 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
| 422 | 422 | // Bailout. |
| 423 | - if ( ! $form_id ) { |
|
| 423 | + if ( ! $form_id) { |
|
| 424 | 424 | return ''; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - $post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
| 428 | - $post_offline_instructions = give_get_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
| 429 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
| 427 | + $post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
| 428 | + $post_offline_instructions = give_get_meta($form_id, '_give_offline_checkout_notes', true); |
|
| 429 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
| 430 | 430 | $offline_instructions = $global_offline_instruction; |
| 431 | 431 | |
| 432 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
| 432 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
| 433 | 433 | $offline_instructions = $post_offline_instructions; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
| 436 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
| 437 | 437 | |
| 438 | 438 | /* translators: %s: form settings url */ |
| 439 | - $offline_instructions = ! empty( $offline_instructions ) |
|
| 439 | + $offline_instructions = ! empty($offline_instructions) |
|
| 440 | 440 | ? $offline_instructions |
| 441 | 441 | : sprintf( |
| 442 | - __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), |
|
| 442 | + __('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), |
|
| 443 | 443 | $settings_url |
| 444 | 444 | ); |
| 445 | 445 | |
| 446 | - $offline_instructions = give_do_email_tags( $offline_instructions, null ); |
|
| 446 | + $offline_instructions = give_do_email_tags($offline_instructions, null); |
|
| 447 | 447 | |
| 448 | 448 | $formmated_offline_instructions = $wpautop |
| 449 | - ? wpautop( do_shortcode( $offline_instructions ) ) |
|
| 449 | + ? wpautop(do_shortcode($offline_instructions)) |
|
| 450 | 450 | : $offline_instructions; |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -477,21 +477,21 @@ discard block |
||
| 477 | 477 | * |
| 478 | 478 | * @return array |
| 479 | 479 | */ |
| 480 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
| 480 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
| 481 | 481 | if ( |
| 482 | 482 | // Show offline payment gateway if enable for new donation form. |
| 483 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
| 483 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
| 484 | 484 | && $form_id |
| 485 | - && ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( 'enabled', 'global' ) ) |
|
| 485 | + && ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array('enabled', 'global')) |
|
| 486 | 486 | ) { |
| 487 | - unset( $gateway_list['offline'] ); |
|
| 487 | + unset($gateway_list['offline']); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | // Output. |
| 491 | 491 | return $gateway_list; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
| 494 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
| 495 | 495 | |
| 496 | 496 | /** |
| 497 | 497 | * Set default gateway to global default payment gateway |
@@ -505,13 +505,13 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return void |
| 507 | 507 | */ |
| 508 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
| 508 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
| 509 | 509 | if ( |
| 510 | - ! give_is_setting_enabled( $meta_value, array( 'global', 'enabled' ) ) |
|
| 511 | - && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) |
|
| 510 | + ! give_is_setting_enabled($meta_value, array('global', 'enabled')) |
|
| 511 | + && ('offline' === give_get_meta($postid, '_give_default_gateway', true)) |
|
| 512 | 512 | ) { |
| 513 | - give_update_meta( $postid, '_give_default_gateway', 'global' ); |
|
| 513 | + give_update_meta($postid, '_give_default_gateway', 'global'); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
| 517 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
|
@@ -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 | |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @return bool |
| 24 | 24 | */ |
| 25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
| 25 | +function give_paypal_standard_billing_fields($form_id) { |
|
| 26 | 26 | |
| 27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
| 28 | - give_default_cc_address_fields( $form_id ); |
|
| 27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
| 28 | + give_default_cc_address_fields($form_id); |
|
| 29 | 29 | |
| 30 | 30 | return true; |
| 31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
| 37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Process PayPal Payment. |
@@ -45,28 +45,28 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | -function give_process_paypal_payment( $payment_data ) { |
|
| 48 | +function give_process_paypal_payment($payment_data) { |
|
| 49 | 49 | |
| 50 | 50 | // Validate nonce. |
| 51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
| 51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
| 52 | 52 | |
| 53 | - $payment_id = give_create_payment( $payment_data ); |
|
| 53 | + $payment_id = give_create_payment($payment_data); |
|
| 54 | 54 | |
| 55 | 55 | // Check payment. |
| 56 | - if ( empty( $payment_id ) ) { |
|
| 56 | + if (empty($payment_id)) { |
|
| 57 | 57 | // Record the error. |
| 58 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
| 59 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
| 58 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
| 59 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
| 60 | 60 | // Problems? Send back. |
| 61 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
| 61 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Redirect to PayPal. |
| 65 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
| 65 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
| 66 | 66 | exit; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
| 69 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -77,17 +77,17 @@ discard block |
||
| 77 | 77 | function give_listen_for_paypal_ipn() { |
| 78 | 78 | |
| 79 | 79 | // Regular PayPal IPN. |
| 80 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
| 80 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
| 81 | 81 | /** |
| 82 | 82 | * Fires while verifying PayPal IPN |
| 83 | 83 | * |
| 84 | 84 | * @since 1.0 |
| 85 | 85 | */ |
| 86 | - do_action( 'give_verify_paypal_ipn' ); |
|
| 86 | + do_action('give_verify_paypal_ipn'); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
| 90 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Process PayPal IPN |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | function give_process_paypal_ipn() { |
| 99 | 99 | |
| 100 | 100 | // Check the request method is POST. |
| 101 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
| 101 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
| 102 | 102 | return; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | $post_data = ''; |
| 107 | 107 | |
| 108 | 108 | // Fallback just in case post_max_size is lower than needed. |
| 109 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 110 | - $post_data = file_get_contents( 'php://input' ); |
|
| 109 | + if (ini_get('allow_url_fopen')) { |
|
| 110 | + $post_data = file_get_contents('php://input'); |
|
| 111 | 111 | } else { |
| 112 | 112 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
| 113 | - ini_set( 'post_max_size', '12M' ); |
|
| 113 | + ini_set('post_max_size', '12M'); |
|
| 114 | 114 | } |
| 115 | 115 | // Start the encoded data collection with notification command. |
| 116 | 116 | $encoded_data = 'cmd=_notify-validate'; |
@@ -119,41 +119,41 @@ discard block |
||
| 119 | 119 | $arg_separator = give_get_php_arg_separator_output(); |
| 120 | 120 | |
| 121 | 121 | // Verify there is a post_data. |
| 122 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 122 | + if ($post_data || strlen($post_data) > 0) { |
|
| 123 | 123 | // Append the data. |
| 124 | - $encoded_data .= $arg_separator . $post_data; |
|
| 124 | + $encoded_data .= $arg_separator.$post_data; |
|
| 125 | 125 | } else { |
| 126 | 126 | // Check if POST is empty. |
| 127 | - if ( empty( $_POST ) ) { |
|
| 127 | + if (empty($_POST)) { |
|
| 128 | 128 | // Nothing to do. |
| 129 | 129 | return; |
| 130 | 130 | } else { |
| 131 | 131 | // Loop through each POST. |
| 132 | - foreach ( $_POST as $key => $value ) { |
|
| 132 | + foreach ($_POST as $key => $value) { |
|
| 133 | 133 | // Encode the value and append the data. |
| 134 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
| 134 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Convert collected post data to an array. |
| 140 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 140 | + parse_str($encoded_data, $encoded_data_array); |
|
| 141 | 141 | |
| 142 | - foreach ( $encoded_data_array as $key => $value ) { |
|
| 142 | + foreach ($encoded_data_array as $key => $value) { |
|
| 143 | 143 | |
| 144 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 145 | - $new_key = str_replace( '&', '&', $key ); |
|
| 146 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
| 144 | + if (false !== strpos($key, 'amp;')) { |
|
| 145 | + $new_key = str_replace('&', '&', $key); |
|
| 146 | + $new_key = str_replace('amp;', '&', $new_key); |
|
| 147 | 147 | |
| 148 | - unset( $encoded_data_array[ $key ] ); |
|
| 149 | - $encoded_data_array[ $new_key ] = $value; |
|
| 148 | + unset($encoded_data_array[$key]); |
|
| 149 | + $encoded_data_array[$new_key] = $value; |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $api_response = false; |
| 154 | 154 | |
| 155 | 155 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
| 156 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
| 156 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
| 157 | 157 | |
| 158 | 158 | $remote_post_vars = array( |
| 159 | 159 | 'method' => 'POST', |
@@ -173,25 +173,25 @@ discard block |
||
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | // Validate the IPN. |
| 176 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
| 176 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
| 177 | 177 | |
| 178 | - if ( is_wp_error( $api_response ) ) { |
|
| 179 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 180 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
| 178 | + if (is_wp_error($api_response)) { |
|
| 179 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 180 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
| 181 | 181 | |
| 182 | 182 | return; // Something went wrong. |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
| 186 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 187 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
| 185 | + if ('VERIFIED' !== $api_response['body']) { |
|
| 186 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 187 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
| 188 | 188 | |
| 189 | 189 | return; // Response not okay. |
| 190 | 190 | } |
| 191 | 191 | }// End if(). |
| 192 | 192 | |
| 193 | 193 | // Check if $post_data_array has been populated. |
| 194 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
| 194 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
| 195 | 195 | return; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -200,28 +200,28 @@ discard block |
||
| 200 | 200 | 'payment_status' => '', |
| 201 | 201 | ); |
| 202 | 202 | |
| 203 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 203 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
| 204 | 204 | |
| 205 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 205 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
| 206 | 206 | $txn_type = $encoded_data_array['txn_type']; |
| 207 | 207 | |
| 208 | 208 | // Check for PayPal IPN Notifications and update data based on it. |
| 209 | - $current_timestamp = current_time( 'timestamp' ); |
|
| 209 | + $current_timestamp = current_time('timestamp'); |
|
| 210 | 210 | $paypal_ipn_vars = array( |
| 211 | - 'auth_status' => isset( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
| 212 | - 'transaction_id' => isset( $encoded_data_array['txn_id'] ) ? $encoded_data_array['txn_id'] : 'N/A', |
|
| 211 | + 'auth_status' => isset($api_response['body']) ? $api_response['body'] : 'N/A', |
|
| 212 | + 'transaction_id' => isset($encoded_data_array['txn_id']) ? $encoded_data_array['txn_id'] : 'N/A', |
|
| 213 | 213 | 'payment_id' => $payment_id, |
| 214 | 214 | ); |
| 215 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars, false ); |
|
| 216 | - give_insert_payment_note( $payment_id, sprintf( |
|
| 217 | - __( 'IPN received on %s at %s', 'give' ), |
|
| 218 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
| 219 | - date_i18n( 'H:i', $current_timestamp ) |
|
| 215 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars, false); |
|
| 216 | + give_insert_payment_note($payment_id, sprintf( |
|
| 217 | + __('IPN received on %s at %s', 'give'), |
|
| 218 | + date_i18n('m/d/Y', $current_timestamp), |
|
| 219 | + date_i18n('H:i', $current_timestamp) |
|
| 220 | 220 | ) |
| 221 | 221 | ); |
| 222 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
| 222 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
| 223 | 223 | |
| 224 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
| 224 | + if (has_action('give_paypal_'.$txn_type)) { |
|
| 225 | 225 | /** |
| 226 | 226 | * Fires while processing PayPal IPN $txn_type. |
| 227 | 227 | * |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @param array $encoded_data_array Encoded data. |
| 233 | 233 | * @param int $payment_id Payment id. |
| 234 | 234 | */ |
| 235 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
| 235 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
| 236 | 236 | } else { |
| 237 | 237 | /** |
| 238 | 238 | * Fires while process PayPal IPN. |
@@ -244,12 +244,12 @@ discard block |
||
| 244 | 244 | * @param array $encoded_data_array Encoded data. |
| 245 | 245 | * @param int $payment_id Payment id. |
| 246 | 246 | */ |
| 247 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
| 247 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
| 248 | 248 | } |
| 249 | 249 | exit; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
| 252 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | 255 | * Process web accept (one time) payment IPNs. |
@@ -261,99 +261,99 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @return void |
| 263 | 263 | */ |
| 264 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
| 264 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
| 265 | 265 | |
| 266 | 266 | // Only allow through these transaction types. |
| 267 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
| 267 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
| 268 | 268 | return; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Need $payment_id to continue. |
| 272 | - if ( empty( $payment_id ) ) { |
|
| 272 | + if (empty($payment_id)) { |
|
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Collect donation payment details. |
| 277 | 277 | $paypal_amount = $data['mc_gross']; |
| 278 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 279 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 280 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 281 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 278 | + $payment_status = strtolower($data['payment_status']); |
|
| 279 | + $currency_code = strtolower($data['mc_currency']); |
|
| 280 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
| 281 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 282 | 282 | |
| 283 | 283 | // Must be a PayPal standard IPN. |
| 284 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
| 284 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
| 285 | 285 | return; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // Verify payment recipient. |
| 289 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
| 289 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
| 290 | 290 | |
| 291 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 292 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 293 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 294 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
| 291 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 292 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
| 293 | + give_update_payment_status($payment_id, 'failed'); |
|
| 294 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
| 295 | 295 | |
| 296 | 296 | return; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Verify payment currency. |
| 300 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
| 300 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
| 301 | 301 | |
| 302 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 303 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 304 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 305 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
| 302 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 303 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
| 304 | + give_update_payment_status($payment_id, 'failed'); |
|
| 305 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
| 306 | 306 | |
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Process refunds & reversed. |
| 311 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
| 312 | - give_process_paypal_refund( $data, $payment_id ); |
|
| 311 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
| 312 | + give_process_paypal_refund($data, $payment_id); |
|
| 313 | 313 | |
| 314 | 314 | return; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Only complete payments once. |
| 318 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
| 318 | + if ('publish' === get_post_status($payment_id)) { |
|
| 319 | 319 | return; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | // Retrieve the total donation amount (before PayPal). |
| 323 | - $payment_amount = give_donation_amount( $payment_id ); |
|
| 323 | + $payment_amount = give_donation_amount($payment_id); |
|
| 324 | 324 | |
| 325 | 325 | // Check that the donation PP and local db amounts match. |
| 326 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 326 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 327 | 327 | // The prices don't match |
| 328 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 329 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
| 330 | - give_update_payment_status( $payment_id, 'failed' ); |
|
| 331 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
| 328 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
| 329 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
| 330 | + give_update_payment_status($payment_id, 'failed'); |
|
| 331 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
| 332 | 332 | |
| 333 | 333 | return; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Process completed donations. |
| 337 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
| 337 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
| 338 | 338 | |
| 339 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 340 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
| 341 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
| 342 | - give_update_payment_status( $payment_id, 'publish' ); |
|
| 339 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 340 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
| 341 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
| 342 | + give_update_payment_status($payment_id, 'publish'); |
|
| 343 | 343 | |
| 344 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 344 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
| 345 | 345 | |
| 346 | 346 | // Look for possible pending reasons, such as an echeck. |
| 347 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
| 347 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
| 348 | 348 | |
| 349 | - if ( ! empty( $note ) ) { |
|
| 350 | - give_insert_payment_note( $payment_id, $note ); |
|
| 349 | + if ( ! empty($note)) { |
|
| 350 | + give_insert_payment_note($payment_id, $note); |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
| 356 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | 359 | * Process PayPal IPN Refunds |
@@ -365,35 +365,35 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @return void |
| 367 | 367 | */ |
| 368 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
| 368 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
| 369 | 369 | |
| 370 | 370 | // Collect payment details. |
| 371 | - if ( empty( $payment_id ) ) { |
|
| 371 | + if (empty($payment_id)) { |
|
| 372 | 372 | return; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | // Only refund payments once. |
| 376 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
| 376 | + if ('refunded' === get_post_status($payment_id)) { |
|
| 377 | 377 | return; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - $payment_amount = give_donation_amount( $payment_id ); |
|
| 380 | + $payment_amount = give_donation_amount($payment_id); |
|
| 381 | 381 | $refund_amount = $data['payment_gross'] * - 1; |
| 382 | 382 | |
| 383 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 383 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
| 384 | 384 | |
| 385 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
| 386 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
| 385 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
| 386 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
| 387 | 387 | |
| 388 | 388 | return; // This is a partial refund |
| 389 | 389 | |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
| 393 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
| 394 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 395 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
| 396 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
| 392 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
| 393 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
| 394 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
| 395 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
| 396 | + give_update_payment_status($payment_id, 'refunded'); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -405,24 +405,24 @@ discard block |
||
| 405 | 405 | * |
| 406 | 406 | * @return string |
| 407 | 407 | */ |
| 408 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
| 408 | +function give_get_paypal_redirect($ssl_check = false) { |
|
| 409 | 409 | |
| 410 | - if ( is_ssl() || ! $ssl_check ) { |
|
| 410 | + if (is_ssl() || ! $ssl_check) { |
|
| 411 | 411 | $protocol = 'https://'; |
| 412 | 412 | } else { |
| 413 | 413 | $protocol = 'http://'; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | // Check the current payment mode |
| 417 | - if ( give_is_test_mode() ) { |
|
| 417 | + if (give_is_test_mode()) { |
|
| 418 | 418 | // Test mode |
| 419 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 419 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
| 420 | 420 | } else { |
| 421 | 421 | // Live mode |
| 422 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
| 422 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
| 425 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
@@ -432,9 +432,9 @@ discard block |
||
| 432 | 432 | * @return string |
| 433 | 433 | */ |
| 434 | 434 | function give_get_paypal_page_style() { |
| 435 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
| 435 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
| 436 | 436 | |
| 437 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
| 437 | + return apply_filters('give_paypal_page_style', $page_style); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
@@ -448,26 +448,26 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @return string |
| 450 | 450 | */ |
| 451 | -function give_paypal_success_page_content( $content ) { |
|
| 451 | +function give_paypal_success_page_content($content) { |
|
| 452 | 452 | |
| 453 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
| 453 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
| 454 | 454 | return $content; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
| 457 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
| 458 | 458 | |
| 459 | - if ( ! $payment_id ) { |
|
| 459 | + if ( ! $payment_id) { |
|
| 460 | 460 | $session = give_get_purchase_session(); |
| 461 | - $payment_id = give_get_donation_id_by_key( $session['purchase_key'] ); |
|
| 461 | + $payment_id = give_get_donation_id_by_key($session['purchase_key']); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - $payment = get_post( $payment_id ); |
|
| 465 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
| 464 | + $payment = get_post($payment_id); |
|
| 465 | + if ($payment && 'pending' === $payment->post_status) { |
|
| 466 | 466 | |
| 467 | 467 | // Payment is still pending so show processing indicator to fix the race condition. |
| 468 | 468 | ob_start(); |
| 469 | 469 | |
| 470 | - give_get_template_part( 'payment', 'processing' ); |
|
| 470 | + give_get_template_part('payment', 'processing'); |
|
| 471 | 471 | |
| 472 | 472 | $content = ob_get_clean(); |
| 473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
| 480 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
| 481 | 481 | |
| 482 | 482 | /** |
| 483 | 483 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -489,16 +489,16 @@ discard block |
||
| 489 | 489 | * |
| 490 | 490 | * @return string A link to the PayPal transaction details |
| 491 | 491 | */ |
| 492 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
| 492 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
| 493 | 493 | |
| 494 | 494 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
| 495 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
| 495 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
| 496 | 496 | |
| 497 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
| 497 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
| 498 | 498 | |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
| 501 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
| 502 | 502 | |
| 503 | 503 | |
| 504 | 504 | /** |
@@ -510,64 +510,64 @@ discard block |
||
| 510 | 510 | * |
| 511 | 511 | * @return string |
| 512 | 512 | */ |
| 513 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
| 513 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
| 514 | 514 | |
| 515 | 515 | $note = ''; |
| 516 | 516 | |
| 517 | - switch ( $pending_reason ) { |
|
| 517 | + switch ($pending_reason) { |
|
| 518 | 518 | |
| 519 | 519 | case 'echeck' : |
| 520 | 520 | |
| 521 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
| 521 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
| 522 | 522 | |
| 523 | 523 | break; |
| 524 | 524 | |
| 525 | 525 | case 'address' : |
| 526 | 526 | |
| 527 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
| 527 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
| 528 | 528 | |
| 529 | 529 | break; |
| 530 | 530 | |
| 531 | 531 | case 'intl' : |
| 532 | 532 | |
| 533 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
| 533 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
| 534 | 534 | |
| 535 | 535 | break; |
| 536 | 536 | |
| 537 | 537 | case 'multi-currency' : |
| 538 | 538 | |
| 539 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
| 539 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
| 540 | 540 | |
| 541 | 541 | break; |
| 542 | 542 | |
| 543 | 543 | case 'paymentreview' : |
| 544 | 544 | case 'regulatory_review' : |
| 545 | 545 | |
| 546 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
| 546 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
| 547 | 547 | |
| 548 | 548 | break; |
| 549 | 549 | |
| 550 | 550 | case 'unilateral' : |
| 551 | 551 | |
| 552 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
| 552 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
| 553 | 553 | |
| 554 | 554 | break; |
| 555 | 555 | |
| 556 | 556 | case 'upgrade' : |
| 557 | 557 | |
| 558 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
| 558 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
| 559 | 559 | |
| 560 | 560 | break; |
| 561 | 561 | |
| 562 | 562 | case 'verify' : |
| 563 | 563 | |
| 564 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
| 564 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
| 565 | 565 | |
| 566 | 566 | break; |
| 567 | 567 | |
| 568 | 568 | case 'other' : |
| 569 | 569 | |
| 570 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
| 570 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
| 571 | 571 | |
| 572 | 572 | break; |
| 573 | 573 | |
@@ -585,49 +585,49 @@ discard block |
||
| 585 | 585 | * |
| 586 | 586 | * @return mixed|string |
| 587 | 587 | */ |
| 588 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
| 588 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
| 589 | 589 | // Only send to PayPal if the pending payment is created successfully. |
| 590 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
| 590 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
| 591 | 591 | |
| 592 | 592 | // Get the success url. |
| 593 | - $return_url = add_query_arg( array( |
|
| 593 | + $return_url = add_query_arg(array( |
|
| 594 | 594 | 'payment-confirmation' => 'paypal', |
| 595 | 595 | 'payment-id' => $payment_id, |
| 596 | 596 | |
| 597 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
| 597 | + ), get_permalink(give_get_option('success_page'))); |
|
| 598 | 598 | |
| 599 | 599 | // Get the PayPal redirect uri. |
| 600 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
| 600 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
| 601 | 601 | |
| 602 | 602 | // Item name. |
| 603 | - $item_name = give_payment_gateway_item_title( $payment_data ); |
|
| 603 | + $item_name = give_payment_gateway_item_title($payment_data); |
|
| 604 | 604 | |
| 605 | 605 | // Setup PayPal API params. |
| 606 | 606 | $paypal_args = array( |
| 607 | - 'business' => give_get_option( 'paypal_email', false ), |
|
| 607 | + 'business' => give_get_option('paypal_email', false), |
|
| 608 | 608 | 'first_name' => $payment_data['user_info']['first_name'], |
| 609 | 609 | 'last_name' => $payment_data['user_info']['last_name'], |
| 610 | 610 | 'email' => $payment_data['user_email'], |
| 611 | 611 | 'invoice' => $payment_data['purchase_key'], |
| 612 | 612 | 'amount' => $payment_data['price'], |
| 613 | - 'item_name' => stripslashes( $item_name ), |
|
| 613 | + 'item_name' => stripslashes($item_name), |
|
| 614 | 614 | 'no_shipping' => '1', |
| 615 | 615 | 'shipping' => '0', |
| 616 | 616 | 'no_note' => '1', |
| 617 | - 'currency_code' => give_get_currency( $payment_id, $payment_data ), |
|
| 618 | - 'charset' => get_bloginfo( 'charset' ), |
|
| 617 | + 'currency_code' => give_get_currency($payment_id, $payment_data), |
|
| 618 | + 'charset' => get_bloginfo('charset'), |
|
| 619 | 619 | 'custom' => $payment_id, |
| 620 | 620 | 'rm' => '2', |
| 621 | 621 | 'return' => $return_url, |
| 622 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
| 622 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
| 623 | 623 | 'notify_url' => $listener_url, |
| 624 | 624 | 'page_style' => give_get_paypal_page_style(), |
| 625 | - 'cbt' => get_bloginfo( 'name' ), |
|
| 625 | + 'cbt' => get_bloginfo('name'), |
|
| 626 | 626 | 'bn' => 'givewp_SP', |
| 627 | 627 | ); |
| 628 | 628 | |
| 629 | 629 | // Add user address if present. |
| 630 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
| 630 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
| 631 | 631 | $default_address = array( |
| 632 | 632 | 'line1' => '', |
| 633 | 633 | 'line2' => '', |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | 'country' => '', |
| 638 | 638 | ); |
| 639 | 639 | |
| 640 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
| 640 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
| 641 | 641 | |
| 642 | 642 | $paypal_args['address1'] = $address['line1']; |
| 643 | 643 | $paypal_args['address2'] = $address['line2']; |
@@ -658,13 +658,13 @@ discard block |
||
| 658 | 658 | * |
| 659 | 659 | * @since 1.8 |
| 660 | 660 | */ |
| 661 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
| 661 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
| 662 | 662 | |
| 663 | 663 | // Build query. |
| 664 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
| 664 | + $paypal_redirect .= http_build_query($paypal_args); |
|
| 665 | 665 | |
| 666 | 666 | // Fix for some sites that encode the entities. |
| 667 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
| 667 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
| 668 | 668 | |
| 669 | 669 | return $paypal_redirect; |
| 670 | 670 | } |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | function give_get_paypal_button_type() { |
| 680 | 680 | // paypal_button_type can be donation or standard. |
| 681 | 681 | $paypal_button_type = '_donations'; |
| 682 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
| 682 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
| 683 | 683 | $paypal_button_type = '_xclick'; |
| 684 | 684 | } |
| 685 | 685 | |
@@ -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. |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function give_load_ajax_gateway() { |
| 41 | 41 | |
| 42 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
|
| 42 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. |
|
| 43 | 43 | |
| 44 | - if ( isset( $post_data['give_payment_mode'] ) ) { |
|
| 44 | + if (isset($post_data['give_payment_mode'])) { |
|
| 45 | 45 | |
| 46 | - $form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : ''; |
|
| 46 | + $form_id_prefix = ! empty($post_data['give_form_id_prefix']) ? $post_data['give_form_id_prefix'] : ''; |
|
| 47 | 47 | |
| 48 | 48 | $args = array( |
| 49 | 49 | 'id_prefix' => $form_id_prefix, |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @since 1.7 |
| 56 | 56 | */ |
| 57 | - do_action( 'give_donation_form', $post_data['give_form_id'], $args ); |
|
| 57 | + do_action('give_donation_form', $post_data['give_form_id'], $args); |
|
| 58 | 58 | |
| 59 | 59 | exit(); |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 64 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 63 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 64 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Create wp nonce using Ajax call. |
@@ -73,18 +73,18 @@ discard block |
||
| 73 | 73 | * @return void |
| 74 | 74 | */ |
| 75 | 75 | function give_donation_form_nonce() { |
| 76 | - if ( isset( $_POST['give_form_id'] ) ) { |
|
| 76 | + if (isset($_POST['give_form_id'])) { |
|
| 77 | 77 | |
| 78 | 78 | // Get donation form id. |
| 79 | - $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
|
| 79 | + $form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0; |
|
| 80 | 80 | |
| 81 | 81 | // Send nonce json data. |
| 82 | - wp_send_json_success( wp_create_nonce( "give_donation_form_nonce_{$form_id}" ) ); |
|
| 82 | + wp_send_json_success(wp_create_nonce("give_donation_form_nonce_{$form_id}")); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | -add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
| 87 | -add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
| 86 | +add_action('wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
| 87 | +add_action('wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | * @return void |
| 97 | 97 | */ |
| 98 | 98 | function __give_donation_form_reset_all_nonce() { |
| 99 | - if ( isset( $_POST['give_form_id'] ) ) { |
|
| 99 | + if (isset($_POST['give_form_id'])) { |
|
| 100 | 100 | |
| 101 | 101 | // Get donation form id. |
| 102 | - $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
|
| 102 | + $form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0; |
|
| 103 | 103 | |
| 104 | 104 | $data = array( |
| 105 | - 'give_form_hash' => wp_create_nonce( "give_donation_form_nonce_{$form_id}" ), |
|
| 106 | - 'give_form_user_register_hash' => wp_create_nonce( "give_form_create_user_nonce_{$form_id}" ) |
|
| 105 | + 'give_form_hash' => wp_create_nonce("give_donation_form_nonce_{$form_id}"), |
|
| 106 | + 'give_form_user_register_hash' => wp_create_nonce("give_form_create_user_nonce_{$form_id}") |
|
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -112,15 +112,15 @@ discard block |
||
| 112 | 112 | * @since 2.2.0 |
| 113 | 113 | * |
| 114 | 114 | */ |
| 115 | - $data = apply_filters( 'give_donation_form_reset_all_nonce_data', $data ); |
|
| 115 | + $data = apply_filters('give_donation_form_reset_all_nonce_data', $data); |
|
| 116 | 116 | |
| 117 | 117 | // Send nonce json data. |
| 118 | - wp_send_json_success( $data ); |
|
| 118 | + wp_send_json_success($data); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | -add_action( 'wp_ajax_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce' ); |
|
| 123 | -add_action( 'wp_ajax_nopriv_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce' ); |
|
| 122 | +add_action('wp_ajax_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce'); |
|
| 123 | +add_action('wp_ajax_nopriv_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce'); |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Sets an error within the donation form if no gateways are enabled. |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | function give_no_gateway_error() { |
| 134 | 134 | $gateways = give_get_enabled_payment_gateways(); |
| 135 | 135 | |
| 136 | - if ( empty( $gateways ) ) { |
|
| 137 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
| 136 | + if (empty($gateways)) { |
|
| 137 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
| 138 | 138 | } else { |
| 139 | - give_unset_error( 'no_gateways' ); |
|
| 139 | + give_unset_error('no_gateways'); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | -add_action( 'init', 'give_no_gateway_error' ); |
|
| 143 | +add_action('init', 'give_no_gateway_error'); |
|
@@ -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 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | // Set cache group id. |
| 55 | 55 | $current_blog_id = get_current_blog_id(); |
| 56 | 56 | $this->incrementer_name = "give-cache-incrementer-sessions-{$current_blog_id}"; |
| 57 | - $incrementer_value = wp_cache_get( $this->incrementer_name ); |
|
| 58 | - $incrementer_value = ! empty( $incrementer_value ) ? $incrementer_value : microtime( true ); |
|
| 57 | + $incrementer_value = wp_cache_get($this->incrementer_name); |
|
| 58 | + $incrementer_value = ! empty($incrementer_value) ? $incrementer_value : microtime(true); |
|
| 59 | 59 | $this->cache_group = "{$this->cache_group}_{$current_blog_id}_{$incrementer_value}"; |
| 60 | 60 | |
| 61 | 61 | $this->register_table(); |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | UNIQUE KEY session_id (session_id) |
| 102 | 102 | ) {$charset_collate};"; |
| 103 | 103 | |
| 104 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
| 105 | - dbDelta( $sql ); |
|
| 104 | + require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
| 105 | + dbDelta($sql); |
|
| 106 | 106 | |
| 107 | - update_option( $this->table_name . '_db_version', $this->version, false ); |
|
| 107 | + update_option($this->table_name.'_db_version', $this->version, false); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @return mixed |
| 120 | 120 | */ |
| 121 | - public function get_session( $donor_id, $default = false ) { |
|
| 121 | + public function get_session($donor_id, $default = false) { |
|
| 122 | 122 | global $wpdb; |
| 123 | 123 | |
| 124 | - if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
| 124 | + if (defined('WP_SETUP_CONFIG')) { |
|
| 125 | 125 | return false; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if ( ! ( $value = wp_cache_get( $donor_id, $this->cache_group ) ) ) { // @codingStandardsIgnoreLine |
|
| 128 | + if ( ! ($value = wp_cache_get($donor_id, $this->cache_group))) { // @codingStandardsIgnoreLine |
|
| 129 | 129 | |
| 130 | 130 | // @codingStandardsIgnoreStart |
| 131 | 131 | $value = $wpdb->get_var( |
@@ -140,14 +140,14 @@ discard block |
||
| 140 | 140 | ); |
| 141 | 141 | // @codingStandardsIgnoreEnd |
| 142 | 142 | |
| 143 | - if ( is_null( $value ) ) { |
|
| 143 | + if (is_null($value)) { |
|
| 144 | 144 | $value = $default; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - wp_cache_add( $donor_id, $value, $this->cache_group ); |
|
| 147 | + wp_cache_add($donor_id, $value, $this->cache_group); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - return maybe_unserialize( $value ); |
|
| 150 | + return maybe_unserialize($value); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param string $donor_id Donor ID. |
| 157 | 157 | * @param int $timestamp Timestamp to expire the cookie. |
| 158 | 158 | */ |
| 159 | - public function update_session_timestamp( $donor_id, $timestamp ) { |
|
| 159 | + public function update_session_timestamp($donor_id, $timestamp) { |
|
| 160 | 160 | global $wpdb; |
| 161 | 161 | |
| 162 | 162 | // @codingStandardsIgnoreStart. |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param int $donor_id Customer ID. |
| 185 | 185 | */ |
| 186 | - public function delete_session( $donor_id ) { |
|
| 186 | + public function delete_session($donor_id) { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | - wp_cache_delete( $donor_id, $this->cache_group ); |
|
| 189 | + wp_cache_delete($donor_id, $this->cache_group); |
|
| 190 | 190 | |
| 191 | 191 | // @codingStandardsIgnoreStart |
| 192 | 192 | $wpdb->delete( |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | public function delete_expired_sessions() { |
| 210 | 210 | global $wpdb; |
| 211 | 211 | |
| 212 | - wp_cache_set( $this->incrementer_name, microtime( true ) ); |
|
| 212 | + wp_cache_set($this->incrementer_name, microtime(true)); |
|
| 213 | 213 | |
| 214 | 214 | // @codingStandardsIgnoreStart |
| 215 | 215 | $wpdb->query( |
@@ -232,10 +232,10 @@ discard block |
||
| 232 | 232 | * @param array $data Data. |
| 233 | 233 | * @param array $format Array for data format of each key:value in data. |
| 234 | 234 | */ |
| 235 | - public function __replace( $table_name, $data, $format = null ) { |
|
| 235 | + public function __replace($table_name, $data, $format = null) { |
|
| 236 | 236 | global $wpdb; |
| 237 | 237 | |
| 238 | - wp_cache_set( $data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time() ); |
|
| 238 | + wp_cache_set($data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time()); |
|
| 239 | 239 | |
| 240 | 240 | |
| 241 | 241 | // @codingStandardsIgnoreStart |