Skip to content

Commit 56fc8a8

Browse files
committed
Fix: updated Menu class and removed unused $this->tabs property and fixed Warning related to translations
1 parent 39ffaf4 commit 56fc8a8

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/Admin/Settings/Menu.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515
}
1616

1717
class Menu extends Api {
18-
/**
19-
* Tabs for the settings page.
20-
*
21-
* @since 2.0.0
22-
* @access public
23-
*
24-
* @var array
25-
*/
26-
public $tabs = [];
27-
2818
/**
2919
* Constructor
3020
*
@@ -34,7 +24,6 @@ class Menu extends Api {
3424
*/
3525
public function __construct() {
3626
$this->prefix = 'perform_';
37-
$this->tabs = Helpers::get_settings_tabs();
3827

3928
add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 9 );
4029
add_action( 'wp_ajax_perform_save_settings', [ $this, 'save_settings' ] );

src/Includes/Helpers.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,30 @@ public static function find_field_by_id( $id ) {
243243
*/
244244
public static function get_settings_tabs() {
245245
$tabs = [
246-
'general' => esc_html__( 'General', 'perform' ),
247-
'bloat' => esc_html__( 'Bloat', 'perform' ),
248-
'assets' => esc_html__( 'Assets', 'perform' ),
249-
'cdn' => esc_html__( 'CDN', 'perform' ),
250-
'advanced' => esc_html__( 'Advanced', 'perform' ),
246+
'general' => 'General',
247+
'bloat' => 'Bloat',
248+
'assets' => 'Assets',
249+
'cdn' => 'CDN',
250+
'advanced' => 'Advanced',
251251
];
252252

253253
// Add WooCommerce tab if WooCommerce is active.
254254
if ( self::is_woocommerce_active() ) {
255-
$tabs['woocommerce'] = esc_html__( 'WooCommerce', 'perform' );
255+
$tabs['woocommerce'] = 'WooCommerce';
256256
}
257-
return $tabs;
257+
258+
/**
259+
* ✅ Safe translation wrapper
260+
* Translate only after init, otherwise return plain labels.
261+
*/
262+
if ( did_action( 'init' ) ) {
263+
foreach ( $tabs as $key => $label ) {
264+
$tabs[ $key ] = esc_html__( $label, 'perform' );
265+
}
266+
}
267+
268+
//return $tabs;
269+
return apply_filters( 'perform_settings_tabs', $tabs );
258270
}
259271

260272
/**

src/Plugin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public function register() {
3030
register_activation_hook( PERFORM_PLUGIN_FILE, [ $this, 'activate' ] );
3131
register_deactivation_hook( PERFORM_PLUGIN_FILE, [ $this, 'deactivate' ] );
3232

33-
// Load text domain.
34-
add_action( 'plugins_loaded', [ $this, 'load_plugin_textdomain' ], 9 );
35-
3633
// Register services used throughout the plugin.
37-
add_action( 'plugins_loaded', [ $this, 'register_services' ], 10 );
34+
add_action( 'plugins_loaded', [ $this, 'register_services' ] );
35+
36+
// Load text domain.
37+
add_action( 'init', [ $this, 'load_plugin_textdomain' ] );
3838
}
3939

4040
/**

0 commit comments

Comments
 (0)