@@ -10,11 +10,11 @@ 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 | |
| 17 | -add_filter( 'cmb2_meta_boxes', 'give_single_forms_cmb2_metaboxes' ); |
|
| 17 | +add_filter('cmb2_meta_boxes', 'give_single_forms_cmb2_metaboxes');
|
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Define the metabox and field configurations. |
@@ -23,23 +23,23 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | -function give_single_forms_cmb2_metaboxes( array $meta_boxes ) {
|
|
| 26 | +function give_single_forms_cmb2_metaboxes(array $meta_boxes) {
|
|
| 27 | 27 | |
| 28 | 28 | $post_id = give_get_admin_post_id(); |
| 29 | - $price = give_get_form_price( $post_id ); |
|
| 30 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
| 31 | - $goal = give_get_form_goal( $post_id ); |
|
| 32 | - $variable_pricing = give_has_variable_prices( $post_id ); |
|
| 33 | - $prices = give_get_variable_prices( $post_id ); |
|
| 29 | + $price = give_get_form_price($post_id); |
|
| 30 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
| 31 | + $goal = give_get_form_goal($post_id); |
|
| 32 | + $variable_pricing = give_has_variable_prices($post_id); |
|
| 33 | + $prices = give_get_variable_prices($post_id); |
|
| 34 | 34 | |
| 35 | 35 | //No empty prices - min. 1.00 for new forms |
| 36 | - if ( empty( $price ) && is_null( $post_id ) ) {
|
|
| 37 | - $price = esc_attr( give_format_amount( '1.00' ) ); |
|
| 36 | + if (empty($price) && is_null($post_id)) {
|
|
| 37 | + $price = esc_attr(give_format_amount('1.00'));
|
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | //Min. $1.00 for new forms |
| 41 | - if ( empty( $custom_amount_minimum ) ) {
|
|
| 42 | - $custom_amount_minimum = esc_attr( give_format_amount( '1.00' ) ); |
|
| 41 | + if (empty($custom_amount_minimum)) {
|
|
| 42 | + $custom_amount_minimum = esc_attr(give_format_amount('1.00'));
|
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Start with an underscore to hide fields from custom fields list |
@@ -48,327 +48,327 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * Repeatable Field Groups |
| 50 | 50 | */ |
| 51 | - $meta_boxes['form_field_options'] = apply_filters( 'give_forms_field_options', array( |
|
| 51 | + $meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array(
|
|
| 52 | 52 | 'id' => 'form_field_options', |
| 53 | - 'title' => esc_html__( 'Donation Options', 'give' ), |
|
| 54 | - 'object_types' => array( 'give_forms' ), |
|
| 53 | + 'title' => esc_html__('Donation Options', 'give'),
|
|
| 54 | + 'object_types' => array('give_forms'),
|
|
| 55 | 55 | 'context' => 'normal', |
| 56 | 56 | 'priority' => 'high', //Show above Content WYSIWYG |
| 57 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
| 57 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array(
|
|
| 58 | 58 | //Donation Option |
| 59 | 59 | array( |
| 60 | - 'name' => esc_html__( 'Donation Option', 'give' ), |
|
| 61 | - 'description' => esc_html__( 'Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
| 62 | - 'id' => $prefix . 'price_option', |
|
| 60 | + 'name' => esc_html__('Donation Option', 'give'),
|
|
| 61 | + 'description' => esc_html__('Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'),
|
|
| 62 | + 'id' => $prefix.'price_option', |
|
| 63 | 63 | 'type' => 'radio_inline', |
| 64 | 64 | 'default' => 'set', |
| 65 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
| 66 | - 'set' => esc_html__( 'Set Donation', 'give' ), |
|
| 67 | - 'multi' => esc_html__( 'Multi-level Donation', 'give' ), |
|
| 68 | - ) ), |
|
| 65 | + 'options' => apply_filters('give_forms_price_options', array(
|
|
| 66 | + 'set' => esc_html__('Set Donation', 'give'),
|
|
| 67 | + 'multi' => esc_html__('Multi-level Donation', 'give'),
|
|
| 68 | + )), |
|
| 69 | 69 | ), |
| 70 | 70 | array( |
| 71 | - 'name' => esc_html__( 'Set Donation', 'give' ), |
|
| 72 | - 'description' => esc_html__( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
| 73 | - 'id' => $prefix . 'set_price', |
|
| 71 | + 'name' => esc_html__('Set Donation', 'give'),
|
|
| 72 | + 'description' => esc_html__('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'),
|
|
| 73 | + 'id' => $prefix.'set_price', |
|
| 74 | 74 | 'type' => 'text_small', |
| 75 | 75 | 'row_classes' => 'give-subfield', |
| 76 | 76 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
| 77 | 77 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 78 | 78 | 'attributes' => array( |
| 79 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
| 80 | - 'value' => give_format_decimal( $price ), |
|
| 79 | + 'placeholder' => give_format_decimal('1.00'),
|
|
| 80 | + 'value' => give_format_decimal($price), |
|
| 81 | 81 | 'class' => 'cmb-type-text-small give-money-field', |
| 82 | 82 | ), |
| 83 | 83 | ), |
| 84 | 84 | //Donation levels: Header |
| 85 | 85 | array( |
| 86 | - 'id' => $prefix . 'levels_header', |
|
| 86 | + 'id' => $prefix.'levels_header', |
|
| 87 | 87 | 'type' => 'levels_repeater_header', |
| 88 | 88 | ), |
| 89 | 89 | //Donation Levels: Repeatable CMB2 Group |
| 90 | 90 | array( |
| 91 | - 'id' => $prefix . 'donation_levels', |
|
| 91 | + 'id' => $prefix.'donation_levels', |
|
| 92 | 92 | 'type' => 'group', |
| 93 | 93 | 'row_classes' => 'give-subfield', |
| 94 | 94 | 'options' => array( |
| 95 | - 'add_button' => esc_html__( 'Add Level', 'give' ), |
|
| 95 | + 'add_button' => esc_html__('Add Level', 'give'),
|
|
| 96 | 96 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
| 97 | 97 | 'sortable' => true, // beta |
| 98 | 98 | ), |
| 99 | 99 | // Fields array works the same, except id's only need to be unique for this group. Prefix is not needed. |
| 100 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
| 100 | + 'fields' => apply_filters('give_donation_levels_table_row', array(
|
|
| 101 | 101 | array( |
| 102 | - 'name' => esc_html__( 'ID', 'give' ), |
|
| 103 | - 'id' => $prefix . 'id', |
|
| 102 | + 'name' => esc_html__('ID', 'give'),
|
|
| 103 | + 'id' => $prefix.'id', |
|
| 104 | 104 | 'type' => 'levels_id', |
| 105 | 105 | ), |
| 106 | 106 | array( |
| 107 | - 'name' => esc_html__( 'Amount', 'give' ), |
|
| 108 | - 'id' => $prefix . 'amount', |
|
| 107 | + 'name' => esc_html__('Amount', 'give'),
|
|
| 108 | + 'id' => $prefix.'amount', |
|
| 109 | 109 | 'type' => 'text_small', |
| 110 | - 'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', |
|
| 111 | - 'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', |
|
| 110 | + 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : '',
|
|
| 111 | + 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : '',
|
|
| 112 | 112 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 113 | 113 | 'attributes' => array( |
| 114 | - 'placeholder' => give_format_decimal( '1.00' ), |
|
| 114 | + 'placeholder' => give_format_decimal('1.00'),
|
|
| 115 | 115 | 'class' => 'cmb-type-text-small give-money-field', |
| 116 | 116 | ), |
| 117 | 117 | 'before' => 'give_format_admin_multilevel_amount', |
| 118 | 118 | ), |
| 119 | 119 | array( |
| 120 | - 'name' => esc_html__( 'Text', 'give' ), |
|
| 121 | - 'id' => $prefix . 'text', |
|
| 120 | + 'name' => esc_html__('Text', 'give'),
|
|
| 121 | + 'id' => $prefix.'text', |
|
| 122 | 122 | 'type' => 'text', |
| 123 | 123 | 'attributes' => array( |
| 124 | - 'placeholder' => esc_html__( 'Donation Level', 'give' ), |
|
| 124 | + 'placeholder' => esc_html__('Donation Level', 'give'),
|
|
| 125 | 125 | 'class' => 'give-multilevel-text-field', |
| 126 | 126 | ), |
| 127 | 127 | ), |
| 128 | 128 | array( |
| 129 | - 'name' => esc_html__( 'Default', 'give' ), |
|
| 130 | - 'id' => $prefix . 'default', |
|
| 129 | + 'name' => esc_html__('Default', 'give'),
|
|
| 130 | + 'id' => $prefix.'default', |
|
| 131 | 131 | 'type' => 'give_default_radio_inline' |
| 132 | 132 | ), |
| 133 | - ) ), |
|
| 133 | + )), |
|
| 134 | 134 | ), |
| 135 | 135 | //Display Style |
| 136 | 136 | array( |
| 137 | - 'name' => esc_html__( 'Display Style', 'give' ), |
|
| 138 | - 'description' => esc_html__( 'Set how the donations levels will display on the form.', 'give' ), |
|
| 139 | - 'id' => $prefix . 'display_style', |
|
| 137 | + 'name' => esc_html__('Display Style', 'give'),
|
|
| 138 | + 'description' => esc_html__('Set how the donations levels will display on the form.', 'give'),
|
|
| 139 | + 'id' => $prefix.'display_style', |
|
| 140 | 140 | 'type' => 'radio_inline', |
| 141 | 141 | 'default' => 'buttons', |
| 142 | 142 | 'options' => array( |
| 143 | - 'buttons' => esc_html__( 'Buttons', 'give' ), |
|
| 144 | - 'radios' => esc_html__( 'Radios', 'give' ), |
|
| 145 | - 'dropdown' => esc_html__( 'Dropdown', 'give' ), |
|
| 143 | + 'buttons' => esc_html__('Buttons', 'give'),
|
|
| 144 | + 'radios' => esc_html__('Radios', 'give'),
|
|
| 145 | + 'dropdown' => esc_html__('Dropdown', 'give'),
|
|
| 146 | 146 | ), |
| 147 | 147 | ), |
| 148 | 148 | //Custom Amount |
| 149 | 149 | array( |
| 150 | - 'name' => esc_html__( 'Custom Amount', 'give' ), |
|
| 151 | - 'description' => esc_html__( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
| 152 | - 'id' => $prefix . 'custom_amount', |
|
| 150 | + 'name' => esc_html__('Custom Amount', 'give'),
|
|
| 151 | + 'description' => esc_html__('Do you want the user to be able to input their own donation amount?', 'give'),
|
|
| 152 | + 'id' => $prefix.'custom_amount', |
|
| 153 | 153 | 'type' => 'radio_inline', |
| 154 | 154 | 'default' => 'no', |
| 155 | 155 | 'options' => array( |
| 156 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 157 | - 'no' => esc_html__( 'No', 'give' ), |
|
| 156 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 157 | + 'no' => esc_html__('No', 'give'),
|
|
| 158 | 158 | ), |
| 159 | 159 | ), |
| 160 | 160 | array( |
| 161 | - 'name' => esc_html__( 'Custom Amount Minimum', 'give' ), |
|
| 162 | - 'description' => esc_html__( 'If you would like to set a minimum custom donation amount please enter it here.', 'give' ), |
|
| 163 | - 'id' => $prefix . 'custom_amount_minimum', |
|
| 161 | + 'name' => esc_html__('Custom Amount Minimum', 'give'),
|
|
| 162 | + 'description' => esc_html__('If you would like to set a minimum custom donation amount please enter it here.', 'give'),
|
|
| 163 | + 'id' => $prefix.'custom_amount_minimum', |
|
| 164 | 164 | 'type' => 'text_small', |
| 165 | 165 | 'row_classes' => 'give-subfield', |
| 166 | 166 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
| 167 | 167 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 168 | 168 | 'attributes' => array( |
| 169 | 169 | 'placeholder' => give_format_decimal('1.00'),
|
| 170 | - 'value' => give_format_decimal( $custom_amount_minimum ), |
|
| 170 | + 'value' => give_format_decimal($custom_amount_minimum), |
|
| 171 | 171 | 'class' => 'cmb-type-text-small give-money-field', |
| 172 | 172 | ) |
| 173 | 173 | ), |
| 174 | 174 | array( |
| 175 | - 'name' => esc_html__( 'Custom Amount Text', 'give' ), |
|
| 176 | - 'description' => esc_html__( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
| 177 | - 'id' => $prefix . 'custom_amount_text', |
|
| 175 | + 'name' => esc_html__('Custom Amount Text', 'give'),
|
|
| 176 | + 'description' => esc_html__('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'),
|
|
| 177 | + 'id' => $prefix.'custom_amount_text', |
|
| 178 | 178 | 'type' => 'text', |
| 179 | 179 | 'row_classes' => 'give-subfield', |
| 180 | 180 | 'attributes' => array( |
| 181 | 181 | 'rows' => 3, |
| 182 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
| 182 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'),
|
|
| 183 | 183 | ), |
| 184 | 184 | ), |
| 185 | 185 | //Goals |
| 186 | 186 | array( |
| 187 | - 'name' => esc_html__( 'Goal', 'give' ), |
|
| 188 | - 'description' => esc_html__( 'Do you want to set a donation goal for this form?', 'give' ), |
|
| 189 | - 'id' => $prefix . 'goal_option', |
|
| 187 | + 'name' => esc_html__('Goal', 'give'),
|
|
| 188 | + 'description' => esc_html__('Do you want to set a donation goal for this form?', 'give'),
|
|
| 189 | + 'id' => $prefix.'goal_option', |
|
| 190 | 190 | 'type' => 'radio_inline', |
| 191 | 191 | 'default' => 'no', |
| 192 | 192 | 'options' => array( |
| 193 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 194 | - 'no' => esc_html__( 'No', 'give' ), |
|
| 193 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 194 | + 'no' => esc_html__('No', 'give'),
|
|
| 195 | 195 | ), |
| 196 | 196 | ), |
| 197 | 197 | array( |
| 198 | - 'name' => esc_html__( 'Goal Amount', 'give' ), |
|
| 199 | - 'description' => esc_html__( 'This is the monetary goal amount you want to reach for this donation form.', 'give' ), |
|
| 200 | - 'id' => $prefix . 'set_goal', |
|
| 198 | + 'name' => esc_html__('Goal Amount', 'give'),
|
|
| 199 | + 'description' => esc_html__('This is the monetary goal amount you want to reach for this donation form.', 'give'),
|
|
| 200 | + 'id' => $prefix.'set_goal', |
|
| 201 | 201 | 'type' => 'text_small', |
| 202 | 202 | 'row_classes' => 'give-subfield', |
| 203 | 203 | 'render_row_cb' => 'give_cmb_amount_field_render_row_cb', |
| 204 | 204 | 'sanitization_cb' => 'give_sanitize_price_field_value', |
| 205 | 205 | 'attributes' => array( |
| 206 | - 'placeholder' => give_format_decimal( '0.00' ), |
|
| 207 | - 'value' => give_format_decimal( $goal ), |
|
| 206 | + 'placeholder' => give_format_decimal('0.00'),
|
|
| 207 | + 'value' => give_format_decimal($goal), |
|
| 208 | 208 | 'class' => 'cmb-type-text-small give-money-field', |
| 209 | 209 | ), |
| 210 | 210 | ), |
| 211 | 211 | |
| 212 | 212 | array( |
| 213 | - 'name' => esc_html__( 'Goal Format', 'give' ), |
|
| 214 | - 'description' => esc_html__( 'Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
| 215 | - 'id' => $prefix . 'goal_format', |
|
| 213 | + 'name' => esc_html__('Goal Format', 'give'),
|
|
| 214 | + 'description' => esc_html__('Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'),
|
|
| 215 | + 'id' => $prefix.'goal_format', |
|
| 216 | 216 | 'type' => 'radio_inline', |
| 217 | 217 | 'default' => 'amount', |
| 218 | 218 | 'row_classes' => 'give-subfield', |
| 219 | 219 | 'options' => array( |
| 220 | - 'amount' => esc_html__( 'Amount', 'give' ), |
|
| 221 | - 'percentage' => esc_html__( 'Percentage', 'give' ), |
|
| 220 | + 'amount' => esc_html__('Amount', 'give'),
|
|
| 221 | + 'percentage' => esc_html__('Percentage', 'give'),
|
|
| 222 | 222 | ), |
| 223 | 223 | ), |
| 224 | 224 | array( |
| 225 | - 'name' => esc_html__( 'Goal Progress Bar Color', 'give' ), |
|
| 226 | - 'id' => $prefix . 'goal_color', |
|
| 225 | + 'name' => esc_html__('Goal Progress Bar Color', 'give'),
|
|
| 226 | + 'id' => $prefix.'goal_color', |
|
| 227 | 227 | 'type' => 'colorpicker', |
| 228 | 228 | 'row_classes' => 'give-subfield', |
| 229 | 229 | 'default' => '#2bc253', |
| 230 | 230 | ), |
| 231 | 231 | |
| 232 | 232 | array( |
| 233 | - 'name' => esc_html__( 'Close Form when Goal Achieved', 'give' ), |
|
| 234 | - 'desc' => esc_html__( 'Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
| 235 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
| 233 | + 'name' => esc_html__('Close Form when Goal Achieved', 'give'),
|
|
| 234 | + 'desc' => esc_html__('Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give'),
|
|
| 235 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
| 236 | 236 | 'type' => 'radio_inline', |
| 237 | 237 | 'row_classes' => 'give-subfield', |
| 238 | 238 | 'options' => array( |
| 239 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 240 | - 'no' => esc_html__( 'No', 'give' ), |
|
| 239 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 240 | + 'no' => esc_html__('No', 'give'),
|
|
| 241 | 241 | ), |
| 242 | 242 | 'default' => 'no', |
| 243 | 243 | ), |
| 244 | 244 | array( |
| 245 | - 'name' => esc_html__( 'Goal Achieved Message', 'give' ), |
|
| 246 | - 'desc' => esc_html__( 'Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give' ), |
|
| 247 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
| 245 | + 'name' => esc_html__('Goal Achieved Message', 'give'),
|
|
| 246 | + 'desc' => esc_html__('Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give'),
|
|
| 247 | + 'id' => $prefix.'form_goal_achieved_message', |
|
| 248 | 248 | 'type' => 'textarea', |
| 249 | 249 | 'row_classes' => 'give-subfield', |
| 250 | 250 | 'attributes' => array( |
| 251 | - 'placeholder' => esc_attr__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
| 251 | + 'placeholder' => esc_attr__('Thank you to all our donors, we have met our fundraising goal.', 'give'),
|
|
| 252 | 252 | ), |
| 253 | 253 | ) |
| 254 | 254 | ) |
| 255 | 255 | ) |
| 256 | - ) ); |
|
| 256 | + )); |
|
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * Content Field |
| 261 | 261 | */ |
| 262 | - $meta_boxes['form_content_options'] = apply_filters( 'give_forms_content_options', array( |
|
| 262 | + $meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array(
|
|
| 263 | 263 | 'id' => 'form_content_options', |
| 264 | - 'title' => esc_html__( 'Form Content', 'give' ), |
|
| 265 | - 'object_types' => array( 'give_forms' ), |
|
| 264 | + 'title' => esc_html__('Form Content', 'give'),
|
|
| 265 | + 'object_types' => array('give_forms'),
|
|
| 266 | 266 | 'context' => 'normal', |
| 267 | 267 | 'priority' => 'high', //Show above Content WYSIWYG |
| 268 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
| 268 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array(
|
|
| 269 | 269 | //Donation Option |
| 270 | 270 | array( |
| 271 | - 'name' => esc_html__( 'Display Content', 'give' ), |
|
| 272 | - 'description' => esc_html__( 'Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give' ), |
|
| 273 | - 'id' => $prefix . 'content_option', |
|
| 271 | + 'name' => esc_html__('Display Content', 'give'),
|
|
| 272 | + 'description' => esc_html__('Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give'),
|
|
| 273 | + 'id' => $prefix.'content_option', |
|
| 274 | 274 | 'type' => 'select', |
| 275 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 276 | - 'none' => esc_html__( 'No Content', 'give' ), |
|
| 277 | - 'give_pre_form' => esc_html__( 'Display content ABOVE the fields', 'give' ), |
|
| 278 | - 'give_post_form' => esc_html__( 'Display content BELOW the fields', 'give' ), |
|
| 275 | + 'options' => apply_filters('give_forms_content_options_select', array(
|
|
| 276 | + 'none' => esc_html__('No Content', 'give'),
|
|
| 277 | + 'give_pre_form' => esc_html__('Display content ABOVE the fields', 'give'),
|
|
| 278 | + 'give_post_form' => esc_html__('Display content BELOW the fields', 'give'),
|
|
| 279 | 279 | ) |
| 280 | 280 | ), |
| 281 | 281 | 'default' => 'none', |
| 282 | 282 | ), |
| 283 | 283 | array( |
| 284 | - 'name' => esc_html__( 'Content', 'give' ), |
|
| 285 | - 'description' => esc_html__( 'This content will display on the single give form page.', 'give' ), |
|
| 286 | - 'id' => $prefix . 'form_content', |
|
| 284 | + 'name' => esc_html__('Content', 'give'),
|
|
| 285 | + 'description' => esc_html__('This content will display on the single give form page.', 'give'),
|
|
| 286 | + 'id' => $prefix.'form_content', |
|
| 287 | 287 | 'row_classes' => 'give-subfield', |
| 288 | 288 | 'type' => 'wysiwyg' |
| 289 | 289 | ), |
| 290 | 290 | ) |
| 291 | 291 | ) |
| 292 | - ) ); |
|
| 292 | + )); |
|
| 293 | 293 | |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | 296 | * Display Options |
| 297 | 297 | */ |
| 298 | - $meta_boxes['form_display_options'] = apply_filters( 'give_form_display_options', array( |
|
| 298 | + $meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array(
|
|
| 299 | 299 | 'id' => 'form_display_options', |
| 300 | - 'title' => esc_html__( 'Form Display Options', 'give' ), |
|
| 301 | - 'object_types' => array( 'give_forms' ), |
|
| 300 | + 'title' => esc_html__('Form Display Options', 'give'),
|
|
| 301 | + 'object_types' => array('give_forms'),
|
|
| 302 | 302 | 'context' => 'normal', // 'normal', 'advanced', or 'side' |
| 303 | 303 | 'priority' => 'high', //Show above Content WYSIWYG |
| 304 | 304 | 'show_names' => true, // Show field names on the left |
| 305 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
| 305 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array(
|
|
| 306 | 306 | array( |
| 307 | - 'name' => esc_html__( 'Payment Fields', 'give' ), |
|
| 308 | - 'desc' => esc_html__( 'How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give' ), |
|
| 309 | - 'id' => $prefix . 'payment_display', |
|
| 307 | + 'name' => esc_html__('Payment Fields', 'give'),
|
|
| 308 | + 'desc' => esc_html__('How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'),
|
|
| 309 | + 'id' => $prefix.'payment_display', |
|
| 310 | 310 | 'type' => 'select', |
| 311 | 311 | 'options' => array( |
| 312 | - 'onpage' => esc_html__( 'Show on Page', 'give' ), |
|
| 313 | - 'reveal' => esc_html__( 'Reveal Upon Click', 'give' ), |
|
| 314 | - 'modal' => esc_html__( 'Modal Window Upon Click', 'give' ), |
|
| 312 | + 'onpage' => esc_html__('Show on Page', 'give'),
|
|
| 313 | + 'reveal' => esc_html__('Reveal Upon Click', 'give'),
|
|
| 314 | + 'modal' => esc_html__('Modal Window Upon Click', 'give'),
|
|
| 315 | 315 | ), |
| 316 | 316 | 'default' => 'onpage', |
| 317 | 317 | ), |
| 318 | 318 | array( |
| 319 | - 'id' => $prefix . 'reveal_label', |
|
| 320 | - 'name' => esc_html__( 'Reveal / Modal Open Text', 'give' ), |
|
| 321 | - 'desc' => esc_html__( 'The button label for completing the donation.', 'give' ), |
|
| 319 | + 'id' => $prefix.'reveal_label', |
|
| 320 | + 'name' => esc_html__('Reveal / Modal Open Text', 'give'),
|
|
| 321 | + 'desc' => esc_html__('The button label for completing the donation.', 'give'),
|
|
| 322 | 322 | 'type' => 'text_small', |
| 323 | 323 | 'row_classes' => 'give-subfield', |
| 324 | 324 | 'attributes' => array( |
| 325 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
| 325 | + 'placeholder' => esc_attr__('Donate Now', 'give'),
|
|
| 326 | 326 | ), |
| 327 | 327 | ), |
| 328 | 328 | array( |
| 329 | - 'id' => $prefix . 'checkout_label', |
|
| 330 | - 'name' => esc_html__( 'Complete Donation Text', 'give' ), |
|
| 331 | - 'desc' => esc_html__( 'The button label for completing a donation.', 'give' ), |
|
| 329 | + 'id' => $prefix.'checkout_label', |
|
| 330 | + 'name' => esc_html__('Complete Donation Text', 'give'),
|
|
| 331 | + 'desc' => esc_html__('The button label for completing a donation.', 'give'),
|
|
| 332 | 332 | 'type' => 'text_small', |
| 333 | 333 | 'attributes' => array( |
| 334 | - 'placeholder' => esc_html__( 'Donate Now', 'give' ), |
|
| 334 | + 'placeholder' => esc_html__('Donate Now', 'give'),
|
|
| 335 | 335 | ), |
| 336 | 336 | ), |
| 337 | 337 | array( |
| 338 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
| 339 | - 'desc' => esc_html__( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
| 340 | - 'id' => $prefix . 'default_gateway', |
|
| 338 | + 'name' => esc_html__('Default Gateway', 'give'),
|
|
| 339 | + 'desc' => esc_html__('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'),
|
|
| 340 | + 'id' => $prefix.'default_gateway', |
|
| 341 | 341 | 'type' => 'default_gateway' |
| 342 | 342 | ), |
| 343 | 343 | array( |
| 344 | - 'name' => esc_html__( 'Disable Guest Donations', 'give' ), |
|
| 345 | - 'desc' => esc_html__( 'Do you want to require users be logged-in to make donations?', 'give' ), |
|
| 346 | - 'id' => $prefix . 'logged_in_only', |
|
| 344 | + 'name' => esc_html__('Disable Guest Donations', 'give'),
|
|
| 345 | + 'desc' => esc_html__('Do you want to require users be logged-in to make donations?', 'give'),
|
|
| 346 | + 'id' => $prefix.'logged_in_only', |
|
| 347 | 347 | 'type' => 'checkbox' |
| 348 | 348 | ), |
| 349 | 349 | array( |
| 350 | - 'name' => esc_html__( 'Register / Login Form', 'give' ), |
|
| 351 | - 'desc' => esc_html__( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
| 352 | - 'id' => $prefix . 'show_register_form', |
|
| 350 | + 'name' => esc_html__('Register / Login Form', 'give'),
|
|
| 351 | + 'desc' => esc_html__('Display the registration and login forms in the payment section for non-logged-in users.', 'give'),
|
|
| 352 | + 'id' => $prefix.'show_register_form', |
|
| 353 | 353 | 'type' => 'select', |
| 354 | 354 | 'options' => array( |
| 355 | - 'both' => esc_html__( 'Registration and Login Forms', 'give' ), |
|
| 356 | - 'registration' => esc_html__( 'Registration Form Only', 'give' ), |
|
| 357 | - 'login' => esc_html__( 'Login Form Only', 'give' ), |
|
| 358 | - 'none' => esc_html__( 'None', 'give' ), |
|
| 355 | + 'both' => esc_html__('Registration and Login Forms', 'give'),
|
|
| 356 | + 'registration' => esc_html__('Registration Form Only', 'give'),
|
|
| 357 | + 'login' => esc_html__('Login Form Only', 'give'),
|
|
| 358 | + 'none' => esc_html__('None', 'give'),
|
|
| 359 | 359 | ), |
| 360 | 360 | 'default' => 'none', |
| 361 | 361 | ), |
| 362 | 362 | array( |
| 363 | - 'name' => esc_html__( 'Floating Labels', 'give' ), |
|
| 363 | + 'name' => esc_html__('Floating Labels', 'give'),
|
|
| 364 | 364 | /* translators: %s: forms https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */ |
| 365 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) ), |
|
| 366 | - 'id' => $prefix . 'form_floating_labels', |
|
| 365 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels')),
|
|
| 366 | + 'id' => $prefix.'form_floating_labels', |
|
| 367 | 367 | 'type' => 'select', |
| 368 | 368 | 'options' => array( |
| 369 | - '' => esc_html__( 'Use the global setting', 'give' ), |
|
| 370 | - 'enabled' => esc_html__( 'Enabled', 'give' ), |
|
| 371 | - 'disabled' => esc_html__( 'Disabled', 'give' ), |
|
| 369 | + '' => esc_html__('Use the global setting', 'give'),
|
|
| 370 | + 'enabled' => esc_html__('Enabled', 'give'),
|
|
| 371 | + 'disabled' => esc_html__('Disabled', 'give'),
|
|
| 372 | 372 | ), |
| 373 | 373 | 'default' => 'none', |
| 374 | 374 | ) |
@@ -380,47 +380,47 @@ discard block |
||
| 380 | 380 | /** |
| 381 | 381 | * Terms & Conditions |
| 382 | 382 | */ |
| 383 | - $meta_boxes['form_terms_options'] = apply_filters( 'give_forms_terms_options', array( |
|
| 383 | + $meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array(
|
|
| 384 | 384 | 'id' => 'form_terms_options', |
| 385 | - 'title' => esc_html__( 'Terms and Conditions', 'give' ), |
|
| 386 | - 'object_types' => array( 'give_forms' ), |
|
| 385 | + 'title' => esc_html__('Terms and Conditions', 'give'),
|
|
| 386 | + 'object_types' => array('give_forms'),
|
|
| 387 | 387 | 'context' => 'normal', |
| 388 | 388 | 'priority' => 'high', //Show above Content WYSIWYG |
| 389 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
| 389 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array(
|
|
| 390 | 390 | //Donation Option |
| 391 | 391 | array( |
| 392 | - 'name' => esc_html__( 'Terms and Conditions', 'give' ), |
|
| 393 | - 'description' => esc_html__( 'Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give' ), |
|
| 394 | - 'id' => $prefix . 'terms_option', |
|
| 392 | + 'name' => esc_html__('Terms and Conditions', 'give'),
|
|
| 393 | + 'description' => esc_html__('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'),
|
|
| 394 | + 'id' => $prefix.'terms_option', |
|
| 395 | 395 | 'type' => 'select', |
| 396 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 397 | - 'none' => esc_html__( 'No', 'give' ), |
|
| 398 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
| 396 | + 'options' => apply_filters('give_forms_content_options_select', array(
|
|
| 397 | + 'none' => esc_html__('No', 'give'),
|
|
| 398 | + 'yes' => esc_html__('Yes', 'give'),
|
|
| 399 | 399 | ) |
| 400 | 400 | ), |
| 401 | 401 | 'default' => 'none', |
| 402 | 402 | ), |
| 403 | 403 | array( |
| 404 | - 'id' => $prefix . 'agree_label', |
|
| 405 | - 'name' => esc_html__( 'Agree to Terms Label', 'give' ), |
|
| 406 | - 'desc' => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
| 404 | + 'id' => $prefix.'agree_label', |
|
| 405 | + 'name' => esc_html__('Agree to Terms Label', 'give'),
|
|
| 406 | + 'desc' => esc_html__('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'),
|
|
| 407 | 407 | 'type' => 'text', |
| 408 | 408 | 'row_classes' => 'give-subfield', |
| 409 | 409 | 'size' => 'regular', |
| 410 | 410 | 'attributes' => array( |
| 411 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
| 411 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'),
|
|
| 412 | 412 | ), |
| 413 | 413 | ), |
| 414 | 414 | array( |
| 415 | - 'id' => $prefix . 'agree_text', |
|
| 415 | + 'id' => $prefix.'agree_text', |
|
| 416 | 416 | 'row_classes' => 'give-subfield', |
| 417 | - 'name' => esc_html__( 'Agreement Text', 'give' ), |
|
| 418 | - 'desc' => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
| 417 | + 'name' => esc_html__('Agreement Text', 'give'),
|
|
| 418 | + 'desc' => esc_html__('This is the actual text which the user will have to agree to in order to make a donation.', 'give'),
|
|
| 419 | 419 | 'type' => 'wysiwyg' |
| 420 | 420 | ), |
| 421 | 421 | ) |
| 422 | 422 | ) |
| 423 | - ) ); |
|
| 423 | + )); |
|
| 424 | 424 | |
| 425 | 425 | return $meta_boxes; |
| 426 | 426 | |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | <div class="table-container"> |
| 436 | 436 | <div class="table-row"> |
| 437 | - <div class="table-cell col-amount"><?php esc_html_e( 'Amount', 'give' ); ?></div> |
|
| 438 | - <div class="table-cell col-text"><?php esc_html_e( 'Text', 'give' ); ?></div> |
|
| 439 | - <div class="table-cell col-default"><?php esc_html_e( 'Default', 'give' ); ?></div> |
|
| 437 | + <div class="table-cell col-amount"><?php esc_html_e('Amount', 'give'); ?></div>
|
|
| 438 | + <div class="table-cell col-text"><?php esc_html_e('Text', 'give'); ?></div>
|
|
| 439 | + <div class="table-cell col-default"><?php esc_html_e('Default', 'give'); ?></div>
|
|
| 440 | 440 | <?php |
| 441 | 441 | /** |
| 442 | 442 | * Fires in repeatable donation levels table head. |
@@ -448,9 +448,9 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @since 1.0 |
| 450 | 450 | */ |
| 451 | - do_action( 'give_donation_levels_table_head' ); |
|
| 451 | + do_action('give_donation_levels_table_head');
|
|
| 452 | 452 | ?> |
| 453 | - <div class="table-cell col-sort"><?php esc_html_e( 'Sort', 'give' ); ?></div> |
|
| 453 | + <div class="table-cell col-sort"><?php esc_html_e('Sort', 'give'); ?></div>
|
|
| 454 | 454 | |
| 455 | 455 | </div> |
| 456 | 456 | </div> |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | <?php |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | -add_action( 'cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10 ); |
|
| 461 | +add_action('cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10);
|
|
| 462 | 462 | |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -475,25 +475,25 @@ discard block |
||
| 475 | 475 | * @param $object_type |
| 476 | 476 | * @param $field_type_object |
| 477 | 477 | */ |
| 478 | -function give_cmb_render_levels_id( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
|
|
| 478 | +function give_cmb_render_levels_id($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
|
|
| 479 | 479 | |
| 480 | - $escaped_value = ( isset( $escaped_value['level_id'] ) ? $escaped_value['level_id'] : '' ); |
|
| 480 | + $escaped_value = (isset($escaped_value['level_id']) ? $escaped_value['level_id'] : ''); |
|
| 481 | 481 | |
| 482 | 482 | $field_options_array = array( |
| 483 | 483 | 'class' => 'give-hidden give-level-id-input', |
| 484 | - 'name' => $field_type_object->_name( '[level_id]' ), |
|
| 485 | - 'id' => $field_type_object->_id( '_level_id' ), |
|
| 484 | + 'name' => $field_type_object->_name('[level_id]'),
|
|
| 485 | + 'id' => $field_type_object->_id('_level_id'),
|
|
| 486 | 486 | 'value' => $escaped_value, |
| 487 | 487 | 'type' => 'number', |
| 488 | 488 | 'desc' => '', |
| 489 | 489 | ); |
| 490 | 490 | |
| 491 | - echo '<p class="give-level-id">' . $escaped_value . '</p>'; |
|
| 492 | - echo $field_type_object->input( $field_options_array ); |
|
| 491 | + echo '<p class="give-level-id">'.$escaped_value.'</p>'; |
|
| 492 | + echo $field_type_object->input($field_options_array); |
|
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | -add_action( 'cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5 ); |
|
| 496 | +add_action('cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5);
|
|
| 497 | 497 | |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -505,13 +505,13 @@ discard block |
||
| 505 | 505 | * @param $object_type |
| 506 | 506 | * @param $field_type_object |
| 507 | 507 | */ |
| 508 | -function give_cmb_give_default_radio_inline( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
|
|
| 509 | - echo '<input type="radio" class="cmb2-option donation-level-radio" name="' . $field_object->args['_name'] . '" id="' . $field_object->args['id'] . '" value="default" ' . checked( 'default', $escaped_value, false ) . '>'; |
|
| 510 | - echo '<label for="' . $field_object->args['id'] . '">' . esc_html__( 'Default', 'give' ) . '</label>'; |
|
| 508 | +function give_cmb_give_default_radio_inline($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
|
|
| 509 | + echo '<input type="radio" class="cmb2-option donation-level-radio" name="'.$field_object->args['_name'].'" id="'.$field_object->args['id'].'" value="default" '.checked('default', $escaped_value, false).'>';
|
|
| 510 | + echo '<label for="'.$field_object->args['id'].'">'.esc_html__('Default', 'give').'</label>';
|
|
| 511 | 511 | |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | -add_action( 'cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5 ); |
|
| 514 | +add_action('cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5);
|
|
| 515 | 515 | |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -521,20 +521,20 @@ discard block |
||
| 521 | 521 | */ |
| 522 | 522 | function give_add_shortcode_to_publish_metabox() {
|
| 523 | 523 | |
| 524 | - if ( 'give_forms' !== get_post_type() ) {
|
|
| 524 | + if ('give_forms' !== get_post_type()) {
|
|
| 525 | 525 | return false; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | global $post; |
| 529 | 529 | |
| 530 | 530 | //Only enqueue scripts for CPT on post type screen |
| 531 | - if ( 'give_forms' === $post->post_type ) {
|
|
| 531 | + if ('give_forms' === $post->post_type) {
|
|
| 532 | 532 | //Shortcode column with select all input |
| 533 | - $shortcode = htmlentities( '[give_form id="' . $post->ID . '"]' ); |
|
| 534 | - echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">' . esc_html__( 'Give Form Shortcode:', 'give' ) . '</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="' . $shortcode . '"></div>'; |
|
| 533 | + $shortcode = htmlentities('[give_form id="'.$post->ID.'"]');
|
|
| 534 | + echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">'.esc_html__('Give Form Shortcode:', 'give').'</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="'.$shortcode.'"></div>';
|
|
| 535 | 535 | |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | -add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' ); |
|
| 540 | +add_action('post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox');
|
|
@@ -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 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return object |
| 100 | 100 | */ |
| 101 | - public function get( $row_id ) { |
|
| 101 | + public function get($row_id) { |
|
| 102 | 102 | /* @var WPDB $wpdb */ |
| 103 | 103 | global $wpdb; |
| 104 | 104 | |
| 105 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 105 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return object |
| 118 | 118 | */ |
| 119 | - public function get_by( $column, $row_id ) { |
|
| 119 | + public function get_by($column, $row_id) { |
|
| 120 | 120 | /* @var WPDB $wpdb */ |
| 121 | 121 | global $wpdb; |
| 122 | 122 | |
| 123 | - $column = esc_sql( $column ); |
|
| 124 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
| 123 | + $column = esc_sql($column); |
|
| 124 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return string Column value. |
| 137 | 137 | */ |
| 138 | - public function get_column( $column, $row_id ) { |
|
| 138 | + public function get_column($column, $row_id) { |
|
| 139 | 139 | /* @var WPDB $wpdb */ |
| 140 | 140 | global $wpdb; |
| 141 | 141 | |
| 142 | - $column = esc_sql( $column ); |
|
| 143 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 142 | + $column = esc_sql($column); |
|
| 143 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
| 158 | + public function get_column_by($column, $column_where, $column_value) { |
|
| 159 | 159 | /* @var WPDB $wpdb */ |
| 160 | 160 | global $wpdb; |
| 161 | 161 | |
| 162 | - $column_where = esc_sql( $column_where ); |
|
| 163 | - $column = esc_sql( $column ); |
|
| 164 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
| 162 | + $column_where = esc_sql($column_where); |
|
| 163 | + $column = esc_sql($column); |
|
| 164 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return int |
| 177 | 177 | */ |
| 178 | - public function insert( $data, $type = '' ) { |
|
| 178 | + public function insert($data, $type = '') { |
|
| 179 | 179 | /* @var WPDB $wpdb */ |
| 180 | 180 | global $wpdb; |
| 181 | 181 | |
| 182 | 182 | // Set default values. |
| 183 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 183 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * Fires before inserting data to the database. |
@@ -189,22 +189,22 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @param array $data |
| 191 | 191 | */ |
| 192 | - do_action( "give_pre_insert_{$type}", $data ); |
|
| 192 | + do_action("give_pre_insert_{$type}", $data); |
|
| 193 | 193 | |
| 194 | 194 | // Initialise column format array |
| 195 | 195 | $column_formats = $this->get_columns(); |
| 196 | 196 | |
| 197 | 197 | // Force fields to lower case |
| 198 | - $data = array_change_key_case( $data ); |
|
| 198 | + $data = array_change_key_case($data); |
|
| 199 | 199 | |
| 200 | 200 | // White list columns |
| 201 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 201 | + $data = array_intersect_key($data, $column_formats); |
|
| 202 | 202 | |
| 203 | 203 | // Reorder $column_formats to match the order of columns given in $data |
| 204 | - $data_keys = array_keys( $data ); |
|
| 205 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 204 | + $data_keys = array_keys($data); |
|
| 205 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 206 | 206 | |
| 207 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
| 207 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * Fires after inserting data to the database. |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param int $insert_id |
| 215 | 215 | * @param array $data |
| 216 | 216 | */ |
| 217 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
| 217 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
| 218 | 218 | |
| 219 | 219 | return $wpdb->insert_id; |
| 220 | 220 | } |
@@ -231,18 +231,18 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return bool |
| 233 | 233 | */ |
| 234 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
| 234 | + public function update($row_id, $data = array(), $where = '') { |
|
| 235 | 235 | /* @var WPDB $wpdb */ |
| 236 | 236 | global $wpdb; |
| 237 | 237 | |
| 238 | 238 | // Row ID must be positive integer |
| 239 | - $row_id = absint( $row_id ); |
|
| 239 | + $row_id = absint($row_id); |
|
| 240 | 240 | |
| 241 | - if ( empty( $row_id ) ) { |
|
| 241 | + if (empty($row_id)) { |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if ( empty( $where ) ) { |
|
| 245 | + if (empty($where)) { |
|
| 246 | 246 | $where = $this->primary_key; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -250,16 +250,16 @@ discard block |
||
| 250 | 250 | $column_formats = $this->get_columns(); |
| 251 | 251 | |
| 252 | 252 | // Force fields to lower case |
| 253 | - $data = array_change_key_case( $data ); |
|
| 253 | + $data = array_change_key_case($data); |
|
| 254 | 254 | |
| 255 | 255 | // White list columns |
| 256 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 256 | + $data = array_intersect_key($data, $column_formats); |
|
| 257 | 257 | |
| 258 | 258 | // Reorder $column_formats to match the order of columns given in $data |
| 259 | - $data_keys = array_keys( $data ); |
|
| 260 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 259 | + $data_keys = array_keys($data); |
|
| 260 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 261 | 261 | |
| 262 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
| 262 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
| 263 | 263 | return false; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -276,18 +276,18 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return bool |
| 278 | 278 | */ |
| 279 | - public function delete( $row_id = 0 ) { |
|
| 279 | + public function delete($row_id = 0) { |
|
| 280 | 280 | /* @var WPDB $wpdb */ |
| 281 | 281 | global $wpdb; |
| 282 | 282 | |
| 283 | 283 | // Row ID must be positive integer |
| 284 | - $row_id = absint( $row_id ); |
|
| 284 | + $row_id = absint($row_id); |
|
| 285 | 285 | |
| 286 | - if ( empty( $row_id ) ) { |
|
| 286 | + if (empty($row_id)) { |
|
| 287 | 287 | return false; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
| 290 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
| 291 | 291 | return false; |
| 292 | 292 | } |
| 293 | 293 | |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @return bool If the table name exists. |
| 306 | 306 | */ |
| 307 | - public function table_exists( $table ) { |
|
| 307 | + public function table_exists($table) { |
|
| 308 | 308 | /* @var WPDB $wpdb */ |
| 309 | 309 | global $wpdb; |
| 310 | 310 | |
| 311 | - $table = sanitize_text_field( $table ); |
|
| 311 | + $table = sanitize_text_field($table); |
|
| 312 | 312 | |
| 313 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
| 313 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @return bool Returns if the customers table was installed and upgrade routine run. |
| 323 | 323 | */ |
| 324 | 324 | public function installed() { |
| 325 | - return $this->table_exists( $this->table_name ); |
|
| 325 | + return $this->table_exists($this->table_name); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function __construct() { |
| 81 | 81 | |
| 82 | - if ( 'none' === $this->get_template() ) { |
|
| 82 | + if ('none' === $this->get_template()) { |
|
| 83 | 83 | $this->html = false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
| 87 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
| 86 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
| 87 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @since 1.0 |
| 95 | 95 | */ |
| 96 | - public function __set( $key, $value ) { |
|
| 96 | + public function __set($key, $value) { |
|
| 97 | 97 | $this->$key = $value; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | * @since 1.0 |
| 104 | 104 | */ |
| 105 | 105 | public function get_from_name() { |
| 106 | - if ( ! $this->from_name ) { |
|
| 107 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
| 106 | + if ( ! $this->from_name) { |
|
| 107 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
| 110 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | * @since 1.0 |
| 117 | 117 | */ |
| 118 | 118 | public function get_from_address() { |
| 119 | - if ( ! $this->from_address ) { |
|
| 120 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
| 119 | + if ( ! $this->from_address) { |
|
| 120 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
| 123 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | * @since 1.0 |
| 130 | 130 | */ |
| 131 | 131 | public function get_content_type() { |
| 132 | - if ( ! $this->content_type && $this->html ) { |
|
| 133 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
| 134 | - } else if ( ! $this->html ) { |
|
| 132 | + if ( ! $this->content_type && $this->html) { |
|
| 133 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
| 134 | + } else if ( ! $this->html) { |
|
| 135 | 135 | $this->content_type = 'text/plain'; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
| 138 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | * @since 1.0 |
| 145 | 145 | */ |
| 146 | 146 | public function get_headers() { |
| 147 | - if ( ! $this->headers ) { |
|
| 147 | + if ( ! $this->headers) { |
|
| 148 | 148 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
| 149 | 149 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
| 150 | 150 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
| 153 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function get_templates() { |
| 162 | 162 | $templates = array( |
| 163 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
| 164 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
| 163 | + 'default' => esc_html__('Default Template', 'give'), |
|
| 164 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | - return apply_filters( 'give_email_templates', $templates ); |
|
| 167 | + return apply_filters('give_email_templates', $templates); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -173,11 +173,11 @@ discard block |
||
| 173 | 173 | * @since 1.0 |
| 174 | 174 | */ |
| 175 | 175 | public function get_template() { |
| 176 | - if ( ! $this->template ) { |
|
| 177 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
| 176 | + if ( ! $this->template) { |
|
| 177 | + $this->template = give_get_option('email_template', 'default'); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - return apply_filters( 'give_email_template', $this->template ); |
|
| 180 | + return apply_filters('give_email_template', $this->template); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @since 1.0 |
| 187 | 187 | */ |
| 188 | 188 | public function get_heading() { |
| 189 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
| 189 | + return apply_filters('give_email_heading', $this->heading); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @return mixed |
| 198 | 198 | */ |
| 199 | - public function parse_tags( $content ) { |
|
| 199 | + public function parse_tags($content) { |
|
| 200 | 200 | return $content; |
| 201 | 201 | } |
| 202 | 202 | |
@@ -205,19 +205,19 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @since 1.0 |
| 207 | 207 | */ |
| 208 | - public function build_email( $message ) { |
|
| 208 | + public function build_email($message) { |
|
| 209 | 209 | |
| 210 | - if ( false === $this->html ) { |
|
| 211 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
| 210 | + if (false === $this->html) { |
|
| 211 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $message = $this->text_to_html( $message ); |
|
| 214 | + $message = $this->text_to_html($message); |
|
| 215 | 215 | |
| 216 | 216 | $template = $this->get_template(); |
| 217 | 217 | |
| 218 | 218 | ob_start(); |
| 219 | 219 | |
| 220 | - give_get_template_part( 'emails/header', $template, true ); |
|
| 220 | + give_get_template_part('emails/header', $template, true); |
|
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * Fires in the email head. |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @param Give_Emails $this The email object. |
| 228 | 228 | */ |
| 229 | - do_action( 'give_email_header', $this ); |
|
| 229 | + do_action('give_email_header', $this); |
|
| 230 | 230 | |
| 231 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
| 231 | + if (has_action('give_email_template_'.$template)) { |
|
| 232 | 232 | /** |
| 233 | 233 | * Fires in a specific email template. |
| 234 | 234 | * |
| 235 | 235 | * @since 1.0 |
| 236 | 236 | */ |
| 237 | - do_action( "give_email_template_{$template}" ); |
|
| 237 | + do_action("give_email_template_{$template}"); |
|
| 238 | 238 | } else { |
| 239 | - give_get_template_part( 'emails/body', $template, true ); |
|
| 239 | + give_get_template_part('emails/body', $template, true); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @param Give_Emails $this The email object. |
| 248 | 248 | */ |
| 249 | - do_action( 'give_email_body', $this ); |
|
| 249 | + do_action('give_email_body', $this); |
|
| 250 | 250 | |
| 251 | - give_get_template_part( 'emails/footer', $template, true ); |
|
| 251 | + give_get_template_part('emails/footer', $template, true); |
|
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * Fires in the email footer. |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @param Give_Emails $this The email object. |
| 259 | 259 | */ |
| 260 | - do_action( 'give_email_footer', $this ); |
|
| 260 | + do_action('give_email_footer', $this); |
|
| 261 | 261 | |
| 262 | 262 | $body = ob_get_clean(); |
| 263 | - $message = str_replace( '{email}', $message, $body ); |
|
| 263 | + $message = str_replace('{email}', $message, $body); |
|
| 264 | 264 | |
| 265 | - return apply_filters( 'give_email_message', $message, $this ); |
|
| 265 | + return apply_filters('give_email_message', $message, $this); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return bool |
| 277 | 277 | */ |
| 278 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
| 278 | + public function send($to, $subject, $message, $attachments = '') { |
|
| 279 | 279 | |
| 280 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
| 281 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
| 280 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
| 281 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
| 282 | 282 | |
| 283 | 283 | return false; |
| 284 | 284 | } |
@@ -290,16 +290,16 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @param Give_Emails $this The email object. |
| 292 | 292 | */ |
| 293 | - do_action( 'give_email_send_before', $this ); |
|
| 293 | + do_action('give_email_send_before', $this); |
|
| 294 | 294 | |
| 295 | - $subject = $this->parse_tags( $subject ); |
|
| 296 | - $message = $this->parse_tags( $message ); |
|
| 295 | + $subject = $this->parse_tags($subject); |
|
| 296 | + $message = $this->parse_tags($message); |
|
| 297 | 297 | |
| 298 | - $message = $this->build_email( $message ); |
|
| 298 | + $message = $this->build_email($message); |
|
| 299 | 299 | |
| 300 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
| 300 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
| 301 | 301 | |
| 302 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
| 302 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * Fires after sending an email. |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * |
| 309 | 309 | * @param Give_Emails $this The email object. |
| 310 | 310 | */ |
| 311 | - do_action( 'give_email_send_after', $this ); |
|
| 311 | + do_action('give_email_send_after', $this); |
|
| 312 | 312 | |
| 313 | 313 | return $sent; |
| 314 | 314 | |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | * @since 1.0 |
| 321 | 321 | */ |
| 322 | 322 | public function send_before() { |
| 323 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
| 324 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
| 325 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
| 323 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
| 324 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
| 325 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | * @since 1.0 |
| 332 | 332 | */ |
| 333 | 333 | public function send_after() { |
| 334 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
| 335 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
| 336 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
| 334 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
| 335 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
| 336 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
| 337 | 337 | |
| 338 | 338 | // Reset heading to an empty string |
| 339 | 339 | $this->heading = ''; |
@@ -344,10 +344,10 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @since 1.0 |
| 346 | 346 | */ |
| 347 | - public function text_to_html( $message ) { |
|
| 347 | + public function text_to_html($message) { |
|
| 348 | 348 | |
| 349 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
| 350 | - $message = wpautop( $message ); |
|
| 349 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
| 350 | + $message = wpautop($message); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | return $message; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param $field_args |
| 226 | 226 | * @param $field |
| 227 | 227 | * |
| 228 | - * @return bool |
|
| 228 | + * @return false|null |
|
| 229 | 229 | */ |
| 230 | 230 | function give_format_admin_multilevel_amount( $field_args, $field ) { |
| 231 | 231 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @param array $field_args |
| 376 | 376 | * @param object $field |
| 377 | 377 | * |
| 378 | - * @return mixed |
|
| 378 | + * @return string |
|
| 379 | 379 | */ |
| 380 | 380 | function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
| 381 | 381 | return stripslashes( $value ); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @param array $field_args |
| 409 | 409 | * @param object $field |
| 410 | 410 | * |
| 411 | - * @return mixed |
|
| 411 | + * @return string |
|
| 412 | 412 | */ |
| 413 | 413 | function give_sanitize_price_field_value( $value, $field_args, $field ){ |
| 414 | 414 | return give_sanitize_amount( $value ); |
@@ -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 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @return mixed |
| 24 | 24 | */ |
| 25 | 25 | function give_get_price_decimals() { |
| 26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
| 26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return mixed |
| 35 | 35 | */ |
| 36 | 36 | function give_get_price_thousand_separator() { |
| 37 | - return give_get_option( 'thousands_separator', ',' ); |
|
| 37 | + return give_get_option('thousands_separator', ','); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return mixed |
| 46 | 46 | */ |
| 47 | 47 | function give_get_price_decimal_separator() { |
| 48 | - return give_get_option( 'decimal_separator', '.' ); |
|
| 48 | + return give_get_option('decimal_separator', '.'); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -62,67 +62,67 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return string $amount Newly sanitized amount |
| 64 | 64 | */ |
| 65 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
| 65 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
| 66 | 66 | |
| 67 | 67 | // Bailout. |
| 68 | - if ( empty( $number ) ) { |
|
| 68 | + if (empty($number)) { |
|
| 69 | 69 | return $number; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Remove slash from amount. |
| 73 | 73 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
| 74 | 74 | // To prevent notices and warning remove slash from amount/number. |
| 75 | - $number = wp_unslash( $number ); |
|
| 75 | + $number = wp_unslash($number); |
|
| 76 | 76 | |
| 77 | 77 | $thousand_separator = give_get_price_thousand_separator(); |
| 78 | 78 | |
| 79 | 79 | $locale = localeconv(); |
| 80 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
| 80 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
| 81 | 81 | |
| 82 | 82 | // Remove locale from string |
| 83 | - if ( ! is_float( $number ) ) { |
|
| 84 | - $number = str_replace( $decimals, '.', $number ); |
|
| 83 | + if ( ! is_float($number)) { |
|
| 84 | + $number = str_replace($decimals, '.', $number); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // Remove thousand amount formatting if amount has. |
| 88 | 88 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
| 89 | 89 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
| 90 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
| 91 | - $number = str_replace( $thousand_separator, '', $number ); |
|
| 92 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
| 93 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
| 90 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
| 91 | + $number = str_replace($thousand_separator, '', $number); |
|
| 92 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
| 93 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // Remove non numeric entity before decimal separator. |
| 97 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
| 97 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
| 98 | 98 | $default_dp = give_get_price_decimals(); |
| 99 | 99 | |
| 100 | 100 | // Reset negative amount to zero. |
| 101 | - if ( 0 > $number ) { |
|
| 102 | - $number = number_format( 0, $default_dp, '.' ); |
|
| 101 | + if (0 > $number) { |
|
| 102 | + $number = number_format(0, $default_dp, '.'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // If number does not have decimal then add number of decimals to it. |
| 106 | 106 | if ( |
| 107 | - false === strpos( $number, '.' ) |
|
| 108 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
| 107 | + false === strpos($number, '.') |
|
| 108 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
| 109 | 109 | ) { |
| 110 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
| 110 | + $number = number_format($number, $default_dp, '.', ''); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Format number by custom number of decimals. |
| 114 | - if ( false !== $dp ) { |
|
| 115 | - $dp = intval( empty( $dp ) ? $default_dp : $dp ); |
|
| 116 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
| 117 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
| 114 | + if (false !== $dp) { |
|
| 115 | + $dp = intval(empty($dp) ? $default_dp : $dp); |
|
| 116 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
| 117 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Trim zeros. |
| 121 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
| 122 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
| 121 | + if ($trim_zeros && strstr($number, '.')) { |
|
| 122 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
| 125 | + return apply_filters('give_sanitize_amount', $number); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,22 +135,22 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return string $amount Newly formatted amount or Price Not Available |
| 137 | 137 | */ |
| 138 | -function give_format_amount( $amount, $decimals = true ) { |
|
| 139 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
| 140 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
| 138 | +function give_format_amount($amount, $decimals = true) { |
|
| 139 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
| 140 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
| 141 | 141 | |
| 142 | - if ( empty( $amount ) ) { |
|
| 142 | + if (empty($amount)) { |
|
| 143 | 143 | $amount = 0; |
| 144 | 144 | } else { |
| 145 | 145 | // Sanitize amount before formatting. |
| 146 | - $amount = give_sanitize_amount( $amount ); |
|
| 146 | + $amount = give_sanitize_amount($amount); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $decimals = $decimals ? give_get_price_decimals() : 0; |
| 150 | 150 | |
| 151 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 151 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 152 | 152 | |
| 153 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 153 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -167,33 +167,33 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return float|string formatted amount number with large number names. |
| 169 | 169 | */ |
| 170 | -function give_human_format_large_amount( $amount ) { |
|
| 170 | +function give_human_format_large_amount($amount) { |
|
| 171 | 171 | |
| 172 | 172 | // Get thousand separator. |
| 173 | 173 | $thousands_sep = give_get_price_thousand_separator(); |
| 174 | 174 | |
| 175 | 175 | // Sanitize amount. |
| 176 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
| 176 | + $sanitize_amount = give_sanitize_amount($amount); |
|
| 177 | 177 | |
| 178 | 178 | // Explode amount to calculate name of large numbers. |
| 179 | - $amount_array = explode( $thousands_sep, $amount ); |
|
| 179 | + $amount_array = explode($thousands_sep, $amount); |
|
| 180 | 180 | |
| 181 | 181 | // Calculate amount parts count. |
| 182 | - $amount_count_parts = count( $amount_array ); |
|
| 182 | + $amount_count_parts = count($amount_array); |
|
| 183 | 183 | |
| 184 | 184 | // Human format amount (default). |
| 185 | 185 | $human_format_amount = $amount; |
| 186 | 186 | |
| 187 | 187 | // Calculate large number formatted amount. |
| 188 | - if ( 4 < $amount_count_parts ) { |
|
| 189 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
| 190 | - } elseif ( 3 < $amount_count_parts ) { |
|
| 191 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
| 192 | - } elseif ( 2 < $amount_count_parts ) { |
|
| 193 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
| 188 | + if (4 < $amount_count_parts) { |
|
| 189 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
| 190 | + } elseif (3 < $amount_count_parts) { |
|
| 191 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
| 192 | + } elseif (2 < $amount_count_parts) { |
|
| 193 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
| 196 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -206,15 +206,15 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return string $amount Newly formatted amount or Price Not Available |
| 208 | 208 | */ |
| 209 | -function give_format_decimal( $amount, $dp = false ) { |
|
| 209 | +function give_format_decimal($amount, $dp = false) { |
|
| 210 | 210 | $decimal_separator = give_get_price_decimal_separator(); |
| 211 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
| 211 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
| 212 | 212 | |
| 213 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
| 214 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
| 213 | + if (false !== strpos($formatted_amount, '.')) { |
|
| 214 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
| 217 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
@@ -228,13 +228,13 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @return bool |
| 230 | 230 | */ |
| 231 | -function give_format_admin_multilevel_amount( $field_args, $field ) { |
|
| 231 | +function give_format_admin_multilevel_amount($field_args, $field) { |
|
| 232 | 232 | |
| 233 | - if ( empty( $field->value ) ) { |
|
| 233 | + if (empty($field->value)) { |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $field->value = give_format_decimal( $field->value ); |
|
| 237 | + $field->value = give_format_decimal($field->value); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -247,24 +247,24 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return mixed|string|void |
| 249 | 249 | */ |
| 250 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
| 250 | +function give_currency_filter($price = '', $currency = '') { |
|
| 251 | 251 | |
| 252 | - if ( empty( $currency ) ) { |
|
| 252 | + if (empty($currency)) { |
|
| 253 | 253 | $currency = give_get_currency(); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $position = give_get_option( 'currency_position', 'before' ); |
|
| 256 | + $position = give_get_option('currency_position', 'before'); |
|
| 257 | 257 | |
| 258 | 258 | $negative = $price < 0; |
| 259 | 259 | |
| 260 | - if ( $negative ) { |
|
| 260 | + if ($negative) { |
|
| 261 | 261 | // Remove proceeding "-". |
| 262 | - $price = substr( $price, 1 ); |
|
| 262 | + $price = substr($price, 1); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - $symbol = give_currency_symbol( $currency ); |
|
| 265 | + $symbol = give_currency_symbol($currency); |
|
| 266 | 266 | |
| 267 | - switch ( $currency ): |
|
| 267 | + switch ($currency): |
|
| 268 | 268 | case 'GBP' : |
| 269 | 269 | case 'BRL' : |
| 270 | 270 | case 'EUR' : |
@@ -293,13 +293,13 @@ discard block |
||
| 293 | 293 | case 'MAD' : |
| 294 | 294 | case 'KRW' : |
| 295 | 295 | case 'ZAR' : |
| 296 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
| 296 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
| 297 | 297 | break; |
| 298 | 298 | case 'NOK' : |
| 299 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
| 299 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
| 300 | 300 | break; |
| 301 | 301 | default : |
| 302 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
| 302 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
| 303 | 303 | break; |
| 304 | 304 | endswitch; |
| 305 | 305 | |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | * filter name will be give_usd_currency_filter_after |
| 316 | 316 | * |
| 317 | 317 | */ |
| 318 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
| 318 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
| 319 | 319 | |
| 320 | - if ( $negative ) { |
|
| 320 | + if ($negative) { |
|
| 321 | 321 | // Prepend the minus sign before the currency sign. |
| 322 | - $formatted = '-' . $formatted; |
|
| 322 | + $formatted = '-'.$formatted; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | return $formatted; |
@@ -335,22 +335,22 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | function give_currency_decimal_filter() { |
| 337 | 337 | |
| 338 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 338 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 339 | 339 | |
| 340 | 340 | // Set default number of decimals. |
| 341 | 341 | $decimals = give_get_price_decimals(); |
| 342 | 342 | |
| 343 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 343 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 344 | 344 | |
| 345 | 345 | |
| 346 | 346 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
| 347 | - if ( 1 <= func_num_args() ) { |
|
| 348 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
| 347 | + if (1 <= func_num_args()) { |
|
| 348 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | $currency = give_get_currency(); |
| 352 | 352 | |
| 353 | - switch ( $currency ) { |
|
| 353 | + switch ($currency) { |
|
| 354 | 354 | case 'RIAL' : |
| 355 | 355 | case 'JPY' : |
| 356 | 356 | case 'TWD' : |
@@ -360,11 +360,11 @@ discard block |
||
| 360 | 360 | break; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
| 363 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 367 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
| 366 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
| 367 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
| 368 | 368 | |
| 369 | 369 | /** |
| 370 | 370 | * Sanitize thousand separator |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | * |
| 379 | 379 | * @return mixed |
| 380 | 380 | */ |
| 381 | -function give_sanitize_thousand_separator( $value, $field_args, $field ) { |
|
| 382 | - return stripslashes( $value ); |
|
| 381 | +function give_sanitize_thousand_separator($value, $field_args, $field) { |
|
| 382 | + return stripslashes($value); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | * |
| 396 | 396 | * @return mixed |
| 397 | 397 | */ |
| 398 | -function give_sanitize_number_decimals( $value, $field_args, $field ) { |
|
| 399 | - return absint( $value ); |
|
| 398 | +function give_sanitize_number_decimals($value, $field_args, $field) { |
|
| 399 | + return absint($value); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -411,8 +411,8 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @return mixed |
| 413 | 413 | */ |
| 414 | -function give_sanitize_price_field_value( $value, $field_args, $field ) { |
|
| 415 | - return give_sanitize_amount( $value ); |
|
| 414 | +function give_sanitize_price_field_value($value, $field_args, $field) { |
|
| 415 | + return give_sanitize_amount($value); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
@@ -426,29 +426,29 @@ discard block |
||
| 426 | 426 | * |
| 427 | 427 | * @return void |
| 428 | 428 | */ |
| 429 | -function give_cmb_amount_field_render_row_cb( $field_args, $field ) { |
|
| 429 | +function give_cmb_amount_field_render_row_cb($field_args, $field) { |
|
| 430 | 430 | |
| 431 | 431 | // Get args. |
| 432 | - $id = $field->args( 'id' ); |
|
| 433 | - $label = $field->args( 'name' ); |
|
| 434 | - $name = $field->args( '_name' ); |
|
| 435 | - $description = $field->args( 'description' ); |
|
| 436 | - $attributes = $field->args( 'attributes' ); |
|
| 432 | + $id = $field->args('id'); |
|
| 433 | + $label = $field->args('name'); |
|
| 434 | + $name = $field->args('_name'); |
|
| 435 | + $description = $field->args('description'); |
|
| 436 | + $attributes = $field->args('attributes'); |
|
| 437 | 437 | $attributes_string = ''; |
| 438 | 438 | $row_class = $field->row_classes(); |
| 439 | 439 | |
| 440 | 440 | // Get attributes. |
| 441 | - if ( ! empty( $attributes ) ) { |
|
| 442 | - foreach ( $attributes as $attribute_name => $attribute_val ) { |
|
| 441 | + if ( ! empty($attributes)) { |
|
| 442 | + foreach ($attributes as $attribute_name => $attribute_val) { |
|
| 443 | 443 | $attributes_string[] = "$attribute_name=\"$attribute_val\""; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $attributes_string = implode( ' ', $attributes_string ); |
|
| 446 | + $attributes_string = implode(' ', $attributes_string); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // Get row class. |
| 450 | - if ( ! empty( $row_class ) && is_array( $row_class ) ) { |
|
| 451 | - $row_class = implode( ' ', $row_class ); |
|
| 450 | + if ( ! empty($row_class) && is_array($row_class)) { |
|
| 451 | + $row_class = implode(' ', $row_class); |
|
| 452 | 452 | } |
| 453 | 453 | ?> |
| 454 | 454 | <div class="cmb-row <?php echo $row_class; ?>"> |
@@ -456,9 +456,9 @@ discard block |
||
| 456 | 456 | <label for="<?php echo $id; ?>"><?php echo $label; ?></label> |
| 457 | 457 | </div> |
| 458 | 458 | <div class="cmb-td"> |
| 459 | - <?php echo( give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); ?> |
|
| 459 | + <?php echo(give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : ''); ?> |
|
| 460 | 460 | <input id="<?php echo $id; ?>" type="text" name="<?php echo $name; ?>" <?php echo $attributes_string ?>/> |
| 461 | - <?php echo( give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); ?> |
|
| 461 | + <?php echo(give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : ''); ?> |
|
| 462 | 462 | |
| 463 | 463 | <span class="cmb2-metabox-description"><?php echo $description; ?></span> |
| 464 | 464 | </div> |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * |
| 478 | 478 | * @return string Date format string |
| 479 | 479 | */ |
| 480 | -function give_date_format ( $date_context = '' ) { |
|
| 480 | +function give_date_format($date_context = '') { |
|
| 481 | 481 | /** |
| 482 | 482 | * Filter the date context |
| 483 | 483 | * |
@@ -498,18 +498,18 @@ discard block |
||
| 498 | 498 | * |
| 499 | 499 | * } |
| 500 | 500 | */ |
| 501 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
| 501 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
| 502 | 502 | |
| 503 | 503 | // Set date format to default date format. |
| 504 | 504 | $date_format = get_option('date_format'); |
| 505 | 505 | |
| 506 | 506 | |
| 507 | 507 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
| 508 | - if( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
| 509 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
| 510 | - ? $date_format_contexts[ $date_context ] |
|
| 508 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
| 509 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
| 510 | + ? $date_format_contexts[$date_context] |
|
| 511 | 511 | : $date_format; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - return apply_filters( 'give_date_format', $date_format ); |
|
| 514 | + return apply_filters('give_date_format', $date_format); |
|
| 515 | 515 | } |
| 516 | 516 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool|object List of all user donations |
| 32 | 32 | */ |
| 33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
| 33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
| 34 | 34 | |
| 35 | - if ( empty( $user ) ) { |
|
| 35 | + if (empty($user)) { |
|
| 36 | 36 | $user = get_current_user_id(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
| 39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
| 44 | 44 | |
| 45 | - if ( $pagination ) { |
|
| 46 | - if ( get_query_var( 'paged' ) ) { |
|
| 47 | - $paged = get_query_var( 'paged' ); |
|
| 48 | - } else if ( get_query_var( 'page' ) ) { |
|
| 49 | - $paged = get_query_var( 'page' ); |
|
| 45 | + if ($pagination) { |
|
| 46 | + if (get_query_var('paged')) { |
|
| 47 | + $paged = get_query_var('paged'); |
|
| 48 | + } else if (get_query_var('page')) { |
|
| 49 | + $paged = get_query_var('page'); |
|
| 50 | 50 | } else { |
| 51 | 51 | $paged = 1; |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $args = apply_filters( 'give_get_users_purchases_args', array( |
|
| 55 | + $args = apply_filters('give_get_users_purchases_args', array( |
|
| 56 | 56 | 'user' => $user, |
| 57 | 57 | 'number' => $number, |
| 58 | 58 | 'status' => $status, |
| 59 | 59 | 'orderby' => 'date' |
| 60 | - ) ); |
|
| 60 | + )); |
|
| 61 | 61 | |
| 62 | - if ( $pagination ) { |
|
| 62 | + if ($pagination) { |
|
| 63 | 63 | |
| 64 | 64 | $args['page'] = $paged; |
| 65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
| 72 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 73 | + $customer = new Give_Customer($user, $by_user_id); |
|
| 74 | 74 | |
| 75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
| 75 | + if ( ! empty($customer->payment_ids)) { |
|
| 76 | 76 | |
| 77 | - unset( $args['user'] ); |
|
| 78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
| 77 | + unset($args['user']); |
|
| 78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
| 82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
| 83 | 83 | |
| 84 | 84 | // No donations |
| 85 | - if ( ! $purchases ) { |
|
| 85 | + if ( ! $purchases) { |
|
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return bool|object List of unique forms donated by user |
| 103 | 103 | */ |
| 104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
| 105 | - if ( empty( $user ) ) { |
|
| 104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
| 105 | + if (empty($user)) { |
|
| 106 | 106 | $user = get_current_user_id(); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ( empty( $user ) ) { |
|
| 109 | + if (empty($user)) { |
|
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
| 113 | + $by_user_id = is_numeric($user) ? true : false; |
|
| 114 | 114 | |
| 115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
| 115 | + $customer = new Give_Customer($user, $by_user_id); |
|
| 116 | 116 | |
| 117 | - if ( empty( $customer->payment_ids ) ) { |
|
| 117 | + if (empty($customer->payment_ids)) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // Get all the items donated |
| 122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
| 123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
| 124 | - if ( ! empty( $limit_payments ) ) { |
|
| 125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
| 122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
| 123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
| 124 | + if ( ! empty($limit_payments)) { |
|
| 125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
| 126 | 126 | } |
| 127 | 127 | $donation_data = array(); |
| 128 | - foreach ( $payment_ids as $payment_id ) { |
|
| 129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
| 128 | + foreach ($payment_ids as $payment_id) { |
|
| 129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( empty( $donation_data ) ) { |
|
| 132 | + if (empty($donation_data)) { |
|
| 133 | 133 | return false; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
| 137 | 137 | $completed_donations_ids = array(); |
| 138 | - foreach ( $donation_data as $purchase_meta ) { |
|
| 138 | + foreach ($donation_data as $purchase_meta) { |
|
| 139 | 139 | $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ( empty( $completed_donations_ids ) ) { |
|
| 142 | + if (empty($completed_donations_ids)) { |
|
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Only include each donation once |
| 147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
| 147 | + $form_ids = array_unique($completed_donations_ids); |
|
| 148 | 148 | |
| 149 | 149 | // Make sure we still have some products and a first item |
| 150 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
| 150 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
| 151 | 151 | return false; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $post_type = get_post_type( $form_ids[0] ); |
|
| 154 | + $post_type = get_post_type($form_ids[0]); |
|
| 155 | 155 | |
| 156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
| 156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
| 157 | 157 | 'include' => $form_ids, |
| 158 | 158 | 'post_type' => $post_type, |
| 159 | - 'posts_per_page' => - 1 |
|
| 160 | - ) ); |
|
| 159 | + 'posts_per_page' => -1 |
|
| 160 | + )); |
|
| 161 | 161 | |
| 162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
| 162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return bool - true if has donated, false other wise. |
| 177 | 177 | */ |
| 178 | -function give_has_purchases( $user_id = null ) { |
|
| 179 | - if ( empty( $user_id ) ) { |
|
| 178 | +function give_has_purchases($user_id = null) { |
|
| 179 | + if (empty($user_id)) { |
|
| 180 | 180 | $user_id = get_current_user_id(); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
| 183 | + if (give_get_users_purchases($user_id, 1)) { |
|
| 184 | 184 | return true; // User has at least one donation |
| 185 | 185 | } |
| 186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return array |
| 202 | 202 | */ |
| 203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
| 203 | +function give_get_purchase_stats_by_user($user = '') { |
|
| 204 | 204 | |
| 205 | - if ( is_email( $user ) ) { |
|
| 205 | + if (is_email($user)) { |
|
| 206 | 206 | |
| 207 | 207 | $field = 'email'; |
| 208 | 208 | |
| 209 | - } elseif ( is_numeric( $user ) ) { |
|
| 209 | + } elseif (is_numeric($user)) { |
|
| 210 | 210 | |
| 211 | 211 | $field = 'user_id'; |
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | $stats = array(); |
| 216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
| 216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
| 217 | 217 | |
| 218 | - if ( $customer ) { |
|
| 218 | + if ($customer) { |
|
| 219 | 219 | |
| 220 | - $customer = new Give_Customer( $customer->id ); |
|
| 220 | + $customer = new Give_Customer($customer->id); |
|
| 221 | 221 | |
| 222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
| 223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
| 222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
| 223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
| 224 | 224 | |
| 225 | 225 | } |
| 226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @since 1.7 |
| 231 | 231 | */ |
| 232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
| 232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
| 233 | 233 | |
| 234 | 234 | return $stats; |
| 235 | 235 | } |
@@ -247,22 +247,22 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return int - the total number of donations |
| 249 | 249 | */ |
| 250 | -function give_count_purchases_of_customer( $user = null ) { |
|
| 250 | +function give_count_purchases_of_customer($user = null) { |
|
| 251 | 251 | |
| 252 | 252 | //Logged in? |
| 253 | - if ( empty( $user ) ) { |
|
| 253 | + if (empty($user)) { |
|
| 254 | 254 | $user = get_current_user_id(); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | //Email access? |
| 258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
| 258 | + if (empty($user) && Give()->email_access->token_email) { |
|
| 259 | 259 | $user = Give()->email_access->token_email; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | |
| 263 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
| 263 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
| 264 | 264 | |
| 265 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
| 265 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return float - the total amount the user has spent |
| 277 | 277 | */ |
| 278 | -function give_purchase_total_of_user( $user = null ) { |
|
| 278 | +function give_purchase_total_of_user($user = null) { |
|
| 279 | 279 | |
| 280 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
| 280 | + $stats = give_get_purchase_stats_by_user($user); |
|
| 281 | 281 | |
| 282 | 282 | return $stats['total_spent']; |
| 283 | 283 | } |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return bool |
| 295 | 295 | */ |
| 296 | -function give_validate_username( $username ) { |
|
| 297 | - $sanitized = sanitize_user( $username, false ); |
|
| 298 | - $valid = ( $sanitized == $username ); |
|
| 296 | +function give_validate_username($username) { |
|
| 297 | + $sanitized = sanitize_user($username, false); |
|
| 298 | + $valid = ($sanitized == $username); |
|
| 299 | 299 | |
| 300 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
| 300 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
@@ -314,32 +314,32 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return void |
| 316 | 316 | */ |
| 317 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
| 317 | +function give_add_past_purchases_to_new_user($user_id) { |
|
| 318 | 318 | |
| 319 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
| 319 | + $email = get_the_author_meta('user_email', $user_id); |
|
| 320 | 320 | |
| 321 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
| 321 | + $payments = give_get_payments(array('s' => $email)); |
|
| 322 | 322 | |
| 323 | - if ( $payments ) { |
|
| 324 | - foreach ( $payments as $payment ) { |
|
| 325 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
| 323 | + if ($payments) { |
|
| 324 | + foreach ($payments as $payment) { |
|
| 325 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
| 326 | 326 | continue; |
| 327 | 327 | } // This payment already associated with an account |
| 328 | 328 | |
| 329 | - $meta = give_get_payment_meta( $payment->ID ); |
|
| 330 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
| 329 | + $meta = give_get_payment_meta($payment->ID); |
|
| 330 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
| 331 | 331 | $meta['user_info']['id'] = $user_id; |
| 332 | 332 | $meta['user_info'] = $meta['user_info']; |
| 333 | 333 | |
| 334 | 334 | // Store the updated user ID in the payment meta |
| 335 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
| 336 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
| 335 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
| 336 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
| 342 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
| 343 | 343 | |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -361,34 +361,34 @@ discard block |
||
| 361 | 361 | * @since 1.0 |
| 362 | 362 | * @return array - The donor's address, if any |
| 363 | 363 | */ |
| 364 | -function give_get_donor_address( $user_id = 0 ) { |
|
| 365 | - if ( empty( $user_id ) ) { |
|
| 364 | +function give_get_donor_address($user_id = 0) { |
|
| 365 | + if (empty($user_id)) { |
|
| 366 | 366 | $user_id = get_current_user_id(); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
| 369 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
| 370 | 370 | |
| 371 | - if ( ! isset( $address['line1'] ) ) { |
|
| 371 | + if ( ! isset($address['line1'])) { |
|
| 372 | 372 | $address['line1'] = ''; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if ( ! isset( $address['line2'] ) ) { |
|
| 375 | + if ( ! isset($address['line2'])) { |
|
| 376 | 376 | $address['line2'] = ''; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if ( ! isset( $address['city'] ) ) { |
|
| 379 | + if ( ! isset($address['city'])) { |
|
| 380 | 380 | $address['city'] = ''; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ( ! isset( $address['zip'] ) ) { |
|
| 383 | + if ( ! isset($address['zip'])) { |
|
| 384 | 384 | $address['zip'] = ''; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - if ( ! isset( $address['country'] ) ) { |
|
| 387 | + if ( ! isset($address['country'])) { |
|
| 388 | 388 | $address['country'] = ''; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - if ( ! isset( $address['state'] ) ) { |
|
| 391 | + if ( ! isset($address['state'])) { |
|
| 392 | 392 | $address['state'] = ''; |
| 393 | 393 | } |
| 394 | 394 | |
@@ -408,42 +408,42 @@ discard block |
||
| 408 | 408 | * |
| 409 | 409 | * @return void |
| 410 | 410 | */ |
| 411 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
| 411 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
| 412 | 412 | |
| 413 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
| 413 | + if (empty($user_id) || empty($user_data)) { |
|
| 414 | 414 | return; |
| 415 | 415 | } |
| 416 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
| 416 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
| 417 | 417 | |
| 418 | 418 | /* translators: %s: site name */ |
| 419 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
| 419 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
| 420 | 420 | /* translators: %s: user login */ |
| 421 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
| 421 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
| 422 | 422 | /* translators: %s: user email */ |
| 423 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
| 423 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
| 424 | 424 | |
| 425 | 425 | @wp_mail( |
| 426 | - get_option( 'admin_email' ), |
|
| 426 | + get_option('admin_email'), |
|
| 427 | 427 | sprintf( |
| 428 | 428 | /* translators: %s: site name */ |
| 429 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
| 429 | + esc_attr__('[%s] New User Registration', 'give'), |
|
| 430 | 430 | $blogname |
| 431 | 431 | ), |
| 432 | 432 | $message |
| 433 | 433 | ); |
| 434 | 434 | |
| 435 | 435 | /* translators: %s: user login */ |
| 436 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
| 436 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
| 437 | 437 | /* translators: %s: paswword */ |
| 438 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
| 438 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
| 439 | 439 | |
| 440 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
| 440 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
| 441 | 441 | |
| 442 | 442 | wp_mail( |
| 443 | 443 | $user_data['user_email'], |
| 444 | 444 | sprintf( |
| 445 | 445 | /* translators: %s: site name */ |
| 446 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
| 446 | + esc_attr__('[%s] Your username and password', 'give'), |
|
| 447 | 447 | $blogname |
| 448 | 448 | ), |
| 449 | 449 | $message |
@@ -451,4 +451,4 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
| 454 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
@@ -689,7 +689,7 @@ |
||
| 689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
| 690 | 690 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
| 691 | 691 | ); |
| 692 | - }else{ |
|
| 692 | + } else{ |
|
| 693 | 693 | $messages[$subscription['id']] = sprintf( |
| 694 | 694 | __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
| 695 | 695 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @access private |
| 220 | 220 | * @since 1.0 |
| 221 | 221 | * |
| 222 | - * @return bool |
|
| 222 | + * @return false|null |
|
| 223 | 223 | */ |
| 224 | 224 | public function auto_updater() { |
| 225 | 225 | |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | * @access public |
| 476 | 476 | * @since 1.7 |
| 477 | 477 | * |
| 478 | - * @return bool|void |
|
| 478 | + * @return false|null |
|
| 479 | 479 | */ |
| 480 | 480 | public function weekly_license_check() { |
| 481 | 481 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | * @access public |
| 528 | 528 | * @since 1.7 |
| 529 | 529 | * |
| 530 | - * @return bool|void |
|
| 530 | + * @return false|null |
|
| 531 | 531 | */ |
| 532 | 532 | public function weekly_subscription_check() { |
| 533 | 533 | |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | * @access private |
| 608 | 608 | * @since 1.7 |
| 609 | 609 | * |
| 610 | - * @return bool|void |
|
| 610 | + * @return false|null |
|
| 611 | 611 | */ |
| 612 | 612 | private function __single_subscription_check() { |
| 613 | 613 | // Do not fire if license key is not set. |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | * @access private |
| 803 | 803 | * @since 1.7 |
| 804 | 804 | * |
| 805 | - * @return void|bool |
|
| 805 | + * @return false|null |
|
| 806 | 806 | */ |
| 807 | 807 | private function __remove_license_key_from_subscriptions(){ |
| 808 | 808 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -10,11 +10,11 @@ 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 | |
| 17 | -if ( ! class_exists( 'Give_License' ) ) : |
|
| 17 | +if ( ! class_exists('Give_License')) : |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Give_License Class |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @var string |
| 105 | 105 | */ |
| 106 | - private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
| 106 | + private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Account URL |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @var null|string |
| 115 | 115 | */ |
| 116 | - private $account_url = 'https://givewp.com/my-account/'; |
|
| 116 | + private $account_url = 'https://givewp.com/my-account/'; |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * Ccheckout URL |
@@ -142,19 +142,19 @@ discard block |
||
| 142 | 142 | * @param string $_checkout_url |
| 143 | 143 | * @param string $_account_url |
| 144 | 144 | */ |
| 145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
| 145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
| 146 | 146 | $give_options = give_get_settings(); |
| 147 | 147 | |
| 148 | 148 | $this->file = $_file; |
| 149 | 149 | $this->item_name = $_item_name; |
| 150 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
| 150 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
| 151 | 151 | $this->version = $_version; |
| 152 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
| 153 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
| 152 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
| 153 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
| 154 | 154 | $this->author = $_author; |
| 155 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
| 156 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
| 157 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
| 155 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
| 156 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
| 157 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
| 158 | 158 | |
| 159 | 159 | // Setup hooks |
| 160 | 160 | $this->includes(); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return void |
| 174 | 174 | */ |
| 175 | 175 | private function includes() { |
| 176 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 176 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
| 177 | 177 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -191,26 +191,26 @@ discard block |
||
| 191 | 191 | private function hooks() { |
| 192 | 192 | |
| 193 | 193 | // Register settings |
| 194 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
| 194 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
| 195 | 195 | |
| 196 | 196 | // Activate license key on settings save |
| 197 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
| 197 | + add_action('admin_init', array($this, 'activate_license')); |
|
| 198 | 198 | |
| 199 | 199 | // Deactivate license key |
| 200 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
| 200 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
| 201 | 201 | |
| 202 | 202 | // Updater |
| 203 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
| 203 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
| 204 | 204 | |
| 205 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
| 205 | + add_action('admin_notices', array($this, 'notices')); |
|
| 206 | 206 | |
| 207 | 207 | // Check license weekly. |
| 208 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
| 209 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
| 208 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
| 209 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
| 210 | 210 | |
| 211 | 211 | // Check subscription weekly. |
| 212 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
| 213 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
| 212 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
| 213 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function auto_updater() { |
| 225 | 225 | |
| 226 | - if ( ! $this->is_valid_license() ) { |
|
| 226 | + if ( ! $this->is_valid_license()) { |
|
| 227 | 227 | return false; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -252,16 +252,16 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return array License settings. |
| 254 | 254 | */ |
| 255 | - public function settings( $settings ) { |
|
| 255 | + public function settings($settings) { |
|
| 256 | 256 | |
| 257 | 257 | $give_license_settings = array( |
| 258 | 258 | array( |
| 259 | 259 | 'name' => $this->item_name, |
| 260 | - 'id' => $this->item_shortname . '_license_key', |
|
| 260 | + 'id' => $this->item_shortname.'_license_key', |
|
| 261 | 261 | 'desc' => '', |
| 262 | 262 | 'type' => 'license_key', |
| 263 | 263 | 'options' => array( |
| 264 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
| 264 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
| 265 | 265 | 'shortname' => $this->item_shortname, |
| 266 | 266 | 'item_name' => $this->item_name, |
| 267 | 267 | 'api_url' => $this->api_url, |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | ) |
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | - return array_merge( $settings, $give_license_settings ); |
|
| 275 | + return array_merge($settings, $give_license_settings); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -287,18 +287,18 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @return array License settings content. |
| 289 | 289 | */ |
| 290 | - public function license_settings_content( $settings ) { |
|
| 290 | + public function license_settings_content($settings) { |
|
| 291 | 291 | |
| 292 | 292 | $give_license_settings = array( |
| 293 | 293 | array( |
| 294 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
| 294 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
| 295 | 295 | 'desc' => '<hr>', |
| 296 | 296 | 'type' => 'give_title', |
| 297 | 297 | 'id' => 'give_title' |
| 298 | 298 | ), |
| 299 | 299 | ); |
| 300 | 300 | |
| 301 | - return array_merge( $settings, $give_license_settings ); |
|
| 301 | + return array_merge($settings, $give_license_settings); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -313,37 +313,37 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | public function activate_license() { |
| 315 | 315 | // Bailout: Check if license key set of not. |
| 316 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 316 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 317 | 317 | return; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Security check. |
| 321 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
| 321 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
| 322 | 322 | |
| 323 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 323 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 324 | 324 | |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | // Check if user have correct permissions. |
| 328 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 328 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Allow third party addon developers to handle license activation. |
| 333 | - if( $this->__is_third_party_addon() ){ |
|
| 334 | - do_action( 'give_activate_license', $this ); |
|
| 333 | + if ($this->__is_third_party_addon()) { |
|
| 334 | + do_action('give_activate_license', $this); |
|
| 335 | 335 | return; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // Delete previous license setting if a empty license key submitted. |
| 339 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 340 | - delete_option( $this->item_shortname . '_license_active' ); |
|
| 339 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
| 340 | + delete_option($this->item_shortname.'_license_active'); |
|
| 341 | 341 | return; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
| 345 | - foreach ( $_POST as $key => $value ) { |
|
| 346 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
| 345 | + foreach ($_POST as $key => $value) { |
|
| 346 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
| 347 | 347 | // Don't activate a key when deactivating a different key |
| 348 | 348 | return; |
| 349 | 349 | } |
@@ -351,15 +351,15 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | |
| 353 | 353 | // Check if plugin previously installed. |
| 354 | - if ( $this->is_valid_license() ) { |
|
| 354 | + if ($this->is_valid_license()) { |
|
| 355 | 355 | return; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | // Get license key. |
| 359 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
| 359 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
| 360 | 360 | |
| 361 | 361 | // Bailout. |
| 362 | - if( empty( $license ) ) { |
|
| 362 | + if (empty($license)) { |
|
| 363 | 363 | return; |
| 364 | 364 | } |
| 365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | $api_params = array( |
| 371 | 371 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
| 372 | 372 | 'license' => $license, |
| 373 | - 'item_name' => urlencode( $this->item_name ), |
|
| 373 | + 'item_name' => urlencode($this->item_name), |
|
| 374 | 374 | 'url' => home_url() |
| 375 | 375 | ); |
| 376 | 376 | |
@@ -385,16 +385,16 @@ discard block |
||
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | 387 | // Make sure there are no errors |
| 388 | - if ( is_wp_error( $response ) ) { |
|
| 388 | + if (is_wp_error($response)) { |
|
| 389 | 389 | return; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | // Tell WordPress to look for updates |
| 393 | - set_site_transient( 'update_plugins', null ); |
|
| 393 | + set_site_transient('update_plugins', null); |
|
| 394 | 394 | |
| 395 | 395 | // Decode license data |
| 396 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 397 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
| 396 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 397 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
| 398 | 398 | |
| 399 | 399 | // Check subscription for license key and store this to db (if any). |
| 400 | 400 | $this->__single_subscription_check(); |
@@ -412,34 +412,34 @@ discard block |
||
| 412 | 412 | */ |
| 413 | 413 | public function deactivate_license() { |
| 414 | 414 | |
| 415 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 415 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
| 419 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
| 420 | 420 | |
| 421 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 421 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 422 | 422 | |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 425 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 426 | 426 | return; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | // Allow third party addon developers to handle license deactivation. |
| 430 | - if( $this->__is_third_party_addon() ){ |
|
| 431 | - do_action( 'give_deactivate_license', $this ); |
|
| 430 | + if ($this->__is_third_party_addon()) { |
|
| 431 | + do_action('give_deactivate_license', $this); |
|
| 432 | 432 | return; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Run on deactivate button press |
| 436 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
| 436 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
| 437 | 437 | |
| 438 | 438 | // Data to send to the API |
| 439 | 439 | $api_params = array( |
| 440 | 440 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
| 441 | 441 | 'license' => $this->license, |
| 442 | - 'item_name' => urlencode( $this->item_name ), |
|
| 442 | + 'item_name' => urlencode($this->item_name), |
|
| 443 | 443 | 'url' => home_url() |
| 444 | 444 | ); |
| 445 | 445 | |
@@ -454,15 +454,15 @@ discard block |
||
| 454 | 454 | ); |
| 455 | 455 | |
| 456 | 456 | // Make sure there are no errors |
| 457 | - if ( is_wp_error( $response ) ) { |
|
| 457 | + if (is_wp_error($response)) { |
|
| 458 | 458 | return; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // Decode the license data |
| 462 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 462 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 463 | 463 | |
| 464 | 464 | // Remove license data. |
| 465 | - delete_option( $this->item_shortname . '_license_active' ); |
|
| 465 | + delete_option($this->item_shortname.'_license_active'); |
|
| 466 | 466 | |
| 467 | 467 | // Remove license key from subscriptions if exist. |
| 468 | 468 | $this->__remove_license_key_from_subscriptions(); |
@@ -479,18 +479,18 @@ discard block |
||
| 479 | 479 | */ |
| 480 | 480 | public function weekly_license_check() { |
| 481 | 481 | |
| 482 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
| 482 | + if ( ! empty($_POST['give_settings'])) { |
|
| 483 | 483 | // Don't fire when saving settings |
| 484 | 484 | return false; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if( empty( $this->license ) ) { |
|
| 487 | + if (empty($this->license)) { |
|
| 488 | 488 | return false; |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | // Allow third party addon developers to handle their license check. |
| 492 | - if( $this->__is_third_party_addon() ){ |
|
| 493 | - do_action( 'give_weekly_license_check', $this ); |
|
| 492 | + if ($this->__is_third_party_addon()) { |
|
| 493 | + do_action('give_weekly_license_check', $this); |
|
| 494 | 494 | return false; |
| 495 | 495 | } |
| 496 | 496 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | $api_params = array( |
| 499 | 499 | 'edd_action'=> 'check_license', |
| 500 | 500 | 'license' => $this->license, |
| 501 | - 'item_name' => urlencode( $this->item_name ), |
|
| 501 | + 'item_name' => urlencode($this->item_name), |
|
| 502 | 502 | 'url' => home_url() |
| 503 | 503 | ); |
| 504 | 504 | |
@@ -513,12 +513,12 @@ discard block |
||
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | 515 | // Make sure the response came back okay. |
| 516 | - if ( is_wp_error( $response ) ) { |
|
| 516 | + if (is_wp_error($response)) { |
|
| 517 | 517 | return false; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 521 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
| 520 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 521 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -531,24 +531,24 @@ discard block |
||
| 531 | 531 | */ |
| 532 | 532 | public function weekly_subscription_check() { |
| 533 | 533 | |
| 534 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
| 534 | + if ( ! empty($_POST['give_settings'])) { |
|
| 535 | 535 | // Don't fire when saving settings |
| 536 | 536 | return false; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | // Remove old subscription data. |
| 540 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
| 541 | - delete_option( 'give_subscriptions' ); |
|
| 542 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
| 540 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
| 541 | + delete_option('give_subscriptions'); |
|
| 542 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - if( empty( $this->license ) ) { |
|
| 545 | + if (empty($this->license)) { |
|
| 546 | 546 | return false; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | // Allow third party addon developers to handle there subscription check. |
| 550 | - if( $this->__is_third_party_addon() ){ |
|
| 551 | - do_action( 'give_weekly_subscription_check', $this ); |
|
| 550 | + if ($this->__is_third_party_addon()) { |
|
| 551 | + do_action('give_weekly_subscription_check', $this); |
|
| 552 | 552 | return false; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | // This is custom feature to check subscriptions. |
| 563 | 563 | 'edd_action'=> 'check_subscription', |
| 564 | 564 | 'license' => $this->license, |
| 565 | - 'item_name' => urlencode( $this->item_name ), |
|
| 565 | + 'item_name' => urlencode($this->item_name), |
|
| 566 | 566 | 'url' => home_url() |
| 567 | 567 | ); |
| 568 | 568 | |
@@ -577,27 +577,27 @@ discard block |
||
| 577 | 577 | ); |
| 578 | 578 | |
| 579 | 579 | // Make sure the response came back okay. |
| 580 | - if ( is_wp_error( $response ) ) { |
|
| 580 | + if (is_wp_error($response)) { |
|
| 581 | 581 | return false; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 584 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
| 585 | 585 | |
| 586 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
| 587 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
| 586 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
| 587 | + $subscriptions = get_option('give_subscriptions', array()); |
|
| 588 | 588 | |
| 589 | 589 | // Update subscription data only if subscription does not exist already. |
| 590 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
| 591 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
| 592 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
| 590 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
| 591 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
| 592 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // Store licenses for subscription. |
| 596 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
| 597 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
| 596 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
| 597 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - update_option( 'give_subscriptions', $subscriptions ); |
|
| 600 | + update_option('give_subscriptions', $subscriptions); |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | |
@@ -611,11 +611,11 @@ discard block |
||
| 611 | 611 | */ |
| 612 | 612 | private function __single_subscription_check() { |
| 613 | 613 | // Do not fire if license key is not set. |
| 614 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
| 614 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
| 615 | 615 | return false; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - if( empty( $this->license ) ) { |
|
| 618 | + if (empty($this->license)) { |
|
| 619 | 619 | return false; |
| 620 | 620 | } |
| 621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | // This is custom feature to check subscriptions. |
| 627 | 627 | 'edd_action'=> 'check_subscription', |
| 628 | 628 | 'license' => $this->license, |
| 629 | - 'item_name' => urlencode( $this->item_name ), |
|
| 629 | + 'item_name' => urlencode($this->item_name), |
|
| 630 | 630 | 'url' => home_url() |
| 631 | 631 | ); |
| 632 | 632 | |
@@ -641,27 +641,27 @@ discard block |
||
| 641 | 641 | ); |
| 642 | 642 | |
| 643 | 643 | // Make sure the response came back okay. |
| 644 | - if ( is_wp_error( $response ) ) { |
|
| 644 | + if (is_wp_error($response)) { |
|
| 645 | 645 | return false; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 648 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
| 649 | 649 | |
| 650 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
| 651 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
| 650 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
| 651 | + $subscriptions = get_option('give_subscriptions', array()); |
|
| 652 | 652 | |
| 653 | 653 | // Update subscription data only if subscription does not exist already. |
| 654 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
| 655 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
| 656 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
| 654 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
| 655 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
| 656 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | // Store licenses for subscription. |
| 660 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
| 661 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
| 660 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
| 661 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - update_option( 'give_subscriptions', $subscriptions ); |
|
| 664 | + update_option('give_subscriptions', $subscriptions); |
|
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | |
@@ -679,87 +679,87 @@ discard block |
||
| 679 | 679 | static $addon_license_key_in_subscriptions; |
| 680 | 680 | |
| 681 | 681 | // Set default value. |
| 682 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
| 682 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
| 683 | 683 | |
| 684 | - if( empty( $this->license ) ) { |
|
| 684 | + if (empty($this->license)) { |
|
| 685 | 685 | return; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - if( ! current_user_can( 'manage_shop_settings' ) ) { |
|
| 688 | + if ( ! current_user_can('manage_shop_settings')) { |
|
| 689 | 689 | return; |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | // Do not show licenses notices on license tab. |
| 693 | - if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) { |
|
| 693 | + if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) { |
|
| 694 | 694 | return; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | $messages = array(); |
| 698 | 698 | |
| 699 | 699 | // Get subscriptions. |
| 700 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
| 700 | + $subscriptions = get_option('give_subscriptions'); |
|
| 701 | 701 | |
| 702 | 702 | // Show subscription messages. |
| 703 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
| 703 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
| 704 | 704 | |
| 705 | - foreach ( $subscriptions as $subscription ) { |
|
| 705 | + foreach ($subscriptions as $subscription) { |
|
| 706 | 706 | // Subscription expires timestamp. |
| 707 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
| 707 | + $subscription_expires = strtotime($subscription['expires']); |
|
| 708 | 708 | |
| 709 | 709 | // Start showing subscriptions message before one week of renewal date. |
| 710 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
| 710 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
| 711 | 711 | continue; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | // Check if subscription message already exist in messages. |
| 715 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
| 715 | + if (array_key_exists($subscription['id'], $messages)) { |
|
| 716 | 716 | continue; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
| 719 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
| 720 | 720 | |
| 721 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
| 721 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
| 722 | 722 | $messages[$subscription['id']] = sprintf( |
| 723 | - __( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
| 724 | - urldecode( $subscription['invoice_url'] ), |
|
| 723 | + __('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
| 724 | + urldecode($subscription['invoice_url']), |
|
| 725 | 725 | $subscription['payment_id'], |
| 726 | 726 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
| 727 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
| 727 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
| 728 | 728 | ); |
| 729 | - }else{ |
|
| 729 | + } else { |
|
| 730 | 730 | $messages[$subscription['id']] = sprintf( |
| 731 | - __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
| 732 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
| 733 | - urldecode( $subscription['invoice_url'] ), |
|
| 731 | + __('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
| 732 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
| 733 | + urldecode($subscription['invoice_url']), |
|
| 734 | 734 | $subscription['payment_id'], |
| 735 | 735 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
| 736 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
| 736 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
| 737 | 737 | ); |
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | // Stop validation for these licencse keys. |
| 742 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
| 742 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
| 743 | 743 | } |
| 744 | 744 | $showed_subscriptions_message = true; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | // Show non subscription addon messages. |
| 748 | - if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) { |
|
| 748 | + if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) { |
|
| 749 | 749 | |
| 750 | 750 | $messages['general'] = sprintf( |
| 751 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
| 752 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
| 751 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
| 752 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
| 753 | 753 | ); |
| 754 | 754 | $showed_invalid_message = true; |
| 755 | 755 | |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // Print messages. |
| 759 | - if( ! empty( $messages ) ) { |
|
| 760 | - foreach( $messages as $notice_id => $message ) { |
|
| 761 | - echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">'; |
|
| 762 | - echo '<p>' . $message . '</p>'; |
|
| 759 | + if ( ! empty($messages)) { |
|
| 760 | + foreach ($messages as $notice_id => $message) { |
|
| 761 | + echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">'; |
|
| 762 | + echo '<p>'.$message.'</p>'; |
|
| 763 | 763 | echo '</div>'; |
| 764 | 764 | } |
| 765 | 765 | } |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * @return bool |
| 775 | 775 | */ |
| 776 | 776 | public function is_valid_license() { |
| 777 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
| 777 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
| 778 | 778 | return true; |
| 779 | 779 | } |
| 780 | 780 | |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @return bool |
| 791 | 791 | */ |
| 792 | 792 | private function __is_third_party_addon() { |
| 793 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
| 793 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /** |
@@ -804,26 +804,26 @@ discard block |
||
| 804 | 804 | * |
| 805 | 805 | * @return void|bool |
| 806 | 806 | */ |
| 807 | - private function __remove_license_key_from_subscriptions(){ |
|
| 808 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
| 807 | + private function __remove_license_key_from_subscriptions() { |
|
| 808 | + $subscriptions = get_option('give_subscriptions', array()); |
|
| 809 | 809 | |
| 810 | 810 | // Bailout. |
| 811 | - if( empty( $this->license ) ) { |
|
| 811 | + if (empty($this->license)) { |
|
| 812 | 812 | return false; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - if( ! empty( $subscriptions ) ) { |
|
| 816 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
| 817 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
| 818 | - if( false !== $license_index ) { |
|
| 815 | + if ( ! empty($subscriptions)) { |
|
| 816 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
| 817 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
| 818 | + if (false !== $license_index) { |
|
| 819 | 819 | // Remove license key. |
| 820 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
| 820 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
| 821 | 821 | |
| 822 | 822 | // Rearrange license keys. |
| 823 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
| 823 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
| 824 | 824 | |
| 825 | 825 | // Update subscription information. |
| 826 | - update_option( 'give_subscriptions', $subscriptions ); |
|
| 826 | + update_option('give_subscriptions', $subscriptions); |
|
| 827 | 827 | break; |
| 828 | 828 | } |
| 829 | 829 | } |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | * |
| 839 | 839 | * @return void |
| 840 | 840 | */ |
| 841 | - private function __remove_license_notices_show_blocker(){ |
|
| 841 | + private function __remove_license_notices_show_blocker() { |
|
| 842 | 842 | global $wpdb; |
| 843 | 843 | |
| 844 | 844 | // Delete permanent notice blocker. |
@@ -876,18 +876,18 @@ discard block |
||
| 876 | 876 | * |
| 877 | 877 | * @return bool |
| 878 | 878 | */ |
| 879 | - private function __is_notice_dismissed( $notice_id ){ |
|
| 879 | + private function __is_notice_dismissed($notice_id) { |
|
| 880 | 880 | $current_user = wp_get_current_user(); |
| 881 | 881 | $is_notice_dismissed = false; |
| 882 | 882 | |
| 883 | 883 | // Ge is notice dismissed permanently. |
| 884 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
| 884 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
| 885 | 885 | ? $already_dismiss_notices |
| 886 | 886 | : array(); |
| 887 | 887 | |
| 888 | 888 | |
| 889 | - if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) { |
|
| 890 | - $is_notice_dismissed = true; |
|
| 889 | + if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) { |
|
| 890 | + $is_notice_dismissed = true; |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | return $is_notice_dismissed; |
@@ -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 |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | * @return void |
| 39 | 39 | */ |
| 40 | 40 | function give_load_ajax_gateway() { |
| 41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
| 41 | + if (isset($_POST['give_payment_mode'])) { |
|
| 42 | 42 | /** |
| 43 | 43 | * Fire to render donation form. |
| 44 | 44 | * |
| 45 | 45 | * @since 1.7 |
| 46 | 46 | */ |
| 47 | - do_action( 'give_donation_form', $_POST['give_form_id'] ); |
|
| 47 | + do_action('give_donation_form', $_POST['give_form_id']); |
|
| 48 | 48 | |
| 49 | 49 | exit(); |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 54 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 53 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 54 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Sets an error on checkout if no gateways are enabled |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | function give_no_gateway_error() { |
| 64 | 64 | $gateways = give_get_enabled_payment_gateways(); |
| 65 | 65 | |
| 66 | - if ( empty( $gateways ) ) { |
|
| 67 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
| 66 | + if (empty($gateways)) { |
|
| 67 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
| 68 | 68 | } else { |
| 69 | - give_unset_error( 'no_gateways' ); |
|
| 69 | + give_unset_error('no_gateways'); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | -add_action( 'init', 'give_no_gateway_error' ); |
|
| 73 | +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 | |
@@ -38,35 +38,35 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
| 40 | 40 | */ |
| 41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
| 41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
| 42 | 42 | |
| 43 | - $this->setup_dates( $start_date, $end_date ); |
|
| 43 | + $this->setup_dates($start_date, $end_date); |
|
| 44 | 44 | |
| 45 | 45 | // Make sure start date is valid |
| 46 | - if ( is_wp_error( $this->start_date ) ) { |
|
| 46 | + if (is_wp_error($this->start_date)) { |
|
| 47 | 47 | return $this->start_date; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Make sure end date is valid |
| 51 | - if ( is_wp_error( $this->end_date ) ) { |
|
| 51 | + if (is_wp_error($this->end_date)) { |
|
| 52 | 52 | return $this->end_date; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( empty( $form_id ) ) { |
|
| 55 | + if (empty($form_id)) { |
|
| 56 | 56 | |
| 57 | 57 | // Global sale stats |
| 58 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
| 58 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
| 59 | 59 | |
| 60 | - if ( is_array( $status ) ) { |
|
| 60 | + if (is_array($status)) { |
|
| 61 | 61 | $count = 0; |
| 62 | - foreach ( $status as $payment_status ) { |
|
| 62 | + foreach ($status as $payment_status) { |
|
| 63 | 63 | $count += give_count_payments()->$payment_status; |
| 64 | 64 | } |
| 65 | 65 | } else { |
| 66 | 66 | $count = give_count_payments()->$status; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
| 69 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
| 70 | 70 | |
| 71 | 71 | } else { |
| 72 | 72 | |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | // Product specific stats |
| 76 | 76 | global $give_logs; |
| 77 | 77 | |
| 78 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 78 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 79 | 79 | |
| 80 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
| 80 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
| 81 | 81 | |
| 82 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 82 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
@@ -101,31 +101,31 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return float|int Total amount of donations based on the passed arguments. |
| 103 | 103 | */ |
| 104 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
| 104 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
| 105 | 105 | |
| 106 | 106 | global $wpdb; |
| 107 | 107 | |
| 108 | - $this->setup_dates( $start_date, $end_date ); |
|
| 108 | + $this->setup_dates($start_date, $end_date); |
|
| 109 | 109 | |
| 110 | 110 | // Make sure start date is valid |
| 111 | - if ( is_wp_error( $this->start_date ) ) { |
|
| 111 | + if (is_wp_error($this->start_date)) { |
|
| 112 | 112 | return $this->start_date; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Make sure end date is valid |
| 116 | - if ( is_wp_error( $this->end_date ) ) { |
|
| 116 | + if (is_wp_error($this->end_date)) { |
|
| 117 | 117 | return $this->end_date; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 120 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 121 | 121 | |
| 122 | - if ( empty( $form_id ) ) { |
|
| 122 | + if (empty($form_id)) { |
|
| 123 | 123 | |
| 124 | 124 | // Global earning stats |
| 125 | 125 | $args = array( |
| 126 | 126 | 'post_type' => 'give_payment', |
| 127 | 127 | 'nopaging' => true, |
| 128 | - 'post_status' => array( 'publish' ), |
|
| 128 | + 'post_status' => array('publish'), |
|
| 129 | 129 | 'fields' => 'ids', |
| 130 | 130 | 'update_post_term_cache' => false, |
| 131 | 131 | 'suppress_filters' => false, |
@@ -137,24 +137,24 @@ discard block |
||
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | 139 | //Filter by Gateway ID meta_key |
| 140 | - if ( $gateway_id !== false ) { |
|
| 140 | + if ($gateway_id !== false) { |
|
| 141 | 141 | $args['meta_key'] = '_give_payment_gateway'; |
| 142 | 142 | $args['meta_value'] = $gateway_id; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 146 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 147 | - $earnings = get_transient( $key ); |
|
| 145 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 146 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 147 | + $earnings = get_transient($key); |
|
| 148 | 148 | |
| 149 | - if ( false === $earnings ) { |
|
| 150 | - $sales = get_posts( $args ); |
|
| 149 | + if (false === $earnings) { |
|
| 150 | + $sales = get_posts($args); |
|
| 151 | 151 | $earnings = 0; |
| 152 | - if ( $sales ) { |
|
| 153 | - $sales = implode( ',', array_map('intval', $sales ) ); |
|
| 154 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
| 152 | + if ($sales) { |
|
| 153 | + $sales = implode(',', array_map('intval', $sales)); |
|
| 154 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
| 155 | 155 | } |
| 156 | 156 | // Cache the results for one hour |
| 157 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
| 157 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | } else { |
@@ -174,37 +174,37 @@ discard block |
||
| 174 | 174 | 'give_transient_type' => 'give_earnings', |
| 175 | 175 | // This is not a valid query arg, but is used for cache keying |
| 176 | 176 | ); |
| 177 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 178 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 177 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 178 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 179 | 179 | //Set transient for faster stats |
| 180 | - $earnings = get_transient( $key ); |
|
| 180 | + $earnings = get_transient($key); |
|
| 181 | 181 | |
| 182 | - if ( false === $earnings ) { |
|
| 182 | + if (false === $earnings) { |
|
| 183 | 183 | |
| 184 | 184 | $this->timestamp = false; |
| 185 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
| 185 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
| 186 | 186 | $earnings = 0; |
| 187 | 187 | |
| 188 | - if ( $log_ids ) { |
|
| 189 | - $log_ids = implode( ',', array_map('intval', $log_ids ) ); |
|
| 190 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
| 188 | + if ($log_ids) { |
|
| 189 | + $log_ids = implode(',', array_map('intval', $log_ids)); |
|
| 190 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
| 191 | 191 | |
| 192 | - foreach ( $payment_ids as $payment_id ) { |
|
| 193 | - $earnings += give_get_payment_amount( $payment_id ); |
|
| 192 | + foreach ($payment_ids as $payment_id) { |
|
| 193 | + $earnings += give_get_payment_amount($payment_id); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Cache the results for one hour |
| 199 | - set_transient( $key, $earnings, 60 * 60 ); |
|
| 199 | + set_transient($key, $earnings, 60 * 60); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | //remove our filter |
| 204 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 204 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 205 | 205 | |
| 206 | 206 | //return earnings |
| 207 | - return round( $earnings, give_currency_decimal_filter() ); |
|
| 207 | + return round($earnings, give_currency_decimal_filter()); |
|
| 208 | 208 | |
| 209 | 209 | } |
| 210 | 210 | |
@@ -221,29 +221,29 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @return float|int Total amount of donations based on the passed arguments. |
| 223 | 223 | */ |
| 224 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
| 224 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
| 225 | 225 | |
| 226 | - $this->setup_dates( $start_date, $end_date ); |
|
| 226 | + $this->setup_dates($start_date, $end_date); |
|
| 227 | 227 | |
| 228 | 228 | // Make sure start date is valid |
| 229 | - if ( is_wp_error( $this->start_date ) ) { |
|
| 229 | + if (is_wp_error($this->start_date)) { |
|
| 230 | 230 | return $this->start_date; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Make sure end date is valid |
| 234 | - if ( is_wp_error( $this->end_date ) ) { |
|
| 234 | + if (is_wp_error($this->end_date)) { |
|
| 235 | 235 | return $this->end_date; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 238 | + add_filter('posts_where', array($this, 'payments_where')); |
|
| 239 | 239 | |
| 240 | - if ( empty( $form_id ) ) { |
|
| 240 | + if (empty($form_id)) { |
|
| 241 | 241 | |
| 242 | 242 | // Global earning stats |
| 243 | 243 | $args = array( |
| 244 | 244 | 'post_type' => 'give_payment', |
| 245 | 245 | 'nopaging' => true, |
| 246 | - 'post_status' => array( 'publish' ), |
|
| 246 | + 'post_status' => array('publish'), |
|
| 247 | 247 | 'fields' => 'ids', |
| 248 | 248 | 'update_post_term_cache' => false, |
| 249 | 249 | 'suppress_filters' => false, |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | ); |
| 256 | 256 | |
| 257 | 257 | //Filter by Gateway ID meta_key |
| 258 | - if ( $gateway_id !== false ) { |
|
| 258 | + if ($gateway_id !== false) { |
|
| 259 | 259 | $args['meta_key'] = '_give_payment_gateway'; |
| 260 | 260 | $args['meta_value'] = $gateway_id; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 264 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 263 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 264 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 265 | 265 | |
| 266 | 266 | } else { |
| 267 | 267 | |
@@ -280,12 +280,12 @@ discard block |
||
| 280 | 280 | 'give_transient_type' => 'give_earnings', |
| 281 | 281 | // This is not a valid query arg, but is used for cache keying |
| 282 | 282 | ); |
| 283 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
| 284 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
| 283 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
| 284 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | //remove our filter |
| 288 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
| 288 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
| 289 | 289 | |
| 290 | 290 | //return earnings |
| 291 | 291 | return $key; |
@@ -302,16 +302,16 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return array Best selling forms |
| 304 | 304 | */ |
| 305 | - public function get_best_selling( $number = 10 ) { |
|
| 305 | + public function get_best_selling($number = 10) { |
|
| 306 | 306 | |
| 307 | 307 | global $wpdb; |
| 308 | 308 | |
| 309 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
| 309 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
| 310 | 310 | "SELECT post_id as form_id, max(meta_value) as sales |
| 311 | 311 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
| 312 | 312 | GROUP BY meta_value+0 |
| 313 | 313 | DESC LIMIT %d;", $number |
| 314 | - ) ); |
|
| 314 | + )); |
|
| 315 | 315 | |
| 316 | 316 | return $give_forms; |
| 317 | 317 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function give_system_info_callback() { |
| 26 | 26 | |
| 27 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 27 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | 30 | ?> |
| 31 | - <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" aria-label="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give' ); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
| 31 | + <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" aria-label="<?php esc_attr_e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give'); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
| 32 | 32 | <p class="submit"> |
| 33 | 33 | <input type="hidden" name="give-action" value="download_sysinfo"/> |
| 34 | - <?php submit_button( esc_html__( 'Download System Info File', 'give' ), 'secondary', 'give-download-sysinfo', false ); ?> |
|
| 34 | + <?php submit_button(esc_html__('Download System Info File', 'give'), 'secondary', 'give-download-sysinfo', false); ?> |
|
| 35 | 35 | </p> |
| 36 | 36 | <?php |
| 37 | 37 | } |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | * @return bool |
| 48 | 48 | */ |
| 49 | 49 | function give_allow_sessions_for_sysinfo() { |
| 50 | - if ( is_admin() && ( isset( $_GET['page'] ) && isset( $_GET['tab'] ) ) && ( $_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings' ) ) { |
|
| 50 | + if (is_admin() && (isset($_GET['page']) && isset($_GET['tab'])) && ($_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings')) { |
|
| 51 | 51 | return true; |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | -add_filter( 'give_start_session', 'give_allow_sessions_for_sysinfo' ); |
|
| 55 | +add_filter('give_start_session', 'give_allow_sessions_for_sysinfo'); |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -67,63 +67,63 @@ discard block |
||
| 67 | 67 | function give_tools_sysinfo_get() { |
| 68 | 68 | global $wpdb, $give_options; |
| 69 | 69 | |
| 70 | - if ( ! class_exists( 'Browser' ) ) { |
|
| 71 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php'; |
|
| 70 | + if ( ! class_exists('Browser')) { |
|
| 71 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/browser.php'; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $browser = new Browser(); |
| 75 | 75 | |
| 76 | 76 | // Get theme info |
| 77 | - if ( get_bloginfo( 'version' ) < '3.4' ) { |
|
| 78 | - $theme_data = wp_get_theme( get_stylesheet_directory() . '/style.css' ); |
|
| 79 | - $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; |
|
| 77 | + if (get_bloginfo('version') < '3.4') { |
|
| 78 | + $theme_data = wp_get_theme(get_stylesheet_directory().'/style.css'); |
|
| 79 | + $theme = $theme_data['Name'].' '.$theme_data['Version']; |
|
| 80 | 80 | } else { |
| 81 | 81 | $theme_data = wp_get_theme(); |
| 82 | - $theme = $theme_data->Name . ' ' . $theme_data->Version; |
|
| 82 | + $theme = $theme_data->Name.' '.$theme_data->Version; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Try to identify the hosting provider |
| 86 | 86 | $host = give_get_host(); |
| 87 | 87 | |
| 88 | - $return = '### Begin System Info ###' . "\n\n"; |
|
| 88 | + $return = '### Begin System Info ###'."\n\n"; |
|
| 89 | 89 | |
| 90 | 90 | // Start with the basics... |
| 91 | - $return .= '-- Site Info' . "\n\n"; |
|
| 92 | - $return .= 'Site URL: ' . site_url() . "\n"; |
|
| 93 | - $return .= 'Home URL: ' . home_url() . "\n"; |
|
| 94 | - $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n"; |
|
| 91 | + $return .= '-- Site Info'."\n\n"; |
|
| 92 | + $return .= 'Site URL: '.site_url()."\n"; |
|
| 93 | + $return .= 'Home URL: '.home_url()."\n"; |
|
| 94 | + $return .= 'Multisite: '.(is_multisite() ? 'Yes' : 'No')."\n"; |
|
| 95 | 95 | |
| 96 | - $return = apply_filters( 'give_sysinfo_after_site_info', $return ); |
|
| 96 | + $return = apply_filters('give_sysinfo_after_site_info', $return); |
|
| 97 | 97 | |
| 98 | 98 | // Can we determine the site's host? |
| 99 | - if ( $host ) { |
|
| 100 | - $return .= "\n" . '-- Hosting Provider' . "\n\n"; |
|
| 101 | - $return .= 'Host: ' . $host . "\n"; |
|
| 99 | + if ($host) { |
|
| 100 | + $return .= "\n".'-- Hosting Provider'."\n\n"; |
|
| 101 | + $return .= 'Host: '.$host."\n"; |
|
| 102 | 102 | |
| 103 | - $return = apply_filters( 'give_sysinfo_after_host_info', $return ); |
|
| 103 | + $return = apply_filters('give_sysinfo_after_host_info', $return); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // The local users' browser information, handled by the Browser class |
| 107 | - $return .= "\n" . '-- User Browser' . "\n\n"; |
|
| 107 | + $return .= "\n".'-- User Browser'."\n\n"; |
|
| 108 | 108 | $return .= $browser; |
| 109 | 109 | |
| 110 | - $return = apply_filters( 'give_sysinfo_after_user_browser', $return ); |
|
| 110 | + $return = apply_filters('give_sysinfo_after_user_browser', $return); |
|
| 111 | 111 | |
| 112 | 112 | // WordPress configuration |
| 113 | - $return .= "\n" . '-- WordPress Configuration' . "\n\n"; |
|
| 114 | - $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n"; |
|
| 115 | - $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n"; |
|
| 116 | - $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n"; |
|
| 117 | - $return .= 'Active Theme: ' . $theme . "\n"; |
|
| 118 | - $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n"; |
|
| 113 | + $return .= "\n".'-- WordPress Configuration'."\n\n"; |
|
| 114 | + $return .= 'Version: '.get_bloginfo('version')."\n"; |
|
| 115 | + $return .= 'Language: '.(defined('WPLANG') && WPLANG ? WPLANG : 'en_US')."\n"; |
|
| 116 | + $return .= 'Permalink Structure: '.(get_option('permalink_structure') ? get_option('permalink_structure') : 'Default')."\n"; |
|
| 117 | + $return .= 'Active Theme: '.$theme."\n"; |
|
| 118 | + $return .= 'Show On Front: '.get_option('show_on_front')."\n"; |
|
| 119 | 119 | |
| 120 | 120 | // Only show page specs if frontpage is set to 'page' |
| 121 | - if ( get_option( 'show_on_front' ) == 'page' ) { |
|
| 122 | - $front_page_id = get_option( 'page_on_front' ); |
|
| 123 | - $blog_page_id = get_option( 'page_for_posts' ); |
|
| 121 | + if (get_option('show_on_front') == 'page') { |
|
| 122 | + $front_page_id = get_option('page_on_front'); |
|
| 123 | + $blog_page_id = get_option('page_for_posts'); |
|
| 124 | 124 | |
| 125 | - $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n"; |
|
| 126 | - $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n"; |
|
| 125 | + $return .= 'Page On Front: '.($front_page_id != 0 ? get_the_title($front_page_id).' (#'.$front_page_id.')' : 'Unset')."\n"; |
|
| 126 | + $return .= 'Page For Posts: '.($blog_page_id != 0 ? get_the_title($blog_page_id).' (#'.$blog_page_id.')' : 'Unset')."\n"; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Make sure wp_remote_post() is working |
@@ -132,205 +132,205 @@ discard block |
||
| 132 | 132 | $params = array( |
| 133 | 133 | 'sslverify' => false, |
| 134 | 134 | 'timeout' => 60, |
| 135 | - 'user-agent' => 'Give/' . GIVE_VERSION, |
|
| 135 | + 'user-agent' => 'Give/'.GIVE_VERSION, |
|
| 136 | 136 | 'body' => $request |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | - $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
| 139 | + $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); |
|
| 140 | 140 | |
| 141 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
| 141 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
| 142 | 142 | $WP_REMOTE_POST = 'wp_remote_post() works'; |
| 143 | 143 | } else { |
| 144 | 144 | $WP_REMOTE_POST = 'wp_remote_post() does not work'; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; |
|
| 148 | - $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n"; |
|
| 149 | - $return .= 'Admin AJAX: ' . ( give_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n"; |
|
| 150 | - $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n"; |
|
| 151 | - $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; |
|
| 152 | - $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n"; |
|
| 147 | + $return .= 'Remote Post: '.$WP_REMOTE_POST."\n"; |
|
| 148 | + $return .= 'Table Prefix: '.'Length: '.strlen($wpdb->prefix).' Status: '.(strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable')."\n"; |
|
| 149 | + $return .= 'Admin AJAX: '.(give_test_ajax_works() ? 'Accessible' : 'Inaccessible')."\n"; |
|
| 150 | + $return .= 'WP_DEBUG: '.(defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set')."\n"; |
|
| 151 | + $return .= 'Memory Limit: '.WP_MEMORY_LIMIT."\n"; |
|
| 152 | + $return .= 'Registered Post Stati: '.implode(', ', get_post_stati())."\n"; |
|
| 153 | 153 | |
| 154 | - $return = apply_filters( 'give_sysinfo_after_wordpress_config', $return ); |
|
| 154 | + $return = apply_filters('give_sysinfo_after_wordpress_config', $return); |
|
| 155 | 155 | |
| 156 | 156 | // GIVE configuration |
| 157 | - $return .= "\n" . '-- Give Configuration' . "\n\n"; |
|
| 158 | - $return .= 'Version: ' . GIVE_VERSION . "\n"; |
|
| 159 | - $return .= 'Upgraded From: ' . get_option( 'give_version_upgraded_from', 'None' ) . "\n"; |
|
| 160 | - $return .= 'Test Mode: ' . ( give_is_test_mode() ? "Enabled\n" : "Disabled\n" ); |
|
| 161 | - $return .= 'Currency Code: ' . give_get_currency() . "\n"; |
|
| 162 | - $return .= 'Currency Position: ' . give_get_option( 'currency_position', 'before' ) . "\n"; |
|
| 163 | - $return .= 'Decimal Separator: ' . give_get_option( 'decimal_separator', '.' ) . "\n"; |
|
| 164 | - $return .= 'Thousands Separator: ' . give_get_option( 'thousands_separator', ',' ) . "\n"; |
|
| 157 | + $return .= "\n".'-- Give Configuration'."\n\n"; |
|
| 158 | + $return .= 'Version: '.GIVE_VERSION."\n"; |
|
| 159 | + $return .= 'Upgraded From: '.get_option('give_version_upgraded_from', 'None')."\n"; |
|
| 160 | + $return .= 'Test Mode: '.(give_is_test_mode() ? "Enabled\n" : "Disabled\n"); |
|
| 161 | + $return .= 'Currency Code: '.give_get_currency()."\n"; |
|
| 162 | + $return .= 'Currency Position: '.give_get_option('currency_position', 'before')."\n"; |
|
| 163 | + $return .= 'Decimal Separator: '.give_get_option('decimal_separator', '.')."\n"; |
|
| 164 | + $return .= 'Thousands Separator: '.give_get_option('thousands_separator', ',')."\n"; |
|
| 165 | 165 | |
| 166 | - $return = apply_filters( 'give_sysinfo_after_give_config', $return ); |
|
| 166 | + $return = apply_filters('give_sysinfo_after_give_config', $return); |
|
| 167 | 167 | |
| 168 | 168 | // GIVE pages |
| 169 | - $return .= "\n" . '-- Give Page Configuration' . "\n\n"; |
|
| 170 | - $return .= 'Success Page: ' . ( ! empty( $give_options['success_page'] ) ? get_permalink( $give_options['success_page'] ) . "\n" : "Unset\n" ); |
|
| 171 | - $return .= 'Failure Page: ' . ( ! empty( $give_options['failure_page'] ) ? get_permalink( $give_options['failure_page'] ) . "\n" : "Unset\n" ); |
|
| 172 | - $return .= 'Give Forms Slug: ' . ( defined( 'GIVE_SLUG' ) ? '/' . GIVE_SLUG . "\n" : "/donations\n" ); |
|
| 169 | + $return .= "\n".'-- Give Page Configuration'."\n\n"; |
|
| 170 | + $return .= 'Success Page: '.( ! empty($give_options['success_page']) ? get_permalink($give_options['success_page'])."\n" : "Unset\n"); |
|
| 171 | + $return .= 'Failure Page: '.( ! empty($give_options['failure_page']) ? get_permalink($give_options['failure_page'])."\n" : "Unset\n"); |
|
| 172 | + $return .= 'Give Forms Slug: '.(defined('GIVE_SLUG') ? '/'.GIVE_SLUG."\n" : "/donations\n"); |
|
| 173 | 173 | |
| 174 | - $return = apply_filters( 'give_sysinfo_after_give_pages', $return ); |
|
| 174 | + $return = apply_filters('give_sysinfo_after_give_pages', $return); |
|
| 175 | 175 | |
| 176 | 176 | // GIVE gateways |
| 177 | - $return .= "\n" . '-- Give Gateway Configuration' . "\n\n"; |
|
| 177 | + $return .= "\n".'-- Give Gateway Configuration'."\n\n"; |
|
| 178 | 178 | |
| 179 | 179 | $active_gateways = give_get_enabled_payment_gateways(); |
| 180 | - if ( $active_gateways ) { |
|
| 181 | - $default_gateway_is_active = give_is_gateway_active( give_get_default_gateway( null ) ); |
|
| 182 | - if ( $default_gateway_is_active ) { |
|
| 183 | - $default_gateway = give_get_default_gateway( null ); |
|
| 184 | - $default_gateway = $active_gateways[ $default_gateway ]['admin_label']; |
|
| 180 | + if ($active_gateways) { |
|
| 181 | + $default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null)); |
|
| 182 | + if ($default_gateway_is_active) { |
|
| 183 | + $default_gateway = give_get_default_gateway(null); |
|
| 184 | + $default_gateway = $active_gateways[$default_gateway]['admin_label']; |
|
| 185 | 185 | } else { |
| 186 | 186 | $default_gateway = 'Test Donation'; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $gateways = array(); |
| 190 | - foreach ( $active_gateways as $gateway ) { |
|
| 190 | + foreach ($active_gateways as $gateway) { |
|
| 191 | 191 | $gateways[] = $gateway['admin_label']; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $return .= 'Enabled Gateways: ' . implode( ', ', $gateways ) . "\n"; |
|
| 195 | - $return .= 'Default Gateway: ' . $default_gateway . "\n"; |
|
| 194 | + $return .= 'Enabled Gateways: '.implode(', ', $gateways)."\n"; |
|
| 195 | + $return .= 'Default Gateway: '.$default_gateway."\n"; |
|
| 196 | 196 | } else { |
| 197 | - $return .= 'Enabled Gateways: None' . "\n"; |
|
| 197 | + $return .= 'Enabled Gateways: None'."\n"; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - $return = apply_filters( 'give_sysinfo_after_give_gateways', $return ); |
|
| 200 | + $return = apply_filters('give_sysinfo_after_give_gateways', $return); |
|
| 201 | 201 | |
| 202 | 202 | // GIVE Templates |
| 203 | - $dir = get_stylesheet_directory() . '/give_templates/*'; |
|
| 204 | - if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) { |
|
| 205 | - $return .= "\n" . '-- Give Template Overrides' . "\n\n"; |
|
| 203 | + $dir = get_stylesheet_directory().'/give_templates/*'; |
|
| 204 | + if (is_dir($dir) && (count(glob("$dir/*")) !== 0)) { |
|
| 205 | + $return .= "\n".'-- Give Template Overrides'."\n\n"; |
|
| 206 | 206 | |
| 207 | - foreach ( glob( $dir ) as $file ) { |
|
| 208 | - $return .= 'Filename: ' . basename( $file ) . "\n"; |
|
| 207 | + foreach (glob($dir) as $file) { |
|
| 208 | + $return .= 'Filename: '.basename($file)."\n"; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - $return = apply_filters( 'give_sysinfo_after_give_templates', $return ); |
|
| 211 | + $return = apply_filters('give_sysinfo_after_give_templates', $return); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // Must-use plugins |
| 215 | 215 | $muplugins = get_mu_plugins(); |
| 216 | - if ( count( $muplugins > 0 ) ) { |
|
| 217 | - $return .= "\n" . '-- Must-Use Plugins' . "\n\n"; |
|
| 216 | + if (count($muplugins > 0)) { |
|
| 217 | + $return .= "\n".'-- Must-Use Plugins'."\n\n"; |
|
| 218 | 218 | |
| 219 | - foreach ( $muplugins as $plugin => $plugin_data ) { |
|
| 220 | - $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; |
|
| 219 | + foreach ($muplugins as $plugin => $plugin_data) { |
|
| 220 | + $return .= $plugin_data['Name'].': '.$plugin_data['Version']."\n"; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $return = apply_filters( 'give_sysinfo_after_wordpress_mu_plugins', $return ); |
|
| 223 | + $return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // WordPress active plugins |
| 227 | - $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; |
|
| 227 | + $return .= "\n".'-- WordPress Active Plugins'."\n\n"; |
|
| 228 | 228 | |
| 229 | 229 | $plugins = get_plugins(); |
| 230 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
| 230 | + $active_plugins = get_option('active_plugins', array()); |
|
| 231 | 231 | |
| 232 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
| 233 | - if ( ! in_array( $plugin_path, $active_plugins ) ) { |
|
| 232 | + foreach ($plugins as $plugin_path => $plugin) { |
|
| 233 | + if ( ! in_array($plugin_path, $active_plugins)) { |
|
| 234 | 234 | continue; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
| 237 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins', $return ); |
|
| 240 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins', $return); |
|
| 241 | 241 | |
| 242 | 242 | // WordPress inactive plugins |
| 243 | - $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; |
|
| 243 | + $return .= "\n".'-- WordPress Inactive Plugins'."\n\n"; |
|
| 244 | 244 | |
| 245 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
| 246 | - if ( in_array( $plugin_path, $active_plugins ) ) { |
|
| 245 | + foreach ($plugins as $plugin_path => $plugin) { |
|
| 246 | + if (in_array($plugin_path, $active_plugins)) { |
|
| 247 | 247 | continue; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
| 250 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins_inactive', $return ); |
|
| 253 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return); |
|
| 254 | 254 | |
| 255 | - if ( is_multisite() ) { |
|
| 255 | + if (is_multisite()) { |
|
| 256 | 256 | // WordPress Multisite active plugins |
| 257 | - $return .= "\n" . '-- Network Active Plugins' . "\n\n"; |
|
| 257 | + $return .= "\n".'-- Network Active Plugins'."\n\n"; |
|
| 258 | 258 | |
| 259 | 259 | $plugins = wp_get_active_network_plugins(); |
| 260 | - $active_plugins = get_site_option( 'active_sitewide_plugins', array() ); |
|
| 260 | + $active_plugins = get_site_option('active_sitewide_plugins', array()); |
|
| 261 | 261 | |
| 262 | - foreach ( $plugins as $plugin_path ) { |
|
| 263 | - $plugin_base = plugin_basename( $plugin_path ); |
|
| 262 | + foreach ($plugins as $plugin_path) { |
|
| 263 | + $plugin_base = plugin_basename($plugin_path); |
|
| 264 | 264 | |
| 265 | - if ( ! array_key_exists( $plugin_base, $active_plugins ) ) { |
|
| 265 | + if ( ! array_key_exists($plugin_base, $active_plugins)) { |
|
| 266 | 266 | continue; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $plugin = get_plugin_data( $plugin_path ); |
|
| 270 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
| 269 | + $plugin = get_plugin_data($plugin_path); |
|
| 270 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - $return = apply_filters( 'give_sysinfo_after_wordpress_ms_plugins', $return ); |
|
| 273 | + $return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Server configuration (really just versioning) |
| 277 | - $return .= "\n" . '-- Webserver Configuration' . "\n\n"; |
|
| 278 | - $return .= 'PHP Version: ' . PHP_VERSION . "\n"; |
|
| 279 | - $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; |
|
| 280 | - $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; |
|
| 277 | + $return .= "\n".'-- Webserver Configuration'."\n\n"; |
|
| 278 | + $return .= 'PHP Version: '.PHP_VERSION."\n"; |
|
| 279 | + $return .= 'MySQL Version: '.$wpdb->db_version()."\n"; |
|
| 280 | + $return .= 'Webserver Info: '.$_SERVER['SERVER_SOFTWARE']."\n"; |
|
| 281 | 281 | |
| 282 | - $return = apply_filters( 'give_sysinfo_after_webserver_config', $return ); |
|
| 282 | + $return = apply_filters('give_sysinfo_after_webserver_config', $return); |
|
| 283 | 283 | |
| 284 | 284 | // PHP configs... now we're getting to the important stuff |
| 285 | - $return .= "\n" . '-- PHP Configuration' . "\n\n"; |
|
| 286 | - $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" ); |
|
| 287 | - $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n"; |
|
| 288 | - $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
| 289 | - $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n"; |
|
| 290 | - $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
| 291 | - $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n"; |
|
| 292 | - $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n"; |
|
| 293 | - $return .= 'URL-aware fopen: ' . ( ini_get( 'allow_url_fopen' ) ? 'On (' . ini_get( 'allow_url_fopen' ) . ')' : 'N/A' ) . "\n"; |
|
| 294 | - $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n"; |
|
| 295 | - |
|
| 296 | - $return = apply_filters( 'give_sysinfo_after_php_config', $return ); |
|
| 285 | + $return .= "\n".'-- PHP Configuration'."\n\n"; |
|
| 286 | + $return .= 'Safe Mode: '.(ini_get('safe_mode') ? 'Enabled' : 'Disabled'."\n"); |
|
| 287 | + $return .= 'Memory Limit: '.ini_get('memory_limit')."\n"; |
|
| 288 | + $return .= 'Upload Max Size: '.ini_get('upload_max_filesize')."\n"; |
|
| 289 | + $return .= 'Post Max Size: '.ini_get('post_max_size')."\n"; |
|
| 290 | + $return .= 'Upload Max Filesize: '.ini_get('upload_max_filesize')."\n"; |
|
| 291 | + $return .= 'Time Limit: '.ini_get('max_execution_time')."\n"; |
|
| 292 | + $return .= 'Max Input Vars: '.ini_get('max_input_vars')."\n"; |
|
| 293 | + $return .= 'URL-aware fopen: '.(ini_get('allow_url_fopen') ? 'On ('.ini_get('allow_url_fopen').')' : 'N/A')."\n"; |
|
| 294 | + $return .= 'Display Errors: '.(ini_get('display_errors') ? 'On ('.ini_get('display_errors').')' : 'N/A')."\n"; |
|
| 295 | + |
|
| 296 | + $return = apply_filters('give_sysinfo_after_php_config', $return); |
|
| 297 | 297 | |
| 298 | 298 | // PHP extensions and such |
| 299 | - $return .= "\n" . '-- PHP Extensions' . "\n\n"; |
|
| 300 | - $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 299 | + $return .= "\n".'-- PHP Extensions'."\n\n"; |
|
| 300 | + $return .= 'cURL: '.(function_exists('curl_init') ? 'Supported' : 'Not Supported')."\n"; |
|
| 301 | 301 | |
| 302 | 302 | //cURL version |
| 303 | - if ( function_exists( 'curl_init' ) && function_exists( 'curl_version' ) ) { |
|
| 303 | + if (function_exists('curl_init') && function_exists('curl_version')) { |
|
| 304 | 304 | $curl_values = curl_version(); |
| 305 | - $return .= 'cURL Version: ' . $curl_values["version"] . "\n"; |
|
| 305 | + $return .= 'cURL Version: '.$curl_values["version"]."\n"; |
|
| 306 | 306 | } |
| 307 | - $return .= 'zlib: ' . ( function_exists( 'gzcompress' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 308 | - $return .= 'GD: ' . ( ( extension_loaded( 'gd' ) && function_exists( 'gd_info' ) ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 309 | - $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
| 310 | - $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 311 | - $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 312 | - $return .= 'DOM: ' . ( extension_loaded( 'dom' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 313 | - $return .= 'MBString: ' . ( extension_loaded( 'mbstring' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
| 307 | + $return .= 'zlib: '.(function_exists('gzcompress') ? 'Supported' : 'Not Supported')."\n"; |
|
| 308 | + $return .= 'GD: '.((extension_loaded('gd') && function_exists('gd_info')) ? 'Supported' : 'Not Supported')."\n"; |
|
| 309 | + $return .= 'fsockopen: '.(function_exists('fsockopen') ? 'Supported' : 'Not Supported')."\n"; |
|
| 310 | + $return .= 'SOAP Client: '.(class_exists('SoapClient') ? 'Installed' : 'Not Installed')."\n"; |
|
| 311 | + $return .= 'Suhosin: '.(extension_loaded('suhosin') ? 'Installed' : 'Not Installed')."\n"; |
|
| 312 | + $return .= 'DOM: '.(extension_loaded('dom') ? 'Installed' : 'Not Installed')."\n"; |
|
| 313 | + $return .= 'MBString: '.(extension_loaded('mbstring') ? 'Installed' : 'Not Installed')."\n"; |
|
| 314 | 314 | |
| 315 | - $return = apply_filters( 'give_sysinfo_after_php_ext', $return ); |
|
| 315 | + $return = apply_filters('give_sysinfo_after_php_ext', $return); |
|
| 316 | 316 | |
| 317 | 317 | // Session stuff |
| 318 | - $return .= "\n" . '-- Session Configuration' . "\n\n"; |
|
| 319 | - $return .= 'Give Use Sessions: ' . ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ? 'Enforced' : ( Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n"; |
|
| 320 | - $return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n"; |
|
| 318 | + $return .= "\n".'-- Session Configuration'."\n\n"; |
|
| 319 | + $return .= 'Give Use Sessions: '.(defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled'))."\n"; |
|
| 320 | + $return .= 'Session: '.(isset($_SESSION) ? 'Enabled' : 'Disabled')."\n"; |
|
| 321 | 321 | |
| 322 | 322 | // The rest of this is only relevant is session is enabled |
| 323 | - if ( isset( $_SESSION ) ) { |
|
| 324 | - $return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n"; |
|
| 325 | - $return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n"; |
|
| 326 | - $return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n"; |
|
| 327 | - $return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
| 328 | - $return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
| 323 | + if (isset($_SESSION)) { |
|
| 324 | + $return .= 'Session Name: '.esc_html(ini_get('session.name'))."\n"; |
|
| 325 | + $return .= 'Cookie Path: '.esc_html(ini_get('session.cookie_path'))."\n"; |
|
| 326 | + $return .= 'Save Path: '.esc_html(ini_get('session.save_path'))."\n"; |
|
| 327 | + $return .= 'Use Cookies: '.(ini_get('session.use_cookies') ? 'On' : 'Off')."\n"; |
|
| 328 | + $return .= 'Use Only Cookies: '.(ini_get('session.use_only_cookies') ? 'On' : 'Off')."\n"; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $return = apply_filters( 'give_sysinfo_after_session_config', $return ); |
|
| 331 | + $return = apply_filters('give_sysinfo_after_session_config', $return); |
|
| 332 | 332 | |
| 333 | - $return .= "\n" . '### End System Info ###'; |
|
| 333 | + $return .= "\n".'### End System Info ###'; |
|
| 334 | 334 | |
| 335 | 335 | return $return; |
| 336 | 336 | } |
@@ -344,17 +344,17 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | function give_tools_sysinfo_download() { |
| 346 | 346 | |
| 347 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 347 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 348 | 348 | return; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | nocache_headers(); |
| 352 | 352 | |
| 353 | - header( 'Content-Type: text/plain' ); |
|
| 354 | - header( 'Content-Disposition: attachment; filename="give-system-info.txt"' ); |
|
| 353 | + header('Content-Type: text/plain'); |
|
| 354 | + header('Content-Disposition: attachment; filename="give-system-info.txt"'); |
|
| 355 | 355 | |
| 356 | - echo wp_strip_all_tags( $_POST['give-sysinfo'] ); |
|
| 356 | + echo wp_strip_all_tags($_POST['give-sysinfo']); |
|
| 357 | 357 | give_die(); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | -add_action( 'give_download_sysinfo', 'give_tools_sysinfo_download' ); |
|
| 361 | 360 | \ No newline at end of file |
| 361 | +add_action('give_download_sysinfo', 'give_tools_sysinfo_download'); |
|
| 362 | 362 | \ No newline at end of file |