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
28 changes: 28 additions & 0 deletions .github/workflows/wpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Wordpress Basic Checks

on:
push:
branches:
- '**' # matches every branch
- '!master'

jobs:
phpcs:
name: WPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: WPCS check
uses: 10up/wpcs-action@stable
with:
enable_warnings: false # Enable checking for warnings (-w)
paths: '.' # Paths to check, space separated
excludes: '' # Paths to excludes, space separated
standard: 'WordPress' # Standard to use. Accepts WordPress|WordPress-Core|WordPress-Docs|WordPress-Extra|WordPress-VIP-Go|WordPressVIPMinimum|10up-Default.
standard_repo: '' # Public (git) repository URL of the coding standard
repo_branch: 'master' # Branch of Standard repository
phpcs_bin_path: 'phpcs' # Custom PHPCS bin path
use_local_config: 'true' # Use local config if available
extra_args: '' # Extra arguments passing to the command
only_changed_files: '' # Run the linter only on the changed files. Accepts true|false
only_changed_lines: '' # Run the linter only on the changed lines. Accepts true|false
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

##### 6.1.4
- Fix issues in the input fields. Tested with new WP version

##### 6.1.2
- Fix possible error when code switch websites and could leave website in a broken state

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
- Contributors: Mailjet
- Tags: email, marketing, signup, newsletter, widget, smtp, woocommerce, contact form 7
- Requires at least: 4.4
- Tested up to: 6.6.2
- Stable tag: 6.1.3
- Tested up to: 6.8.1
- Stable tag: 6.1.4
- Requires PHP: 7.4
- License: GPLv2 or later
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -162,6 +162,9 @@ find vendor/ -type d -name ".git" -exec rm -rf {} \;

## Changelog

##### 6.1.4
- Fix issues in the input fields. Tested with new WP version

##### 6.1.2
- Fix possible error when code switch websites and could leave website in a broken state

Expand Down
113 changes: 113 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">

<description>The Coding standard for the WordPress Coding Standards itself.</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset
#############################################################################
-->

<file>.</file>

<!-- Exclude Composer vendor directory. -->
<exclude-pattern>*/vendor/*</exclude-pattern>

<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>

<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps"/>

<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="."/>

<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>

<arg name="tab-width" value="0"/> <!-- Prevents PHPCS from enforcing tab width -->

<!-- Exclude specific rule that enforces tabs -->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="ignoreIndentationTokens" type="array">
<element value="T_COMMENT"/>
<element value="T_DOC_COMMENT_OPEN_TAG"/>
</property>
</properties>
</rule>

<!-- Disable tab enforcement -->
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>

<rule ref="WordPress">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/> <!-- Fully exclude tab enforcement -->
</rule>

<!--
#############################################################################
SET UP THE RULESETS
#############################################################################
-->

<rule ref="WordPress">
<!-- This project needs to comply with naming standards from PHPCS, not WP. -->
<exclude name="WordPress.Files.FileName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>

<!-- While conditions with assignments are a typical way to walk the token stream. -->
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>

<!-- The code in this project is run in the context of PHPCS, not WP. -->
<exclude name="WordPress.DateTime"/>
<exclude name="WordPress.DB"/>
<exclude name="WordPress.Security"/>
<exclude name="WordPress.WP"/>

<!-- Linting is done in a separate CI job, no need to duplicate it. -->
<exclude name="Generic.PHP.Syntax"/>
</rule>

<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->

<rule ref="WordPress.Arrays.MultipleStatementAlignment">
<properties>
<property name="alignMultilineItems" value="!=100"/>
<property name="exact" value="false" phpcs-only="true"/>
</properties>
</rule>

<rule ref="WordPress">
<!-- Disable inline comment ending enforcement -->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
<!-- Disable requirement for a short description in doc comments -->
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<!-- Disable snake_case requirement for method names -->
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
<!-- Disable enforcement of full stops at the end of parameter comments -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode"/>
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis"/>
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket"/>
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket"/>
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis"/>
<exclude name="Generic.Commenting.DocComment.ShortNotCapital"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen"/>
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.Found"/>
<exclude name="Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure"/>
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose"/>
<exclude name="WordPress.PHP.DontExtract.extract_extract"/>
<exclude name="Squiz.Commenting.FileComment.Missing"/>
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
<exclude name="WordPress.PHP.DisallowShortTernary.Found"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
</rule>
</ruleset>
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
- Contributors: Mailjet
- Tags: email, marketing, signup, newsletter, widget, smtp, woocommerce, contact form 7
- Requires at least: 4.4
- Tested up to: 6.6.2
- Stable tag: 6.1.3
- Tested up to: 6.8.1
- Stable tag: 6.1.4
- Requires PHP: 7.4
- License: GPLv2 or later
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -152,6 +152,9 @@ find vendor/ -type d -name ".git" -exec rm -rf {} \;

== Changelog ==

= 6.1.4 =
- Fix issues in the input fields. Tested with new WP version

= 6.1.2 =
- Fix possible error when code switch websites and could leave website in a broken state

Expand Down
22 changes: 10 additions & 12 deletions src/admin/MailjetAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
* The admin-specific functionality of the plugin.
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package Mailjet
* @subpackage Mailjet/admin
* @author Your Name <email@example.com>
*/
class MailjetAdmin
{
class MailjetAdmin {

/**
* The ID of this plugin.
*
Expand All @@ -34,21 +35,19 @@ class MailjetAdmin
* Initialize the class and set its properties.
*
* @since 5.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct($plugin_name, $version)
{
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
$this->version = $version;
}
/**
* Register the stylesheets for the admin area.
*
* @since 5.0.0
*/
public function enqueue_styles()
{
public function enqueue_styles() {
/**
* This function is provided for demonstration purposes only.
*
Expand All @@ -67,8 +66,7 @@ public function enqueue_styles()
*
* @since 5.0.0
*/
public function enqueue_scripts()
{
public function enqueue_scripts() {
/**
* This function is provided for demonstration purposes only.
*
Expand All @@ -80,6 +78,6 @@ public function enqueue_scripts()
* between the defined hooks and the functions defined in this
* class.
*/
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/mailjet-admin.js', array('jquery'), $this->version, \false);
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/mailjet-admin.js', array( 'jquery' ), $this->version, \false);
}
}
16 changes: 7 additions & 9 deletions src/admin/partials/MailjetAdminDisplay.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
* @package Mailjet
* @subpackage Mailjet/admin/partials
*/
class MailjetAdminDisplay
{
private static $leftMenuFile = '/settingTemplates/SubscriptionSettingsPartials/leftMenu.php';
class MailjetAdminDisplay {

private static $leftMenuFile = '/settingTemplates/SubscriptionSettingsPartials/leftMenu.php';
private static $bottomLinksFile = '/bottomLinks.php';
public static function getSettingsLeftMenu()
{
$currentPage = !empty($_REQUEST['page']) ? sanitize_text_field($_REQUEST['page']) : null;
public static function getSettingsLeftMenu() {
$currentPage = ! empty($_REQUEST['page']) ? sanitize_text_field($_REQUEST['page']) : null;
set_query_var('currentPage', $currentPage);
load_template(MAILJET_ADMIN_TAMPLATE_DIR . self::$leftMenuFile);
}
public static function renderBottomLinks()
{
public static function renderBottomLinks() {
$userGuideLink = Mailjeti18n::getMailjetUserGuideLinkByLocale();
$supportLink = Mailjeti18n::getMailjetSupportLinkByLocale();
$supportLink = Mailjeti18n::getMailjetSupportLinkByLocale();
set_query_var('supportLink', $supportLink);
set_query_var('userGuideLink', $userGuideLink);
load_template(MAILJET_ADMIN_TAMPLATE_DIR . self::$bottomLinksFile);
Expand Down
25 changes: 11 additions & 14 deletions src/front/MailjetPublic.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* @subpackage Mailjet/public
* @author Your Name <email@example.com>
*/
class MailjetPublic
{
class MailjetPublic {

/**
* The ID of this plugin.
*
Expand All @@ -36,21 +36,19 @@ class MailjetPublic
* Initialize the class and set its properties.
*
* @since 5.0.0
* @param string $plugin_name The name of the plugin.
* @param string $version The version of this plugin.
* @param string $plugin_name The name of the plugin.
* @param string $version The version of this plugin.
*/
public function __construct($plugin_name, $version)
{
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
$this->version = $version;
}
/**
* Register the stylesheets for the public-facing side of the site.
*
* @since 5.0.0
*/
public function enqueue_styles()
{
public function enqueue_styles() {
/**
* This function is provided for demonstration purposes only.
*
Expand All @@ -62,15 +60,14 @@ public function enqueue_styles()
* between the defined hooks and the functions defined in this
* class.
*/
// wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mailjet-public.css', array(), $this->version, 'all' );
// wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mailjet-public.css', array(), $this->version, 'all' );
}
/**
* Register the JavaScript for the public-facing side of the site.
*
* @since 5.0.0
*/
public function enqueue_scripts()
{
public function enqueue_scripts() {
/**
* This function is provided for demonstration purposes only.
*
Expand All @@ -82,14 +79,14 @@ public function enqueue_scripts()
* between the defined hooks and the functions defined in this
* class.
*/
// wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mailjet-public.js', array( 'jquery' ), $this->version, false );
// wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mailjet-public.js', array( 'jquery' ), $this->version, false );
if (Mailjet::getOption('activate_mailjet_woo_integration') === '1' && Mailjet::getOption('mailjet_woo_abandoned_cart_activate') === '1') {
global $wp;
$currentUrl = \trim(home_url(add_query_arg(array(), $wp->request)), '/ ');
// check current page is wc checkout page
if ($currentUrl === \trim(get_permalink(wc_get_page_id('checkout')), '/ ')) {
wp_enqueue_script('woocommerce_capture_guest', plugins_url('../front/js/woocommerce_capture_guest.js', __FILE__), '', '', \true);
wp_localize_script('woocommerce_capture_guest', 'woocommerce_capture_guest_params', array('ajax_url' => admin_url('admin-ajax.php')));
wp_localize_script('woocommerce_capture_guest', 'woocommerce_capture_guest_params', array( 'ajax_url' => admin_url('admin-ajax.php') ));
}
}
}
Expand Down
Loading