| 1 |
<?php |
| 2 |
namespace YayMail\Elements; |
| 3 |
|
| 4 |
use YayMail\Abstracts\BaseElement; |
| 5 |
use YayMail\Utils\SingletonTrait; |
| 6 |
/** |
| 7 |
* ImageBox Elements |
| 8 |
*/ |
| 9 |
class ImageBox extends BaseElement { |
| 10 |
|
| 11 |
use SingletonTrait; |
| 12 |
|
| 13 |
protected static $type = 'image_box'; |
| 14 |
|
| 15 |
public $available_email_ids = [ YAYMAIL_ALL_EMAILS ]; |
| 16 |
|
| 17 |
public static function get_data( $attributes = [] ) { |
| 18 |
$src = esc_url( YAYMAIL_PLUGIN_URL . 'assets/images/default-photo.png' ); |
| 19 |
self::$icon = '<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 20 20"> |
| 20 |
<path d="M18.31,2.5H1.69c-.38,0-.69-.34-.69-.75s.31-.75.69-.75h16.62c.38,0,.69.34.69.75s-.31.75-.69.75Z"/> |
| 21 |
<path d="M18.31,7.75h-6.9c-.38,0-.69-.34-.69-.75s.31-.75.69-.75h6.9c.38,0,.69.34.69.75s-.31.75-.69.75Z"/> |
| 22 |
<path d="M18.31,13.75h-6.9c-.38,0-.69-.34-.69-.75s.31-.75.69-.75h6.9c.38,0,.69.34.69.75s-.31.75-.69.75Z"/> |
| 23 |
<path d="M18.31,19H1.69c-.38,0-.69-.34-.69-.75s.31-.75.69-.75h16.62c.38,0,.69.34.69.75s-.31.75-.69.75Z"/> |
| 24 |
<path d="M8.43,13.66H1l-.04-.79v-6.63l.79-.04h7.44l.04.79v6.63l-.79.04ZM2.46,12.16h5.27v-4.46H2.46v4.46Z"/> |
| 25 |
</svg>'; |
| 26 |
|
| 27 |
return [ |
| 28 |
'id' => uniqid(), |
| 29 |
'type' => self::$type, |
| 30 |
'name' => __( 'Image Box', 'yaymail' ), |
| 31 |
'icon' => self::$icon, |
| 32 |
'group' => 'basic', |
| 33 |
'available' => true, |
| 34 |
'position' => 120, |
| 35 |
'data' => [ |
| 36 |
'container_group_definition' => [ |
| 37 |
'component' => 'GroupDefinition', |
| 38 |
'title' => __( 'Container settings', 'yaymail' ), |
| 39 |
'description' => __( 'Handle container layout settings', 'yaymail' ), |
| 40 |
], |
| 41 |
'background_color' => [ |
| 42 |
'value_path' => 'background_color', |
| 43 |
'component' => 'Color', |
| 44 |
'title' => __( 'Background color', 'yaymail' ), |
| 45 |
'default_value' => isset( $attributes['background_color'] ) ? $attributes['background_color'] : '#fff', |
| 46 |
'type' => 'style', |
| 47 |
], |
| 48 |
'text_color' => [ |
| 49 |
'value_path' => 'text_color', |
| 50 |
'component' => 'Color', |
| 51 |
'title' => __( 'Text color', 'yaymail' ), |
| 52 |
'default_value' => isset( $attributes['text_color'] ) ? $attributes['text_color'] : YAYMAIL_COLOR_TEXT_DEFAULT, |
| 53 |
'type' => 'style', |
| 54 |
], |
| 55 |
'column_breaker' => [ |
| 56 |
'component' => 'LineBreaker', |
| 57 |
], |
| 58 |
'column_settings' => [ |
| 59 |
'component' => 'GroupDefinition', |
| 60 |
'title' => __( 'Column settings', 'yaymail' ), |
| 61 |
'description' => __( 'Handle column settings', 'yaymail' ), |
| 62 |
], |
| 63 |
'image_box' => [ |
| 64 |
'component' => 'ImageBox', |
| 65 |
'value_path' => 'image_box', |
| 66 |
'column_1' => [ |
| 67 |
'padding' => [ |
| 68 |
'value' => $attributes['column_1']['padding'] ?? [ |
| 69 |
'top' => '10', |
| 70 |
'right' => '10', |
| 71 |
'bottom' => '10', |
| 72 |
'left' => '50', |
| 73 |
], |
| 74 |
'type' => 'style', |
| 75 |
], |
| 76 |
'align' => [ |
| 77 |
'value' => $attributes['column_1']['align'] ?? 'center', |
| 78 |
'type' => 'style', |
| 79 |
], |
| 80 |
'image' => [ |
| 81 |
'value' => $attributes['column_1']['image'] ?? $src, |
| 82 |
'type' => 'content', |
| 83 |
], |
| 84 |
'width' => [ |
| 85 |
'value' => $attributes['column_1']['width'] ?? '242', |
| 86 |
'type' => 'style', |
| 87 |
], |
| 88 |
'url' => [ |
| 89 |
'value' => $attributes['column_1']['url'] ?? '#', |
| 90 |
'type' => 'content', |
| 91 |
], |
| 92 |
'alt' => [ |
| 93 |
'value' => $attributes['column_1']['alt'] ?? '', |
| 94 |
'type' => 'content', |
| 95 |
], |
| 96 |
], |
| 97 |
'column_2' => [ |
| 98 |
'padding' => [ |
| 99 |
'value' => $attributes['column_2']['padding'] ?? [ |
| 100 |
'top' => '10', |
| 101 |
'right' => '50', |
| 102 |
'bottom' => '10', |
| 103 |
'left' => '10', |
| 104 |
], |
| 105 |
'type' => 'style', |
| 106 |
], |
| 107 |
'font_family' => [ |
| 108 |
'value' => $attributes['column_2']['font_family'] ?? YAYMAIL_DEFAULT_FAMILY, |
| 109 |
'type' => 'style', |
| 110 |
], |
| 111 |
'rich_text' => [ |
| 112 |
'value' => $attributes['column_2']['rich_text'] ?? '<p><span style="font-size: 18px;"><strong>This is a title</strong></span></p><p><span> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy.</span></p><p><span>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</span></p>', |
| 113 |
'type' => 'content', |
| 114 |
], |
| 115 |
], |
| 116 |
], |
| 117 |
], |
| 118 |
]; |
| 119 |
} |
| 120 |
} |
| 121 |
|