@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function __construct() { |
| 104 | 104 | |
| 105 | - if ( 'none' === $this->get_template() ) { |
|
| 105 | + if ('none' === $this->get_template()) { |
|
| 106 | 106 | $this->html = false; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
| 110 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
| 109 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
| 110 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param $key |
| 120 | 120 | * @param $value |
| 121 | 121 | */ |
| 122 | - public function __set( $key, $value ) { |
|
| 122 | + public function __set($key, $value) { |
|
| 123 | 123 | $this->$key = $value; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | * @since 1.0 |
| 130 | 130 | */ |
| 131 | 131 | public function get_from_name() { |
| 132 | - if ( ! $this->from_name ) { |
|
| 133 | - $this->from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
| 132 | + if ( ! $this->from_name) { |
|
| 133 | + $this->from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
| 136 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | * @since 1.0 |
| 143 | 143 | */ |
| 144 | 144 | public function get_from_address() { |
| 145 | - if ( ! $this->from_address ) { |
|
| 146 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
| 145 | + if ( ! $this->from_address) { |
|
| 146 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
| 149 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | * @since 1.0 |
| 156 | 156 | */ |
| 157 | 157 | public function get_content_type() { |
| 158 | - if ( ! $this->content_type ) { |
|
| 158 | + if ( ! $this->content_type) { |
|
| 159 | 159 | $this->content_type = $this->html |
| 160 | - ? apply_filters( 'give_email_default_content_type', 'text/html', $this ) |
|
| 160 | + ? apply_filters('give_email_default_content_type', 'text/html', $this) |
|
| 161 | 161 | : 'text/plain'; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
| 164 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -170,13 +170,13 @@ discard block |
||
| 170 | 170 | * @since 1.0 |
| 171 | 171 | */ |
| 172 | 172 | public function get_headers() { |
| 173 | - if ( ! $this->headers ) { |
|
| 173 | + if ( ! $this->headers) { |
|
| 174 | 174 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
| 175 | 175 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
| 176 | 176 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
| 179 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function get_templates() { |
| 188 | 188 | $templates = array( |
| 189 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
| 190 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
| 189 | + 'default' => esc_html__('Default Template', 'give'), |
|
| 190 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - return apply_filters( 'give_email_templates', $templates ); |
|
| 193 | + return apply_filters('give_email_templates', $templates); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | * @since 1.0 |
| 200 | 200 | */ |
| 201 | 201 | public function get_template() { |
| 202 | - if ( ! $this->template ) { |
|
| 203 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
| 202 | + if ( ! $this->template) { |
|
| 203 | + $this->template = give_get_option('email_template', 'default'); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - return apply_filters( 'give_email_template', $this->template ); |
|
| 206 | + return apply_filters('give_email_template', $this->template); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @since 1.0 |
| 213 | 213 | */ |
| 214 | 214 | public function get_heading() { |
| 215 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
| 215 | + return apply_filters('give_email_heading', $this->heading); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return mixed |
| 224 | 224 | */ |
| 225 | - public function parse_tags( $content ) { |
|
| 225 | + public function parse_tags($content) { |
|
| 226 | 226 | return $content; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -235,34 +235,34 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return string |
| 237 | 237 | */ |
| 238 | - public function build_email( $message ) { |
|
| 238 | + public function build_email($message) { |
|
| 239 | 239 | |
| 240 | - if ( false === $this->html ) { |
|
| 240 | + if (false === $this->html) { |
|
| 241 | 241 | |
| 242 | 242 | // Added Replacement check to simply behaviour of anchor tags. |
| 243 | 243 | $pattern = '/<a.+?href\=(?:["|\'])(.+?)(?:["|\']).*?>(.+?)<\/a>/i'; |
| 244 | 244 | $message = preg_replace_callback( |
| 245 | 245 | $pattern, |
| 246 | - function ( $return ) { |
|
| 247 | - if ( $return[1] !== $return[2] ) { |
|
| 246 | + function($return) { |
|
| 247 | + if ($return[1] !== $return[2]) { |
|
| 248 | 248 | return "{$return[2]} ( {$return[1]} )"; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - return trailingslashit( $return[1] ); |
|
| 251 | + return trailingslashit($return[1]); |
|
| 252 | 252 | }, |
| 253 | 253 | $message |
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
| 256 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $message = $this->text_to_html( $message ); |
|
| 259 | + $message = $this->text_to_html($message); |
|
| 260 | 260 | |
| 261 | 261 | $template = $this->get_template(); |
| 262 | 262 | |
| 263 | 263 | ob_start(); |
| 264 | 264 | |
| 265 | - give_get_template_part( 'emails/header', $template, true ); |
|
| 265 | + give_get_template_part('emails/header', $template, true); |
|
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Fires in the email head. |
@@ -271,17 +271,17 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @param Give_Emails $this The email object. |
| 273 | 273 | */ |
| 274 | - do_action( 'give_email_header', $this ); |
|
| 274 | + do_action('give_email_header', $this); |
|
| 275 | 275 | |
| 276 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
| 276 | + if (has_action('give_email_template_'.$template)) { |
|
| 277 | 277 | /** |
| 278 | 278 | * Fires in a specific email template. |
| 279 | 279 | * |
| 280 | 280 | * @since 1.0 |
| 281 | 281 | */ |
| 282 | - do_action( "give_email_template_{$template}" ); |
|
| 282 | + do_action("give_email_template_{$template}"); |
|
| 283 | 283 | } else { |
| 284 | - give_get_template_part( 'emails/body', $template, true ); |
|
| 284 | + give_get_template_part('emails/body', $template, true); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @param Give_Emails $this The email object. |
| 293 | 293 | */ |
| 294 | - do_action( 'give_email_body', $this ); |
|
| 294 | + do_action('give_email_body', $this); |
|
| 295 | 295 | |
| 296 | - give_get_template_part( 'emails/footer', $template, true ); |
|
| 296 | + give_get_template_part('emails/footer', $template, true); |
|
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | 299 | * Fires in the email footer. |
@@ -302,28 +302,28 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @param Give_Emails $this The email object. |
| 304 | 304 | */ |
| 305 | - do_action( 'give_email_footer', $this ); |
|
| 305 | + do_action('give_email_footer', $this); |
|
| 306 | 306 | |
| 307 | 307 | $body = ob_get_clean(); |
| 308 | 308 | |
| 309 | 309 | // Email tag. |
| 310 | - $message = str_replace( '{email}', $message, $body ); |
|
| 310 | + $message = str_replace('{email}', $message, $body); |
|
| 311 | 311 | |
| 312 | 312 | // Email logo tag. |
| 313 | - $header_img = give_get_meta( $this->form_id, '_give_email_logo', true ); |
|
| 314 | - $header_img = $this->form_id ? $header_img : give_get_option( 'email_logo', '' ); |
|
| 313 | + $header_img = give_get_meta($this->form_id, '_give_email_logo', true); |
|
| 314 | + $header_img = $this->form_id ? $header_img : give_get_option('email_logo', ''); |
|
| 315 | 315 | |
| 316 | - if ( ! empty( $header_img ) ) { |
|
| 316 | + if ( ! empty($header_img)) { |
|
| 317 | 317 | $header_img = sprintf( |
| 318 | 318 | '<div id="template_header_image"><p style="margin-top:0;"><img style="max-width:450px;" src="%1$s" alt="%2$s" /></p></div>', |
| 319 | - esc_url( $header_img ), |
|
| 320 | - get_bloginfo( 'name' ) |
|
| 319 | + esc_url($header_img), |
|
| 320 | + get_bloginfo('name') |
|
| 321 | 321 | ); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $message = str_replace( '{email_logo}', $header_img, $message ); |
|
| 324 | + $message = str_replace('{email_logo}', $header_img, $message); |
|
| 325 | 325 | |
| 326 | - return apply_filters( 'give_email_message', $message, $this ); |
|
| 326 | + return apply_filters('give_email_message', $message, $this); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -336,10 +336,10 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @return bool |
| 338 | 338 | */ |
| 339 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
| 339 | + public function send($to, $subject, $message, $attachments = '') { |
|
| 340 | 340 | |
| 341 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
| 342 | - give_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
| 341 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
| 342 | + give_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
| 343 | 343 | |
| 344 | 344 | return false; |
| 345 | 345 | } |
@@ -351,16 +351,16 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @param Give_Emails $this The email object. |
| 353 | 353 | */ |
| 354 | - do_action( 'give_email_send_before', $this ); |
|
| 354 | + do_action('give_email_send_before', $this); |
|
| 355 | 355 | |
| 356 | - $subject = $this->parse_tags( $subject ); |
|
| 357 | - $message = $this->parse_tags( $message ); |
|
| 356 | + $subject = $this->parse_tags($subject); |
|
| 357 | + $message = $this->parse_tags($message); |
|
| 358 | 358 | |
| 359 | - $message = $this->build_email( $message ); |
|
| 359 | + $message = $this->build_email($message); |
|
| 360 | 360 | |
| 361 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
| 361 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
| 362 | 362 | |
| 363 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
| 363 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * Fires after sending an email. |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * |
| 370 | 370 | * @param Give_Emails $this The email object. |
| 371 | 371 | */ |
| 372 | - do_action( 'give_email_send_after', $this ); |
|
| 372 | + do_action('give_email_send_after', $this); |
|
| 373 | 373 | |
| 374 | 374 | return $sent; |
| 375 | 375 | |
@@ -381,9 +381,9 @@ discard block |
||
| 381 | 381 | * @since 1.0 |
| 382 | 382 | */ |
| 383 | 383 | public function send_before() { |
| 384 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
| 385 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
| 386 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
| 384 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
| 385 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
| 386 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -392,9 +392,9 @@ discard block |
||
| 392 | 392 | * @since 1.0 |
| 393 | 393 | */ |
| 394 | 394 | public function send_after() { |
| 395 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
| 396 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
| 397 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
| 395 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
| 396 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
| 397 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
| 398 | 398 | |
| 399 | 399 | // Reset email related params. |
| 400 | 400 | $this->heading = ''; |
@@ -408,10 +408,10 @@ discard block |
||
| 408 | 408 | * |
| 409 | 409 | * @since 1.0 |
| 410 | 410 | */ |
| 411 | - public function text_to_html( $message ) { |
|
| 411 | + public function text_to_html($message) { |
|
| 412 | 412 | |
| 413 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
| 414 | - $message = wpautop( $message ); |
|
| 413 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
| 414 | + $message = wpautop($message); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | return $message; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | -function give_trigger_donation_receipt( $payment_id ) { |
|
| 26 | +function give_trigger_donation_receipt($payment_id) { |
|
| 27 | 27 | // Make sure we don't send a receipt while editing a donation. |
| 28 | - if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) { |
|
| 28 | + if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) { |
|
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | // Send email. |
| 33 | - give_email_donation_receipt( $payment_id ); |
|
| 33 | + give_email_donation_receipt($payment_id); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | -add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999, 1 ); |
|
| 37 | 36 | \ No newline at end of file |
| 37 | +add_action('give_complete_donation', 'give_trigger_donation_receipt', 999, 1); |
|
| 38 | 38 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return array |
| 22 | 22 | */ |
| 23 | - private function set_toottip_args( $args ) { |
|
| 23 | + private function set_toottip_args($args) { |
|
| 24 | 24 | $args = wp_parse_args( |
| 25 | 25 | $args, |
| 26 | 26 | array( |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // Auto set width of tooltip. |
| 64 | 64 | if ( |
| 65 | - ! empty( $args['auto_width'] ) && |
|
| 66 | - ! empty( $args['label'] ) && |
|
| 67 | - empty( $args['size'] ) |
|
| 65 | + ! empty($args['auto_width']) && |
|
| 66 | + ! empty($args['label']) && |
|
| 67 | + empty($args['size']) |
|
| 68 | 68 | ) { |
| 69 | - if ( 15 < str_word_count( $args['label'] ) ) { |
|
| 69 | + if (15 < str_word_count($args['label'])) { |
|
| 70 | 70 | $args['size'] = 'large'; |
| 71 | - } elseif ( 7 < str_word_count( $args['label'] ) ) { |
|
| 71 | + } elseif (7 < str_word_count($args['label'])) { |
|
| 72 | 72 | $args['size'] = 'medium'; |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @return string |
| 89 | 89 | */ |
| 90 | - public function render( $args ) { |
|
| 91 | - $args = $this->set_toottip_args( $args ); |
|
| 90 | + public function render($args) { |
|
| 91 | + $args = $this->set_toottip_args($args); |
|
| 92 | 92 | |
| 93 | 93 | $tooltip_pos = array( |
| 94 | 94 | 'top' => 'hint--top', |
@@ -118,21 +118,21 @@ discard block |
||
| 118 | 118 | $args['attributes']['aria-label'] = $args['label']; |
| 119 | 119 | |
| 120 | 120 | // Set classes. |
| 121 | - $args['attributes']['class'] = ! empty( $args['attributes']['class'] ) ? $args['attributes']['class'] : ''; |
|
| 122 | - $args['attributes']['class'] .= " {$tooltip_pos[ $args['position'] ]}"; |
|
| 123 | - $args['attributes']['class'] .= ! empty( $args['status'] ) ? " {$tooltip_status[ $args['status'] ]}" : ''; |
|
| 124 | - $args['attributes']['class'] .= ! empty( $args['size'] ) ? " {$tooltip_size[ $args['size'] ]}" : ''; |
|
| 121 | + $args['attributes']['class'] = ! empty($args['attributes']['class']) ? $args['attributes']['class'] : ''; |
|
| 122 | + $args['attributes']['class'] .= " {$tooltip_pos[$args['position']]}"; |
|
| 123 | + $args['attributes']['class'] .= ! empty($args['status']) ? " {$tooltip_status[$args['status']]}" : ''; |
|
| 124 | + $args['attributes']['class'] .= ! empty($args['size']) ? " {$tooltip_size[$args['size']]}" : ''; |
|
| 125 | 125 | $args['attributes']['class'] .= $args['show_always'] ? ' hint--always' : ''; |
| 126 | 126 | $args['attributes']['class'] .= $args['round_edges'] ? ' hint--rounded' : ''; |
| 127 | 127 | $args['attributes']['class'] .= $args['animate'] ? ' hint--bounce' : ' hint--no-animate'; |
| 128 | - $args['attributes']['class'] = trim( $args['attributes']['class'] ); |
|
| 128 | + $args['attributes']['class'] = trim($args['attributes']['class']); |
|
| 129 | 129 | |
| 130 | 130 | // Set link attribute in tooltip has anchor tag. |
| 131 | - if ( 'a' === $args['tag'] && ! empty( $args['link'] ) ) { |
|
| 132 | - $args['attributes']['href'] = esc_url( $args['link'] ); |
|
| 131 | + if ('a' === $args['tag'] && ! empty($args['link'])) { |
|
| 132 | + $args['attributes']['href'] = esc_url($args['link']); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - return sprintf( '<%1$s %2$s rel="tooltip">%3$s</%1$s>', $args['tag'], give_get_attribute_str( $args['attributes'] ), $args['tag_content'] ); |
|
| 135 | + return sprintf('<%1$s %2$s rel="tooltip">%3$s</%1$s>', $args['tag'], give_get_attribute_str($args['attributes']), $args['tag_content']); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - function render_link( $args ) { |
|
| 149 | + function render_link($args) { |
|
| 150 | 150 | $args['tag'] = 'a'; |
| 151 | - $tooltip_markup = $this->render( $args ); |
|
| 151 | + $tooltip_markup = $this->render($args); |
|
| 152 | 152 | |
| 153 | 153 | return $tooltip_markup; |
| 154 | 154 | } |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return string |
| 165 | 165 | */ |
| 166 | - function render_span( $args ) { |
|
| 166 | + function render_span($args) { |
|
| 167 | 167 | // Set tooltip args from string. |
| 168 | - if ( is_string( $args ) ) { |
|
| 169 | - $args = array( 'label' => $args ); |
|
| 168 | + if (is_string($args)) { |
|
| 169 | + $args = array('label' => $args); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $args['tag'] = 'span'; |
| 173 | - $tooltip_markup = $this->render( $args ); |
|
| 173 | + $tooltip_markup = $this->render($args); |
|
| 174 | 174 | |
| 175 | 175 | return $tooltip_markup; |
| 176 | 176 | } |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return string |
| 187 | 187 | */ |
| 188 | - function render_help( $args ) { |
|
| 188 | + function render_help($args) { |
|
| 189 | 189 | // Set tooltip args from string. |
| 190 | - if ( is_string( $args ) ) { |
|
| 191 | - $args = array( 'label' => $args ); |
|
| 190 | + if (is_string($args)) { |
|
| 191 | + $args = array('label' => $args); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $args['tag_content'] = '<i class="give-icon give-icon-question"></i>'; |
| 195 | 195 | $args['attributes']['class'] = 'give-tooltip'; |
| 196 | - $tooltip_markup = $this->render_span( $args ); |
|
| 196 | + $tooltip_markup = $this->render_span($args); |
|
| 197 | 197 | |
| 198 | 198 | return $tooltip_markup; |
| 199 | 199 | } |
@@ -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,7 +25,7 @@ discard block |
||
| 25 | 25 | * @return array|bool array if errors are present, false if none found |
| 26 | 26 | */ |
| 27 | 27 | function give_get_errors() { |
| 28 | - return Give()->session->get( 'give_errors' ); |
|
| 28 | + return Give()->session->get('give_errors'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | -function give_set_error( $error_id, $error_message, $notice_args = array() ) { |
|
| 45 | +function give_set_error($error_id, $error_message, $notice_args = array()) { |
|
| 46 | 46 | $errors = give_get_errors(); |
| 47 | - if ( ! $errors ) { |
|
| 47 | + if ( ! $errors) { |
|
| 48 | 48 | $errors = array(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if( is_array( $notice_args ) && ! empty( $notice_args ) ) { |
|
| 52 | - $errors[ $error_id ] = array( |
|
| 51 | + if (is_array($notice_args) && ! empty($notice_args)) { |
|
| 52 | + $errors[$error_id] = array( |
|
| 53 | 53 | 'message' => $error_message, |
| 54 | 54 | 'notice_args' => $notice_args, |
| 55 | 55 | ); |
| 56 | 56 | } else { |
| 57 | 57 | // Backward compatibility v<1.8.11. |
| 58 | - $errors[ $error_id ] = $error_message; |
|
| 58 | + $errors[$error_id] = $error_message; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - Give()->session->set( 'give_errors', $errors ); |
|
| 61 | + Give()->session->set('give_errors', $errors); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return void |
| 70 | 70 | */ |
| 71 | 71 | function give_clear_errors() { |
| 72 | - Give()->session->set( 'give_errors', null ); |
|
| 72 | + Give()->session->set('give_errors', null); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return void |
| 84 | 84 | */ |
| 85 | -function give_unset_error( $error_id ) { |
|
| 85 | +function give_unset_error($error_id) { |
|
| 86 | 86 | $errors = give_get_errors(); |
| 87 | - if ( $errors ) { |
|
| 87 | + if ($errors) { |
|
| 88 | 88 | /** |
| 89 | 89 | * Check If $error_id exists in the array. |
| 90 | 90 | * If exists then unset it. |
| 91 | 91 | * |
| 92 | 92 | * @since 1.8.13 |
| 93 | 93 | */ |
| 94 | - if ( isset( $errors[ $error_id ] ) ) { |
|
| 95 | - unset( $errors[ $error_id ] ); |
|
| 94 | + if (isset($errors[$error_id])) { |
|
| 95 | + unset($errors[$error_id]); |
|
| 96 | 96 | } |
| 97 | - Give()->session->set( 'give_errors', $errors ); |
|
| 97 | + Give()->session->set('give_errors', $errors); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function _give_die_handler() { |
| 108 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
| 108 | + if (defined('GIVE_UNIT_TESTS')) { |
|
| 109 | 109 | return '_give_die_handler'; |
| 110 | 110 | } else { |
| 111 | 111 | die(); |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
| 129 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
| 130 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
| 131 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
| 128 | +function give_die($message = '', $title = '', $status = 400) { |
|
| 129 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
| 130 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
| 131 | + wp_die($message, $title, array('response' => $status)); |
|
| 132 | 132 | } |
@@ -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 | |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | * ) |
| 53 | 53 | */ |
| 54 | 54 | |
| 55 | - $_post = give_clean( $_POST ); |
|
| 55 | + $_post = give_clean($_POST); |
|
| 56 | 56 | |
| 57 | - if ( empty( $_post ) || empty( $_post['data'] ) || empty( $_post['hook'] ) ) { |
|
| 57 | + if (empty($_post) || empty($_post['data']) || empty($_post['hook'])) { |
|
| 58 | 58 | exit(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Fire the hook. |
| 63 | 63 | */ |
| 64 | - do_action( $_post['hook'], $_post['data'] ); |
|
| 64 | + do_action($_post['hook'], $_post['data']); |
|
| 65 | 65 | |
| 66 | 66 | exit(); |
| 67 | 67 | } |
@@ -6,16 +6,16 @@ discard block |
||
| 6 | 6 | * @version 1.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } // Exit if accessed directly. |
| 12 | 12 | |
| 13 | 13 | // For gmail compatibility, including CSS styles in head/body are stripped out therefore styles need to be inline. These variables contain rules which are added to the template inline. !important; is a gmail hack to prevent styles being stripped if it doesn't like something. |
| 14 | -$body = " |
|
| 14 | +$body = " |
|
| 15 | 15 | background-color: #f6f6f6; |
| 16 | 16 | font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; |
| 17 | 17 | "; |
| 18 | -$wrapper = " |
|
| 18 | +$wrapper = " |
|
| 19 | 19 | width:100%; |
| 20 | 20 | -webkit-text-size-adjust:none !important; |
| 21 | 21 | margin:0; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | border-radius:3px !important; |
| 30 | 30 | padding: 20px; |
| 31 | 31 | "; |
| 32 | -$template_header = " |
|
| 32 | +$template_header = " |
|
| 33 | 33 | color: #00000; |
| 34 | 34 | border-top-left-radius:3px !important; |
| 35 | 35 | border-top-right-radius:3px !important; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | text-align: center; |
| 40 | 40 | vertical-align:middle; |
| 41 | 41 | "; |
| 42 | -$body_content = " |
|
| 42 | +$body_content = " |
|
| 43 | 43 | border-radius:3px !important; |
| 44 | 44 | font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; |
| 45 | 45 | "; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | line-height:150%; |
| 51 | 51 | text-align:left; |
| 52 | 52 | "; |
| 53 | -$header_content_h1 = " |
|
| 53 | +$header_content_h1 = " |
|
| 54 | 54 | color: #000000; |
| 55 | 55 | margin:0; |
| 56 | 56 | padding: 28px 24px; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | <html> |
| 66 | 66 | <head> |
| 67 | 67 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 68 | - <title><?php echo get_bloginfo( 'name' ); ?></title> |
|
| 68 | + <title><?php echo get_bloginfo('name'); ?></title> |
|
| 69 | 69 | </head> |
| 70 | 70 | <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="<?php echo $body; ?>"> |
| 71 | 71 | <div style="<?php echo $wrapper; ?>"> |
@@ -4,17 +4,17 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if ( ! is_user_logged_in() ) { |
|
| 7 | +if ( ! is_user_logged_in()) { |
|
| 8 | 8 | |
| 9 | - if ( ! empty( $_GET['payment_key'] ) ) { |
|
| 10 | - $give_login_redirect = add_query_arg( 'payment_key', give_clean( $_GET['payment_key'] ) , give_get_history_page_uri() ); |
|
| 9 | + if ( ! empty($_GET['payment_key'])) { |
|
| 10 | + $give_login_redirect = add_query_arg('payment_key', give_clean($_GET['payment_key']), give_get_history_page_uri()); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | // Show any error messages after form submission |
| 14 | - Give()->notices->render_frontend_notices( 0 ); ?> |
|
| 14 | + Give()->notices->render_frontend_notices(0); ?> |
|
| 15 | 15 | <form id="give-login-form" class="give-form" action="" method="post"> |
| 16 | 16 | <fieldset> |
| 17 | - <legend><?php _e( 'Log into Your Account', 'give' ); ?></legend> |
|
| 17 | + <legend><?php _e('Log into Your Account', 'give'); ?></legend> |
|
| 18 | 18 | <?php |
| 19 | 19 | /** |
| 20 | 20 | * Fires in the login shortcode, before the login fields. |
@@ -23,27 +23,27 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @since 1.0 |
| 25 | 25 | */ |
| 26 | - do_action( 'give_login_fields_before' ); |
|
| 26 | + do_action('give_login_fields_before'); |
|
| 27 | 27 | ?> |
| 28 | 28 | <div class="give-login-username give-login"> |
| 29 | - <label for="give_user_login"><?php _e( 'Username', 'give' ); ?></label> |
|
| 29 | + <label for="give_user_login"><?php _e('Username', 'give'); ?></label> |
|
| 30 | 30 | <input name="give_user_login" id="give_user_login" class="give-required give-input" type="text" required aria-required="true" /> |
| 31 | 31 | </div> |
| 32 | 32 | |
| 33 | 33 | <div class="give-login-password give-login"> |
| 34 | - <label for="give_user_pass"><?php _e( 'Password', 'give' ); ?></label> |
|
| 34 | + <label for="give_user_pass"><?php _e('Password', 'give'); ?></label> |
|
| 35 | 35 | <input name="give_user_pass" id="give_user_pass" class="give-password give-required give-input" type="password" required aria-required="true" /> |
| 36 | 36 | </div> |
| 37 | 37 | |
| 38 | 38 | <div class="give-login-submit give-login"> |
| 39 | - <input type="hidden" name="give_login_redirect" value="<?php echo esc_url( $give_login_redirect ); ?>" /> |
|
| 40 | - <input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce( 'give-login-nonce' ); ?>" /> |
|
| 39 | + <input type="hidden" name="give_login_redirect" value="<?php echo esc_url($give_login_redirect); ?>" /> |
|
| 40 | + <input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce('give-login-nonce'); ?>" /> |
|
| 41 | 41 | <input type="hidden" name="give_action" value="user_login" /> |
| 42 | - <input id="give_login_submit" type="submit" class="give_submit" value="<?php _e( 'Log In', 'give' ); ?>" /> |
|
| 42 | + <input id="give_login_submit" type="submit" class="give_submit" value="<?php _e('Log In', 'give'); ?>" /> |
|
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="give-lost-password give-login"> |
| 46 | - <a href="<?php echo wp_lostpassword_url(); ?>"><?php _e( 'Reset Password', 'give' ); ?></a> |
|
| 46 | + <a href="<?php echo wp_lostpassword_url(); ?>"><?php _e('Reset Password', 'give'); ?></a> |
|
| 47 | 47 | </div> |
| 48 | 48 | <?php |
| 49 | 49 | /** |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @since 1.0 |
| 55 | 55 | */ |
| 56 | - do_action( 'give_login_fields_after' ); |
|
| 56 | + do_action('give_login_fields_after'); |
|
| 57 | 57 | ?> |
| 58 | 58 | </fieldset> |
| 59 | 59 | </form> |
| 60 | -<?php } elseif( isset( $_GET['give-login-success'] ) && true === (bool) $_GET['give-login-success'] ) { ?> |
|
| 61 | - <?php Give()->notices->print_frontend_notice( apply_filters('give_successful_login_message', __( 'Login successful. Welcome!', 'give' )), true, 'success' ); ?> |
|
| 60 | +<?php } elseif (isset($_GET['give-login-success']) && true === (bool) $_GET['give-login-success']) { ?> |
|
| 61 | + <?php Give()->notices->print_frontend_notice(apply_filters('give_successful_login_message', __('Login successful. Welcome!', 'give')), true, 'success'); ?> |
|
| 62 | 62 | <?php } else { ?> |
| 63 | - <?php Give()->notices->print_frontend_notice( apply_filters('give_already_logged_in_message', sprintf( __( 'You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give' ), esc_url( $give_logout_redirect ) ) ), true, 'warning' ); ?> |
|
| 63 | + <?php Give()->notices->print_frontend_notice(apply_filters('give_already_logged_in_message', sprintf(__('You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give'), esc_url($give_logout_redirect))), true, 'warning'); ?> |
|
| 64 | 64 | <?php } ?> |
| 65 | 65 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /* @var WPDB $wpdb */ |
| 36 | 36 | global $wpdb; |
| 37 | 37 | |
| 38 | - $this->table_name = $wpdb->prefix . 'give_logs'; |
|
| 38 | + $this->table_name = $wpdb->prefix.'give_logs'; |
|
| 39 | 39 | $this->primary_key = 'ID'; |
| 40 | 40 | $this->version = '1.0'; |
| 41 | 41 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @return array Default column values. |
| 74 | 74 | */ |
| 75 | 75 | public function get_column_defaults() { |
| 76 | - $log_create_date = current_time( 'mysql', 0 ); |
|
| 77 | - $log_create_date_gmt = get_gmt_from_date( $log_create_date ); |
|
| 76 | + $log_create_date = current_time('mysql', 0); |
|
| 77 | + $log_create_date_gmt = get_gmt_from_date($log_create_date); |
|
| 78 | 78 | |
| 79 | 79 | return array( |
| 80 | 80 | 'ID' => 0, |
@@ -97,39 +97,39 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return bool|int |
| 99 | 99 | */ |
| 100 | - public function add( $data = array() ) { |
|
| 100 | + public function add($data = array()) { |
|
| 101 | 101 | // Valid table columns. |
| 102 | - $table_columns = array_keys( $this->get_columns() ); |
|
| 102 | + $table_columns = array_keys($this->get_columns()); |
|
| 103 | 103 | |
| 104 | 104 | // Filter data. |
| 105 | - foreach ( $data as $table_column => $column_data ) { |
|
| 106 | - if ( ! in_array( $table_column, $table_columns ) ) { |
|
| 107 | - unset( $data[ $table_column ] ); |
|
| 105 | + foreach ($data as $table_column => $column_data) { |
|
| 106 | + if ( ! in_array($table_column, $table_columns)) { |
|
| 107 | + unset($data[$table_column]); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Set default values. |
| 112 | - $current_log_data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 112 | + $current_log_data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 113 | 113 | |
| 114 | 114 | // Log parent should be an int. |
| 115 | - $current_log_data['log_parent'] = absint( $current_log_data['log_parent'] ); |
|
| 115 | + $current_log_data['log_parent'] = absint($current_log_data['log_parent']); |
|
| 116 | 116 | |
| 117 | 117 | // Get log. |
| 118 | - $existing_log = $this->get_log_by( $current_log_data['ID'] ); |
|
| 118 | + $existing_log = $this->get_log_by($current_log_data['ID']); |
|
| 119 | 119 | |
| 120 | 120 | // Update an existing log. |
| 121 | - if ( $existing_log ) { |
|
| 121 | + if ($existing_log) { |
|
| 122 | 122 | |
| 123 | 123 | // Create new log data from existing and new log data. |
| 124 | - $current_log_data = array_merge( $current_log_data, $existing_log ); |
|
| 124 | + $current_log_data = array_merge($current_log_data, $existing_log); |
|
| 125 | 125 | |
| 126 | 126 | // Update log data. |
| 127 | - $this->update( $current_log_data['ID'], $current_log_data ); |
|
| 127 | + $this->update($current_log_data['ID'], $current_log_data); |
|
| 128 | 128 | |
| 129 | 129 | $log_id = $current_log_data['ID']; |
| 130 | 130 | |
| 131 | 131 | } else { |
| 132 | - $log_id = $this->insert( $current_log_data, 'log' ); |
|
| 132 | + $log_id = $this->insert($current_log_data, 'log'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $log_id; |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return bool|null|array |
| 149 | 149 | */ |
| 150 | - public function get_log_by( $log_id = 0, $by = 'id' ) { |
|
| 150 | + public function get_log_by($log_id = 0, $by = 'id') { |
|
| 151 | 151 | /* @var WPDB $wpdb */ |
| 152 | 152 | global $wpdb; |
| 153 | 153 | $log = null; |
| 154 | 154 | |
| 155 | 155 | // Make sure $log_id is int. |
| 156 | - $log_id = absint( $log_id ); |
|
| 156 | + $log_id = absint($log_id); |
|
| 157 | 157 | |
| 158 | 158 | // Bailout. |
| 159 | - if ( empty( $log_id ) ) { |
|
| 159 | + if (empty($log_id)) { |
|
| 160 | 160 | return null; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - switch ( $by ) { |
|
| 163 | + switch ($by) { |
|
| 164 | 164 | case 'id': |
| 165 | 165 | $log = $wpdb->get_row( |
| 166 | 166 | $wpdb->prepare( |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | break; |
| 173 | 173 | |
| 174 | 174 | default: |
| 175 | - $log = apply_filters( "give_get_log_by_{$by}", $log, $log_id ); |
|
| 175 | + $log = apply_filters("give_get_log_by_{$by}", $log, $log_id); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return $log; |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return mixed |
| 190 | 190 | */ |
| 191 | - public function get_logs( $args = array() ) { |
|
| 191 | + public function get_logs($args = array()) { |
|
| 192 | 192 | global $wpdb; |
| 193 | - $sql_query = $this->get_sql( $args ); |
|
| 193 | + $sql_query = $this->get_sql($args); |
|
| 194 | 194 | |
| 195 | 195 | // Get log. |
| 196 | - if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) { |
|
| 197 | - $logs = $wpdb->get_results( $sql_query ); |
|
| 198 | - Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query ); |
|
| 196 | + if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) { |
|
| 197 | + $logs = $wpdb->get_results($sql_query); |
|
| 198 | + Give_Cache::set('give_logs', $logs, 3600, true, $sql_query); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | return $logs; |
@@ -212,21 +212,21 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return int |
| 214 | 214 | */ |
| 215 | - public function count( $args = array() ) { |
|
| 215 | + public function count($args = array()) { |
|
| 216 | 216 | /* @var WPDB $wpdb */ |
| 217 | 217 | global $wpdb; |
| 218 | 218 | $args['number'] = - 1; |
| 219 | 219 | $args['fields'] = 'ID'; |
| 220 | 220 | $args['count'] = true; |
| 221 | 221 | |
| 222 | - $sql_query = $this->get_sql( $args ); |
|
| 222 | + $sql_query = $this->get_sql($args); |
|
| 223 | 223 | |
| 224 | - if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) { |
|
| 225 | - $count = $wpdb->get_var( $sql_query ); |
|
| 226 | - Give_Cache::set( 'give_logs_count', $count, 3600, true, $args ); |
|
| 224 | + if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) { |
|
| 225 | + $count = $wpdb->get_var($sql_query); |
|
| 226 | + Give_Cache::set('give_logs_count', $count, 3600, true, $args); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - return absint( $count ); |
|
| 229 | + return absint($count); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | PRIMARY KEY (ID) |
| 253 | 253 | ) {$charset_collate};"; |
| 254 | 254 | |
| 255 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 256 | - dbDelta( $sql ); |
|
| 255 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 256 | + dbDelta($sql); |
|
| 257 | 257 | |
| 258 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 258 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | - public function get_sql( $args = array() ) { |
|
| 272 | + public function get_sql($args = array()) { |
|
| 273 | 273 | /* @var WPDB $wpdb */ |
| 274 | 274 | global $wpdb; |
| 275 | 275 | |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | 'count' => false, |
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | - $args = wp_parse_args( $args, $defaults ); |
|
| 286 | + $args = wp_parse_args($args, $defaults); |
|
| 287 | 287 | |
| 288 | 288 | // validate params. |
| 289 | - $this->validate_params( $args ); |
|
| 289 | + $this->validate_params($args); |
|
| 290 | 290 | |
| 291 | - if ( $args['number'] < 1 ) { |
|
| 291 | + if ($args['number'] < 1) { |
|
| 292 | 292 | $args['number'] = 99999999999; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -296,78 +296,78 @@ discard block |
||
| 296 | 296 | $where = ''; |
| 297 | 297 | |
| 298 | 298 | // Get sql query for meta. |
| 299 | - if ( ! empty( $args['meta_query'] ) ) { |
|
| 300 | - $meta_query_object = new WP_Meta_Query( $args['meta_query'] ); |
|
| 301 | - $meta_query = $meta_query_object->get_sql( 'log', $this->table_name, 'id' ); |
|
| 302 | - $where = implode( '', $meta_query ); |
|
| 299 | + if ( ! empty($args['meta_query'])) { |
|
| 300 | + $meta_query_object = new WP_Meta_Query($args['meta_query']); |
|
| 301 | + $meta_query = $meta_query_object->get_sql('log', $this->table_name, 'id'); |
|
| 302 | + $where = implode('', $meta_query); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $where .= ' WHERE 1=1 '; |
| 306 | 306 | |
| 307 | 307 | // Set offset. |
| 308 | - if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) { |
|
| 309 | - $args['offset'] = $args['number'] * ( $args['paged'] - 1 ); |
|
| 308 | + if (empty($args['offset']) && (0 < $args['paged'])) { |
|
| 309 | + $args['offset'] = $args['number'] * ($args['paged'] - 1); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Set fields. |
| 313 | 313 | $fields = "{$this->table_name}.*"; |
| 314 | - if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) { |
|
| 314 | + if (is_string($args['fields']) && ('all' !== $args['fields'])) { |
|
| 315 | 315 | $fields = "{$this->table_name}.{$args['fields']}"; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Set count. |
| 319 | - if ( $args['count'] ) { |
|
| 319 | + if ($args['count']) { |
|
| 320 | 320 | $fields = "COUNT({$fields})"; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // Specific logs. |
| 324 | - if ( ! empty( $args['ID'] ) ) { |
|
| 324 | + if ( ! empty($args['ID'])) { |
|
| 325 | 325 | |
| 326 | - if ( ! is_array( $args['ID'] ) ) { |
|
| 327 | - $args['ID'] = explode( ',', $args['ID'] ); |
|
| 326 | + if ( ! is_array($args['ID'])) { |
|
| 327 | + $args['ID'] = explode(',', $args['ID']); |
|
| 328 | 328 | } |
| 329 | - $log_ids = implode( ',', array_map( 'intval', $args['ID'] ) ); |
|
| 329 | + $log_ids = implode(',', array_map('intval', $args['ID'])); |
|
| 330 | 330 | |
| 331 | 331 | $where .= " AND {$this->table_name}.ID IN( {$log_ids} ) "; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Logs created for a specific date or in a date range |
| 335 | - if ( ! empty( $args['date_query'] ) ) { |
|
| 336 | - $date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" ); |
|
| 337 | - $where .= $date_query_object->get_sql(); |
|
| 335 | + if ( ! empty($args['date_query'])) { |
|
| 336 | + $date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date"); |
|
| 337 | + $where .= $date_query_object->get_sql(); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // Logs create for specific parent. |
| 341 | - if ( ! empty( $args['log_parent'] ) ) { |
|
| 342 | - if ( ! is_array( $args['log_parent'] ) ) { |
|
| 343 | - $args['log_parent'] = explode( ',', $args['log_parent'] ); |
|
| 341 | + if ( ! empty($args['log_parent'])) { |
|
| 342 | + if ( ! is_array($args['log_parent'])) { |
|
| 343 | + $args['log_parent'] = explode(',', $args['log_parent']); |
|
| 344 | 344 | } |
| 345 | - $parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) ); |
|
| 345 | + $parent_ids = implode(',', array_map('intval', $args['log_parent'])); |
|
| 346 | 346 | |
| 347 | 347 | $where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) "; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | // Logs create for specific type. |
| 351 | 351 | // is_array check is for backward compatibility. |
| 352 | - if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) { |
|
| 353 | - if ( ! is_array( $args['log_type'] ) ) { |
|
| 354 | - $args['log_type'] = explode( ',', $args['log_type'] ); |
|
| 352 | + if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) { |
|
| 353 | + if ( ! is_array($args['log_type'])) { |
|
| 354 | + $args['log_type'] = explode(',', $args['log_type']); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) ); |
|
| 357 | + $log_types = implode('\',\'', array_map('trim', $args['log_type'])); |
|
| 358 | 358 | |
| 359 | 359 | $where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) "; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby']; |
|
| 362 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby']; |
|
| 363 | 363 | |
| 364 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
| 365 | - $args['order'] = esc_sql( $args['order'] ); |
|
| 364 | + $args['orderby'] = esc_sql($args['orderby']); |
|
| 365 | + $args['order'] = esc_sql($args['order']); |
|
| 366 | 366 | |
| 367 | 367 | return $wpdb->prepare( |
| 368 | 368 | "SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;", |
| 369 | - absint( $args['offset'] ), |
|
| 370 | - absint( $args['number'] ) |
|
| 369 | + absint($args['offset']), |
|
| 370 | + absint($args['number']) |
|
| 371 | 371 | ); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -382,13 +382,11 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return mixed |
| 384 | 384 | */ |
| 385 | - private function validate_params( &$args ) { |
|
| 385 | + private function validate_params(&$args) { |
|
| 386 | 386 | // fields params |
| 387 | 387 | $args['fields'] = 'ids' === $args['fields'] ? |
| 388 | - 'ID' : |
|
| 389 | - $args['fields']; |
|
| 390 | - $args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ? |
|
| 391 | - $args['fields'] : |
|
| 392 | - 'all'; |
|
| 388 | + 'ID' : $args['fields']; |
|
| 389 | + $args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ? |
|
| 390 | + $args['fields'] : 'all'; |
|
| 393 | 391 | } |
| 394 | 392 | } |