Code Monkey home page Code Monkey logo

Comments (4)

arnaudbroes avatar arnaudbroes commented on August 16, 2024

@congkun-ck thank you for reporting this. I agree that this isn't the best way to do things and I've already developed a fix for this.

The reason why this is currently isn't causing too many issues I think is because most WordPress sites store roles in the database and therefore they would already be accessible when we create that instance of the WP_Roles class. But it is possible to prevent the WP_Roles class from pulling data from the database and instead only use what's dynamically registered.

In any case, I wanted to check if you would like a beta build for this? If so, I'll generate one and post it here down below.

from all-in-one-seo-pack.

congkun-ck avatar congkun-ck commented on August 16, 2024

@arnaudbroes thanks for the quick response, Arnaud.
I made a quick mitigation on my website with a small plugin which just resets $current_user on setup_theme, so I am now not blocked. However I am happy to help try the beta fix.

from all-in-one-seo-pack.

arnaudbroes avatar arnaudbroes commented on August 16, 2024

@congkun-ck I've made some other changes but to fix this I basically just assigned our instance to a variable instead of the global like this -

	public function getUserRoles() {
		global $wp_roles;

		$wpRoles = $wp_roles;
		if ( ! is_object( $wpRoles ) ) {
			// Don't assign this to the global because otherwise WordPress won't override it.
			$wpRoles = new \WP_Roles();
		}

		$roleNames = $wpRoles->get_names();
		asort( $roleNames );

		return $roleNames;
	}

from all-in-one-seo-pack.

arnaudbroes avatar arnaudbroes commented on August 16, 2024

@congkun-ck we fixed this some months ago in version 4.1.5 so I'll close the issue now.

from all-in-one-seo-pack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.