| 1 |
<?php |
| 2 |
/** |
| 3 |
* Brevo Extension |
| 4 |
* |
| 5 |
* @package NotificationX\Extensions |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace NotificationX\Extensions\Brevo; |
| 9 |
|
| 10 |
use NotificationX\GetInstance; |
| 11 |
use NotificationX\Extensions\Extension; |
| 12 |
|
| 13 |
/** |
| 14 |
* Brevo Extension |
| 15 |
* @method static Brevo get_instance($args = null) |
| 16 |
*/ |
| 17 |
class Brevo extends Extension { |
| 18 |
/** |
| 19 |
* Instance of Brevo |
| 20 |
* |
| 21 |
* @var Brevo |
| 22 |
*/ |
| 23 |
use GetInstance; |
| 24 |
|
| 25 |
public $priority = 16; |
| 26 |
public $id = 'brevo'; |
| 27 |
public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/brevo.png'; |
| 28 |
public $doc_link = 'https://notificationx.com/docs/brevo-email-subscription-alert/'; |
| 29 |
public $types = 'email_subscription'; |
| 30 |
public $module = 'modules_brevo'; |
| 31 |
public $module_priority = 21; |
| 32 |
public $is_pro = true; |
| 33 |
|
| 34 |
/** |
| 35 |
* Email Subscription themes Brevo cannot fill. |
| 36 |
* |
| 37 |
* A Brevo contact carries no geo data -- there is no `location` object the |
| 38 |
* way MailChimp returns one, and no lat/lon contact attribute -- so the |
| 39 |
* Maps theme (and its responsive counterpart) would render an empty map for |
| 40 |
* every entry. Excluding them in get_themes()/get_res_themes() below keeps |
| 41 |
* them out of the theme picker for this source only; every other Email |
| 42 |
* Subscription source keeps them. |
| 43 |
* |
| 44 |
* @var string[] |
| 45 |
*/ |
| 46 |
const UNSUPPORTED_THEMES = [ 'maps_theme' ]; |
| 47 |
|
| 48 |
/** |
| 49 |
* @var string[] |
| 50 |
*/ |
| 51 |
const UNSUPPORTED_RES_THEMES = [ 'subscriptions-res-theme-four' ]; |
| 52 |
|
| 53 |
/** |
| 54 |
* Initially Invoked when initialized. |
| 55 |
*/ |
| 56 |
public function __construct(){ |
| 57 |
parent::__construct(); |
| 58 |
} |
| 59 |
|
| 60 |
public function init_extension() |
| 61 |
{ |
| 62 |
$this->title = __('Brevo', 'notificationx'); |
| 63 |
$this->module_title = __('Brevo', 'notificationx'); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Themes inherited from the Email Subscription type, minus the ones Brevo |
| 68 |
* has no data for. |
| 69 |
* |
| 70 |
* @return array |
| 71 |
*/ |
| 72 |
public function get_themes() { |
| 73 |
return $this->exclude_themes( parent::get_themes(), self::UNSUPPORTED_THEMES ); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Responsive themes inherited from the Email Subscription type, minus the |
| 78 |
* ones Brevo has no data for. |
| 79 |
* |
| 80 |
* @return array |
| 81 |
*/ |
| 82 |
public function get_res_themes() { |
| 83 |
return $this->exclude_themes( parent::get_res_themes(), self::UNSUPPORTED_RES_THEMES ); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Drops type-level themes this source cannot render. |
| 88 |
* |
| 89 |
* Extension::get_themes() prefixes the type's theme names with |
| 90 |
* "{$this->types}_" whenever the extension declares no themes of its own, |
| 91 |
* which is the case here, so the keys to unset carry that prefix. |
| 92 |
* |
| 93 |
* Dropping a theme here is what hides it: Extension::__nx_themes() appends |
| 94 |
* this source to each returned theme's `includes source` rule, so a theme |
| 95 |
* that never comes back from this method never lists `brevo` as a valid |
| 96 |
* source and stays hidden in the picker. |
| 97 |
* |
| 98 |
* @param array $themes |
| 99 |
* @param string[] $unsupported |
| 100 |
* @return array |
| 101 |
*/ |
| 102 |
protected function exclude_themes( $themes, $unsupported ) { |
| 103 |
if ( ! is_array( $themes ) ) { |
| 104 |
return $themes; |
| 105 |
} |
| 106 |
foreach ( $unsupported as $name ) { |
| 107 |
unset( $themes[ $this->types . '_' . $name ] ); |
| 108 |
} |
| 109 |
return $themes; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Get data for Brevo Extension. |
| 114 |
* |
| 115 |
* @param array $args Settings arguments. |
| 116 |
* @return array |
| 117 |
*/ |
| 118 |
public function get_data( $args = array() ){ |
| 119 |
return 'Hello From Brevo'; |
| 120 |
} |
| 121 |
|
| 122 |
public function doc(){ |
| 123 |
/* translators: %1$s: signed in & retrieved API key from Brevo account link URL, %2$s: documentation link URL, %3$s: Integration with Brevo link URL, %4$s: Email Marketing Strategy link URL, %5$s: Email Subscription List link URL */ |
| 124 |
return sprintf(__('<p>Make sure that you have <a target="_blank" href="%1$s">signed in & retrieved an API key from your Brevo account</a> to use its contact list & email subscriptions data. For further assistance, check out our step by step <a target="_blank" href="%2$s">documentation</a>.</p> |
| 125 |
<p>👉 NotificationX <a target="_blank" href="%3$s">Integration with Brevo</a></p> |
| 126 |
<p><strong>Recommended Blogs:</strong></p> |
| 127 |
<p>🔥 How To Improve Your <a target="_blank" href="%4$s">Email Marketing Strategy</a> With Social Proof</p> |
| 128 |
<p>🚀 Hacks To Grow Your <a target="_blank" href="%5$s">Email Subscription List</a> On WordPress Website</p>', 'notificationx'), |
| 129 |
'https://help.brevo.com/hc/en-us/articles/209467485-Create-and-manage-your-API-keys', |
| 130 |
'https://notificationx.com/docs/brevo-email-subscription-alert/', |
| 131 |
'https://notificationx.com/integrations/brevo/', |
| 132 |
'https://wpdeveloper.com/email-marketing-social-proof/', |
| 133 |
'https://wpdeveloper.com/email-subscription-list-wordpress/' |
| 134 |
); |
| 135 |
} |
| 136 |
} |
| 137 |
|