ad-layers icon indicating copy to clipboard operation
ad-layers copied to clipboard

PHP Fatal error on Ad Server Settings admin page

Open onpubcom opened this issue 9 years ago • 5 comments

With the latest version of the plugin, going to the Ad Server Settings (/wp-admin/edit.php?post_type=ad-layer&page=ad_layers_ad_server_settings) page in wp-admin throws the following exception, resulting in a fatal error:

PHP Fatal error: Uncaught exception 'FM_Submenu_Not_Initialized_Exception' with message 'The Fieldmanger context for this submenu was not initialized'

This renders the plugin no longer fully configurable via the wp-admin UI.

onpubcom avatar Feb 16 '16 21:02 onpubcom

Ad Layers is dependent on Fieldmanager for its admin area. Please ensure you are using the latest version from here: https://github.com/alleyinteractive/wordpress-fieldmanager

Ad Layers requires an update made to Fieldmanager in July 2015 for submenu pages, so it seems that you're running a quite old version.

bcampeau avatar Feb 19 '16 19:02 bcampeau

Will do. Thanks for this info!

onpubcom avatar Feb 19 '16 19:02 onpubcom

Hi @bcampeau : I am facing the same issue, although I have recent versions for both fieldmanager and ad-layers.

kala725 avatar Feb 08 '17 08:02 kala725

Hi @bcampeau : I have figured out the issue and it was in my code. However the error returned needs to be fine tuned.

It will happen when I limit the ad-layer access to some capability.

add_filter( 'register_post_type_args', function( $args, $post_type ) {
	if ( 'ad-layer' === $post_type ) {
		$args['capabilities'] = [
			'edit_posts' => 'manage_advertising',
			'edit_others_posts' => 'manage_advertising',
		];
	}
	return $args;
}, 10, 2 );

When the logged in user, doesn't have the capability, this error is returned, while trying to change the settings.

(Ideally if we hide all the options like server settings, then it can be avoided.) If there is other way of doing so, please let me know.

kala725 avatar Feb 08 '17 08:02 kala725

We'll take a look at it for the next version, but if you'd like to submit a pull request with a proposed solution you're more than welcome.

bcampeau avatar Feb 08 '17 22:02 bcampeau