Skip to content

Commit

Permalink
Fix capability
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo-sg-pacheco committed Oct 14, 2024
1 parent 684288d commit 6637ce1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* `Fixed` for any bug fixes.
* `Security` in case of vulnerabilities

## [1.0.2] - 2024-10-14
### Fixed
* Capability by managing it later.

## [1.0.1] - 2024-10-14
### Fixed
* Capability to `manage_woocommerce` if woocommerce is enabled, or else `manage_options`.
Expand Down
14 changes: 9 additions & 5 deletions src/php/class-wpfactory-cross-selling.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* WPFactory Cross-Selling
*
* @version 1.0.1
* @version 1.0.2
* @since 1.0.0
* @author WPFactory
*/
Expand Down Expand Up @@ -32,7 +32,7 @@ class WPFactory_Cross_Selling {
*
* @var string
*/
protected $version = '1.0.1';
protected $version = '1.0.2';

/**
* Setup args.
Expand Down Expand Up @@ -91,7 +91,7 @@ class WPFactory_Cross_Selling {
/**
* Setups the class.
*
* @version 1.0.1
* @version 1.0.2
* @since 1.0.0
*
* @param $args
Expand All @@ -117,7 +117,7 @@ function setup( $args = null ) {
$args['admin_page'] = wp_parse_args( $args['admin_page'], array(
'page_title' => __( 'WPFactory Recommendations', 'wpfactory-cross-selling' ),
'menu_title' => __( 'Recommendations', 'wpfactory-cross-selling' ),
'capability' => class_exists( 'WooCommerce' ) ? 'manage_woocommerce' : 'manage_options',
'capability' => '',
'position' => 2
) );

Expand Down Expand Up @@ -217,7 +217,7 @@ function enqueue_admin_styles() {
/**
* Creates cross-selling submenu.
*
* @version 1.0.0
* @version 1.0.2
* @since 1.0.0
*
* @return void
Expand All @@ -236,6 +236,10 @@ function create_cross_selling_submenu() {
$capability = $admin_page['capability'] ?? '';
$position = $admin_page['position'] ?? '';

if ( empty( $capability ) ) {
$capability = class_exists( 'WooCommerce' ) ? 'manage_woocommerce' : 'manage_options';
}

// Creates the submenu page.
\add_submenu_page(
WPFactory_Admin_Menu::get_instance()->get_menu_slug(),
Expand Down

0 comments on commit 6637ce1

Please sign in to comment.