Skip to content

Commit

Permalink
Merge pull request #254 from Codeinwp/fix/253
Browse files Browse the repository at this point in the history
fix: current_user_can early usage
  • Loading branch information
vytisbulkevicius authored Feb 29, 2024
2 parents f57f69a + e55948b commit 84a9db9
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions classes/admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* working behind the seen
*/

/*
**========== Direct access not allowed ===========
/*
**========== Direct access not allowed ===========
*/
if ( ! defined( 'ABSPATH' ) ) {
die( 'Not Allowed' );
Expand Down Expand Up @@ -52,7 +52,7 @@ function __construct() {
array(
$this,
'add_menu_pages',
)
)
);

add_action( 'init', array( 'NM_PersonalizedProduct', 'set_ppom_menu_permission' ) );
Expand All @@ -62,7 +62,7 @@ function __construct() {
add_action( 'wp_ajax_ppom_attach_ppoms', array( $this, 'ppom_attach_ppoms' ) );

// Adding setting tab in WooCommerce
if ( ! ppom_settings_migrated() && current_user_can( 'manage_options' ) ) {
if ( ! ppom_settings_migrated() ) {
add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 50 );
// Display settings
add_action( 'woocommerce_settings_tabs_ppom_settings', array( $this, 'settings_tab' ) );
Expand All @@ -83,7 +83,7 @@ function __construct() {
'ppom_multi_select_role_setting',
),
2,
10
10
);

}
Expand Down Expand Up @@ -114,7 +114,7 @@ function add_menu_pages() {
$page ['callback'],
),
$this->plugin_meta ['logo'],
$this->plugin_meta ['menu_position']
$this->plugin_meta ['menu_position']
);
} else {

Expand All @@ -127,7 +127,7 @@ function add_menu_pages() {
array(
$this,
$page ['callback'],
)
)
);
}

Expand All @@ -142,9 +142,9 @@ function add_menu_pages() {
array(
$this,
$page ['callback'],
)
)
);
}
}
}
}

Expand Down Expand Up @@ -312,20 +312,26 @@ function validate_plugin() {

public static function add_settings_tab( $settings_tabs ) {

$settings_tabs['ppom_settings'] = __( 'PPOM Settings', 'woocommerce-product-addon' );
if ( current_user_can( 'manage_options' ) ) {
$settings_tabs['ppom_settings'] = __('PPOM Settings', 'woocommerce-product-addon');
}

return $settings_tabs;
}

function settings_tab() {

woocommerce_admin_fields( ppom_array_settings() );
if ( current_user_can( 'manage_options' ) ) {
woocommerce_admin_fields(ppom_array_settings());
}

}

function save_settings() {

woocommerce_update_options( ppom_array_settings() );
if ( current_user_can( 'manage_options' ) ) {
woocommerce_update_options(ppom_array_settings());
}
}

function ppom_setting_wpml( $value, $option, $raw_value ) {
Expand Down

0 comments on commit 84a9db9

Please sign in to comment.