Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'remove-widgets' not working #22

Closed
nightillusions opened this issue May 9, 2018 · 2 comments
Closed

'remove-widgets' not working #22

nightillusions opened this issue May 9, 2018 · 2 comments

Comments

@nightillusions
Copy link

nightillusions commented May 9, 2018

Hi there,

the intervention( 'remove-widgets' ); doesn´t work in my setup. Still all WordPress Widgets are present in backend:
Widgets in backend

My code:

<?php
require __DIR__ . '/../vendor/autoload.php';
use function \Sober\Intervention\intervention;

if (function_exists('Sober\Intervention\intervention')) {
	add_action( 'init', function() {
		// Add Welcome Dashboard
		intervention( 'add-dashboard-item', [
			'Willkommen',
			'Willkommen im Backend der ' . get_bloginfo( 'name' )
		] );
		// Add SVG Support
		intervention( 'add-svg-support', [
			'admin',
			'editor'
		] );
		// Remove Dashboard Items
		intervention( 'remove-dashboard-items' );
		// Remove Emoji
		intervention( 'remove-emoji' );
		// Remove Howdy
		intervention( 'remove-howdy', '' );
		// Remove footer
		intervention( 'update-label-footer', 'Mit &#x2764; von <a href="https://wdj.ac">wdj Digitalagentur</a>' );
		// Remove Page Components
		intervention( 'remove-page-components', [
			'author',
			'comments'
		] );
		// Remove Post Components
		intervention( 'remove-post-components', [
			'comments',
			'trackbacks'
		] );
		// Remove toolbar from non-admin users
		intervention( 'remove-toolbar-frontend', [
			'all-not-admin'
		] );
		// Remove unused user fields
		intervention( 'remove-user-fields', [
			'option-title',
			'option-editor',
			'option-schemes',
			'option-shortcuts',
			'option-toolbar',
			'contact',
			'contact-web',
			'about',
			'about-bio',
			'about-profile'
		] );
		// Remove toolbar items for all
		intervention( 'remove-toolbar-items', [
			'logo',
			'comments',
			'customize',
		], [ 'all' ] );
		// Remove toolbar items for non-admin users
		intervention( 'remove-toolbar-items', [
			'updates',
		], [ 'all-not-admin' ] );
		// Remove update notices from non-admin users
		intervention( 'remove-update-notices', [
			'editor',
			'author'
		] );
		// Remove senseless user roles from WordPress
		intervention( 'remove-user-roles', [
			'subscriber',
			'contributor'
		] );
		// Remove Widgets
		intervention( 'remove-widgets' );
		// Default 100 pagination
		intervention( 'update-pagination', 100 );
		// Remove Menu items
		intervention( 'remove-menu-items', 'danger-zone', 'all-not-admin' );
		intervention( 'remove-menu-items', [
			'comments',
			'media',
			'media-new',
			'plugin-editor',
			'theme-editor'
		], 'all' );
		intervention( 'remove-menu-items', [
			'tool-import',
			'tool-export',
			'acf',
			'acf-new',
			'acf-tools',
			'acf-updates',
		], 'all-not-admin' );
	});
} 

Any ideas what could cause this issue?

@darrenjacoby
Copy link
Owner

darrenjacoby commented May 11, 2018

I'll test, but you can remove this in your code so long, (before calling the intervention methods)

add_action( 'init', function() {

@nightillusions
Copy link
Author

nightillusions commented May 11, 2018

Thanks for your feedback.

I´m using it in mu-plugins. Without hook:

Fatal error:  Uncaught Error: Call to undefined function wp_get_current_user() in /html/wordpress/wp-includes/capabilities.php:590
Stack trace:
#0 /html/wordpress/wp-content/mu-plugins/gesundheitsregion/vendor/soberwp/intervention/src/Module/AddSvgSupport.php(37): current_user_can('administrator')
#1 /html/wordpress/wp-content/mu-plugins/gesundheitsregion/vendor/soberwp/intervention/src/Module/AddSvgSupport.php(24): Sober\Intervention\Module\AddSvgSupport-&gt;addSvgSupport()
#2 /html/wordpress/wp-content/mu-plugins/gesundheitsregion/vendor/soberwp/intervention/intervention.php(15): Sober\Intervention\Module\AddSvgSupport-&gt;run()
#3 /html/wordpress/wp-content/mu-plugins/gesundheitsregion/extras/admin.php(13): Sober\Intervention\intervention('add-svg-support', Array)
#4 /html/wordpress/wp-content/mu-plugins/gesundheitsregion/gesundheitsregion.php(5): require_once('/html/wordpress...')
#5 /html/wordpress/wp-content/mu-plugins/mu-autoloader.php(13): require('/html/wordpress...')
#6 /html/wordpress/wp-settings.php(260): include_onc in /html/wordpress/wp-includes/capabilities.php on line 590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants