| 1 |
<?php |
| 2 |
|
| 3 |
namespace YayMail\Templates; |
| 4 |
|
| 5 |
use YayMail\Helper\Helper; |
| 6 |
// Templates Default |
| 7 |
use YayMail\Templates\DefaultTemplate\CancelledOrder; |
| 8 |
use YayMail\Templates\DefaultTemplate\CustomerCompletedOrder; |
| 9 |
use YayMail\Templates\DefaultTemplate\CustomerInvoice; |
| 10 |
use YayMail\Templates\DefaultTemplate\CustomerNewAccount; |
| 11 |
use YayMail\Templates\DefaultTemplate\CustomerNote; |
| 12 |
use YayMail\Templates\DefaultTemplate\CustomerOnHoldOrder; |
| 13 |
use YayMail\Templates\DefaultTemplate\CustomerProcessingOrder; |
| 14 |
use YayMail\Templates\DefaultTemplate\CustomerRefundedOrder; |
| 15 |
use YayMail\Templates\DefaultTemplate\CustomerResetPassword; |
| 16 |
use YayMail\Templates\DefaultTemplate\FailedOrder; |
| 17 |
use YayMail\Templates\DefaultTemplate\NewOrder; |
| 18 |
use YayMail\Templates\DefaultTemplate\CustomOrderStastus; |
| 19 |
use YayMail\Templates\DefaultTemplate\YITHSubscription; |
| 20 |
use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorDefault; |
| 21 |
use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorNewOrder; |
| 22 |
use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorCommissionsBulk; |
| 23 |
use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiVendorRegistration; |
| 24 |
use YayMail\Templates\DefaultTemplate\YITHMultiVendor\YITHMultiCommissions; |
| 25 |
use YayMail\Templates\DefaultTemplate\GermanizedForWoo\SimpleInvoice; |
| 26 |
use YayMail\Templates\DefaultTemplate\YITHWishlist\EstimateMail; |
| 27 |
use YayMail\Templates\DefaultTemplate\WooBookings\BookingsDefault; |
| 28 |
|
| 29 |
defined( 'ABSPATH' ) || exit; |
| 30 |
/** |
| 31 |
* Plugin activate/deactivate logic |
| 32 |
*/ |
| 33 |
class Templates { |
| 34 |
|
| 35 |
protected static $instance = null; |
| 36 |
|
| 37 |
public static function getInstance() { |
| 38 |
if ( null == self::$instance ) { |
| 39 |
self::$instance = new self(); |
| 40 |
} |
| 41 |
|
| 42 |
return self::$instance; |
| 43 |
} |
| 44 |
|
| 45 |
public static function getList() { |
| 46 |
$wc_emails = \WC_Emails::instance(); |
| 47 |
$listEmails = (array) $wc_emails::instance()->emails; |
| 48 |
$listEmails = apply_filters( 'YaymailCreateFollowUpTemplates', $listEmails ); |
| 49 |
$listEmailDefaultOfWoo = array( |
| 50 |
'new_order', |
| 51 |
'failed_order', |
| 52 |
'customer_reset_password', |
| 53 |
'customer_refunded_order', |
| 54 |
'customer_processing_order', |
| 55 |
'customer_on_hold_order', |
| 56 |
'customer_note', |
| 57 |
'customer_new_account', |
| 58 |
'customer_invoice', |
| 59 |
'customer_completed_order', |
| 60 |
'cancelled_order', |
| 61 |
); |
| 62 |
// Get Default Template |
| 63 |
$newOrderArr = NewOrder::getTemplates(); |
| 64 |
$cancelledOrderArr = CancelledOrder::getTemplates(); |
| 65 |
$cusComdOrderArr = CustomerCompletedOrder::getTemplates(); |
| 66 |
$cusInvoiceArr = CustomerInvoice::getTemplates(); |
| 67 |
$cusNewAccountArr = CustomerNewAccount::getTemplates(); |
| 68 |
$cusNoteArr = CustomerNote::getTemplates(); |
| 69 |
$cusOnHoldOrderArr = CustomerOnHoldOrder::getTemplates(); |
| 70 |
$cusProOrderArr = CustomerProcessingOrder::getTemplates(); |
| 71 |
$cusRefdOrderArr = CustomerRefundedOrder::getTemplates(); |
| 72 |
$cusResPasswordArr = CustomerResetPassword::getTemplates(); |
| 73 |
$faiOrderArr = FailedOrder::getTemplates(); |
| 74 |
|
| 75 |
$listTemplates = array(); |
| 76 |
$listTemplates = array_merge( $listTemplates, $newOrderArr ); |
| 77 |
$listTemplates = array_merge( $listTemplates, $cancelledOrderArr ); |
| 78 |
$listTemplates = array_merge( $listTemplates, $faiOrderArr ); |
| 79 |
$listTemplates = array_merge( $listTemplates, $cusOnHoldOrderArr ); |
| 80 |
$listTemplates = array_merge( $listTemplates, $cusProOrderArr ); |
| 81 |
$listTemplates = array_merge( $listTemplates, $cusComdOrderArr ); |
| 82 |
$listTemplates = array_merge( $listTemplates, $cusRefdOrderArr ); |
| 83 |
$listTemplates = array_merge( $listTemplates, $cusInvoiceArr ); |
| 84 |
$listTemplates = array_merge( $listTemplates, $cusNoteArr ); |
| 85 |
$listTemplates = array_merge( $listTemplates, $cusResPasswordArr ); |
| 86 |
$listTemplates = array_merge( $listTemplates, $cusNewAccountArr ); |
| 87 |
|
| 88 |
foreach ( $listEmails as $key => $value ) { |
| 89 |
if ( ! in_array( $value->id, $listEmailDefaultOfWoo ) ) { |
| 90 |
$newTempalte = apply_filters( 'YaymailNewTempalteDefault','', $key, $value ); |
| 91 |
if ( isset( $newTempalte ) && null != $newTempalte && is_array( $newTempalte ) ) { |
| 92 |
$listTemplates = array_merge( $listTemplates, $newTempalte ); |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
return $listTemplates; |
| 98 |
} |
| 99 |
|
| 100 |
public static function getCssFortmat() { |
| 101 |
$yaymail_settings = get_option( 'yaymail_settings' ); |
| 102 |
$colorTableItems = isset( $yaymail_settings['background_color_table_items'] ) && ! empty( $yaymail_settings['background_color_table_items'] ) ? $yaymail_settings['background_color_table_items'] : '#e5e5e5'; |
| 103 |
$colorTitleTableItems = isset( $yaymail_settings['title_items_color'] ) && ! empty( $yaymail_settings['title_items_color'] ) ? $yaymail_settings['title_items_color'] : '#96588a'; |
| 104 |
$colorContentTableItems = isset( $yaymail_settings['content_items_color'] ) && ! empty( $yaymail_settings['content_items_color'] ) ? $yaymail_settings['content_items_color'] : '#636363'; |
| 105 |
$custom_css = isset( $yaymail_settings['custom_css'] ) && ! empty( $yaymail_settings['custom_css'] ) ? $yaymail_settings['custom_css'] : ''; |
| 106 |
$enableCustomCss = isset( $yaymail_settings['enable_css_custom'] ) && ! empty( $yaymail_settings['enable_css_custom'] ) ? $yaymail_settings['enable_css_custom'] : ''; |
| 107 |
$orderImagePostions = isset( $yaymail_settings['image_position'] ) && ! empty( $yaymail_settings['image_position'] ) ? $yaymail_settings['image_position'] : 'Top'; |
| 108 |
/* |
| 109 |
====== |
| 110 |
@@@ Start css for shortcode [yaymail_items_border] |
| 111 |
@@@ note: use for table has border |
| 112 |
====== */ |
| 113 |
$order_dh = '<table></table>'; |
| 114 |
$css = 'table.yaymail_builder_table_items_border { |
| 115 |
border-collapse: separate !important; |
| 116 |
width: 100%; |
| 117 |
border: 1px solid ' . $colorTableItems . '; |
| 118 |
flex-direction: inherit; |
| 119 |
}'; |
| 120 |
$css .= 'table.yaymail_builder_table_items_content tbody tr td, table.yaymail_builder_table_items_content tbody tr th { |
| 121 |
vertical-align:middle; |
| 122 |
padding:12px; |
| 123 |
text-align:left; |
| 124 |
font-size: 14px; |
| 125 |
border-width: 1px; |
| 126 |
border-style: solid; |
| 127 |
border-color: inherit; |
| 128 |
}'; |
| 129 |
$css .= 'table.yaymail_builder_table_items_content tbody, table.yaymail_builder_table_items_content tbody tr, span[data-shordcode="yaymail_billing_shipping_address_content"] tbody, span[data-shordcode="yaymail_billing_shipping_address_content"] tbody tr { |
| 130 |
border-color: inherit; |
| 131 |
}'; |
| 132 |
|
| 133 |
$css .= 'table.yaymail_builder_table_items_border img { |
| 134 |
max-width: 100%; |
| 135 |
}'; |
| 136 |
|
| 137 |
$css .= 'table.yaymail_builder_table_items_border thead { |
| 138 |
border-width: 1px; |
| 139 |
border-style: solid; |
| 140 |
border-color: inherit |
| 141 |
}'; |
| 142 |
|
| 143 |
$css .= 'table.yaymail_builder_table_items_border thead tr { |
| 144 |
border-width: 1px; |
| 145 |
border-style: solid; |
| 146 |
border-color: inherit |
| 147 |
}'; |
| 148 |
|
| 149 |
$css .= 'table.yaymail_builder_table_items_border thead tr th { |
| 150 |
vertical-align:middle; |
| 151 |
padding:12px; |
| 152 |
text-align:left; |
| 153 |
font-family: inherit; |
| 154 |
font-size: 14px; |
| 155 |
border-width: 1px; |
| 156 |
border-style: solid; |
| 157 |
border-color: inherit |
| 158 |
}'; |
| 159 |
|
| 160 |
$css .= 'table.yaymail_builder_table_items_border tbody { |
| 161 |
border-width: 1px; |
| 162 |
border-style: solid; |
| 163 |
border-color: inherit |
| 164 |
}'; |
| 165 |
|
| 166 |
$css .= 'table.yaymail_builder_table_items_border tbody tr { |
| 167 |
border-width: 1px; |
| 168 |
border-style: solid; |
| 169 |
border-color: inherit |
| 170 |
}'; |
| 171 |
|
| 172 |
$css .= 'table.yaymail_builder_table_items_border tbody tr td { |
| 173 |
padding:12px; |
| 174 |
text-align:left; |
| 175 |
vertical-align:middle; |
| 176 |
font-family: inherit; |
| 177 |
word-break:normal; |
| 178 |
font-size: 14px; |
| 179 |
border-width: 1px; |
| 180 |
border-style: solid; |
| 181 |
border-color: inherit |
| 182 |
}'; |
| 183 |
|
| 184 |
$css .= 'table.yaymail_builder_table_items_border tfoot { |
| 185 |
border-width: 1px; |
| 186 |
border-style: solid; |
| 187 |
border-color: inherit |
| 188 |
}'; |
| 189 |
|
| 190 |
$css .= 'table.yaymail_builder_table_items_border tfoot tr { |
| 191 |
border-width: 1px; |
| 192 |
border-style: solid; |
| 193 |
border-color: inherit |
| 194 |
}'; |
| 195 |
|
| 196 |
$css .= 'table.yaymail_builder_table_items_border tfoot tr td { |
| 197 |
vertical-align:middle; |
| 198 |
padding:12px; |
| 199 |
text-align:left; |
| 200 |
font-family: inherit; |
| 201 |
font-size: 14px; |
| 202 |
border-width: 1px; |
| 203 |
border-style: solid; |
| 204 |
border-color: inherit |
| 205 |
}'; |
| 206 |
|
| 207 |
$css .= ' table.yaymail_builder_table_items_border tfoot tr th { |
| 208 |
vertical-align:middle; |
| 209 |
padding:12px; |
| 210 |
text-align:left; |
| 211 |
font-size: 14px; |
| 212 |
border-width: 1px; |
| 213 |
border-style: solid; |
| 214 |
border-color: inherit |
| 215 |
}'; |
| 216 |
|
| 217 |
$css .= 'table.yaymail_builder_table_items_border tr.order_item ul { |
| 218 |
font-size: small; |
| 219 |
margin: 1em 0 0; |
| 220 |
padding: 0; |
| 221 |
list-style: none; |
| 222 |
}'; |
| 223 |
|
| 224 |
$css .= 'table.yaymail_builder_table_items_border tr.order_item li strong { |
| 225 |
float:left; |
| 226 |
margin-right:.25em; |
| 227 |
clear:both; |
| 228 |
}'; |
| 229 |
|
| 230 |
$css .= 'table.yaymail_builder_table_items_border tr.order_item li { |
| 231 |
margin:0.5em 0 0; |
| 232 |
padding:0; |
| 233 |
}'; |
| 234 |
|
| 235 |
$css .= 'table.yaymail_builder_table_items_border tr.order_item li p { |
| 236 |
margin: 0; |
| 237 |
}'; |
| 238 |
|
| 239 |
/* ====== End ====== */ |
| 240 |
|
| 241 |
/* |
| 242 |
====== |
| 243 |
@@@ Start css for shortcode [yaymail_items] |
| 244 |
@@@ note: use for table not border |
| 245 |
====== */ |
| 246 |
$css .= 'table.yaymail_builder_table_items { |
| 247 |
border-collapse: collapse !important; |
| 248 |
width: 100%; |
| 249 |
color:' . $colorContentTableItems . '; |
| 250 |
}'; |
| 251 |
|
| 252 |
$css .= 'table.yaymail_builder_table_items img { |
| 253 |
max-width: 100% |
| 254 |
}'; |
| 255 |
|
| 256 |
$css .= 'table.yaymail_builder_table_items tbody tr, |
| 257 |
table.yaymail_builder_table_items tbody tr td, |
| 258 |
table.yaymail_builder_table_items thead tr, |
| 259 |
table.yaymail_builder_table_items thead tr th, |
| 260 |
table.yaymail_builder_table_items thead tr td, |
| 261 |
table.yaymail_builder_table_items tfoot tr, |
| 262 |
table.yaymail_builder_table_items tfoot tr th, |
| 263 |
table.yaymail_builder_table_items tfoot tr td { |
| 264 |
vertical-align:middle; |
| 265 |
padding:12px; |
| 266 |
text-align:left; |
| 267 |
font-size:14px; |
| 268 |
}'; |
| 269 |
|
| 270 |
$css .= 'table td { |
| 271 |
font-family: inherit; |
| 272 |
}'; |
| 273 |
|
| 274 |
$css .= 'table.yaymail_builder_table_items tr { |
| 275 |
border-bottom: 1px solid ' . $colorTableItems . ' |
| 276 |
}'; |
| 277 |
|
| 278 |
$css .= '.yaymail_builder_bank_details, .yaymail_builder_account_name { |
| 279 |
color: inherit; |
| 280 |
display:block; |
| 281 |
font-family: inherit; |
| 282 |
font-size:18px; |
| 283 |
font-weight:bold; |
| 284 |
line-height:130%; |
| 285 |
margin:0 0 18px; |
| 286 |
}'; |
| 287 |
|
| 288 |
$css .= '.yaymail_builder_order { |
| 289 |
margin-bottom: 0.83em; |
| 290 |
display:block; |
| 291 |
font-family: inherit; |
| 292 |
font-size:18px; |
| 293 |
font-weight:bold; |
| 294 |
line-height:130%; |
| 295 |
margin:0 0 18px; |
| 296 |
}'; |
| 297 |
|
| 298 |
$css .= 'table.yaymail_builder_table_items tr.order_item ul { |
| 299 |
font-size: small; |
| 300 |
margin: 1em 0 0; |
| 301 |
padding: 0; |
| 302 |
list-style: none; |
| 303 |
}'; |
| 304 |
|
| 305 |
$css .= 'table.yaymail_builder_table_items tr.order_item li strong { |
| 306 |
float:left; |
| 307 |
margin-right:.25em; |
| 308 |
clear:both |
| 309 |
}'; |
| 310 |
|
| 311 |
$css .= 'table.yaymail_builder_table_items tr.order_item li { |
| 312 |
margin:0.5em 0 0; |
| 313 |
padding:0; |
| 314 |
}'; |
| 315 |
|
| 316 |
$css .= 'table.yaymail_builder_table_items tr.order_item li p { |
| 317 |
margin: 0; |
| 318 |
}'; |
| 319 |
|
| 320 |
$css .= 'table.yaymail_builder_table_items ul li { |
| 321 |
list-style: none; |
| 322 |
margin-left: 0px; |
| 323 |
}'; |
| 324 |
/* ====== End ====== */ |
| 325 |
|
| 326 |
$css .= 'h3.yaymail_builder_account_name { |
| 327 |
font-size:16px; |
| 328 |
}'; |
| 329 |
|
| 330 |
$css .= '.yaymail_builder_order a.yaymail_builder_link { |
| 331 |
font-weight: normal; |
| 332 |
text-decoration: underline; |
| 333 |
}'; |
| 334 |
|
| 335 |
$css .= '.yaymail_builder_order ul { |
| 336 |
padding-left: 0px |
| 337 |
}'; |
| 338 |
|
| 339 |
$css .= 'section.yaymail_builder_wrap_account { |
| 340 |
color: inherit; |
| 341 |
font-family: inherit; |
| 342 |
font-size: 14px; |
| 343 |
line-height: 150%; |
| 344 |
text-align: left; |
| 345 |
}'; |
| 346 |
|
| 347 |
$css .= 'section.yaymail_builder_wrap_account ul { |
| 348 |
color: ' . $colorContentTableItems . '; |
| 349 |
}'; |
| 350 |
|
| 351 |
$css .= '.yaymail_builder_instructions{ |
| 352 |
color: ' . $colorContentTableItems . '; |
| 353 |
font-family: inherit; |
| 354 |
font-size: 14px; |
| 355 |
line-height: 150%; |
| 356 |
text-align: left; |
| 357 |
}'; |
| 358 |
|
| 359 |
// reset css |
| 360 |
$css .= 'table p { |
| 361 |
margin: 0px; |
| 362 |
}'; |
| 363 |
|
| 364 |
$css .= 'table h1, table h2, table h3, table h4, table h5, table h6 { |
| 365 |
margin: 0px; |
| 366 |
}'; |
| 367 |
|
| 368 |
$css .= '.yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"], |
| 369 |
.yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"] |
| 370 |
.yaymail_builder_table_items_border { |
| 371 |
border-color: inherit; |
| 372 |
flex-direction: inherit; |
| 373 |
} |
| 374 |
.yaymail-items-order-border tbody[data-shordcode="yaymail_items_border_content"] |
| 375 |
.yaymail_builder_table_items_border tbody { |
| 376 |
flex-direction: inherit; |
| 377 |
}'; |
| 378 |
// add css for table subcription, item download |
| 379 |
$css .= 'table.yaymail_builder_table_subcription, |
| 380 |
table.yaymail_builder_table_tracking_item, |
| 381 |
table.yaymail_builder_table_item_download, |
| 382 |
table.yaymail_builder_table_item_subscription, |
| 383 |
table.yaymail_builder_table_item_multi_vendor { |
| 384 |
color: inherit; |
| 385 |
border-width: 1px; |
| 386 |
border-style: solid; |
| 387 |
border-color: inherit; |
| 388 |
}'; |
| 389 |
$css .= '.yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_expired"], |
| 390 |
.yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_suspended"], |
| 391 |
.yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_cancelled"], |
| 392 |
.yaymail-items-order-border span[data-shordcode="yaymail_items_subscription_information"], |
| 393 |
.yaymail-items-tracking-item span[data-shordcode="yaymail_order_meta:_wc_shipment_tracking_items"], |
| 394 |
.yaymail-items-item-download span[data-shordcode="yaymail_items_downloadable_product"], |
| 395 |
.yaymail-items-subscript-border span[data-shordcode="yaymail_subscription_table"] |
| 396 |
{ |
| 397 |
border-color: inherit; |
| 398 |
}'; |
| 399 |
|
| 400 |
$css .= '#web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h2, |
| 401 |
#web-ad422370-f762-4a26-92de-c4cf3821b8eb-order-item .yaymail_items_border_default h3 { |
| 402 |
color: #96588a; |
| 403 |
}'; |
| 404 |
$css .= '.yaymail_items_border_custom h2,.yaymail_items_border_custom h3 { |
| 405 |
color: inherit !important; |
| 406 |
}'; |
| 407 |
$css .= '.nta-two-column-items table.web-main-row , |
| 408 |
.nta-three-column-items table.web-main-row, |
| 409 |
.nta-four-column-items table.web-main-row |
| 410 |
{ |
| 411 |
width: 100% !important; |
| 412 |
}'; |
| 413 |
if ( 'yes' == $enableCustomCss ) { |
| 414 |
$css .= $custom_css; |
| 415 |
} |
| 416 |
|
| 417 |
if ( 'Left' == $orderImagePostions ) { |
| 418 |
$css .= '.yaymail-product-image{ |
| 419 |
float: left; |
| 420 |
}'; |
| 421 |
} |
| 422 |
|
| 423 |
if ( 'Top' == $orderImagePostions ) { |
| 424 |
$css .= '.yaymail-product-image{ |
| 425 |
float: unset; |
| 426 |
}'; |
| 427 |
} |
| 428 |
return $css; |
| 429 |
} |
| 430 |
} |
| 431 |
|