Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

- Contributors: Mailjet
- Tags: email, marketing, signup, newsletter, widget, smtp, woocommerce, contact form 7
- Requires at least: 4.4
- Tested up to: 6.8.1
- Stable tag: 6.1.6
- Requires at least: 5.6
- Tested up to: 6.8.3
- Stable tag: 6.1.7
- Requires PHP: 7.4
- License: GPLv2 or later
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down
6 changes: 3 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

- Contributors: Mailjet
- Tags: email, marketing, signup, newsletter, widget, smtp, woocommerce, contact form 7
- Requires at least: 4.4
- Tested up to: 6.8.1
- Stable tag: 6.1.6
- Requires at least: 5.6
- Tested up to: 6.8.3
- Stable tag: 6.1.7
- Requires PHP: 7.4
- License: GPLv2 or later
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down
88 changes: 56 additions & 32 deletions src/includes/Mailjet.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,26 @@ class Mailjet {
*
* @since 5.0.0
* @access protected
* @var Mailjet_Loader $loader Maintains and registers all hooks for the plugin.
* @var Mailjet_Loader $loader Maintains and registers all hooks for the plugin.
*/
protected $loader;
/**
* The unique identifier of this plugin.
*
* @since 5.0.0
* @access protected
* @var string $plugin_name The string used to uniquely identify this plugin.
* @var string $plugin_name The string used to uniquely identify this plugin.
*/
protected $plugin_name;
/**
* The current version of the plugin.
*
* @since 1.0.0
* @access protected
* @var string $version The current version of the plugin.
* @var string $version The current version of the plugin.
*/
protected $version;

/**
* Define the core functionality of the plugin.
*
Expand All @@ -58,7 +59,8 @@ class Mailjet {
*
* @since 5.0.0
*/
public function __construct() {
public function __construct()
{
if (\defined('MAILJET_VERSION')) {
$this->version = MAILJET_VERSION;
} else {
Expand All @@ -74,16 +76,17 @@ public function __construct() {
$this->addMailjetPHPMailer();
$this->registerMailjetWidget();

add_shortcode('mailjet_form_builder', array( $this, 'display_mailjet_form_builder_widget' ));
add_shortcode('mailjet_form_builder', array($this, 'display_mailjet_form_builder_widget'));
}

/**
* @param array $attr
* @param array $attr
* @param string $tag
* @return false|string
*/
public static function display_mailjet_form_builder_widget( array $attr = array(), string $tag = '' ) {
\extract(shortcode_atts(array( 'widget_id' => null ), $attr, $tag));
public static function display_mailjet_form_builder_widget(array $attr = array(), string $tag = '')
{
\extract(shortcode_atts(array('widget_id' => null), $attr, $tag));
// GET All Mailjet widgets - to find the one that user actually configured with the shortcode
$instance = self::getOption('mailjet_form_builder_widget_options');

Expand All @@ -97,9 +100,9 @@ public static function display_mailjet_form_builder_widget( array $attr = array(
}
$widget_id = min($widgetIds);
}
if (isset($instance[ (int) $widget_id ])) {
if (isset($instance[(int)$widget_id])) {
ob_start();
the_widget('MailjetWp\\MailjetPlugin\\WidgetFormBuilder\\WP_Mailjet_FormBuilder_Widget', $instance[ (int) $widget_id ]);
the_widget('MailjetWp\\MailjetPlugin\\WidgetFormBuilder\\WP_Mailjet_FormBuilder_Widget', $instance[(int)$widget_id]);
return ob_get_clean();
}

Expand All @@ -122,9 +125,11 @@ public static function display_mailjet_form_builder_widget( array $attr = array(
* @since 5.0.0
* @access private
*/
private function load_dependencies() {
private function load_dependencies()
{
$this->loader = new MailjetLoader();
}

/**
* Define the locale for this plugin for internationalization.
*
Expand All @@ -134,18 +139,21 @@ private function load_dependencies() {
* @since 5.0.0
* @access private
*/
private function set_locale() {
private function set_locale()
{
$plugin_i18n = new Mailjeti18n();
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
}

/**
* Register all of the hooks related to the admin area functionality
* of the plugin.
*
* @since 1.0.0
* @access private
*/
private function define_admin_hooks() {
private function define_admin_hooks()
{
$plugin_admin = new MailjetAdmin($this->get_plugin_name(), $this->get_version());
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
Expand All @@ -163,7 +171,8 @@ private function define_admin_hooks() {
* @since 5.0.0
* @access private
*/
private function define_public_hooks() {
private function define_public_hooks()
{
$plugin_public = new MailjetPublic($this->get_plugin_name(), $this->get_version());
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
Expand All @@ -172,15 +181,17 @@ private function define_public_hooks() {
/**
* @return void
*/
private function addMailjetMenu(): void {
private function addMailjetMenu(): void
{
$plugin_menu = new MailjetMenu();
$this->loader->add_action('admin_menu', $plugin_menu, 'display_menu');
}

/**
* @return void
*/
private function addMailjetSettings(): void {
private function addMailjetSettings(): void
{
$plugin_settings = new MailjetSettings();
$this->loader->add_action('admin_init', $plugin_settings, 'mailjet_settings_admin_init');
$this->loader->add_action('init', $plugin_settings, 'mailjet_settings_init');
Expand All @@ -189,7 +200,8 @@ private function addMailjetSettings(): void {
/**
* @return void
*/
private function addMailjetPHPMailer(): void {
private function addMailjetPHPMailer(): void
{
$plugin_mails = new MailjetMail();
$this->loader->add_action('phpmailer_init', $plugin_mails, 'phpmailer_init_smtp');
$this->loader->add_action('wp_mail_failed', $plugin_mails, 'wp_mail_failed_cb');
Expand All @@ -198,58 +210,69 @@ private function addMailjetPHPMailer(): void {
/**
* @return void
*/
private function registerMailjetWidget(): void {
private function registerMailjetWidget(): void
{
$this->loader->add_action('widgets_init', $this, 'wp_mailjet_register_widgets');
}

/**
* @return void
*/
public function wp_mailjet_register_widgets() {
public function wp_mailjet_register_widgets()
{
$widgetFormBuilder = 'MailjetWp\\MailjetPlugin\\WidgetFormBuilder\\WP_Mailjet_FormBuilder_Widget';
register_widget($widgetFormBuilder);
}

/**
* Run the loader to execute all of the hooks with WordPress.
*
* @since 5.0.0
*/
public function run(): void {
public function run(): void
{
$this->loader->run();
}

/**
* The name of the plugin used to uniquely identify it within the context of
* WordPress and to define internationalization functionality.
*
* @since 1.0.0
* @return string The name of the plugin.
* @since 1.0.0
*/
public function get_plugin_name(): string {
public function get_plugin_name(): string
{
return $this->plugin_name;
}

/**
* The reference to the class that orchestrates the hooks with the plugin.
*
* @since 5.0.0
* @return Mailjet_Loader Orchestrates the hooks of the plugin.
* @since 5.0.0
*/
public function get_loader() {
public function get_loader()
{
return $this->loader;
}

/**
* Retrieve the version number of the plugin.
*
* @since 5.0.0
* @return string The version number of the plugin.
* @since 5.0.0
*/
public function get_version(): string {
public function get_version(): string
{
return $this->version;
}

/**
* @return void
*/
private function addWoocommerceActions(): void {
private function addWoocommerceActions(): void
{
$wooCommerceSettings = WooCommerceSettings::getInstance();
if (isset($_POST['action']) && $_POST['action'] === 'order_notification_settings_custom_hook') {
$wooCommerceSettings->orders_automation_settings_post();
Expand All @@ -259,14 +282,14 @@ private function addWoocommerceActions(): void {
$this->loader->add_action('woocommerce_order_status_changed', $wooCommerceSettings, 'order_edata_sync', 10, 1);
$this->loader->add_action('woocommerce_cheque_process_payment_order_status', $wooCommerceSettings, 'paid_by_cheque_order_edata_sync', 10, 2);
}
$activeActions = self::getOption('mailjet_wc_active_hooks');
$activeActions = self::getOption('mailjet_wc_active_hooks');
$abandonedCartActiveActions = self::getOption('mailjet_wc_abandoned_cart_active_hooks');
if ($activeActions && ! empty($activeActions)) {
if ($activeActions && !empty($activeActions)) {
foreach ($activeActions as $action) {
$this->loader->add_action($action['hook'], $wooCommerceSettings, $action['callable'], 10, 2);
}
}
if ($abandonedCartActiveActions && ! empty($abandonedCartActiveActions)) {
if ($abandonedCartActiveActions && !empty($abandonedCartActiveActions)) {
foreach ($abandonedCartActiveActions as $action) {
$this->loader->add_action($action['hook'], $wooCommerceSettings, $action['callable'], 10, 2);
}
Expand All @@ -277,8 +300,9 @@ private function addWoocommerceActions(): void {
* @param string $key
* @return mixed
*/
public static function getOption( string $key ) {
if ( ! is_multisite()) {
public static function getOption(string $key)
{
if (!is_multisite()) {
return get_option($key);
}

Expand Down
4 changes: 2 additions & 2 deletions wp-mailjet.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace MailjetPlugin;

/**

Check failure on line 5 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

The file-level docblock must follow the opening PHP tag in the file header
* The plugin bootstrap file
*
*
* @link https://www.mailjet.com/partners/wordpress/

Check failure on line 9 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

There must be exactly one blank line before the tags in a doc comment
* @since 5.0.0
* @package Mailjet
*
Expand All @@ -14,8 +14,8 @@
* Plugin Name: Mailjet for WordPress
* Plugin URI: https://www.mailjet.com/partners/wordpress/
* Description: The Best WordPress Plugin For Email Newsletters.
* Version: 6.1.6
* Tested up to: 6.8.1
* Version: 6.1.7
* Tested up to: 6.8.3
* Author: Mailjet SAS
* Author URI: http://mailjet.com
* License: GPL-2.0+
Expand All @@ -40,7 +40,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {

Check failure on line 43 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space after "!"; 0 found

Check failure on line 43 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space before "!"; 0 found
die;
}

Expand All @@ -63,7 +63,7 @@
*/
define('MAILJET_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
define('MAILJET_ADMIN_TAMPLATE_DIR', plugin_dir_path( __FILE__ ) . 'src/templates/admin');
define('MAILJET_FRONT_TEMPLATE_DIR', plugin_dir_path( __FILE__ ). 'src/templates/front');

Check failure on line 66 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Concat operator must be surrounded by a single space


// Call the update logic
Expand All @@ -81,15 +81,15 @@
* @since 5.0.0
*/
function run_mailjet()
{

Check failure on line 84 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Opening brace should be on the same line as the declaration
$plugin = new Mailjet();
$plugin->run();
}


$activator = new MailjetActivator();
register_activation_hook( __FILE__, [$activator, 'activation_check']);

Check failure on line 91 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space before the array closer in a single line array. Found: no spaces

Check failure on line 91 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Short array syntax is not allowed

Check failure on line 91 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space after the array opener in a single line array. Found: no spaces
register_activation_hook( __FILE__, [$activator, 'activation_settings']);

Check failure on line 92 in wp-mailjet.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space after the array opener in a single line array. Found: no spaces

$deactivator = new MailjetDeactivator();
register_deactivation_hook( __FILE__, [$deactivator, 'deactivate']);
Expand Down