wordpress-sdk icon indicating copy to clipboard operation
wordpress-sdk copied to clipboard

PHP Notice when the admin options page slug is similar to the Freemius menu slug

Open bfintal opened this issue 2 years ago • 0 comments

🐞 bug report

Behavior:

  • What is the issue? (*) I have this in my SDK integration (retained only the relevant part):
$sugb_fs = fs_dynamic_init( array(
	// ...
	'menu' => array(
		'slug' => 'stackable',
		// ...
	),
) );

I also add my own menu page (intended to display some plugin options) where that slug starts with the same slug as the menu slug above:

add_action( 'admin_menu', function() {
	add_menu_page(
		__( 'Title', 'default' ), // Title of Page
		__( 'Menu', 'default' ), // Menu Title
		'edit_posts', // Permissions
		'stackable-test', // Slug
		'__return_false', // Callback Function
	);
} );

When logged in as a user without manage_options privileges, navigating to that menu page http://local.local/wp-admin/admin.php?page=stackable-test throws PHP notices:

Notice: Trying to access array offset on value of type bool in /.../plugin/freemius/includes/managers/class-fs-admin-menu-manager.php on line 710

Screen Shot 2021-07-23 at 2 16 45 PM

Changing the admin page slug so as not to start with the Freemius slug fixes the issue.

  • What is the expected behavior?

No PHP notice

Versions: (*)

  • Freemius SDK Version: 2.4.2
  • WordPress Version: 5.8
  • PHP Version: 7.3

Plugin / Theme: (*)

  • Name: Stackable
  • Slug: stackable-ultimate-gutenberg-blocks
  • Freemius ID: 1748

bfintal avatar Jul 23 '21 06:07 bfintal