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
5 changes: 4 additions & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: npm run build

phpcs:
name: PHPCS
name: PHPCS and PHPStan
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -69,3 +69,6 @@ jobs:

- name: Run PHPCS
run: composer phpcs

- name: Run PHPStan
run: vendor/bin/phpstan analyse --error-format=github --memory-limit=1G
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
"prefer-stable": true,
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"php-stubs/woocommerce-stubs": "^3.0",
"php-stubs/wordpress-stubs": "^6.0",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpstan/phpstan": "^2.0",
"squizlabs/php_codesniffer": "^3.7",
"szepeviktor/phpstan-wordpress": "^2.0",
"wp-coding-standards/wpcs": "^3.0"
},
"config": {
Expand All @@ -30,6 +34,10 @@
"scripts": {
"phpcs": "vendor/bin/phpcs",
"phpcbf": "vendor/bin/phpcbf",
"lint": "@phpcs"
"phpstan": "php -d memory_limit=1G vendor/bin/phpstan analyse --memory-limit=1G",
"lint": [
"@phpcs",
"@phpstan"
]
}
}
235 changes: 234 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions includes/Admin/Admin_Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Admin_Settings {
public function __construct() {
// For the admin interface.
add_action( 'admin_menu', array( $this, 'register_settings_menu' ) );
add_action( 'plugin_action_links_' . Functions::get_plugin_path(), array( $this, 'plugin_settings_link' ) );
add_filter( 'plugin_action_links_' . Functions::get_plugin_path(), array( $this, 'plugin_settings_link' ) );

// init tabs here.
new Tabs\Settings();
Expand Down Expand Up @@ -93,7 +93,7 @@ public static function get_settings_tabs() {
$tabs = apply_filters( 'sce_admin_tabs', $tabs );
$tab_html = '<nav class="nav-tab-wrapper">';
$tabs_count = count( $tabs );
if ( $tabs && ! empty( $tabs ) && is_array( $tabs ) ) {
if ( is_array( $tabs ) && count( $tabs ) > 0 ) {
$active_tab = Functions::get_admin_tab();
if ( null === $active_tab ) {
$active_tab = 'settings';
Expand Down Expand Up @@ -148,17 +148,17 @@ public static function get_settings_tabs() {
*
* @since 5.1.0
*
* @param array Associative array of tabs.
* @param string Tab
* @param string Sub Tab
* @param array $sub_tabs Associative array of tabs.
* @param string $current_tab Current tab.
* @param string $current_sub_tab Current sub-tab.
*/
$sub_tabs = apply_filters( 'sce_admin_sub_tabs', array(), $current_tab, $current_sub_tab );

// Check to see if no tabs are available for this view.
if ( null === $current_tab && null === $current_sub_tab ) {
$current_tab = 'settings';
}
if ( $sub_tabs && ! empty( $sub_tabs ) && is_array( $sub_tabs ) ) {
if ( is_array( $sub_tabs ) && count( $sub_tabs ) > 0 ) {
if ( null === $current_sub_tab ) {
$current_sub_tab = '';
}
Expand Down Expand Up @@ -202,9 +202,7 @@ public static function get_settings_tabs() {
$sub_tab_html_array[] = sprintf( '<a href="%s" class="%s" id="mpp-tab-%s">%s</a>', esc_url( $tab_url ), esc_attr( implode( ' ', $classes ) ), esc_attr( $tab_get ), esc_html( $sub_tab['label'] ) );
}
}
if ( ! empty( $sub_tab_html_array ) ) {
echo '<nav class="mpp-sub-links">' . wp_kses_post( rtrim( implode( ' | ', $sub_tab_html_array ), ' | ' ) ) . '</nav>';
}
echo '<nav class="mpp-sub-links">' . wp_kses_post( rtrim( implode( ' | ', $sub_tab_html_array ), ' | ' ) ) . '</nav>';
if ( $do_subtab_action ) {
/**
* Perform a sub tab action.
Expand All @@ -214,7 +212,6 @@ public static function get_settings_tabs() {
* @since 5.1.0
*
* mpp_admin_sub_tab_{current_tab}_{current_sub_tab}
* @param string Sub Tab
*/
do_action(
sprintf( // phpcs:ignore
Expand All @@ -234,9 +231,8 @@ public static function get_settings_tabs() {
*
* @since 5.1.0
*
* @param string $action Can be any action.
* @param string Tab
* @param string Sub Tab
* @param string $current_tab Current tab.
* @param string $current_sub_tab Current sub-tab.
*/
do_action( $do_action, $current_tab, $current_sub_tab );
}
Expand Down
4 changes: 2 additions & 2 deletions includes/Admin/Tabs/Integrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Integrations extends Tabs {
/**
* Tab to run actions against.
*
* @var $tab Settings tab.
* @var string Settings tab.
*/
protected $tab = 'integrations';

Expand All @@ -39,7 +39,7 @@ class Integrations extends Tabs {
public function __construct() {
add_filter( 'sce_admin_tabs', array( $this, 'add_tab' ), 1, 1 );
add_filter( 'sce_admin_sub_tabs', array( $this, 'add_sub_tab' ), 1, 3 );
add_action( 'sce_output_' . $this->tab, array( $this, 'output_settings' ), 1, 3 );
add_action( 'sce_output_' . $this->tab, array( $this, 'output_settings' ), 1, 2 );

/**
* Mailchimp admin panel actions.
Expand Down
Loading
Loading