elementor
1 year ago
logs
1 month ago
strong-testimonials-beaver-block
1 year ago
submodules
8 months ago
class-strong-gutemberg.php
1 year ago
class-strong-log.php
1 year ago
class-strong-mail.php
1 year ago
class-strong-testimonials-average-shortcode.php
1 year ago
class-strong-testimonials-count-shortcode.php
1 year ago
class-strong-testimonials-defaults.php
1 month ago
class-strong-testimonials-form.php
1 month ago
class-strong-testimonials-order.php
1 year ago
class-strong-testimonials-privacy.php
1 year ago
class-strong-testimonials-render.php
1 month ago
class-strong-testimonials-templates.php
1 year ago
class-strong-testimonials-view-shortcode.php
1 week ago
class-strong-testimonials-view-widget.php
1 year ago
class-strong-view-display.php
1 day ago
class-strong-view-form.php
1 day ago
class-strong-view-slideshow.php
1 day ago
class-strong-view.php
1 day ago
class-walker-strong-category-checklist-front.php
1 year ago
deprecated.php
1 year ago
filters.php
1 month ago
functions-activation.php
1 month ago
functions-content.php
11 months ago
functions-image.php
5 months ago
functions-rating.php
1 year ago
functions-template-form.php
1 week ago
functions-template.php
4 months ago
functions-views.php
1 year ago
functions.php
1 month ago
l10n-polylang.php
1 year ago
l10n-wpml.php
1 year ago
post-types.php
1 week ago
retro.php
1 year ago
scripts.php
1 month ago
class-strong-mail.php
65 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Mail class. |
| 4 | */ |
| 5 | |
| 6 | // Exit if accessed directly |
| 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | exit; |
| 9 | } |
| 10 | |
| 11 | if ( ! class_exists( 'Strong_Mail' ) ) : |
| 12 | |
| 13 | class Strong_Mail { |
| 14 | |
| 15 | public function __construct() { |
| 16 | add_action( 'wp_loaded', array( $this, 'process_mail_queue' ), 20 ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Process mail queue |
| 21 | * |
| 22 | * @since 2.8.0 |
| 23 | */ |
| 24 | public function process_mail_queue() { |
| 25 | $current_queue = get_transient( 'wpmtst_mail_queue' ); |
| 26 | if ( ! $current_queue ) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | foreach ( $current_queue as $email ) { |
| 31 | $this->send_mail( $email ); |
| 32 | } |
| 33 | |
| 34 | delete_transient( 'wpmtst_mail_queue' ); |
| 35 | } |
| 36 | |
| 37 | public function send_mail( $email ) { |
| 38 | if ( defined( 'IS_LOCALHOST' ) && IS_LOCALHOST ) { |
| 39 | error_log( print_r( $email, true ) ); |
| 40 | } else { |
| 41 | wp_mail( $email['to'], $email['subject'], $email['message'], $email['headers'] ); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Enqueue mail. |
| 47 | * |
| 48 | * @since 2.8.0 |
| 49 | * @param $email |
| 50 | */ |
| 51 | public function enqueue_mail( $email ) { |
| 52 | $current_queue = get_transient( 'wpmtst_mail_queue' ); |
| 53 | if ( $current_queue ) { |
| 54 | delete_transient( 'wpmtst_mail_queue' ); |
| 55 | } else { |
| 56 | $current_queue = array(); |
| 57 | } |
| 58 | |
| 59 | $current_queue[] = $email; |
| 60 | set_transient( 'wpmtst_mail_queue', $current_queue, DAY_IN_SECONDS ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | endif; |
| 65 |