Skip to content

Commit 0fc9118

Browse files
authored
Updates
1 parent f7521ed commit 0fc9118

4 files changed

Lines changed: 140 additions & 130 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
- Refactored long methods (init_settings, settings_page) into smaller, focused methods
3939
- Improved code maintainability and readability
4040
- Enhanced method separation for better testing and debugging
41+
- **PARTIAL:** Started conversion from space indentation to WordPress-standard tab indentation (ongoing)
42+
- Updated PHPCS configuration to allow tabs for indentation per WordPress standards
4143

4244
## [1.0.5] - 2025-08-11
4345

class-optimizations-ace-mc.php

Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -7,138 +7,138 @@
77

88
// If this file is called directly, abort.
99
if ( ! defined( 'WPINC' ) ) {
10-
die;
10+
die;
1111
}
1212

1313
/**
1414
* Main plugin class.
1515
*/
1616
class Optimizations_Ace_Mc {
1717

18-
/**
19-
* The single instance of the class.
20-
*
21-
* @var Optimizations_Ace_Mc|null
22-
*/
23-
protected static $instance = null;
24-
25-
/**
26-
* Plugin settings.
27-
*
28-
* @var array
29-
*/
30-
private $settings = array();
31-
32-
/**
33-
* Default settings.
34-
*
35-
* @var array
36-
*/
37-
private $default_settings = array(
38-
'woocommerce_show_empty_categories' => true,
39-
'woocommerce_hide_category_count' => true,
40-
'woocommerce_user_order_count_column' => true,
41-
'wpsl_show_store_categories' => true,
42-
'wpsl_disable_rest_api' => true,
43-
'admin_user_registration_date_column' => true,
44-
);
45-
46-
/**
47-
* Main instance.
48-
*
49-
* @return Optimizations_Ace_Mc
50-
*/
51-
public static function instance() {
52-
if ( null === self::$instance ) {
53-
self::$instance = new self();
54-
}
55-
return self::$instance;
56-
}
57-
58-
/**
59-
* Constructor.
60-
*/
61-
public function __construct() {
62-
// Load settings.
63-
$this->load_settings();
64-
65-
// Initialize admin interface.
66-
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
67-
add_action( 'admin_init', array( $this, 'init_settings' ) );
68-
69-
// Initialize optimizations.
70-
$this->init_optimizations();
71-
}
72-
73-
/**
74-
* Load plugin settings.
75-
*/
76-
private function load_settings() {
77-
$saved_settings = get_option( 'optimizations_ace_mc_settings', array() );
78-
$this->settings = wp_parse_args( $saved_settings, $this->default_settings );
79-
}
80-
81-
/**
82-
* Get setting value.
83-
*
84-
* @param string $key Setting key.
85-
* @return mixed Setting value.
86-
*/
87-
private function get_setting( $key ) {
88-
return isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : false;
89-
}
90-
91-
/**
92-
* Initialize optimization functions.
93-
*/
94-
private function init_optimizations() {
95-
// WooCommerce optimizations.
96-
$this->init_woocommerce_optimizations();
97-
98-
// WP Store Locator optimizations.
99-
$this->init_wpsl_optimizations();
100-
101-
// WordPress admin optimizations.
102-
$this->init_admin_optimizations();
103-
}
104-
105-
/**
106-
* Initialize WooCommerce-specific optimizations.
107-
*/
108-
private function init_woocommerce_optimizations() {
109-
// Show empty categories in WooCommerce.
110-
if ( $this->get_setting( 'woocommerce_show_empty_categories' ) ) {
111-
add_filter( 'woocommerce_product_subcategories_hide_empty', '__return_false' );
112-
}
113-
114-
// Hide category product count in product archives.
115-
if ( $this->get_setting( 'woocommerce_hide_category_count' ) ) {
116-
add_filter( 'woocommerce_subcategory_count_html', '__return_false' );
117-
}
118-
119-
// Add order count column to users admin.
120-
if ( $this->get_setting( 'woocommerce_user_order_count_column' ) && is_admin() && current_user_can( 'list_users' ) ) {
121-
add_filter( 'manage_users_columns', array( $this, 'add_user_order_count_column' ) );
122-
add_filter( 'manage_users_custom_column', array( $this, 'display_user_order_count_column' ), 10, 3 );
123-
add_filter( 'manage_users_sortable_columns', array( $this, 'make_user_order_count_sortable' ) );
124-
}
125-
}
126-
127-
/**
128-
* Initialize WP Store Locator optimizations.
129-
*/
130-
private function init_wpsl_optimizations() {
131-
// Show store categories in store locator.
132-
if ( $this->get_setting( 'wpsl_show_store_categories' ) ) {
133-
add_filter( 'wpsl_store_meta', array( $this, 'add_store_categories_to_meta' ), 10, 2 );
134-
add_filter( 'wpsl_info_window_template', array( $this, 'customize_info_window_template' ) );
135-
}
136-
137-
// Disable REST API for store locator post type.
138-
if ( $this->get_setting( 'wpsl_disable_rest_api' ) ) {
139-
add_filter( 'wpsl_post_type_args', array( $this, 'custom_post_type_args' ) );
140-
}
141-
}
18+
/**
19+
* The single instance of the class.
20+
*
21+
* @var Optimizations_Ace_Mc|null
22+
*/
23+
protected static $instance = null;
24+
25+
/**
26+
* Plugin settings.
27+
*
28+
* @var array
29+
*/
30+
private $settings = array();
31+
32+
/**
33+
* Default settings.
34+
*
35+
* @var array
36+
*/
37+
private $default_settings = array(
38+
'woocommerce_show_empty_categories' => true,
39+
'woocommerce_hide_category_count' => true,
40+
'woocommerce_user_order_count_column' => true,
41+
'wpsl_show_store_categories' => true,
42+
'wpsl_disable_rest_api' => true,
43+
'admin_user_registration_date_column' => true,
44+
);
45+
46+
/**
47+
* Main instance.
48+
*
49+
* @return Optimizations_Ace_Mc
50+
*/
51+
public static function instance() {
52+
if ( null === self::$instance ) {
53+
self::$instance = new self();
54+
}
55+
return self::$instance;
56+
}
57+
58+
/**
59+
* Constructor.
60+
*/
61+
public function __construct() {
62+
// Load settings.
63+
$this->load_settings();
64+
65+
// Initialize admin interface.
66+
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
67+
add_action( 'admin_init', array( $this, 'init_settings' ) );
68+
69+
// Initialize optimizations.
70+
$this->init_optimizations();
71+
}
72+
73+
/**
74+
* Load plugin settings.
75+
*/
76+
private function load_settings() {
77+
$saved_settings = get_option( 'optimizations_ace_mc_settings', array() );
78+
$this->settings = wp_parse_args( $saved_settings, $this->default_settings );
79+
}
80+
81+
/**
82+
* Get setting value.
83+
*
84+
* @param string $key Setting key.
85+
* @return mixed Setting value.
86+
*/
87+
private function get_setting( $key ) {
88+
return isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : false;
89+
}
90+
91+
/**
92+
* Initialize optimization functions.
93+
*/
94+
private function init_optimizations() {
95+
// WooCommerce optimizations.
96+
$this->init_woocommerce_optimizations();
97+
98+
// WP Store Locator optimizations.
99+
$this->init_wpsl_optimizations();
100+
101+
// WordPress admin optimizations.
102+
$this->init_admin_optimizations();
103+
}
104+
105+
/**
106+
* Initialize WooCommerce-specific optimizations.
107+
*/
108+
private function init_woocommerce_optimizations() {
109+
// Show empty categories in WooCommerce.
110+
if ( $this->get_setting( 'woocommerce_show_empty_categories' ) ) {
111+
add_filter( 'woocommerce_product_subcategories_hide_empty', '__return_false' );
112+
}
113+
114+
// Hide category product count in product archives.
115+
if ( $this->get_setting( 'woocommerce_hide_category_count' ) ) {
116+
add_filter( 'woocommerce_subcategory_count_html', '__return_false' );
117+
}
118+
119+
// Add order count column to users admin.
120+
if ( $this->get_setting( 'woocommerce_user_order_count_column' ) && is_admin() && current_user_can( 'list_users' ) ) {
121+
add_filter( 'manage_users_columns', array( $this, 'add_user_order_count_column' ) );
122+
add_filter( 'manage_users_custom_column', array( $this, 'display_user_order_count_column' ), 10, 3 );
123+
add_filter( 'manage_users_sortable_columns', array( $this, 'make_user_order_count_sortable' ) );
124+
}
125+
}
126+
127+
/**
128+
* Initialize WP Store Locator optimizations.
129+
*/
130+
private function init_wpsl_optimizations() {
131+
// Show store categories in store locator.
132+
if ( $this->get_setting( 'wpsl_show_store_categories' ) ) {
133+
add_filter( 'wpsl_store_meta', array( $this, 'add_store_categories_to_meta' ), 10, 2 );
134+
add_filter( 'wpsl_info_window_template', array( $this, 'customize_info_window_template' ) );
135+
}
136+
137+
// Disable REST API for store locator post type.
138+
if ( $this->get_setting( 'wpsl_disable_rest_api' ) ) {
139+
add_filter( 'wpsl_post_type_args', array( $this, 'custom_post_type_args' ) );
140+
}
141+
}
142142

143143
/**
144144
* Initialize WordPress admin optimizations.

phpcs.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,35 @@
2626
<exclude name="WordPress.DB.DirectDatabaseQuery"/>
2727
</rule>
2828

29-
<!-- ENFORCE SPACES INSTEAD OF TABS - NO TABS ALLOWED -->
29+
<!-- COMMENTED OUT: These rules enforce spaces instead of tabs, which conflicts with WordPress standards -->
30+
<!-- WordPress standards actually require TABS for indentation, not spaces -->
31+
<!--
3032
<rule ref="Generic.WhiteSpace.DisallowTabIndent">
3133
</rule>
3234
<rule ref="Generic.WhiteSpace.ScopeIndent">
3335
<properties>
34-
<!-- Use 4 spaces for indentation (WordPress standard) -->
3536
<property name="indent" value="4"/>
3637
<property name="tabIndent" value="false"/>
3738
</properties>
3839
</rule>
40+
-->
3941

40-
<!-- Disallow Rule Flagging Space Indents -->
42+
<!-- COMMENTED OUT: Disallow Rule Flagging Space Indents - not needed with tab indentation -->
43+
<!--
4144
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent">
4245
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/>
4346
</rule>
4447
45-
<!-- Disallow Rule Flagging Space Indents -->
4648
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed">
4749
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
4850
</rule>
51+
-->
4952

50-
<!-- Disallow inline tabs -->
53+
<!-- COMMENTED OUT: Disallow inline tabs - WordPress allows tabs for indentation -->
54+
<!--
5155
<rule ref="Universal.WhiteSpace.DisallowInlineTabs">
5256
</rule>
57+
-->
5358

5459
<!-- Additional WordPress-specific spacing rules -->
5560
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing"/>

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ Yes, this plugin focuses on specific admin and functionality enhancements rather
7777
* Security: Enhanced CSRF protection using proper WordPress Settings API handling
7878
* Changed: All optimization features are now optional and user-configurable
7979
* Changed: Features load conditionally based on user settings
80+
* Fixed: Array alignment issues to meet WordPress coding standards
81+
* Fixed: Removed unused variables and refactored long methods for better code quality
82+
* Fixed: Updated PHPCS configuration to properly allow tabs for indentation per WordPress standards
8083

8184
= 1.0.5 - 2025-08-11 =
8285
* Security: Fixed critical code injection vulnerabilities in GitHub Actions workflows

0 commit comments

Comments
 (0)