PluginProbe
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel / trunk
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel vtrunk
1.7.1 1.7.0 1.6.0 1.5.2 trunk 0.1 0.2.0 0.2.1 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.4 0.4.1 0.4.2 0.4.3 1.0 1.1 1.2 1.3.1 1.4.0 1.4.1 1.5.0 1.5.1 All 26 releases
flywp / includes / Email.php

Email.php in FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel trunk, at includes/Email.php

63 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FlyWP;
4
5 class Email {
6
7 /**
8 * Class constructor.
9 */
10 public function __construct() {
11 add_filter( 'wp_mail_from', [ $this, 'mail_from' ], PHP_INT_MAX );
12 add_filter( 'wp_mail_from_name', [ $this, 'mail_from_name' ], PHP_INT_MAX );
13 }
14
15 /**
16 * Set the from email.
17 *
18 * @param string $email
19 *
20 * @return string
21 */
22 public function mail_from( $email ) {
23 $settings = $this->settings();
24
25 if ( ! empty( $settings['from_email'] ) ) {
26 return $settings['from_email'];
27 }
28
29 return $email;
30 }
31
32 /**
33 * Set the from name.
34 *
35 * @param string $name
36 *
37 * @return string
38 */
39 public function mail_from_name( $name ) {
40 $settings = $this->settings();
41
42 if ( ! empty( $settings['from_name'] ) ) {
43 return $settings['from_name'];
44 }
45
46 return $name;
47 }
48
49 /**
50 * Get all email settings.
51 *
52 * @return array
53 */
54 public function settings() {
55 $default = [
56 'from_name' => '',
57 'from_email' => '',
58 ];
59
60 return get_option( 'flywp_email_settings', $default );
61 }
62 }
63