| @@ -42,9 +42,8 @@ | ||
| 42 | 42 | 'modified_by' => '_yaymail_modified_by', |
| 43 | 43 | 'is_v4_supported' => '_yaymail_is_v4_supported', |
| 44 | 44 | 'global_header_settings' => '_yaymail_global_header_settings', |
| 45 | 45 | 'global_footer_settings' => '_yaymail_global_footer_settings', |
| 46 | - 'preheader' => '_yaymail_preheader', | |
| 47 | 46 | ]; |
| 48 | 47 | |
| 49 | 48 | public const DEFAULT_DATA = [ |
| 50 | 49 | 'name' => '', |
| @@ -57,10 +56,8 @@ | ||
| 57 | 56 | 'title_color' => '', |
| 58 | 57 | 'language' => '', |
| 59 | 58 | 'modified_by' => '', |
| 60 | 59 | 'is_v4_supported' => false, |
| 61 | - 'attachments' => [], | |
| 62 | - 'preheader' => '', | |
| 63 | 60 | 'global_header_settings' => [ |
| 64 | 61 | 'content_override' => false, |
| 65 | 62 | 'heading_content' => '<h1 style="font-size: 30px; font-weight: 300; line-height: normal; margin: 0px; color: inherit;">Hello YayMail</h1>', |
| 66 | 63 | 'hidden' => false, |
| @@ -82,10 +79,8 @@ | ||
| 82 | 79 | 'background_color' => self::DEFAULT_DATA['background_color'], |
| 83 | 80 | 'text_link_color' => self::DEFAULT_DATA['text_link_color'], |
| 84 | 81 | 'language' => self::DEFAULT_DATA['language'], |
| 85 | 82 | 'title_color' => self::DEFAULT_DATA['title_color'], |
| 86 | - 'attachments' => self::DEFAULT_DATA['attachments'], | |
| 87 | - 'preheader' => self::DEFAULT_DATA['preheader'], | |
| 88 | 83 | 'global_header_settings' => self::DEFAULT_DATA['global_header_settings'], |
| 89 | 84 | 'global_footer_settings' => self::DEFAULT_DATA['global_footer_settings'], |
| 90 | 85 | ]; |
| 91 | 86 | |
| @@ -92,9 +87,9 @@ | ||
| 92 | 87 | public function __construct( $template_name = '', $language = '' ) { |
| 93 | 88 | |
| 94 | 89 | $this->model = TemplateModel::get_instance(); |
| 95 | 90 | |
| 96 | - if ( is_string( $template_name ) && ! empty( $template_name ) ) { | |
| 91 | + if ( is_string( $template_name ) && ! empty( $template_name ) && Helpers::is_yaymail_email( $template_name ) ) { | |
| 97 | 92 | $template_data = $this->model::find_by_name( $template_name, $language ); |
| 98 | 93 | if ( empty( $template_data['id'] ) && SupportedPlugins::get_instance()->get_support_info( $template_name )['status'] === 'already_supported' ) { |
| 99 | 94 | /** Insert new template when not exists */ |
| 100 | 95 | $template_data = $this->model::insert( |
| @@ -125,11 +120,8 @@ | ||
| 125 | 120 | |
| 126 | 121 | public function is_enabled() { |
| 127 | 122 | // Check if YayMail core is migrated |
| 128 | 123 | // If not, consider template is not activated |
| 129 | - if ( ! defined( 'YAYMAIL_VERSION' ) ) { | |
| 130 | - return $this->get_status() === 'active'; | |
| 131 | - } | |
| 132 | 124 | $old_version = get_option( 'yaymail_version' ); |
| 133 | 125 | if ( $old_version && version_compare( $old_version, '4.0.0', '<' ) ) { |
| 134 | 126 | return false; |
| 135 | 127 | } |
| @@ -203,16 +195,8 @@ | ||
| 203 | 195 | public function get_title_color( $context = 'view' ) { |
| 204 | 196 | return $this->get_prop( 'title_color', $context ); |
| 205 | 197 | } |
| 206 | 198 | |
| 207 | - public function get_attachments( $context = 'view' ) { | |
| 208 | - return $this->get_prop( 'attachments', $context ); | |
| 209 | - } | |
| 210 | - | |
| 211 | - public function get_preheader( $context = 'view' ) { | |
| 212 | - return $this->get_prop( 'preheader', $context ); | |
| 213 | - } | |
| 214 | - | |
| 215 | 199 | /** |
| 216 | 200 | * Get global header |
| 217 | 201 | * |
| 218 | 202 | * @since 4.1.0 |
| @@ -301,14 +285,8 @@ | ||
| 301 | 285 | $this->set_prop( 'language', $value ); |
| 302 | 286 | } |
| 303 | 287 | } |
| 304 | 288 | |
| 305 | - public function set_preheader( $value ) { | |
| 306 | - if ( is_string( $value ) ) { | |
| 307 | - $this->set_prop( 'preheader', $value ); | |
| 308 | - } | |
| 309 | - } | |
| 310 | - | |
| 311 | 289 | public function set_title_color( $value ) { |
| 312 | 290 | if ( ! is_null( $value ) && is_string( $value ) ) { |
| 313 | 291 | $this->set_prop( 'title_color', $value ); |
| 314 | 292 | } |
| @@ -369,12 +347,8 @@ | ||
| 369 | 347 | } |
| 370 | 348 | |
| 371 | 349 | public function get_content( $data ) { |
| 372 | 350 | try { |
| 373 | - if ( strpos( $this->get_name(), 'wp-core-' ) === 0 && ! empty( $this->renderer ) ) { | |
| 374 | - return $this->renderer->generate_content( $data ); | |
| 375 | - } | |
| 376 | - | |
| 377 | 351 | if ( ! empty( $this->renderer ) ) { |
| 378 | 352 | return StyleInline::get_instance()->convert_style_inline( $this->renderer->generate_content( $data ) ); |
| 379 | 353 | } |
| 380 | 354 | } catch ( \Exception $e ) { |
| @@ -380,8 +354,8 @@ | ||
| 380 | 354 | } catch ( \Exception $e ) { |
| 381 | 355 | yaymail_get_logger( $e->getMessage() ); |
| 382 | 356 | } catch ( \Error $e ) { |
| 383 | 357 | yaymail_get_logger( $e->getMessage() ); |
| 384 | - }//end try | |
| 358 | + } | |
| 385 | 359 | return ''; |
| 386 | 360 | } |
| 387 | 361 | } |