Skip to content
Snippets Groups Projects
Commit 4ffdc837 authored by Piotr Potrebka's avatar Piotr Potrebka
Browse files

init

parent 1df74b3a
No related branches found
No related tags found
1 merge request!2Devel
Pipeline #150354 passed with stages
in 53 seconds
<?php
namespace WPDesk\Library\WPEmail\Abstracts;
use WPDesk\View\Renderer\Renderer;
interface ConditionInterface {
public function is_valid(): bool;
}
...@@ -4,7 +4,7 @@ namespace WPDesk\Library\WPEmail\Abstracts; ...@@ -4,7 +4,7 @@ namespace WPDesk\Library\WPEmail\Abstracts;
use WPDesk\View\Renderer\Renderer; use WPDesk\View\Renderer\Renderer;
abstract class EmailGettersAbstract implements EmailGettersInterface, EmailSettersInterface { abstract class EmailGettersAbstract implements EmailGettersInterface, ConditionInterface {
/** /**
* @var Renderer * @var Renderer
...@@ -142,4 +142,8 @@ abstract class EmailGettersAbstract implements EmailGettersInterface, EmailSette ...@@ -142,4 +142,8 @@ abstract class EmailGettersAbstract implements EmailGettersInterface, EmailSette
return $this->renderer->render( dirname( __DIR__ ) . '/html/default.php', [ 'content' => $this->get_content(), 'heading' => $this->get_heading(), 'object' => $this->get_object() ] ); return $this->renderer->render( dirname( __DIR__ ) . '/html/default.php', [ 'content' => $this->get_content(), 'heading' => $this->get_heading(), 'object' => $this->get_object() ] );
} }
public function is_valid(): bool {
return true;
}
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace WPDesk\Library\WPEmail\Emails; namespace WPDesk\Library\WPEmail\Emails;
use WPDesk\Library\WPEmail\Abstracts\ConditionInterface;
use WPDesk\Library\WPEmail\Abstracts\EmailGettersInterface; use WPDesk\Library\WPEmail\Abstracts\EmailGettersInterface;
class EmailSender { class EmailSender {
...@@ -81,9 +82,15 @@ class EmailSender { ...@@ -81,9 +82,15 @@ class EmailSender {
public function send() { public function send() {
foreach ( $this->get_emails() as $email ) { foreach ( $this->get_emails() as $email ) {
$this->before_wp_mail(); $this->before_wp_mail();
wp_mail(
$email->get_recipients(), $email->get_subject(), $email->render(), $email->get_headers(), $email->get_attachments() if( $email instanceof ConditionInterface ) {
); if( $email->is_valid() ) {
wp_mail(
$email->get_recipients(), $email->get_subject(), $email->render(), $email->get_headers(), $email->get_attachments()
);
}
}
$this->after_wp_mail(); $this->after_wp_mail();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment