| @@ -2,9 +2,8 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Summary email base class |
| 4 | 4 | * |
| 5 | 5 | * @since 6.7 |
| 6 | - * | |
| 7 | 6 | * @package Formidable |
| 8 | 7 | */ |
| 9 | 8 | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -13,17 +12,8 @@ | ||
| 13 | 12 | |
| 14 | 13 | abstract class FrmEmailSummary { |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | - * Name of the file with the HTML content, without the file extension. | |
| 18 | - * | |
| 19 | - * @since 6.15 | |
| 20 | - * | |
| 21 | - * @var string | |
| 22 | - */ | |
| 23 | - protected $template = 'base'; | |
| 24 | - | |
| 25 | - /** | |
| 26 | 16 | * Is HTML email? |
| 27 | 17 | * |
| 28 | 18 | * @var bool |
| 29 | 19 | */ |
| @@ -38,15 +28,11 @@ | ||
| 38 | 28 | |
| 39 | 29 | /** |
| 40 | 30 | * Gets inner content. |
| 41 | 31 | * |
| 42 | - * @since 6.15 Method isn't abstract anymore, returning an empty string by default. | |
| 43 | - * | |
| 44 | 32 | * @return false|string |
| 45 | 33 | */ |
| 46 | - protected function get_inner_content() { | |
| 47 | - return ''; | |
| 48 | - } | |
| 34 | + abstract protected function get_inner_content(); | |
| 49 | 35 | |
| 50 | 36 | /** |
| 51 | 37 | * Constructor. |
| 52 | 38 | */ |
| @@ -80,9 +66,9 @@ | ||
| 80 | 66 | */ |
| 81 | 67 | protected function get_headers() { |
| 82 | 68 | return array( |
| 83 | 69 | 'Content-Type: ' . ( $this->is_html ? 'text/html; charset=UTF-8' : 'text/plain' ), |
| 84 | - 'From: ' . get_bloginfo( 'name' ) . ' <' . FrmEmailHelper::get_default_from_email() . '>', | |
| 70 | + 'From: ' . get_bloginfo( 'name' ) . ' <' . get_bloginfo( 'admin_email' ) . '>', | |
| 85 | 71 | ); |
| 86 | 72 | } |
| 87 | 73 | |
| 88 | 74 | /** |
| @@ -93,18 +79,19 @@ | ||
| 93 | 79 | * @return false|string |
| 94 | 80 | */ |
| 95 | 81 | protected function get_content() { |
| 96 | 82 | $args = $this->get_content_args(); |
| 97 | - | |
| 98 | 83 | if ( false === $args ) { |
| 99 | 84 | return false; |
| 100 | 85 | } |
| 101 | 86 | |
| 102 | 87 | ob_start(); |
| 103 | - include $this->get_include_file( $this->template ); | |
| 88 | + include $this->get_include_file( 'base' ); | |
| 104 | 89 | $content = ob_get_clean(); |
| 105 | 90 | |
| 106 | - return str_replace( '%%INNER_CONTENT%%', $this->get_inner_content(), $content ); | |
| 91 | + $content = str_replace( '%%INNER_CONTENT%%', $this->get_inner_content(), $content ); | |
| 92 | + | |
| 93 | + return $content; | |
| 107 | 94 | } |
| 108 | 95 | |
| 109 | 96 | /** |
| 110 | 97 | * Gets include file path from the given file name. |
| @@ -109,28 +96,16 @@ | ||
| 109 | 96 | /** |
| 110 | 97 | * Gets include file path from the given file name. |
| 111 | 98 | * |
| 112 | 99 | * @param string $file_name File name. |
| 113 | - * | |
| 114 | 100 | * @return string |
| 115 | 101 | */ |
| 116 | 102 | protected function get_include_file( $file_name ) { |
| 117 | 103 | $suffix = $this->is_html ? '' : '-plain'; |
| 118 | - return $this->get_include_folder() . $file_name . $suffix . '.php'; | |
| 104 | + return FrmAppHelper::plugin_path() . '/classes/views/summary-emails/' . $file_name . $suffix . '.php'; | |
| 119 | 105 | } |
| 120 | 106 | |
| 121 | 107 | /** |
| 122 | - * Gets the full path to the folder containing the email templates. | |
| 123 | - * | |
| 124 | - * @since 6.15 | |
| 125 | - * | |
| 126 | - * @return string | |
| 127 | - */ | |
| 128 | - protected function get_include_folder() { | |
| 129 | - return FrmAppHelper::plugin_path() . '/classes/views/summary-emails/'; | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | 108 | * Gets content args. |
| 134 | 109 | * |
| 135 | 110 | * @since 6.8 This can return `false` to skip sending email. |
| 136 | 111 | * |
| @@ -156,30 +131,14 @@ | ||
| 156 | 131 | return apply_filters( 'frm_summary_email_content_args', $args, array( 'email_obj' => $this ) ); |
| 157 | 132 | } |
| 158 | 133 | |
| 159 | 134 | /** |
| 160 | - * Check if the email should be sent. | |
| 161 | - * | |
| 162 | - * @since 6.15 | |
| 163 | - * | |
| 164 | - * @return bool | |
| 165 | - */ | |
| 166 | - protected function should_send() { | |
| 167 | - return true; | |
| 168 | - } | |
| 169 | - | |
| 170 | - /** | |
| 171 | 135 | * Sends email. |
| 172 | 136 | * |
| 173 | 137 | * @return bool |
| 174 | 138 | */ |
| 175 | 139 | public function send() { |
| 176 | - if ( ! $this->should_send() ) { | |
| 177 | - return false; | |
| 178 | - } | |
| 179 | - | |
| 180 | 140 | $recipients = $this->get_recipients(); |
| 181 | - | |
| 182 | 141 | if ( ! $recipients ) { |
| 183 | 142 | // Return true to not try to send this email on the next day. |
| 184 | 143 | return true; |
| 185 | 144 | } |
| @@ -184,17 +143,15 @@ | ||
| 184 | 143 | return true; |
| 185 | 144 | } |
| 186 | 145 | |
| 187 | 146 | $content = $this->get_content(); |
| 188 | - | |
| 189 | 147 | if ( false === $content ) { |
| 190 | 148 | return true; |
| 191 | 149 | } |
| 192 | - | |
| 193 | 150 | $subject = $this->get_subject(); |
| 194 | 151 | $headers = $this->get_headers(); |
| 195 | - $sent = wp_mail( $recipients, $subject, $content, $headers ); | |
| 196 | 152 | |
| 153 | + $sent = wp_mail( $recipients, $subject, $content, $headers ); | |
| 197 | 154 | if ( ! $sent ) { |
| 198 | 155 | $headers = implode( "\r\n", $headers ); |
| 199 | 156 | $sent = mail( $recipients, $subject, $content, $headers ); |
| 200 | 157 | } |