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
72 changes: 72 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module.exports = {
root: true,
extends: ['plugin:@wordpress/eslint-plugin/recommended-with-formatting'],
env: {
browser: true,
jquery: true,
},
globals: {
// WordPress globals
wp: 'readonly',
ajaxurl: 'readonly',
pagenow: 'readonly',
typenow: 'readonly',
adminpage: 'readonly',
// Vue.js
Vue: 'readonly',
// Ultimate Multisite globals
wu_moment: 'readonly',
wu_activity_stream_nonce: 'readonly',
wu_checkout: 'readonly',
wu_checkout_form: 'readonly',
wu_block_ui: 'readonly',
wu_block_ui_legacy: 'readonly',
wu_format_money: 'readonly',
wu_template_previewer: 'readonly',
wu_fields: 'readonly',
wu_settings: 'readonly',
wu_addons: 'readonly',
wubox: 'readonly',
Swal: 'readonly',
ClipboardJS: 'readonly',
Shepherd: 'readonly',
ApexCharts: 'readonly',
tippy: 'readonly',
},
rules: {
// Allow tabs for indentation (matches PHP coding standards)
indent: ['error', 'tab', { SwitchCase: 1 }],
// Disable prettier - too strict for legacy code
'prettier/prettier': 'off',
// Relax some rules for legacy code compatibility
'no-unused-vars': ['warn', { vars: 'all', args: 'none', ignoreRestSiblings: true }],
// Allow console for development
'no-console': 'warn',
// Allow var for legacy code
'no-var': 'warn',
// Prefer const but don't enforce strictly for legacy code
'prefer-const': 'warn',
// Object shorthand is nice but not required for legacy code
'object-shorthand': 'warn',
// Allow snake_case for WP compatibility
camelcase: 'off',
// Allow redeclaring globals (we define them above)
'no-redeclare': 'off',
// Disable strict formatting rules for legacy code
'space-in-parens': 'off',
'comma-dangle': 'off',
quotes: 'off',
semi: 'off',
'padded-blocks': 'off',
'eol-last': 'off',
'space-before-function-paren': 'off',
'space-before-blocks': 'off',
},
Comment on lines +36 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Reconsider disabling critical rules like 'no-redeclare'.

While relaxing formatting rules for legacy code is understandable, disabling certain rules can introduce bugs:

  1. Line 54 (no-redeclare: 'off'): Disabling this rule allows redeclaring variables, which can cause subtle bugs. The comment suggests it's disabled to allow redeclaring the globals from lines 8-35, but this shouldn't be necessary if globals are properly declared.

  2. Line 40 (prettier/prettier: 'off'): If you're not using Prettier, consider removing it from the extends chain in line 3 (recommended-with-formatting) to avoid loading unused rules.

  3. Formatting rules (lines 56-63): Consider setting these to 'warn' instead of 'off' to maintain visibility into code style issues.

🔎 Recommended changes
 	rules: {
 		// Allow tabs for indentation (matches PHP coding standards)
 		indent: ['error', 'tab', { SwitchCase: 1 }],
 		// Disable prettier - too strict for legacy code
 		'prettier/prettier': 'off',
 		// Relax some rules for legacy code compatibility
 		'no-unused-vars': ['warn', { vars: 'all', args: 'none', ignoreRestSiblings: true }],
 		// Allow console for development
 		'no-console': 'warn',
 		// Allow var for legacy code
 		'no-var': 'warn',
 		// Prefer const but don't enforce strictly for legacy code
 		'prefer-const': 'warn',
 		// Object shorthand is nice but not required for legacy code
 		'object-shorthand': 'warn',
 		// Allow snake_case for WP compatibility
 		camelcase: 'off',
-		// Allow redeclaring globals (we define them above)
-		'no-redeclare': 'off',
+		// Warn on redeclarations instead of allowing them
+		'no-redeclare': 'warn',
 		// Disable strict formatting rules for legacy code
-		'space-in-parens': 'off',
-		'comma-dangle': 'off',
-		quotes: 'off',
-		semi: 'off',
-		'padded-blocks': 'off',
-		'eol-last': 'off',
-		'space-before-function-paren': 'off',
-		'space-before-blocks': 'off',
+		'space-in-parens': 'warn',
+		'comma-dangle': 'warn',
+		quotes: 'warn',
+		semi: 'warn',
+		'padded-blocks': 'warn',
+		'eol-last': 'warn',
+		'space-before-function-paren': 'warn',
+		'space-before-blocks': 'warn',
 	},
🤖 Prompt for AI Agents
.eslintrc.js lines 36-64: the config currently disables critical rules
(no-redeclare, prettier/prettier, and several formatting rules) which can mask
bugs and unused config; re-enable 'no-redeclare' (set to 'error' or at least
'warn') and instead ensure globals are declared in the top-level "globals"
section or via /* global */ comments so redeclaration is not needed; if Prettier
is not used, remove 'recommended-with-formatting' from extends and re-enable the
'prettier/prettier' rule (or set to 'warn') rather than turning it off; change
the formatting rules currently set to 'off' (space-in-parens, comma-dangle,
quotes, semi, padded-blocks, eol-last, space-before-function-paren,
space-before-blocks) to 'warn' to surface style issues while maintaining legacy
flexibility.

ignorePatterns: [
'**/*.min.js',
'node_modules/',
'vendor/',
'lib/',
'assets/js/lib/',
],
};
44 changes: 44 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
extends: ['@wordpress/stylelint-config'],
rules: {
// Allow !important for WordPress admin overrides
'declaration-no-important': null,
// Relax selector specificity for admin styling
'selector-max-id': null,
// Allow vendor prefixes (handled by build tools if needed)
'property-no-vendor-prefix': null,
'value-no-vendor-prefix': null,
// Relax rules for legacy CSS files
'rule-empty-line-before': null,
'comment-empty-line-before': null,
'no-duplicate-selectors': null,
'no-descending-specificity': null,
'color-hex-length': null,
'font-weight-notation': null,
'selector-pseudo-element-colon-notation': null,
// Allow various class naming patterns (legacy code uses camelCase, etc.)
'selector-class-pattern': null,
// Allow 0px instead of 0 for legacy compatibility
'length-zero-no-unit': null,
// Relax more rules for legacy code
'value-keyword-case': null,
'at-rule-empty-line-before': null,
'selector-attribute-quotes': null,
'block-no-empty': null,
// Allow different ID naming patterns
'selector-id-pattern': null,
// Allow font-family without generic fallback (WordPress icons)
'font-family-no-missing-generic-family-keyword': null,
// Allow quotes around font-family names
'font-family-name-quotes': null,
// Allow duplicate properties (sometimes intentional for fallbacks)
'declaration-block-no-duplicate-properties': null,
},
ignoreFiles: [
'**/*.min.css',
'node_modules/**',
'vendor/**',
'lib/**',
'assets/css/lib/**',
],
};
26 changes: 26 additions & 0 deletions inc/admin-pages/class-base-admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ final public function enqueue_default_hooks(): void {

add_action("load-$this->page_hook", [$this, 'register_widgets'], 20);

add_action("load-$this->page_hook", [$this, 'fire_register_widgets_hook'], 21);

add_action("load-$this->page_hook", [$this, 'add_admin_body_classes'], 20);

/*
Expand Down Expand Up @@ -729,6 +731,30 @@ public function register_scripts() {}
*/
public function register_widgets() {}

/**
* Fire the register widgets hook for this page.
*
* This allows addons to add their own widgets to admin pages.
*
* @since 2.4.10
* @return void
*/
public function fire_register_widgets_hook(): void {

/**
* Fires after widgets are registered for this page.
*
* The dynamic portion of the hook name, `$this->id`, refers to the page id.
*
* @since 2.4.10
*
* @param string $id The page id.
* @param string $page_hook The page hook.
* @param object $page The page object.
*/
do_action("wu_page_{$this->id}_register_widgets", $this->id, $this->page_hook, $this);
}

/**
* Allow child classes to register forms, if they need them.
*
Expand Down
20 changes: 19 additions & 1 deletion inc/functions/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,28 @@ function wu_get_site_by_hash($hash) {
* @return \WP_Ultimo\Models\Site[]
*/
function wu_get_sites($query = []) {
if ( empty($query['number']) ) {
if (empty($query['number'])) {
$query['number'] = 100;
}

// If we're just counting, skip the domain search merge logic
// and do a simple count query.
if ( ! empty($query['count'])) {
if ( ! empty($query['search'])) {
$domain_count = wu_get_domains(
[
'number' => $query['number'],
'search' => '*' . $query['search'] . '*',
'count' => true,
'blog_id__in' => $query['blog_id__in'] ?? false,
]
);
} else {
$domain_count = 0;
}
return \WP_Ultimo\Models\Site::query($query) + $domain_count;
}

if ( ! empty($query['search'])) {
// We also want to find sites with a matching mapped domain.
$domain_ids = wu_get_domains(
Expand Down
10 changes: 9 additions & 1 deletion inc/list-tables/class-site-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,15 @@ public function get_bulk_actions() {

$actions[ wu_request('type', 'all') === 'pending' ? 'delete-pending' : 'delete' ] = __('Delete', 'ultimate-multisite');

return $actions;
/**
* Filter the bulk actions available for sites.
*
* @since 2.4.10
*
* @param array $actions The bulk actions.
* @return array
*/
return apply_filters('wu_site_list_get_bulk_actions', $actions);
}

/**
Expand Down
Loading
Loading