@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
| 30 | - $payment = new Give_Payment( $payment_id ); |
|
| 29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
| 30 | + $payment = new Give_Payment($payment_id); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Fire the action |
| 34 | 34 | */ |
| 35 | - do_action( 'give_donation-receipt_email_notification', $payment_id ); |
|
| 35 | + do_action('give_donation-receipt_email_notification', $payment_id); |
|
| 36 | 36 | |
| 37 | 37 | // If admin notifications are on, send the admin notice. |
| 38 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
| 38 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
| 39 | 39 | /** |
| 40 | 40 | * Fires in the donation email receipt. |
| 41 | 41 | * |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param int $payment_id Payment id. |
| 47 | 47 | * @param mixed $payment_data Payment meta data. |
| 48 | 48 | */ |
| 49 | - do_action( 'give_new-donation_email_notification', $payment_id, $payment->payment_meta ); |
|
| 49 | + do_action('give_new-donation_email_notification', $payment_id, $payment->payment_meta); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return void |
| 61 | 61 | */ |
| 62 | -function give_admin_email_notice( $payment_id ) { |
|
| 62 | +function give_admin_email_notice($payment_id) { |
|
| 63 | 63 | /** |
| 64 | 64 | * Fires in the donation email receipt. |
| 65 | 65 | * |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | * @param int $payment_id Payment id. |
| 71 | 71 | * @param mixed $payment_data Payment meta data. |
| 72 | 72 | */ |
| 73 | - do_action( 'give_new-donation_email_notification', $payment_id ); |
|
| 73 | + do_action('give_new-donation_email_notification', $payment_id); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice' ); |
|
| 76 | +add_action('give_admin_donation_email', 'give_admin_email_notice'); |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function give_get_default_donation_notification_email() { |
| 88 | 88 | |
| 89 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n"; |
|
| 90 | - $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
| 91 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
| 92 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
| 93 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
| 94 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
| 95 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
| 96 | - $default_email_body .= '{sitename}' . "\n"; |
|
| 89 | + $default_email_body = __('Hi there,', 'give')."\n\n"; |
|
| 90 | + $default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
| 91 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n"; |
|
| 92 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
| 93 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
| 94 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
| 95 | + $default_email_body .= __('Thank you,', 'give')."\n\n"; |
|
| 96 | + $default_email_body .= '{sitename}'."\n"; |
|
| 97 | 97 | |
| 98 | - return apply_filters( 'give_default_donation_notification_email', $default_email_body ); |
|
| 98 | + return apply_filters('give_default_donation_notification_email', $default_email_body); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
@@ -109,21 +109,21 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | function give_get_default_donation_receipt_email() { |
| 111 | 111 | |
| 112 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
| 113 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
| 114 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
| 115 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
| 116 | - $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
| 117 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
| 118 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
| 119 | - $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
| 120 | - $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
| 121 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
| 112 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
| 113 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
| 114 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
| 115 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
| 116 | + $default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
| 117 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
| 118 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
| 119 | + $default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
| 120 | + $default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
| 121 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
| 122 | 122 | $default_email_body .= "\n\n"; |
| 123 | - $default_email_body .= __( 'Sincerely,', 'give' ) . "\n"; |
|
| 124 | - $default_email_body .= '{sitename}' . "\n"; |
|
| 123 | + $default_email_body .= __('Sincerely,', 'give')."\n"; |
|
| 124 | + $default_email_body .= '{sitename}'."\n"; |
|
| 125 | 125 | |
| 126 | - return apply_filters( 'give_default_donation_receipt_email', $default_email_body ); |
|
| 126 | + return apply_filters('give_default_donation_receipt_email', $default_email_body); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -136,22 +136,22 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return array $email_names |
| 138 | 138 | */ |
| 139 | -function give_get_email_names( $user_info, $payment = false ) { |
|
| 139 | +function give_get_email_names($user_info, $payment = false) { |
|
| 140 | 140 | $email_names = array(); |
| 141 | 141 | |
| 142 | - if ( is_a( $payment, 'Give_Payment' ) ) { |
|
| 142 | + if (is_a($payment, 'Give_Payment')) { |
|
| 143 | 143 | |
| 144 | - if ( $payment->user_id > 0 ) { |
|
| 144 | + if ($payment->user_id > 0) { |
|
| 145 | 145 | |
| 146 | - $user_data = get_userdata( $payment->user_id ); |
|
| 146 | + $user_data = get_userdata($payment->user_id); |
|
| 147 | 147 | $email_names['name'] = $payment->first_name; |
| 148 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
| 148 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
| 149 | 149 | $email_names['username'] = $user_data->user_login; |
| 150 | 150 | |
| 151 | - } elseif ( ! empty( $payment->first_name ) ) { |
|
| 151 | + } elseif ( ! empty($payment->first_name)) { |
|
| 152 | 152 | |
| 153 | 153 | $email_names['name'] = $payment->first_name; |
| 154 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
| 154 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
| 155 | 155 | $email_names['username'] = $payment->first_name; |
| 156 | 156 | |
| 157 | 157 | } else { |
@@ -164,30 +164,30 @@ discard block |
||
| 164 | 164 | } else { |
| 165 | 165 | |
| 166 | 166 | // Support for old serialized data. |
| 167 | - if ( is_serialized( $user_info ) ) { |
|
| 167 | + if (is_serialized($user_info)) { |
|
| 168 | 168 | |
| 169 | 169 | // Security check. |
| 170 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
| 171 | - if ( ! empty( $matches ) ) { |
|
| 170 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
| 171 | + if ( ! empty($matches)) { |
|
| 172 | 172 | return array( |
| 173 | 173 | 'name' => '', |
| 174 | 174 | 'fullname' => '', |
| 175 | 175 | 'username' => '', |
| 176 | 176 | ); |
| 177 | 177 | } else { |
| 178 | - $user_info = maybe_unserialize( $user_info ); |
|
| 178 | + $user_info = maybe_unserialize($user_info); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
| 184 | - $user_data = get_userdata( $user_info['id'] ); |
|
| 183 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
| 184 | + $user_data = get_userdata($user_info['id']); |
|
| 185 | 185 | $email_names['name'] = $user_info['first_name']; |
| 186 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 186 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 187 | 187 | $email_names['username'] = $user_data->user_login; |
| 188 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
| 188 | + } elseif (isset($user_info['first_name'])) { |
|
| 189 | 189 | $email_names['name'] = $user_info['first_name']; |
| 190 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
| 190 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
| 191 | 191 | $email_names['username'] = $user_info['first_name']; |
| 192 | 192 | } else { |
| 193 | 193 | $email_names['name'] = $user_info['email']; |
@@ -207,37 +207,37 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @since 1.8.14 |
| 209 | 209 | */ |
| 210 | -function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) { |
|
| 210 | +function give_admin_email_user_donor_disconnection($user_id, $donor_id) { |
|
| 211 | 211 | |
| 212 | - $user_id = absint( $user_id ); |
|
| 213 | - $donor_id = absint( $donor_id ); |
|
| 212 | + $user_id = absint($user_id); |
|
| 213 | + $donor_id = absint($donor_id); |
|
| 214 | 214 | |
| 215 | 215 | // Bail Out, if user id doesn't exists. |
| 216 | - if ( empty( $user_id ) ) { |
|
| 216 | + if (empty($user_id)) { |
|
| 217 | 217 | return; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // Bail Out, if donor id doesn't exists. |
| 221 | - if ( empty( $donor_id ) ) { |
|
| 221 | + if (empty($donor_id)) { |
|
| 222 | 222 | return; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 225 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 226 | 226 | |
| 227 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
| 227 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
| 228 | 228 | |
| 229 | 229 | /* translators: %s: payment id */ |
| 230 | - $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' ); |
|
| 230 | + $subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give'); |
|
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | 233 | * Filters the Donor-User Disconnection notification subject. |
| 234 | 234 | * |
| 235 | 235 | * @since 1.8.14 |
| 236 | 236 | */ |
| 237 | - $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) ); |
|
| 237 | + $subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject)); |
|
| 238 | 238 | |
| 239 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
| 240 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
| 239 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
| 240 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
| 241 | 241 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -245,25 +245,25 @@ discard block |
||
| 245 | 245 | * |
| 246 | 246 | * @since 1.8.14 |
| 247 | 247 | */ |
| 248 | - $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers ); |
|
| 248 | + $headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers); |
|
| 249 | 249 | |
| 250 | - $message = __( 'Hi Admin,', 'give' ) . "\n\n"; |
|
| 251 | - $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n"; |
|
| 252 | - $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n"; |
|
| 250 | + $message = __('Hi Admin,', 'give')."\n\n"; |
|
| 251 | + $message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n"; |
|
| 252 | + $message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n"; |
|
| 253 | 253 | $message .= sprintf( |
| 254 | 254 | '<a href="%1$s">%2$s</a>', |
| 255 | - esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ), |
|
| 256 | - __( 'Reconnect User', 'give' ) . "\n\n" |
|
| 255 | + esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'), |
|
| 256 | + __('Reconnect User', 'give')."\n\n" |
|
| 257 | 257 | ); |
| 258 | - $message .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
| 259 | - $message .= '{sitename}' . "\n"; |
|
| 258 | + $message .= __('Thank you,', 'give')."\n\n"; |
|
| 259 | + $message .= '{sitename}'."\n"; |
|
| 260 | 260 | |
| 261 | 261 | $emails = Give()->emails; |
| 262 | - $emails->__set( 'from_name', $from_name ); |
|
| 263 | - $emails->__set( 'from_email', $from_email ); |
|
| 264 | - $emails->__set( 'headers', $headers ); |
|
| 265 | - $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) ); |
|
| 262 | + $emails->__set('from_name', $from_name); |
|
| 263 | + $emails->__set('from_email', $from_email); |
|
| 264 | + $emails->__set('headers', $headers); |
|
| 265 | + $emails->__set('heading', __('User - Donor Profile Disconnection', 'give')); |
|
| 266 | 266 | |
| 267 | - $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) ); |
|
| 267 | + $emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message)); |
|
| 268 | 268 | |
| 269 | 269 | } |
@@ -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 | |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return string $message Fully formatted message |
| 44 | 44 | */ |
| 45 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
| 46 | - return give_do_email_tags( $message, $payment_id ); |
|
| 45 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
| 46 | + return give_do_email_tags($message, $payment_id); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -57,45 +57,45 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return string $message Fully formatted message |
| 59 | 59 | */ |
| 60 | -function give_email_preview_template_tags( $message ) { |
|
| 60 | +function give_email_preview_template_tags($message) { |
|
| 61 | 61 | |
| 62 | - $price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) ); |
|
| 62 | + $price = give_currency_filter(give_format_amount(10.50, array('sanitize' => false))); |
|
| 63 | 63 | |
| 64 | 64 | $gateway = 'PayPal'; |
| 65 | 65 | |
| 66 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
| 66 | + $receipt_id = strtolower(md5(uniqid())); |
|
| 67 | 67 | |
| 68 | - $payment_id = rand( 1, 100 ); |
|
| 69 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id ), give_get_history_page_uri() ) ); |
|
| 68 | + $payment_id = rand(1, 100); |
|
| 69 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id), give_get_history_page_uri())); |
|
| 70 | 70 | |
| 71 | 71 | $receipt_link = sprintf( |
| 72 | 72 | '<a href="%1$s">%2$s</a>', |
| 73 | 73 | $receipt_link_url, |
| 74 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
| 74 | + esc_html__('View the receipt in your browser »', 'give') |
|
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | 77 | // Set user. |
| 78 | 78 | $user = wp_get_current_user(); |
| 79 | 79 | |
| 80 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
| 81 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
| 82 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
| 83 | - $message = str_replace( '{user_email}', $user->user_email, $message ); |
|
| 84 | - $message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message ); |
|
| 85 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
| 86 | - $message = str_replace( '{amount}', $price, $message ); |
|
| 87 | - $message = str_replace( '{price}', $price, $message ); |
|
| 88 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
| 89 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
| 90 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
| 91 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
| 92 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
| 93 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
| 94 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
| 95 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
| 96 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
| 97 | - |
|
| 98 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
| 80 | + $message = str_replace('{name}', $user->display_name, $message); |
|
| 81 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
| 82 | + $message = str_replace('{username}', $user->user_login, $message); |
|
| 83 | + $message = str_replace('{user_email}', $user->user_email, $message); |
|
| 84 | + $message = str_replace('{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message); |
|
| 85 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
| 86 | + $message = str_replace('{amount}', $price, $message); |
|
| 87 | + $message = str_replace('{price}', $price, $message); |
|
| 88 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
| 89 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
| 90 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
| 91 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
| 92 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
| 93 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
| 94 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
| 95 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
| 96 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
| 97 | + |
|
| 98 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return array |
| 113 | 113 | */ |
| 114 | -function give_email_preview_buttons_callback( $field ) { |
|
| 115 | - $field_id = str_replace( '_preview_buttons', '', $field['id'] ); |
|
| 114 | +function give_email_preview_buttons_callback($field) { |
|
| 115 | + $field_id = str_replace('_preview_buttons', '', $field['id']); |
|
| 116 | 116 | |
| 117 | 117 | ob_start(); |
| 118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | '<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>', |
| 121 | 121 | wp_nonce_url( |
| 122 | 122 | add_query_arg( |
| 123 | - array( 'give_action' => 'preview_email', 'email_type' => $field_id ), |
|
| 123 | + array('give_action' => 'preview_email', 'email_type' => $field_id), |
|
| 124 | 124 | home_url() |
| 125 | 125 | ), 'give-preview-email' |
| 126 | 126 | ), |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | echo sprintf( |
| 131 | 131 | ' <a href="%1$s" aria-label="%2$s" class="button-secondary">%3$s</a>', |
| 132 | 132 | wp_nonce_url( |
| 133 | - add_query_arg( array( |
|
| 133 | + add_query_arg(array( |
|
| 134 | 134 | 'give_action' => 'send_preview_email', |
| 135 | 135 | 'email_type' => $field_id, |
| 136 | 136 | 'give-message' => 'sent-test-email', |
| 137 | - ) ), 'give-send-preview-email' ), |
|
| 138 | - esc_attr__( 'Send Test Email.', 'give' ), |
|
| 139 | - esc_html__( 'Send Test Email', 'give' ) |
|
| 137 | + )), 'give-send-preview-email' ), |
|
| 138 | + esc_attr__('Send Test Email.', 'give'), |
|
| 139 | + esc_html__('Send Test Email', 'give') |
|
| 140 | 140 | ); |
| 141 | 141 | |
| 142 | 142 | echo ob_get_clean(); |
@@ -155,28 +155,28 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | //Payment receipt switcher |
| 157 | 157 | $payment_count = give_count_payments()->publish; |
| 158 | - $payment_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' ); |
|
| 158 | + $payment_id = give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id'); |
|
| 159 | 159 | |
| 160 | - if ( $payment_count <= 0 ) { |
|
| 160 | + if ($payment_count <= 0) { |
|
| 161 | 161 | return false; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | //Get payments. |
| 165 | - $payments = new Give_Payments_Query( array( |
|
| 165 | + $payments = new Give_Payments_Query(array( |
|
| 166 | 166 | 'number' => 100, |
| 167 | - ) ); |
|
| 167 | + )); |
|
| 168 | 168 | $payments = $payments->get_payments(); |
| 169 | 169 | $options = array(); |
| 170 | 170 | |
| 171 | 171 | // Default option. |
| 172 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
| 172 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
| 173 | 173 | |
| 174 | 174 | //Provide nice human readable options. |
| 175 | - if ( $payments ) { |
|
| 176 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
| 177 | - foreach ( $payments as $payment ) { |
|
| 175 | + if ($payments) { |
|
| 176 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
| 177 | + foreach ($payments as $payment) { |
|
| 178 | 178 | |
| 179 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
| 179 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -185,27 +185,27 @@ discard block |
||
| 185 | 185 | $transaction_header = '<div style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;">'; |
| 186 | 186 | |
| 187 | 187 | // Remove payment id query param if set from request url. |
| 188 | - $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); |
|
| 188 | + $request_url_data = wp_parse_url($_SERVER['REQUEST_URI']); |
|
| 189 | 189 | $query = $request_url_data['query']; |
| 190 | - $query = remove_query_arg( array( 'preview_id' ), $query ); |
|
| 190 | + $query = remove_query_arg(array('preview_id'), $query); |
|
| 191 | 191 | |
| 192 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); |
|
| 192 | + $request_url = home_url('/?'.str_replace('', '', $query)); |
|
| 193 | 193 | |
| 194 | 194 | $transaction_header .= '<script> |
| 195 | 195 | function change_preview(){ |
| 196 | 196 | var transactions = document.getElementById("give_preview_email_payment_id"); |
| 197 | 197 | var selected_trans = transactions.options[transactions.selectedIndex]; |
| 198 | 198 | if (selected_trans){ |
| 199 | - var url_string = "' . $request_url . '&preview_id=" + selected_trans.value; |
|
| 199 | + var url_string = "' . $request_url.'&preview_id=" + selected_trans.value; |
|
| 200 | 200 | window.location = url_string; |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | </script>'; |
| 204 | 204 | |
| 205 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>'; |
|
| 205 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>'; |
|
| 206 | 206 | |
| 207 | 207 | //The select field with 100 latest transactions |
| 208 | - $transaction_header .= Give()->html->select( array( |
|
| 208 | + $transaction_header .= Give()->html->select(array( |
|
| 209 | 209 | 'name' => 'preview_email_payment_id', |
| 210 | 210 | 'selected' => $payment_id, |
| 211 | 211 | 'id' => 'give_preview_email_payment_id', |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | 'select_atts' => 'onchange="change_preview()"', |
| 216 | 216 | 'show_option_all' => false, |
| 217 | 217 | 'show_option_none' => false, |
| 218 | - ) ); |
|
| 218 | + )); |
|
| 219 | 219 | |
| 220 | 220 | //Closing tag |
| 221 | 221 | $transaction_header .= '</div>'; |
| 222 | 222 | |
| 223 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
| 223 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
| 224 | 224 | |
| 225 | 225 | } |
| 226 | 226 | \ No newline at end of file |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @return static |
| 56 | 56 | */ |
| 57 | 57 | public static function get_instance() { |
| 58 | - if ( null === static::$instance ) { |
|
| 58 | + if (null === static::$instance) { |
|
| 59 | 59 | self::$instance = new static(); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @access public |
| 80 | 80 | */ |
| 81 | 81 | public function setup_hooks() { |
| 82 | - add_action( 'init', array( $this, 'load_translated_texts' ), 999 ); |
|
| 82 | + add_action('init', array($this, 'load_translated_texts'), 999); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return bool|WP_Error false on success otherwise WP_Error object |
| 112 | 112 | */ |
| 113 | - public static function add_text( $args = array() ) { |
|
| 113 | + public static function add_text($args = array()) { |
|
| 114 | 114 | $error = false; |
| 115 | 115 | |
| 116 | 116 | // Set text params. |
@@ -126,43 +126,43 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | try { |
| 128 | 128 | // Check for errors. |
| 129 | - if ( empty( $args['text'] ) ) { |
|
| 129 | + if (empty($args['text'])) { |
|
| 130 | 130 | /* @var WP_Error $error */ |
| 131 | - $error = new WP_Error( 'EMPTY_TEXT', __( 'Empty string is not allowed.', 'give' ), $args ); |
|
| 132 | - throw new Exception( $error->get_error_message( 'EMPTY_TEXT' ) ); |
|
| 131 | + $error = new WP_Error('EMPTY_TEXT', __('Empty string is not allowed.', 'give'), $args); |
|
| 132 | + throw new Exception($error->get_error_message('EMPTY_TEXT')); |
|
| 133 | 133 | |
| 134 | - } elseif ( empty( $args['id'] ) ) { |
|
| 134 | + } elseif (empty($args['id'])) { |
|
| 135 | 135 | /* @var WP_Error $error */ |
| 136 | - $error = new WP_Error( 'EMPTY_ID', __( 'Empty ID is not allowed.', 'give' ), $args ); |
|
| 137 | - throw new Exception( $error->get_error_message( 'EMPTY_ID' ) ); |
|
| 136 | + $error = new WP_Error('EMPTY_ID', __('Empty ID is not allowed.', 'give'), $args); |
|
| 137 | + throw new Exception($error->get_error_message('EMPTY_ID')); |
|
| 138 | 138 | |
| 139 | 139 | } elseif ( |
| 140 | - empty( $args['group'] ) && |
|
| 141 | - array_key_exists( $args['id'], self::$text_configs ) |
|
| 140 | + empty($args['group']) && |
|
| 141 | + array_key_exists($args['id'], self::$text_configs) |
|
| 142 | 142 | ) { |
| 143 | 143 | /* @var WP_Error $error */ |
| 144 | - $error = new WP_Error( 'TEXT_ID_ALREADY_EXIST', __( 'Text ID without group already exist.', 'give' ), $args ); |
|
| 145 | - throw new Exception( $error->get_error_message( 'TEXT_ID_ALREADY_EXIST' ) ); |
|
| 144 | + $error = new WP_Error('TEXT_ID_ALREADY_EXIST', __('Text ID without group already exist.', 'give'), $args); |
|
| 145 | + throw new Exception($error->get_error_message('TEXT_ID_ALREADY_EXIST')); |
|
| 146 | 146 | |
| 147 | 147 | } elseif ( |
| 148 | - ! empty( $args['group'] ) && |
|
| 149 | - ! empty( self::$text_configs[ $args['group'] ] ) && |
|
| 150 | - array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) |
|
| 148 | + ! empty($args['group']) && |
|
| 149 | + ! empty(self::$text_configs[$args['group']]) && |
|
| 150 | + array_key_exists($args['id'], self::$text_configs[$args['group']]) |
|
| 151 | 151 | ) { |
| 152 | 152 | /* @var WP_Error $error */ |
| 153 | - $error = new WP_Error( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __( 'Text ID with in group already exist.', 'give' ), $args ); |
|
| 154 | - throw new Exception( $error->get_error_message( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST' ) ); |
|
| 153 | + $error = new WP_Error('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __('Text ID with in group already exist.', 'give'), $args); |
|
| 154 | + throw new Exception($error->get_error_message('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST')); |
|
| 155 | 155 | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Add text. |
| 159 | - if ( ! empty( $args['group'] ) ) { |
|
| 160 | - self::$text_configs[ $args['group'] ][ $args['id'] ] = $args; |
|
| 159 | + if ( ! empty($args['group'])) { |
|
| 160 | + self::$text_configs[$args['group']][$args['id']] = $args; |
|
| 161 | 161 | } else { |
| 162 | - self::$text_configs[ $args['id'] ] = $args; |
|
| 162 | + self::$text_configs[$args['id']] = $args; |
|
| 163 | 163 | } |
| 164 | - } catch ( Exception $e ) { |
|
| 165 | - error_log( $e->getMessage() ); |
|
| 164 | + } catch (Exception $e) { |
|
| 165 | + error_log($e->getMessage()); |
|
| 166 | 166 | }// End try(). |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @since 2.0 |
| 172 | 172 | */ |
| 173 | - self::$text_configs = apply_filters( 'give_texts', self::$text_configs ); |
|
| 173 | + self::$text_configs = apply_filters('give_texts', self::$text_configs); |
|
| 174 | 174 | |
| 175 | 175 | return $error; |
| 176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - public static function add_label( $args = array() ) { |
|
| 188 | + public static function add_label($args = array()) { |
|
| 189 | 189 | // Set text params. |
| 190 | 190 | $args = wp_parse_args( |
| 191 | 191 | $args, |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $args['type'] = 'label'; |
| 200 | 200 | $args['id'] = "{$args['id']}_label"; |
| 201 | 201 | |
| 202 | - return self::add_text( $args ); |
|
| 202 | + return self::add_text($args); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return string |
| 214 | 214 | */ |
| 215 | - public static function add_tooltip( $args = array() ) { |
|
| 215 | + public static function add_tooltip($args = array()) { |
|
| 216 | 216 | // Set text params. |
| 217 | 217 | $args = wp_parse_args( |
| 218 | 218 | $args, |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $args['type'] = 'tooltip'; |
| 227 | 227 | $args['id'] = "{$args['id']}_tooltip"; |
| 228 | 228 | |
| 229 | - return self::add_text( $args ); |
|
| 229 | + return self::add_text($args); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @return string |
| 241 | 241 | */ |
| 242 | - public static function add_translation( $args = array() ) { |
|
| 242 | + public static function add_translation($args = array()) { |
|
| 243 | 243 | $args = wp_parse_args( |
| 244 | 244 | $args, |
| 245 | 245 | array( |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | ); |
| 251 | 251 | |
| 252 | 252 | // Bailout. |
| 253 | - if ( empty( $args['id'] ) ) { |
|
| 253 | + if (empty($args['id'])) { |
|
| 254 | 254 | return; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if ( ! empty( $args['group'] ) ) { |
|
| 258 | - self::$text_translations[ $args['group'] ][ $args['id'] ] = $args['text']; |
|
| 257 | + if ( ! empty($args['group'])) { |
|
| 258 | + self::$text_translations[$args['group']][$args['id']] = $args['text']; |
|
| 259 | 259 | } else { |
| 260 | - self::$text_translations[ $args['id'] ] = $args['text']; |
|
| 260 | + self::$text_translations[$args['id']] = $args['text']; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -273,12 +273,12 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return string |
| 275 | 275 | */ |
| 276 | - public static function add_label_translation( $id, $group = '', $text = '' ) { |
|
| 277 | - return self::get_text( array( |
|
| 276 | + public static function add_label_translation($id, $group = '', $text = '') { |
|
| 277 | + return self::get_text(array( |
|
| 278 | 278 | 'id' => "{$id}_label", |
| 279 | 279 | 'group' => $group, |
| 280 | 280 | 'text' => $text, |
| 281 | - ) ); |
|
| 281 | + )); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -293,12 +293,12 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return string |
| 295 | 295 | */ |
| 296 | - public static function add_tooltip_translation( $id, $group = '', $text = '' ) { |
|
| 297 | - return self::get_text( array( |
|
| 296 | + public static function add_tooltip_translation($id, $group = '', $text = '') { |
|
| 297 | + return self::get_text(array( |
|
| 298 | 298 | 'id' => "{$id}_label", |
| 299 | 299 | 'group' => $group, |
| 300 | 300 | 'text' => $text, |
| 301 | - ) ); |
|
| 301 | + )); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -312,12 +312,12 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return string |
| 314 | 314 | */ |
| 315 | - public static function get_label( $id, $group = '' ) { |
|
| 316 | - return self::get_text( array( |
|
| 315 | + public static function get_label($id, $group = '') { |
|
| 316 | + return self::get_text(array( |
|
| 317 | 317 | 'id' => "{$id}_label", |
| 318 | 318 | 'group' => $group, |
| 319 | 319 | 'type' => 'label', |
| 320 | - ) ); |
|
| 320 | + )); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -331,12 +331,12 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return string |
| 333 | 333 | */ |
| 334 | - public static function get_tooltip( $id, $group = '' ) { |
|
| 335 | - return self::get_text( array( |
|
| 334 | + public static function get_tooltip($id, $group = '') { |
|
| 335 | + return self::get_text(array( |
|
| 336 | 336 | 'id' => "{$id}_tooltip", |
| 337 | 337 | 'group' => $group, |
| 338 | 338 | 'type' => 'tooltip', |
| 339 | - ) ); |
|
| 339 | + )); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -349,11 +349,11 @@ discard block |
||
| 349 | 349 | * |
| 350 | 350 | * @return string |
| 351 | 351 | */ |
| 352 | - public static function get_text( $args = array() ) { |
|
| 352 | + public static function get_text($args = array()) { |
|
| 353 | 353 | $text = ''; |
| 354 | 354 | |
| 355 | 355 | // Bailout. |
| 356 | - if ( empty( $args ) ) { |
|
| 356 | + if (empty($args)) { |
|
| 357 | 357 | return $text; |
| 358 | 358 | } |
| 359 | 359 | |
@@ -369,40 +369,40 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | // Check if text exist. |
| 371 | 371 | if ( |
| 372 | - empty( $args['id'] ) || |
|
| 373 | - ( empty( $args['group'] ) && ! array_key_exists( $args['id'], self::$text_configs ) ) || |
|
| 374 | - ( ! empty( $args['group'] ) && ! empty( self::$text_configs[ $args['group'] ] ) && ! array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) ) |
|
| 372 | + empty($args['id']) || |
|
| 373 | + (empty($args['group']) && ! array_key_exists($args['id'], self::$text_configs)) || |
|
| 374 | + ( ! empty($args['group']) && ! empty(self::$text_configs[$args['group']]) && ! array_key_exists($args['id'], self::$text_configs[$args['group']])) |
|
| 375 | 375 | ) { |
| 376 | 376 | return $text; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Get text value. |
| 380 | 380 | if ( |
| 381 | - ! empty( $args['group'] ) && |
|
| 382 | - array_key_exists( $args['group'], self::$text_configs ) |
|
| 381 | + ! empty($args['group']) && |
|
| 382 | + array_key_exists($args['group'], self::$text_configs) |
|
| 383 | 383 | ) { |
| 384 | - $text = self::$text_configs[ $args['group'] ][ $args['id'] ]['text']; |
|
| 384 | + $text = self::$text_configs[$args['group']][$args['id']]['text']; |
|
| 385 | 385 | |
| 386 | 386 | // Get translated text if exist. |
| 387 | 387 | if ( |
| 388 | - ! empty( self::$text_translations ) && |
|
| 389 | - ! empty( self::$text_translations[ $args['group'] ] ) && |
|
| 390 | - array_key_exists( $args['id'], self::$text_translations[ $args['group'] ] ) |
|
| 388 | + ! empty(self::$text_translations) && |
|
| 389 | + ! empty(self::$text_translations[$args['group']]) && |
|
| 390 | + array_key_exists($args['id'], self::$text_translations[$args['group']]) |
|
| 391 | 391 | ) { |
| 392 | - $text = self::$text_translations[ $args['group'] ][ $args['id'] ]; |
|
| 392 | + $text = self::$text_translations[$args['group']][$args['id']]; |
|
| 393 | 393 | } |
| 394 | 394 | } elseif ( |
| 395 | - empty( $args['group'] ) && |
|
| 396 | - array_key_exists( $args['id'], self::$text_configs ) |
|
| 395 | + empty($args['group']) && |
|
| 396 | + array_key_exists($args['id'], self::$text_configs) |
|
| 397 | 397 | ) { |
| 398 | - $text = self::$text_configs[ $args['id'] ]['text']; |
|
| 398 | + $text = self::$text_configs[$args['id']]['text']; |
|
| 399 | 399 | |
| 400 | 400 | // Get translated text if exist. |
| 401 | 401 | if ( |
| 402 | - ! empty( self::$text_translations ) && |
|
| 403 | - array_key_exists( $args['id'], self::$text_translations ) |
|
| 402 | + ! empty(self::$text_translations) && |
|
| 403 | + array_key_exists($args['id'], self::$text_translations) |
|
| 404 | 404 | ) { |
| 405 | - $text = self::$text_translations[ $args['id'] ]; |
|
| 405 | + $text = self::$text_translations[$args['id']]; |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @since 2.0 |
| 413 | 413 | */ |
| 414 | - $text = apply_filters( 'give_text', $text, $args, self::$text_configs, self::$text_translations ); |
|
| 414 | + $text = apply_filters('give_text', $text, $args, self::$text_configs, self::$text_translations); |
|
| 415 | 415 | |
| 416 | 416 | return $text; |
| 417 | 417 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @since 1.0 |
| 21 | 21 | */ |
| 22 | -class Give_Forms_Widget extends WP_Widget{ |
|
| 22 | +class Give_Forms_Widget extends WP_Widget { |
|
| 23 | 23 | /** |
| 24 | 24 | * The widget class name |
| 25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * Instantiate the class |
| 32 | 32 | */ |
| 33 | - public function __construct(){ |
|
| 34 | - $this->self = get_class( $this ); |
|
| 33 | + public function __construct() { |
|
| 34 | + $this->self = get_class($this); |
|
| 35 | 35 | |
| 36 | 36 | parent::__construct( |
| 37 | - strtolower( $this->self ), |
|
| 38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
| 37 | + strtolower($this->self), |
|
| 38 | + esc_html__('Give - Donation Form', 'give'), |
|
| 39 | 39 | array( |
| 40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
| 40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
| 45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
| 44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
| 45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -52,19 +52,19 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | - public function admin_widget_scripts( $hook ){ |
|
| 55 | + public function admin_widget_scripts($hook) { |
|
| 56 | 56 | // Directories of assets |
| 57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
| 58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
| 59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
| 57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
| 58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
| 59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
| 60 | 60 | |
| 61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
| 62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 63 | 63 | |
| 64 | 64 | // Widget Script |
| 65 | - if ( $hook == 'widgets.php' ) { |
|
| 65 | + if ($hook == 'widgets.php') { |
|
| 66 | 66 | |
| 67 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
| 67 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * before_widget, and after_widget. |
| 76 | 76 | * @param array $instance The settings for the particular instance of the widget. |
| 77 | 77 | */ |
| 78 | - public function widget( $args, $instance ){ |
|
| 79 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
| 80 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
| 78 | + public function widget($args, $instance) { |
|
| 79 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 80 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
| 81 | 81 | |
| 82 | 82 | echo $args['before_widget']; |
| 83 | 83 | |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @since 1.0 |
| 88 | 88 | */ |
| 89 | - do_action( 'give_before_forms_widget' ); |
|
| 89 | + do_action('give_before_forms_widget'); |
|
| 90 | 90 | |
| 91 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
| 91 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
| 92 | 92 | |
| 93 | - give_get_donation_form( $instance ); |
|
| 93 | + give_get_donation_form($instance); |
|
| 94 | 94 | |
| 95 | 95 | echo $args['after_widget']; |
| 96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @since 1.0 |
| 101 | 101 | */ |
| 102 | - do_action( 'give_after_forms_widget' ); |
|
| 102 | + do_action('give_after_forms_widget'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | - public function form( $instance ){ |
|
| 112 | + public function form($instance) { |
|
| 113 | 113 | $defaults = array( |
| 114 | 114 | 'title' => '', |
| 115 | 115 | 'id' => '', |
@@ -119,84 +119,84 @@ discard block |
||
| 119 | 119 | 'continue_button_title' => '', |
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 122 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 123 | 123 | |
| 124 | 124 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
| 125 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
| 125 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
| 126 | 126 | |
| 127 | 127 | // Query Give Forms |
| 128 | 128 | $args = array( |
| 129 | 129 | 'post_type' => 'give_forms', |
| 130 | - 'posts_per_page' => - 1, |
|
| 130 | + 'posts_per_page' => -1, |
|
| 131 | 131 | 'post_status' => 'publish', |
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | - $give_forms = get_posts( $args ); |
|
| 134 | + $give_forms = get_posts($args); |
|
| 135 | 135 | ?> |
| 136 | 136 | <div class="give_forms_widget_container"> |
| 137 | 137 | |
| 138 | 138 | <?php // Widget: widget Title. ?> |
| 139 | 139 | <p> |
| 140 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
| 141 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
| 142 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
| 140 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
| 141 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
| 142 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
| 143 | 143 | </p> |
| 144 | 144 | |
| 145 | 145 | <?php // Widget: Give Form?> |
| 146 | 146 | <p> |
| 147 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
| 148 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
| 149 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
| 150 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
| 151 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
| 152 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option> |
|
| 147 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
| 148 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
| 149 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
| 150 | + <?php foreach ($give_forms as $give_form) { ?> |
|
| 151 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
| 152 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option> |
|
| 153 | 153 | <?php } ?> |
| 154 | 154 | </select><br> |
| 155 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
| 155 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
| 156 | 156 | </p> |
| 157 | 157 | |
| 158 | 158 | <?php // Widget: Display Style ?> |
| 159 | 159 | <p class="give_forms_display_style_setting_row"> |
| 160 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
| 161 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
| 162 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
| 163 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
| 164 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
| 160 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
| 161 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
| 162 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
| 163 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
| 164 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
| 165 | 165 | <small class="give-field-description"> |
| 166 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
| 166 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
| 167 | 167 | </small> |
| 168 | 168 | </p> |
| 169 | 169 | |
| 170 | 170 | <?php // Widget: Continue Button Title. ?> |
| 171 | 171 | <p class="give_forms_continue_button_title_setting_row"> |
| 172 | - <label for="<?php echo $this->get_field_id( 'continue_button_title' ); ?>"><?php esc_html_e( 'Button Text:', 'give' ); ?></label> |
|
| 173 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'continue_button_title' ); ?>" name="<?php echo $this->get_field_name( 'continue_button_title' ); ?>" value="<?php esc_attr_e( $instance['continue_button_title'] ); ?>" /><br> |
|
| 174 | - <small class="give-field-description"><?php esc_html_e( 'The button label for displaying the additional payment fields.', 'give' ); ?></small> |
|
| 172 | + <label for="<?php echo $this->get_field_id('continue_button_title'); ?>"><?php esc_html_e('Button Text:', 'give'); ?></label> |
|
| 173 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('continue_button_title'); ?>" name="<?php echo $this->get_field_name('continue_button_title'); ?>" value="<?php esc_attr_e($instance['continue_button_title']); ?>" /><br> |
|
| 174 | + <small class="give-field-description"><?php esc_html_e('The button label for displaying the additional payment fields.', 'give'); ?></small> |
|
| 175 | 175 | </p> |
| 176 | 176 | |
| 177 | 177 | <?php // Widget: Floating Labels ?> |
| 178 | 178 | <p> |
| 179 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
| 180 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
| 181 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
| 182 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
| 179 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
| 180 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
| 181 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
| 182 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
| 183 | 183 | <small class="give-field-description"> |
| 184 | 184 | <?php |
| 185 | 185 | printf( |
| 186 | 186 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
| 187 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
| 188 | - esc_url( 'http://docs.givewp.com/form-floating-labels' ) |
|
| 187 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
| 188 | + esc_url('http://docs.givewp.com/form-floating-labels') |
|
| 189 | 189 | ); |
| 190 | 190 | ?></small> |
| 191 | 191 | </p> |
| 192 | 192 | |
| 193 | 193 | <?php // Widget: Display Content ?> |
| 194 | 194 | <p> |
| 195 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
| 196 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
| 197 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
| 198 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
| 199 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
| 195 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
| 196 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
| 197 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
| 198 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
| 199 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
| 200 | 200 | </div> |
| 201 | 201 | <?php |
| 202 | 202 | } |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return void |
| 208 | 208 | */ |
| 209 | - function widget_init(){ |
|
| 210 | - register_widget( $this->self ); |
|
| 209 | + function widget_init() { |
|
| 210 | + register_widget($this->self); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return array |
| 220 | 220 | */ |
| 221 | - public function update( $new_instance, $old_instance ){ |
|
| 221 | + public function update($new_instance, $old_instance) { |
|
| 222 | 222 | $this->flush_widget_cache(); |
| 223 | 223 | |
| 224 | 224 | return $new_instance; |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return void |
| 231 | 231 | */ |
| 232 | - public function flush_widget_cache(){ |
|
| 233 | - wp_cache_delete( $this->self, 'widget' ); |
|
| 232 | + public function flush_widget_cache() { |
|
| 233 | + wp_cache_delete($this->self, 'widget'); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -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 | |
@@ -75,40 +75,40 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | function __construct() { |
| 77 | 77 | // Bailout. |
| 78 | - if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) { |
|
| 78 | + if (empty($this->supports) || ! $this->is_custom_meta_table_active()) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( in_array( 'add_post_metadata', $this->supports ) ) { |
|
| 83 | - add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 ); |
|
| 82 | + if (in_array('add_post_metadata', $this->supports)) { |
|
| 83 | + add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( in_array( 'get_post_metadata', $this->supports ) ) { |
|
| 87 | - add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 0, 4 ); |
|
| 86 | + if (in_array('get_post_metadata', $this->supports)) { |
|
| 87 | + add_filter('get_post_metadata', array($this, '__get_meta'), 0, 4); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( in_array( 'update_post_metadata', $this->supports ) ) { |
|
| 91 | - add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 ); |
|
| 90 | + if (in_array('update_post_metadata', $this->supports)) { |
|
| 91 | + add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( in_array( 'delete_post_metadata', $this->supports ) ) { |
|
| 95 | - add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 ); |
|
| 94 | + if (in_array('delete_post_metadata', $this->supports)) { |
|
| 95 | + add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( in_array( 'posts_where', $this->supports ) ) { |
|
| 99 | - add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 98 | + if (in_array('posts_where', $this->supports)) { |
|
| 99 | + add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( in_array( 'posts_join', $this->supports ) ) { |
|
| 103 | - add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 102 | + if (in_array('posts_join', $this->supports)) { |
|
| 103 | + add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( in_array( 'posts_groupby', $this->supports ) ) { |
|
| 107 | - add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 106 | + if (in_array('posts_groupby', $this->supports)) { |
|
| 107 | + add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ( in_array( 'posts_orderby', $this->supports ) ) { |
|
| 111 | - add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 110 | + if (in_array('posts_orderby', $this->supports)) { |
|
| 111 | + add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -126,16 +126,16 @@ discard block |
||
| 126 | 126 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
| 127 | 127 | * is true. |
| 128 | 128 | */ |
| 129 | - public function get_meta( $id = 0, $meta_key = '', $single = false ) { |
|
| 130 | - $id = $this->sanitize_id( $id ); |
|
| 129 | + public function get_meta($id = 0, $meta_key = '', $single = false) { |
|
| 130 | + $id = $this->sanitize_id($id); |
|
| 131 | 131 | |
| 132 | 132 | // Bailout. |
| 133 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 133 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 134 | 134 | return $this->check; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( $this->raw_result ) { |
|
| 138 | - if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) { |
|
| 137 | + if ($this->raw_result) { |
|
| 138 | + if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) { |
|
| 139 | 139 | $value = ''; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $this->raw_result = false; |
| 144 | 144 | |
| 145 | 145 | } else { |
| 146 | - $value = get_metadata( $this->meta_type, $id, $meta_key, $single ); |
|
| 146 | + $value = get_metadata($this->meta_type, $id, $meta_key, $single); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return $value; |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return int|bool False for failure. True for success. |
| 167 | 167 | */ |
| 168 | - public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
| 169 | - $id = $this->sanitize_id( $id ); |
|
| 168 | + public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
| 169 | + $id = $this->sanitize_id($id); |
|
| 170 | 170 | |
| 171 | 171 | // Bailout. |
| 172 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 172 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 173 | 173 | return $this->check; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
|
| 176 | + $meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique); |
|
| 177 | 177 | |
| 178 | - if ( $meta_id ) { |
|
| 179 | - $this->delete_cache( $id ); |
|
| 178 | + if ($meta_id) { |
|
| 179 | + $this->delete_cache($id); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | return $meta_id; |
@@ -202,18 +202,18 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @return int|bool False on failure, true if success. |
| 204 | 204 | */ |
| 205 | - public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 206 | - $id = $this->sanitize_id( $id ); |
|
| 205 | + public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
| 206 | + $id = $this->sanitize_id($id); |
|
| 207 | 207 | |
| 208 | 208 | // Bailout. |
| 209 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 209 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 210 | 210 | return $this->check; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
|
| 213 | + $meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value); |
|
| 214 | 214 | |
| 215 | - if ( $meta_id ) { |
|
| 216 | - $this->delete_cache( $id ); |
|
| 215 | + if ($meta_id) { |
|
| 216 | + $this->delete_cache($id); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | return $meta_id; |
@@ -236,18 +236,18 @@ discard block |
||
| 236 | 236 | * |
| 237 | 237 | * @return bool False for failure. True for success. |
| 238 | 238 | */ |
| 239 | - public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
|
| 240 | - $id = $this->sanitize_id( $id ); |
|
| 239 | + public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') { |
|
| 240 | + $id = $this->sanitize_id($id); |
|
| 241 | 241 | |
| 242 | 242 | // Bailout. |
| 243 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 243 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 244 | 244 | return $this->check; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
|
| 247 | + $is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all); |
|
| 248 | 248 | |
| 249 | - if ( $is_meta_deleted ) { |
|
| 250 | - $this->delete_cache( $id ); |
|
| 249 | + if ($is_meta_deleted) { |
|
| 250 | + $this->delete_cache($id); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | return $is_meta_deleted; |
@@ -264,41 +264,41 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @return string |
| 266 | 266 | */ |
| 267 | - public function __rename_meta_table_name_in_query( $clause, $wp_query ) { |
|
| 267 | + public function __rename_meta_table_name_in_query($clause, $wp_query) { |
|
| 268 | 268 | global $wpdb; |
| 269 | 269 | |
| 270 | 270 | // Add new table to sql query. |
| 271 | - if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) { |
|
| 272 | - $clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause ); |
|
| 273 | - $clause = str_replace( $wpdb->postmeta, $this->table_name, $clause ); |
|
| 271 | + if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) { |
|
| 272 | + $clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause); |
|
| 273 | + $clause = str_replace($wpdb->postmeta, $this->table_name, $clause); |
|
| 274 | 274 | |
| 275 | - switch( current_filter() ) { |
|
| 275 | + switch (current_filter()) { |
|
| 276 | 276 | case 'posts_join': |
| 277 | - $joins = array( 'INNER JOIN', 'LEFT JOIN' ); |
|
| 277 | + $joins = array('INNER JOIN', 'LEFT JOIN'); |
|
| 278 | 278 | |
| 279 | - foreach ( $joins as $join ) { |
|
| 280 | - if( false !== strpos( $clause, $join ) ) { |
|
| 281 | - $clause = explode( $join, $clause ); |
|
| 279 | + foreach ($joins as $join) { |
|
| 280 | + if (false !== strpos($clause, $join)) { |
|
| 281 | + $clause = explode($join, $clause); |
|
| 282 | 282 | |
| 283 | - foreach ( $clause as $key => $clause_part ) { |
|
| 284 | - if( empty( $clause_part ) ) { |
|
| 283 | + foreach ($clause as $key => $clause_part) { |
|
| 284 | + if (empty($clause_part)) { |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - preg_match( '/wp_give_paymentmeta AS (.*) ON/', $clause_part, $alias_table_name ); |
|
| 288 | + preg_match('/wp_give_paymentmeta AS (.*) ON/', $clause_part, $alias_table_name); |
|
| 289 | 289 | |
| 290 | - if( isset( $alias_table_name[1] ) ) { |
|
| 291 | - $clause[$key] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part ); |
|
| 290 | + if (isset($alias_table_name[1])) { |
|
| 291 | + $clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - $clause = implode( "{$join} ", $clause ); |
|
| 295 | + $clause = implode("{$join} ", $clause); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | break; |
| 299 | 299 | |
| 300 | 300 | case 'posts_where': |
| 301 | - $clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( "mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id" ), $clause ); |
|
| 301 | + $clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array("mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id"), $clause); |
|
| 302 | 302 | break; |
| 303 | 303 | } |
| 304 | 304 | } |
@@ -317,19 +317,19 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return bool |
| 319 | 319 | */ |
| 320 | - protected function is_post_type_query( $wp_query ) { |
|
| 320 | + protected function is_post_type_query($wp_query) { |
|
| 321 | 321 | $status = false; |
| 322 | 322 | |
| 323 | 323 | // Check if it is payment query. |
| 324 | - if ( ! empty( $wp_query->query['post_type'] ) ) { |
|
| 324 | + if ( ! empty($wp_query->query['post_type'])) { |
|
| 325 | 325 | if ( |
| 326 | - is_string( $wp_query->query['post_type'] ) && |
|
| 326 | + is_string($wp_query->query['post_type']) && |
|
| 327 | 327 | $this->post_type === $wp_query->query['post_type'] |
| 328 | 328 | ) { |
| 329 | 329 | $status = true; |
| 330 | 330 | } elseif ( |
| 331 | - is_array( $wp_query->query['post_type'] ) && |
|
| 332 | - in_array( $this->post_type, $wp_query->query['post_type'] ) |
|
| 331 | + is_array($wp_query->query['post_type']) && |
|
| 332 | + in_array($this->post_type, $wp_query->query['post_type']) |
|
| 333 | 333 | ) { |
| 334 | 334 | $status = true; |
| 335 | 335 | } |
@@ -348,8 +348,8 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @return bool |
| 350 | 350 | */ |
| 351 | - protected function is_valid_post_type( $ID ) { |
|
| 352 | - return $ID && ( $this->post_type === get_post_type( $ID ) ); |
|
| 351 | + protected function is_valid_post_type($ID) { |
|
| 352 | + return $ID && ($this->post_type === get_post_type($ID)); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @return void |
| 377 | 377 | */ |
| 378 | - private function delete_cache( $id, $meta_type = '' ) { |
|
| 379 | - $meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type; |
|
| 378 | + private function delete_cache($id, $meta_type = '') { |
|
| 379 | + $meta_type = empty($meta_type) ? $this->meta_type : $meta_type; |
|
| 380 | 380 | |
| 381 | 381 | $group = array( |
| 382 | 382 | // 'form' => 'give-forms', |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | // 'log' => 'give-logs', |
| 387 | 387 | ); |
| 388 | 388 | |
| 389 | - if ( array_key_exists( $meta_type, $group ) ) { |
|
| 390 | - Give_Cache::delete_group( $id, $group[ $meta_type ] ); |
|
| 389 | + if (array_key_exists($meta_type, $group)) { |
|
| 390 | + Give_Cache::delete_group($id, $group[$meta_type]); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | * |
| 403 | 403 | * @return mixed |
| 404 | 404 | */ |
| 405 | - public function __call( $name, $arguments ) { |
|
| 406 | - switch ( $name ) { |
|
| 405 | + public function __call($name, $arguments) { |
|
| 406 | + switch ($name) { |
|
| 407 | 407 | case '__add_meta': |
| 408 | 408 | $this->check = $arguments[0]; |
| 409 | 409 | $id = $arguments[1]; |
@@ -412,11 +412,11 @@ discard block |
||
| 412 | 412 | $unique = $arguments[4]; |
| 413 | 413 | |
| 414 | 414 | // Bailout. |
| 415 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 415 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 416 | 416 | return $this->check; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - return $this->add_meta( $id, $meta_key, $meta_value, $unique ); |
|
| 419 | + return $this->add_meta($id, $meta_key, $meta_value, $unique); |
|
| 420 | 420 | |
| 421 | 421 | case '__get_meta': |
| 422 | 422 | $this->check = $arguments[0]; |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | $single = $arguments[3]; |
| 426 | 426 | |
| 427 | 427 | // Bailout. |
| 428 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 428 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 429 | 429 | return $this->check; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $this->raw_result = true; |
| 433 | 433 | |
| 434 | - return $this->get_meta( $id, $meta_key, $single ); |
|
| 434 | + return $this->get_meta($id, $meta_key, $single); |
|
| 435 | 435 | |
| 436 | 436 | case '__update_meta': |
| 437 | 437 | $this->check = $arguments[0]; |
@@ -440,11 +440,11 @@ discard block |
||
| 440 | 440 | $meta_value = $arguments[3]; |
| 441 | 441 | |
| 442 | 442 | // Bailout. |
| 443 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 443 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 444 | 444 | return $this->check; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - return $this->update_meta( $id, $meta_key, $meta_value ); |
|
| 447 | + return $this->update_meta($id, $meta_key, $meta_value); |
|
| 448 | 448 | |
| 449 | 449 | case '__delete_meta': |
| 450 | 450 | $this->check = $arguments[0]; |
@@ -454,11 +454,11 @@ discard block |
||
| 454 | 454 | $delete_all = $arguments[3]; |
| 455 | 455 | |
| 456 | 456 | // Bailout. |
| 457 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 457 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 458 | 458 | return $this->check; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all ); |
|
| 461 | + return $this->delete_meta($id, $meta_key, $meta_value, $delete_all); |
|
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @category Class |
| 12 | 12 | * @author WordImpress |
| 13 | 13 | */ |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | * and data exists in the queue. |
| 43 | 43 | */ |
| 44 | 44 | public function handle_cron_healthcheck() { |
| 45 | - if ( $this->is_process_running() ) { |
|
| 45 | + if ($this->is_process_running()) { |
|
| 46 | 46 | // Background process already running. |
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ( $this->is_queue_empty() ) { |
|
| 50 | + if ($this->is_queue_empty()) { |
|
| 51 | 51 | // No data to process. |
| 52 | 52 | $this->clear_scheduled_event(); |
| 53 | 53 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | * Schedule fallback event. |
| 62 | 62 | */ |
| 63 | 63 | protected function schedule_event() { |
| 64 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { |
|
| 65 | - wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
| 64 | + if ( ! wp_next_scheduled($this->cron_hook_identifier)) { |
|
| 65 | + wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return mixed |
| 80 | 80 | */ |
| 81 | - protected function task( $update ) { |
|
| 82 | - if ( empty( $update ) ) { |
|
| 81 | + protected function task($update) { |
|
| 82 | + if (empty($update)) { |
|
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -93,29 +93,29 @@ discard block |
||
| 93 | 93 | 'update_info' => $update, |
| 94 | 94 | 'step' => 1, |
| 95 | 95 | 'update' => 1, |
| 96 | - 'heading' => sprintf( 'Update %s of {update_count}', 1 ), |
|
| 96 | + 'heading' => sprintf('Update %s of {update_count}', 1), |
|
| 97 | 97 | 'percentage' => $give_updates->percentage, |
| 98 | 98 | ) |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | 101 | // Continuously skip update if previous update does not complete yet. |
| 102 | - if( |
|
| 102 | + if ( |
|
| 103 | 103 | $resume_update['update_info']['id'] !== $update['id'] && |
| 104 | - ! give_has_upgrade_completed( $resume_update['update_info']['id'] ) |
|
| 104 | + ! give_has_upgrade_completed($resume_update['update_info']['id']) |
|
| 105 | 105 | ) { |
| 106 | 106 | return $update; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Set params. |
| 110 | 110 | $resume_update['update_info'] = $update; |
| 111 | - $give_updates->step = absint( $resume_update['step'] ); |
|
| 112 | - $give_updates->update = absint( $resume_update['update'] ); |
|
| 113 | - $is_parent_update_completed = $give_updates->is_parent_updates_completed( $update ); |
|
| 111 | + $give_updates->step = absint($resume_update['step']); |
|
| 112 | + $give_updates->update = absint($resume_update['update']); |
|
| 113 | + $is_parent_update_completed = $give_updates->is_parent_updates_completed($update); |
|
| 114 | 114 | |
| 115 | 115 | // Skip update if dependency update does not complete yet. |
| 116 | - if ( empty( $is_parent_update_completed ) ) { |
|
| 116 | + if (empty($is_parent_update_completed)) { |
|
| 117 | 117 | // @todo: set error when you have only one update with invalid dependency |
| 118 | - if ( ! is_null( $is_parent_update_completed ) ) { |
|
| 118 | + if ( ! is_null($is_parent_update_completed)) { |
|
| 119 | 119 | return $update; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | Give_Cache::disable(); |
| 127 | 127 | |
| 128 | 128 | // Run update. |
| 129 | - if ( is_array( $update['callback'] ) ) { |
|
| 129 | + if (is_array($update['callback'])) { |
|
| 130 | 130 | $update['callback'][0]->$update['callback'][1](); |
| 131 | 131 | } else { |
| 132 | 132 | $update['callback'](); |
@@ -135,21 +135,21 @@ discard block |
||
| 135 | 135 | // Set update info. |
| 136 | 136 | $doing_upgrade_args = array( |
| 137 | 137 | 'update_info' => $update, |
| 138 | - 'step' => ++ $give_updates->step, |
|
| 138 | + 'step' => ++$give_updates->step, |
|
| 139 | 139 | 'update' => $give_updates->update, |
| 140 | - 'heading' => sprintf( 'Update %s of %s', $give_updates->update, get_option( 'give_db_update_count' ) ), |
|
| 140 | + 'heading' => sprintf('Update %s of %s', $give_updates->update, get_option('give_db_update_count')), |
|
| 141 | 141 | 'percentage' => $give_updates->percentage, |
| 142 | 142 | 'total_percentage' => $give_updates->get_db_update_processing_percentage(), |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | 145 | // Cache upgrade. |
| 146 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
| 146 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
| 147 | 147 | |
| 148 | 148 | // Enable cache. |
| 149 | 149 | Give_Cache::enable(); |
| 150 | 150 | |
| 151 | 151 | // Check if current update completed or not. |
| 152 | - if ( give_has_upgrade_completed( $update['id'] ) ) { |
|
| 152 | + if (give_has_upgrade_completed($update['id'])) { |
|
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | protected function complete() { |
| 166 | 166 | parent::complete(); |
| 167 | 167 | |
| 168 | - delete_option( 'give_db_update_count' ); |
|
| 169 | - delete_option( 'give_doing_upgrade' ); |
|
| 170 | - add_option( 'give_show_db_upgrade_complete_notice', 1, '', 'no' ); |
|
| 168 | + delete_option('give_db_update_count'); |
|
| 169 | + delete_option('give_doing_upgrade'); |
|
| 170 | + add_option('give_show_db_upgrade_complete_notice', 1, '', 'no'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -176,18 +176,18 @@ discard block |
||
| 176 | 176 | * @return int |
| 177 | 177 | */ |
| 178 | 178 | protected function get_memory_limit() { |
| 179 | - if ( function_exists( 'ini_get' ) ) { |
|
| 180 | - $memory_limit = ini_get( 'memory_limit' ); |
|
| 179 | + if (function_exists('ini_get')) { |
|
| 180 | + $memory_limit = ini_get('memory_limit'); |
|
| 181 | 181 | } else { |
| 182 | 182 | // Sensible default. |
| 183 | 183 | $memory_limit = '128M'; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ( ! $memory_limit || '-1' === $memory_limit ) { |
|
| 186 | + if ( ! $memory_limit || '-1' === $memory_limit) { |
|
| 187 | 187 | // Unlimited, set to 32GB. |
| 188 | 188 | $memory_limit = '32000M'; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - return intval( $memory_limit ) * 1024 * 1024; |
|
| 191 | + return intval($memory_limit) * 1024 * 1024; |
|
| 192 | 192 | } |
| 193 | 193 | } |
@@ -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 | |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | * @param bool $_id Post id. Default is false. |
| 338 | 338 | * @param array $_args Arguments passed. |
| 339 | 339 | */ |
| 340 | - public function __construct( $_id = false, $_args = array() ) { |
|
| 340 | + public function __construct($_id = false, $_args = array()) { |
|
| 341 | 341 | |
| 342 | - $donation_form = WP_Post::get_instance( $_id ); |
|
| 342 | + $donation_form = WP_Post::get_instance($_id); |
|
| 343 | 343 | |
| 344 | - return $this->setup_donation_form( $donation_form ); |
|
| 344 | + return $this->setup_donation_form($donation_form); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -354,23 +354,23 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return bool If the setup was successful or not. |
| 356 | 356 | */ |
| 357 | - private function setup_donation_form( $donation_form ) { |
|
| 357 | + private function setup_donation_form($donation_form) { |
|
| 358 | 358 | |
| 359 | - if ( ! is_object( $donation_form ) ) { |
|
| 359 | + if ( ! is_object($donation_form)) { |
|
| 360 | 360 | return false; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( ! is_a( $donation_form, 'WP_Post' ) ) { |
|
| 363 | + if ( ! is_a($donation_form, 'WP_Post')) { |
|
| 364 | 364 | return false; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( 'give_forms' !== $donation_form->post_type ) { |
|
| 367 | + if ('give_forms' !== $donation_form->post_type) { |
|
| 368 | 368 | return false; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - foreach ( $donation_form as $key => $value ) { |
|
| 371 | + foreach ($donation_form as $key => $value) { |
|
| 372 | 372 | |
| 373 | - switch ( $key ) { |
|
| 373 | + switch ($key) { |
|
| 374 | 374 | |
| 375 | 375 | default: |
| 376 | 376 | $this->$key = $value; |
@@ -394,16 +394,16 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return mixed |
| 396 | 396 | */ |
| 397 | - public function __get( $key ) { |
|
| 397 | + public function __get($key) { |
|
| 398 | 398 | |
| 399 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 399 | + if (method_exists($this, 'get_'.$key)) { |
|
| 400 | 400 | |
| 401 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 401 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 402 | 402 | |
| 403 | 403 | } else { |
| 404 | 404 | |
| 405 | 405 | /* translators: %s: property key */ |
| 406 | - return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 406 | + return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 407 | 407 | |
| 408 | 408 | } |
| 409 | 409 | |
@@ -419,30 +419,30 @@ discard block |
||
| 419 | 419 | * |
| 420 | 420 | * @return bool|int False if data isn't passed and class not instantiated for creation, or New Form ID. |
| 421 | 421 | */ |
| 422 | - public function create( $data = array() ) { |
|
| 422 | + public function create($data = array()) { |
|
| 423 | 423 | |
| 424 | - if ( $this->id != 0 ) { |
|
| 424 | + if ($this->id != 0) { |
|
| 425 | 425 | return false; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | $defaults = array( |
| 429 | 429 | 'post_type' => 'give_forms', |
| 430 | 430 | 'post_status' => 'draft', |
| 431 | - 'post_title' => __( 'New Donation Form', 'give' ), |
|
| 431 | + 'post_title' => __('New Donation Form', 'give'), |
|
| 432 | 432 | ); |
| 433 | 433 | |
| 434 | - $args = wp_parse_args( $data, $defaults ); |
|
| 434 | + $args = wp_parse_args($data, $defaults); |
|
| 435 | 435 | |
| 436 | 436 | /** |
| 437 | 437 | * Fired before a donation form is created |
| 438 | 438 | * |
| 439 | 439 | * @param array $args The post object arguments used for creation. |
| 440 | 440 | */ |
| 441 | - do_action( 'give_form_pre_create', $args ); |
|
| 441 | + do_action('give_form_pre_create', $args); |
|
| 442 | 442 | |
| 443 | - $id = wp_insert_post( $args, true ); |
|
| 443 | + $id = wp_insert_post($args, true); |
|
| 444 | 444 | |
| 445 | - $donation_form = WP_Post::get_instance( $id ); |
|
| 445 | + $donation_form = WP_Post::get_instance($id); |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * Fired after a donation form is created |
@@ -450,9 +450,9 @@ discard block |
||
| 450 | 450 | * @param int $id The post ID of the created item. |
| 451 | 451 | * @param array $args The post object arguments used for creation. |
| 452 | 452 | */ |
| 453 | - do_action( 'give_form_post_create', $id, $args ); |
|
| 453 | + do_action('give_form_post_create', $id, $args); |
|
| 454 | 454 | |
| 455 | - return $this->setup_donation_form( $donation_form ); |
|
| 455 | + return $this->setup_donation_form($donation_form); |
|
| 456 | 456 | |
| 457 | 457 | } |
| 458 | 458 | |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @return string Donation form name. |
| 478 | 478 | */ |
| 479 | 479 | public function get_name() { |
| 480 | - return get_the_title( $this->ID ); |
|
| 480 | + return get_the_title($this->ID); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | public function get_price() { |
| 492 | 492 | |
| 493 | - if ( ! isset( $this->price ) ) { |
|
| 493 | + if ( ! isset($this->price)) { |
|
| 494 | 494 | |
| 495 | 495 | $this->price = give_maybe_sanitize_amount( |
| 496 | 496 | give_get_meta( |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | ) |
| 501 | 501 | ); |
| 502 | 502 | |
| 503 | - if ( ! $this->price ) { |
|
| 503 | + if ( ! $this->price) { |
|
| 504 | 504 | $this->price = 0; |
| 505 | 505 | } |
| 506 | 506 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | * @param string $price The donation form price. |
| 515 | 515 | * @param string|int $id The form ID. |
| 516 | 516 | */ |
| 517 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
| 517 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
@@ -527,17 +527,17 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | public function get_minimum_price() { |
| 529 | 529 | |
| 530 | - if ( ! isset( $this->minimum_price ) ) { |
|
| 530 | + if ( ! isset($this->minimum_price)) { |
|
| 531 | 531 | |
| 532 | - $this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
| 532 | + $this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true); |
|
| 533 | 533 | |
| 534 | - if ( ! $this->is_custom_price_mode() ) { |
|
| 534 | + if ( ! $this->is_custom_price_mode()) { |
|
| 535 | 535 | $this->minimum_price = 0; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
| 540 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -550,9 +550,9 @@ discard block |
||
| 550 | 550 | */ |
| 551 | 551 | public function get_prices() { |
| 552 | 552 | |
| 553 | - if ( ! isset( $this->prices ) ) { |
|
| 553 | + if ( ! isset($this->prices)) { |
|
| 554 | 554 | |
| 555 | - $this->prices = give_get_meta( $this->ID, '_give_donation_levels', true ); |
|
| 555 | + $this->prices = give_get_meta($this->ID, '_give_donation_levels', true); |
|
| 556 | 556 | |
| 557 | 557 | } |
| 558 | 558 | |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * @param array $prices The array of mulit-level prices. |
| 565 | 565 | * @param int|string $ID The ID of the form. |
| 566 | 566 | */ |
| 567 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
| 567 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
| 568 | 568 | |
| 569 | 569 | } |
| 570 | 570 | |
@@ -578,21 +578,21 @@ discard block |
||
| 578 | 578 | */ |
| 579 | 579 | public function get_goal() { |
| 580 | 580 | |
| 581 | - if ( ! isset( $this->goal ) ) { |
|
| 581 | + if ( ! isset($this->goal)) { |
|
| 582 | 582 | |
| 583 | - if ( 'donation' === give_get_form_goal_format( $this->ID ) ) { |
|
| 584 | - $this->goal = give_get_meta( $this->ID, '_give_number_of_donation_goal', true ); |
|
| 583 | + if ('donation' === give_get_form_goal_format($this->ID)) { |
|
| 584 | + $this->goal = give_get_meta($this->ID, '_give_number_of_donation_goal', true); |
|
| 585 | 585 | } else { |
| 586 | - $this->goal = give_get_meta( $this->ID, '_give_set_goal', true ); |
|
| 586 | + $this->goal = give_get_meta($this->ID, '_give_set_goal', true); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ( ! $this->goal ) { |
|
| 589 | + if ( ! $this->goal) { |
|
| 590 | 590 | $this->goal = 0; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
| 595 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
| 596 | 596 | |
| 597 | 597 | } |
| 598 | 598 | |
@@ -606,10 +606,10 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | public function is_single_price_mode() { |
| 608 | 608 | |
| 609 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
| 609 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
| 610 | 610 | $ret = 0; |
| 611 | 611 | |
| 612 | - if ( empty( $option ) || $option === 'set' ) { |
|
| 612 | + if (empty($option) || $option === 'set') { |
|
| 613 | 613 | $ret = 1; |
| 614 | 614 | } |
| 615 | 615 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @param bool $ret Is donation form in single price mode? |
| 622 | 622 | * @param int|string $ID The ID of the donation form. |
| 623 | 623 | */ |
| 624 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
| 624 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
| 625 | 625 | |
| 626 | 626 | } |
| 627 | 627 | |
@@ -635,10 +635,10 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | public function is_custom_price_mode() { |
| 637 | 637 | |
| 638 | - $option = give_get_meta( $this->ID, '_give_custom_amount', true ); |
|
| 638 | + $option = give_get_meta($this->ID, '_give_custom_amount', true); |
|
| 639 | 639 | $ret = 0; |
| 640 | 640 | |
| 641 | - if ( give_is_setting_enabled( $option ) ) { |
|
| 641 | + if (give_is_setting_enabled($option)) { |
|
| 642 | 642 | $ret = 1; |
| 643 | 643 | } |
| 644 | 644 | |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | * @param bool $ret Is donation form in custom price mode? |
| 651 | 651 | * @param int|string $ID The ID of the donation form. |
| 652 | 652 | */ |
| 653 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
| 653 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
| 654 | 654 | |
| 655 | 655 | } |
| 656 | 656 | |
@@ -664,20 +664,20 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @return bool |
| 666 | 666 | */ |
| 667 | - public function is_custom_price( $amount ) { |
|
| 667 | + public function is_custom_price($amount) { |
|
| 668 | 668 | $result = false; |
| 669 | - $amount = give_maybe_sanitize_amount( $amount ); |
|
| 669 | + $amount = give_maybe_sanitize_amount($amount); |
|
| 670 | 670 | |
| 671 | - if ( $this->is_custom_price_mode() ) { |
|
| 671 | + if ($this->is_custom_price_mode()) { |
|
| 672 | 672 | |
| 673 | - if ( 'set' === $this->get_type() ) { |
|
| 674 | - if ( $amount !== $this->get_price() ) { |
|
| 673 | + if ('set' === $this->get_type()) { |
|
| 674 | + if ($amount !== $this->get_price()) { |
|
| 675 | 675 | $result = true; |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - } elseif ( 'multi' === $this->get_type() ) { |
|
| 679 | - $level_amounts = array_map( 'give_maybe_sanitize_amount', wp_list_pluck( $this->get_prices(), '_give_amount' ) ); |
|
| 680 | - $result = ! in_array( $amount, $level_amounts ); |
|
| 678 | + } elseif ('multi' === $this->get_type()) { |
|
| 679 | + $level_amounts = array_map('give_maybe_sanitize_amount', wp_list_pluck($this->get_prices(), '_give_amount')); |
|
| 680 | + $result = ! in_array($amount, $level_amounts); |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | * |
| 691 | 691 | * @since 1.8.18 |
| 692 | 692 | */ |
| 693 | - return (bool) apply_filters( 'give_is_custom_price', $result, $amount, $this->ID ); |
|
| 693 | + return (bool) apply_filters('give_is_custom_price', $result, $amount, $this->ID); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
@@ -705,10 +705,10 @@ discard block |
||
| 705 | 705 | */ |
| 706 | 706 | public function has_variable_prices() { |
| 707 | 707 | |
| 708 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
| 708 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
| 709 | 709 | $ret = 0; |
| 710 | 710 | |
| 711 | - if ( $option === 'multi' ) { |
|
| 711 | + if ($option === 'multi') { |
|
| 712 | 712 | $ret = 1; |
| 713 | 713 | } |
| 714 | 714 | |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * @param bool $ret Does donation form have variable prices? |
| 719 | 719 | * @param int|string $ID The ID of the donation form. |
| 720 | 720 | */ |
| 721 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
| 721 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
| 722 | 722 | |
| 723 | 723 | } |
| 724 | 724 | |
@@ -732,17 +732,17 @@ discard block |
||
| 732 | 732 | */ |
| 733 | 733 | public function get_type() { |
| 734 | 734 | |
| 735 | - if ( ! isset( $this->type ) ) { |
|
| 735 | + if ( ! isset($this->type)) { |
|
| 736 | 736 | |
| 737 | - $this->type = give_get_meta( $this->ID, '_give_price_option', true ); |
|
| 737 | + $this->type = give_get_meta($this->ID, '_give_price_option', true); |
|
| 738 | 738 | |
| 739 | - if ( empty( $this->type ) ) { |
|
| 739 | + if (empty($this->type)) { |
|
| 740 | 740 | $this->type = 'set'; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
| 745 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
| 746 | 746 | |
| 747 | 747 | } |
| 748 | 748 | |
@@ -758,23 +758,23 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @return string |
| 760 | 760 | */ |
| 761 | - public function get_form_classes( $args ) { |
|
| 761 | + public function get_form_classes($args) { |
|
| 762 | 762 | |
| 763 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
| 763 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
| 764 | 764 | ? 'float-labels-enabled' |
| 765 | 765 | : ''; |
| 766 | 766 | |
| 767 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
| 767 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
| 768 | 768 | 'give-form', |
| 769 | - 'give-form-' . $this->ID, |
|
| 770 | - 'give-form-type-' . $this->get_type(), |
|
| 769 | + 'give-form-'.$this->ID, |
|
| 770 | + 'give-form-type-'.$this->get_type(), |
|
| 771 | 771 | $float_labels_option, |
| 772 | - ), $this->ID, $args ); |
|
| 772 | + ), $this->ID, $args); |
|
| 773 | 773 | |
| 774 | 774 | // Remove empty class names. |
| 775 | - $form_classes_array = array_filter( $form_classes_array ); |
|
| 775 | + $form_classes_array = array_filter($form_classes_array); |
|
| 776 | 776 | |
| 777 | - return implode( ' ', $form_classes_array ); |
|
| 777 | + return implode(' ', $form_classes_array); |
|
| 778 | 778 | |
| 779 | 779 | } |
| 780 | 780 | |
@@ -789,22 +789,22 @@ discard block |
||
| 789 | 789 | * |
| 790 | 790 | * @return string |
| 791 | 791 | */ |
| 792 | - public function get_form_wrap_classes( $args ) { |
|
| 792 | + public function get_form_wrap_classes($args) { |
|
| 793 | 793 | $custom_class = array( |
| 794 | 794 | 'give-form-wrap', |
| 795 | 795 | ); |
| 796 | 796 | |
| 797 | - if ( $this->is_close_donation_form() ) { |
|
| 797 | + if ($this->is_close_donation_form()) { |
|
| 798 | 798 | $custom_class[] = 'give-form-closed'; |
| 799 | - } else{ |
|
| 800 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 799 | + } else { |
|
| 800 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 801 | 801 | ? $args['display_style'] |
| 802 | - : give_get_meta( $this->ID, '_give_payment_display', true ); |
|
| 802 | + : give_get_meta($this->ID, '_give_payment_display', true); |
|
| 803 | 803 | |
| 804 | 804 | $custom_class[] = "give-display-{$display_option}"; |
| 805 | 805 | |
| 806 | 806 | // If admin want to show only button for form then user inbuilt modal functionality. |
| 807 | - if ( 'button' === $display_option ) { |
|
| 807 | + if ('button' === $display_option) { |
|
| 808 | 808 | $custom_class[] = 'give-display-button-only'; |
| 809 | 809 | } |
| 810 | 810 | } |
@@ -815,10 +815,10 @@ discard block |
||
| 815 | 815 | * |
| 816 | 816 | * @since 1.0 |
| 817 | 817 | */ |
| 818 | - $form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args ); |
|
| 818 | + $form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args); |
|
| 819 | 819 | |
| 820 | 820 | |
| 821 | - return implode( ' ', $form_wrap_classes_array ); |
|
| 821 | + return implode(' ', $form_wrap_classes_array); |
|
| 822 | 822 | |
| 823 | 823 | } |
| 824 | 824 | |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | public function is_set_type_donation_form() { |
| 834 | 834 | $form_type = $this->get_type(); |
| 835 | 835 | |
| 836 | - return ( 'set' === $form_type ? true : false ); |
|
| 836 | + return ('set' === $form_type ? true : false); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | public function is_multi_type_donation_form() { |
| 848 | 848 | $form_type = $this->get_type(); |
| 849 | 849 | |
| 850 | - return ( 'multi' === $form_type ? true : false ); |
|
| 850 | + return ('multi' === $form_type ? true : false); |
|
| 851 | 851 | |
| 852 | 852 | } |
| 853 | 853 | |
@@ -861,15 +861,15 @@ discard block |
||
| 861 | 861 | */ |
| 862 | 862 | public function get_sales() { |
| 863 | 863 | |
| 864 | - if ( ! isset( $this->sales ) ) { |
|
| 864 | + if ( ! isset($this->sales)) { |
|
| 865 | 865 | |
| 866 | - if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) { |
|
| 867 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
| 866 | + if ('' == give_get_meta($this->ID, '_give_form_sales', true)) { |
|
| 867 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
| 868 | 868 | } // End if |
| 869 | 869 | |
| 870 | - $this->sales = give_get_meta( $this->ID, '_give_form_sales', true ); |
|
| 870 | + $this->sales = give_get_meta($this->ID, '_give_form_sales', true); |
|
| 871 | 871 | |
| 872 | - if ( $this->sales < 0 ) { |
|
| 872 | + if ($this->sales < 0) { |
|
| 873 | 873 | // Never let sales be less than zero. |
| 874 | 874 | $this->sales = 0; |
| 875 | 875 | } |
@@ -890,13 +890,13 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @return int|false New number of total sales. |
| 892 | 892 | */ |
| 893 | - public function increase_sales( $quantity = 1 ) { |
|
| 893 | + public function increase_sales($quantity = 1) { |
|
| 894 | 894 | |
| 895 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
| 896 | - $quantity = absint( $quantity ); |
|
| 895 | + $sales = give_get_form_sales_stats($this->ID); |
|
| 896 | + $quantity = absint($quantity); |
|
| 897 | 897 | $total_sales = $sales + $quantity; |
| 898 | 898 | |
| 899 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
| 899 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
| 900 | 900 | |
| 901 | 901 | $this->sales = $total_sales; |
| 902 | 902 | |
@@ -917,17 +917,17 @@ discard block |
||
| 917 | 917 | * |
| 918 | 918 | * @return int|false New number of total sales. |
| 919 | 919 | */ |
| 920 | - public function decrease_sales( $quantity = 1 ) { |
|
| 920 | + public function decrease_sales($quantity = 1) { |
|
| 921 | 921 | |
| 922 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
| 922 | + $sales = give_get_form_sales_stats($this->ID); |
|
| 923 | 923 | |
| 924 | 924 | // Only decrease if not already zero |
| 925 | - if ( $sales > 0 ) { |
|
| 925 | + if ($sales > 0) { |
|
| 926 | 926 | |
| 927 | - $quantity = absint( $quantity ); |
|
| 927 | + $quantity = absint($quantity); |
|
| 928 | 928 | $total_sales = $sales - $quantity; |
| 929 | 929 | |
| 930 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
| 930 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
| 931 | 931 | |
| 932 | 932 | $this->sales = $sales; |
| 933 | 933 | |
@@ -951,15 +951,15 @@ discard block |
||
| 951 | 951 | */ |
| 952 | 952 | public function get_earnings() { |
| 953 | 953 | |
| 954 | - if ( ! isset( $this->earnings ) ) { |
|
| 954 | + if ( ! isset($this->earnings)) { |
|
| 955 | 955 | |
| 956 | - if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
| 957 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
| 956 | + if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) { |
|
| 957 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - $this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true ); |
|
| 960 | + $this->earnings = give_get_meta($this->ID, '_give_form_earnings', true); |
|
| 961 | 961 | |
| 962 | - if ( $this->earnings < 0 ) { |
|
| 962 | + if ($this->earnings < 0) { |
|
| 963 | 963 | // Never let earnings be less than zero |
| 964 | 964 | $this->earnings = 0; |
| 965 | 965 | } |
@@ -980,12 +980,12 @@ discard block |
||
| 980 | 980 | * |
| 981 | 981 | * @return float|false |
| 982 | 982 | */ |
| 983 | - public function increase_earnings( $amount = 0 ) { |
|
| 983 | + public function increase_earnings($amount = 0) { |
|
| 984 | 984 | |
| 985 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
| 985 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
| 986 | 986 | $new_amount = $earnings + (float) $amount; |
| 987 | 987 | |
| 988 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
| 988 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
| 989 | 989 | |
| 990 | 990 | $this->earnings = $new_amount; |
| 991 | 991 | |
@@ -1007,16 +1007,16 @@ discard block |
||
| 1007 | 1007 | * |
| 1008 | 1008 | * @return float|false |
| 1009 | 1009 | */ |
| 1010 | - public function decrease_earnings( $amount ) { |
|
| 1010 | + public function decrease_earnings($amount) { |
|
| 1011 | 1011 | |
| 1012 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
| 1012 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
| 1013 | 1013 | |
| 1014 | - if ( $earnings > 0 ) { |
|
| 1014 | + if ($earnings > 0) { |
|
| 1015 | 1015 | // Only decrease if greater than zero |
| 1016 | 1016 | $new_amount = $earnings - (float) $amount; |
| 1017 | 1017 | |
| 1018 | 1018 | |
| 1019 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
| 1019 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
| 1020 | 1020 | |
| 1021 | 1021 | $this->earnings = $new_amount; |
| 1022 | 1022 | |
@@ -1040,22 +1040,22 @@ discard block |
||
| 1040 | 1040 | * |
| 1041 | 1041 | * @return bool |
| 1042 | 1042 | */ |
| 1043 | - public function is_free( $price_id = false ) { |
|
| 1043 | + public function is_free($price_id = false) { |
|
| 1044 | 1044 | |
| 1045 | 1045 | $is_free = false; |
| 1046 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
| 1046 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
| 1047 | 1047 | |
| 1048 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
| 1049 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
| 1050 | - } elseif ( ! $variable_pricing ) { |
|
| 1051 | - $price = give_get_meta( $this->ID, '_give_set_price', true ); |
|
| 1048 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
| 1049 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
| 1050 | + } elseif ( ! $variable_pricing) { |
|
| 1051 | + $price = give_get_meta($this->ID, '_give_set_price', true); |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
| 1054 | + if (isset($price) && (float) $price == 0) { |
|
| 1055 | 1055 | $is_free = true; |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
| 1058 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
| 1059 | 1059 | |
| 1060 | 1060 | } |
| 1061 | 1061 | |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | */ |
| 1075 | 1075 | public function is_close_donation_form() { |
| 1076 | 1076 | |
| 1077 | - $goal_format = give_get_form_goal_format( $this->ID ); |
|
| 1077 | + $goal_format = give_get_form_goal_format($this->ID); |
|
| 1078 | 1078 | |
| 1079 | 1079 | /** |
| 1080 | 1080 | * Filter the close form result. |
@@ -1084,9 +1084,9 @@ discard block |
||
| 1084 | 1084 | $is_close_form = apply_filters( |
| 1085 | 1085 | 'give_is_close_donation_form', |
| 1086 | 1086 | ( |
| 1087 | - give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true ) ) && |
|
| 1088 | - give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) && |
|
| 1089 | - ( 'donation' === $goal_format ? $this->get_goal() <= $this->get_sales() : $this->get_goal() <= $this->get_earnings() ) |
|
| 1087 | + give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true)) && |
|
| 1088 | + give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true)) && |
|
| 1089 | + ('donation' === $goal_format ? $this->get_goal() <= $this->get_sales() : $this->get_goal() <= $this->get_earnings()) |
|
| 1090 | 1090 | ), |
| 1091 | 1091 | $this->ID |
| 1092 | 1092 | ); |
@@ -1105,17 +1105,17 @@ discard block |
||
| 1105 | 1105 | * |
| 1106 | 1106 | * @return bool The result of the update query. |
| 1107 | 1107 | */ |
| 1108 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
| 1108 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
| 1109 | 1109 | |
| 1110 | 1110 | /* @var WPDB $wpdb */ |
| 1111 | 1111 | global $wpdb; |
| 1112 | 1112 | |
| 1113 | 1113 | // Bailout. |
| 1114 | - if ( empty( $meta_key ) ) { |
|
| 1114 | + if (empty($meta_key)) { |
|
| 1115 | 1115 | return false; |
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | - if ( give_update_meta( $this->ID, $meta_key, $meta_value ) ) { |
|
| 1118 | + if (give_update_meta($this->ID, $meta_key, $meta_value)) { |
|
| 1119 | 1119 | return true; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_get_actions() { |
| 27 | 27 | |
| 28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
| 28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
| 29 | 29 | |
| 30 | 30 | // Add backward compatibility to give-action param ( $_GET ) |
| 31 | - if ( empty( $_get_action ) ) { |
|
| 32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
| 31 | + if (empty($_get_action)) { |
|
| 32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ( isset( $_get_action ) ) { |
|
| 35 | + if (isset($_get_action)) { |
|
| 36 | 36 | /** |
| 37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
| 38 | 38 | * |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param array $_GET Array of HTTP GET variables. |
| 42 | 42 | */ |
| 43 | - do_action( "give_{$_get_action}", $_GET ); |
|
| 43 | + do_action("give_{$_get_action}", $_GET); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | -add_action( 'init', 'give_get_actions' ); |
|
| 48 | +add_action('init', 'give_get_actions'); |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | function give_post_actions() { |
| 60 | 60 | |
| 61 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
| 61 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
| 62 | 62 | |
| 63 | 63 | // Add backward compatibility to give-action param ( $_POST ). |
| 64 | - if ( empty( $_post_action ) ) { |
|
| 65 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
| 64 | + if (empty($_post_action)) { |
|
| 65 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if ( isset( $_post_action ) ) { |
|
| 68 | + if (isset($_post_action)) { |
|
| 69 | 69 | /** |
| 70 | 70 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
| 71 | 71 | * |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @param array $_POST Array of HTTP POST variables. |
| 75 | 75 | */ |
| 76 | - do_action( "give_{$_post_action}", $_POST ); |
|
| 76 | + do_action("give_{$_post_action}", $_POST); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | -add_action( 'init', 'give_post_actions' ); |
|
| 81 | +add_action('init', 'give_post_actions'); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Connect WordPress user with Donor. |
@@ -90,17 +90,17 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | -function give_connect_donor_to_wpuser( $user_id, $user_data ) { |
|
| 93 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
| 94 | 94 | /* @var Give_Donor $donor */ |
| 95 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
| 95 | + $donor = new Give_Donor($user_data['user_email']); |
|
| 96 | 96 | |
| 97 | 97 | // Validate donor id and check if do nor is already connect to wp user or not. |
| 98 | - if ( $donor->id && ! $donor->user_id ) { |
|
| 98 | + if ($donor->id && ! $donor->user_id) { |
|
| 99 | 99 | |
| 100 | 100 | // Update donor user_id. |
| 101 | - if ( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
| 102 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
| 103 | - $donor->add_note( $donor_note ); |
|
| 101 | + if ($donor->update(array('user_id' => $user_id))) { |
|
| 102 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
| 103 | + $donor->add_note($donor_note); |
|
| 104 | 104 | |
| 105 | 105 | // Update user_id meta in payments. |
| 106 | 106 | // if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
| 116 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -127,45 +127,45 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | function give_validate_license_when_site_migrated() { |
| 129 | 129 | // Store current site address if not already stored. |
| 130 | - $home_url_parts = parse_url( home_url() ); |
|
| 131 | - $home_url = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false; |
|
| 132 | - $home_url .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : ''; |
|
| 133 | - $site_address_before_migrate = get_option( 'give_site_address_before_migrate' ); |
|
| 130 | + $home_url_parts = parse_url(home_url()); |
|
| 131 | + $home_url = isset($home_url_parts['host']) ? $home_url_parts['host'] : false; |
|
| 132 | + $home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : ''; |
|
| 133 | + $site_address_before_migrate = get_option('give_site_address_before_migrate'); |
|
| 134 | 134 | |
| 135 | 135 | // Need $home_url to proceed. |
| 136 | - if ( ! $home_url ) { |
|
| 136 | + if ( ! $home_url) { |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Save site address. |
| 141 | - if ( ! $site_address_before_migrate ) { |
|
| 141 | + if ( ! $site_address_before_migrate) { |
|
| 142 | 142 | // Update site address. |
| 143 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
| 143 | + update_option('give_site_address_before_migrate', $home_url); |
|
| 144 | 144 | |
| 145 | 145 | return; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Backwards compat. for before when we were storing URL scheme. |
| 149 | - if ( strpos( $site_address_before_migrate, 'http' ) ) { |
|
| 150 | - $site_address_before_migrate = parse_url( $site_address_before_migrate ); |
|
| 151 | - $site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false; |
|
| 149 | + if (strpos($site_address_before_migrate, 'http')) { |
|
| 150 | + $site_address_before_migrate = parse_url($site_address_before_migrate); |
|
| 151 | + $site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false; |
|
| 152 | 152 | |
| 153 | 153 | // Add path for multisite installs. |
| 154 | - $site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : ''; |
|
| 154 | + $site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : ''; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // If the two URLs don't match run CRON. |
| 158 | - if ( $home_url !== $site_address_before_migrate ) { |
|
| 158 | + if ($home_url !== $site_address_before_migrate) { |
|
| 159 | 159 | // Immediately run cron. |
| 160 | - wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' ); |
|
| 160 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
| 161 | 161 | |
| 162 | 162 | // Update site address. |
| 163 | - update_option( 'give_site_address_before_migrate', $home_url ); |
|
| 163 | + update_option('give_site_address_before_migrate', $home_url); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
| 168 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
| 169 | 169 | |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -175,19 +175,19 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @param $data |
| 177 | 177 | */ |
| 178 | -function give_donor_batch_export_complete( $data ) { |
|
| 178 | +function give_donor_batch_export_complete($data) { |
|
| 179 | 179 | // Remove donor ids cache. |
| 180 | 180 | if ( |
| 181 | - isset( $data['class'] ) |
|
| 181 | + isset($data['class']) |
|
| 182 | 182 | && 'Give_Batch_Donors_Export' === $data['class'] |
| 183 | - && ! empty( $data['forms'] ) |
|
| 184 | - && isset( $data['give_export_option']['query_id'] ) |
|
| 183 | + && ! empty($data['forms']) |
|
| 184 | + && isset($data['give_export_option']['query_id']) |
|
| 185 | 185 | ) { |
| 186 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
| 186 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | -add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
| 190 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | 193 | * Print css for wordpress setting pages. |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | /* @var WP_Screen $screen */ |
| 199 | 199 | $screen = get_current_screen(); |
| 200 | 200 | |
| 201 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
| 201 | + if ( ! ($screen instanceof WP_Screen)) { |
|
| 202 | 202 | return false; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - switch ( true ) { |
|
| 206 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
| 205 | + switch (true) { |
|
| 206 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
| 207 | 207 | ?> |
| 208 | 208 | <style> |
| 209 | 209 | tr.active.update + tr.give-addon-notice-tr td { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
| 243 | +add_action('admin_head', 'give_admin_quick_css'); |
|
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -252,31 +252,31 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
| 255 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
| 256 | 256 | if ( |
| 257 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
| 258 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
| 259 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
| 257 | + ('set' === $_POST['_give_price_option']) || |
|
| 258 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
| 259 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
| 260 | 260 | ) { |
| 261 | 261 | // Delete old meta. |
| 262 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
| 263 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
| 262 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
| 263 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
| 264 | 264 | |
| 265 | 265 | return; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Sanitize donation level amounts. |
| 269 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
| 269 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
| 270 | 270 | |
| 271 | - $min_amount = min( $donation_levels_amounts ); |
|
| 272 | - $max_amount = max( $donation_levels_amounts ); |
|
| 271 | + $min_amount = min($donation_levels_amounts); |
|
| 272 | + $max_amount = max($donation_levels_amounts); |
|
| 273 | 273 | |
| 274 | 274 | // Set Minimum and Maximum amount for Multi Level Donation Forms. |
| 275 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
| 276 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
| 275 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
| 276 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
| 279 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
| 280 | 280 | |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -286,24 +286,24 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param int $payment_id |
| 288 | 288 | */ |
| 289 | -function _give_save_donor_billing_address( $payment_id ) { |
|
| 289 | +function _give_save_donor_billing_address($payment_id) { |
|
| 290 | 290 | /* @var Give_Payment $donation */ |
| 291 | - $donation = new Give_Payment( $payment_id ); |
|
| 291 | + $donation = new Give_Payment($payment_id); |
|
| 292 | 292 | |
| 293 | 293 | // Bailout |
| 294 | - if ( ! $donation->customer_id ) { |
|
| 294 | + if ( ! $donation->customer_id) { |
|
| 295 | 295 | return; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
| 299 | 299 | /* @var Give_Donor $donor */ |
| 300 | - $donor = new Give_Donor( $donation->customer_id ); |
|
| 300 | + $donor = new Give_Donor($donation->customer_id); |
|
| 301 | 301 | |
| 302 | 302 | // Save address. |
| 303 | - $donor->add_address( 'billing[]', $donation->address ); |
|
| 303 | + $donor->add_address('billing[]', $donation->address); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | -add_action( 'give_complete_donation', '_give_save_donor_billing_address', 9999 ); |
|
| 306 | +add_action('give_complete_donation', '_give_save_donor_billing_address', 9999); |
|
| 307 | 307 | |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -313,25 +313,25 @@ discard block |
||
| 313 | 313 | * |
| 314 | 314 | * @param array $args |
| 315 | 315 | */ |
| 316 | -function give_update_log_form_id( $args ) { |
|
| 317 | - $new_form_id = absint( $args[0] ); |
|
| 318 | - $payment_id = absint( $args[1] ); |
|
| 319 | - $logs = Give()->logs->get_logs( $payment_id ); |
|
| 316 | +function give_update_log_form_id($args) { |
|
| 317 | + $new_form_id = absint($args[0]); |
|
| 318 | + $payment_id = absint($args[1]); |
|
| 319 | + $logs = Give()->logs->get_logs($payment_id); |
|
| 320 | 320 | |
| 321 | 321 | // Bailout. |
| 322 | - if ( empty( $logs ) ) { |
|
| 322 | + if (empty($logs)) { |
|
| 323 | 323 | return; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /* @var object $log */ |
| 327 | - foreach ( $logs as $log ) { |
|
| 328 | - Give()->logs->logmeta_db->update_meta( $log->ID, '_give_log_form_id', $new_form_id ); |
|
| 327 | + foreach ($logs as $log) { |
|
| 328 | + Give()->logs->logmeta_db->update_meta($log->ID, '_give_log_form_id', $new_form_id); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Delete cache. |
| 332 | 332 | Give()->logs->delete_cache(); |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | -add_action( 'give_update_log_form_id', 'give_update_log_form_id' ); |
|
| 335 | +add_action('give_update_log_form_id', 'give_update_log_form_id'); |
|
| 336 | 336 | |
| 337 | 337 | |
@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /* @var WPDB $wpdb */ |
| 51 | 51 | global $wpdb; |
| 52 | 52 | |
| 53 | - $wpdb->logmeta = $this->table_name = $wpdb->prefix . 'give_logmeta'; |
|
| 53 | + $wpdb->logmeta = $this->table_name = $wpdb->prefix.'give_logmeta'; |
|
| 54 | 54 | $this->primary_key = 'meta_id'; |
| 55 | 55 | $this->version = '1.0'; |
| 56 | 56 | |
@@ -86,18 +86,18 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return bool |
| 88 | 88 | */ |
| 89 | - public function delete_row( $log_id = 0 ) { |
|
| 89 | + public function delete_row($log_id = 0) { |
|
| 90 | 90 | /* @var WPDB $wpdb */ |
| 91 | 91 | global $wpdb; |
| 92 | 92 | |
| 93 | 93 | // Row ID must be positive integer |
| 94 | - $log_id = absint( $log_id ); |
|
| 94 | + $log_id = absint($log_id); |
|
| 95 | 95 | |
| 96 | - if ( empty( $log_id ) ) { |
|
| 96 | + if (empty($log_id)) { |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) { |
|
| 100 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) { |
|
| 101 | 101 | return false; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | KEY meta_key (meta_key) |
| 127 | 127 | ) {$charset_collate};"; |
| 128 | 128 | |
| 129 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 130 | - dbDelta( $sql ); |
|
| 129 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 130 | + dbDelta($sql); |
|
| 131 | 131 | |
| 132 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 132 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @return bool |
| 144 | 144 | */ |
| 145 | - protected function is_valid_post_type( $ID ) { |
|
| 145 | + protected function is_valid_post_type($ID) { |
|
| 146 | 146 | return $ID && true; |
| 147 | 147 | } |
| 148 | 148 | } |