| 1 |
<?php |
| 2 |
class SUE_Template_Data |
| 3 |
{ |
| 4 |
public $template_args; |
| 5 |
|
| 6 |
public function __construct($template_args = []) { |
| 7 |
$this->template_args = $template_args; |
| 8 |
} |
| 9 |
|
| 10 |
public function get_template_args() { |
| 11 |
return $this->template_args; |
| 12 |
} |
| 13 |
|
| 14 |
public function get_template_args_by_key($key, $default = null) { |
| 15 |
return isset($this->template_args[$key]) ? $this->template_args[$key] : $default; |
| 16 |
} |
| 17 |
|
| 18 |
public function is_preview() { |
| 19 |
return $this->get_template_args_by_key('preview', false); |
| 20 |
} |
| 21 |
|
| 22 |
public function get_email_style_name() { |
| 23 |
return $this->get_template_args_by_key('style', 'default'); |
| 24 |
} |
| 25 |
|
| 26 |
public function get_email_title() { |
| 27 |
return $this->get_template_args_by_key('title', 'Email Title'); |
| 28 |
} |
| 29 |
|
| 30 |
public function get_email_tagline() { |
| 31 |
return $this->get_template_args_by_key('tagline', 'Tagline lorem ipsum dolor sit amet, consectetur adipiscing elit.'); |
| 32 |
} |
| 33 |
|
| 34 |
public function get_email_logo() { |
| 35 |
return $this->get_template_args_by_key('logo', ''); |
| 36 |
} |
| 37 |
|
| 38 |
public function has_email_logo() { |
| 39 |
return !empty($this->get_email_logo()); |
| 40 |
} |
| 41 |
|
| 42 |
public function display_email_logo() { |
| 43 |
if ($this->has_email_logo()) { |
| 44 |
echo '<img src="' . esc_attr($this->get_email_logo()) . '" alt="Email Logo" class="sue-email-logo" style="max-width: 200px; margin-bottom: 20px;">'; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
public function get_email_footer() { |
| 49 |
return $this->get_template_args_by_key('footer', ''); |
| 50 |
} |
| 51 |
|
| 52 |
public function get_email_social_links() { |
| 53 |
return $this->get_template_args_by_key('social', []); |
| 54 |
} |
| 55 |
|
| 56 |
public function get_email_styles() { |
| 57 |
return $this->get_template_args_by_key('styles', ''); |
| 58 |
} |
| 59 |
|
| 60 |
public function get_email_body() { |
| 61 |
|
| 62 |
if($this->is_preview()) { |
| 63 |
return '<p>' . __('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.', 'send-users-email') . '</p>'; |
| 64 |
} |
| 65 |
|
| 66 |
return wp_kses_post( stripslashes_deep( $this->get_template_args_by_key('email_body') ) ); |
| 67 |
} |
| 68 |
|
| 69 |
public function display_social_links() { |
| 70 |
$socials = $this->get_email_social_links(); |
| 71 |
if ( ! empty( $socials ) ) { |
| 72 |
foreach ( Send_Users_Email_Admin::$social as $platform ) { |
| 73 |
if ( isset( $socials[ $platform ] ) ) { |
| 74 |
if ( ! empty( $socials[ $platform ] ) ) { |
| 75 |
echo '<a href="' . esc_url_raw( $socials[ $platform ] ) . '" style="text-decoration: none; margin-right: 10px;">'; |
| 76 |
echo '<img src="' . esc_attr( sue_get_asset_url( $platform . '.png' ) ) . '" alt="' . esc_attr($platform) . '" width="35" style="display:inline-block;border-width:0;max-width: 35px;">'; |
| 77 |
echo '</a>'; |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
|