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

API function/method: Get all WPSEO related capabilities #9300

Closed
2 tasks done
JoryHogeveen opened this issue Mar 21, 2018 · 2 comments
Closed
2 tasks done

API function/method: Get all WPSEO related capabilities #9300

JoryHogeveen opened this issue Mar 21, 2018 · 2 comments

Comments

@JoryHogeveen
Copy link
Contributor

JoryHogeveen commented Mar 21, 2018

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

Please see these two PR's:
#7937 (compatibility with role managers)
#9285 (bugfix getting capabilities on frontend)

Please describe what you expected to happen and why.

There is no simple way (API) to fetch all the capabilities used by Yoast SEO.
For example, GravityForms has a simple method to fetch all capabilities used in the plugin: GFCommon::all_caps()

My current solution is this:

$wpseo = new WPSEO_Capability_Manager_Integration( WPSEO_Capability_Manager_Factory::get() );
$wpseo->register_hooks();

This is off course not very neat and could cause bugs when the WPSEO codebase changes. See #9285 for example.

I think it would be best to create a centralized method for this purpose. WPSEO_Utils::get_capabilities() or something. Or maybe just a function: wpseo_get_capabilities()..

backstory

I'm the author of View Admin As, a plugin which let you switch users, roles, capabilities, languages etc.etc. straight from the wp toolbar. Especially the capability switcher relies on compatibility with other plugins so I'm trying to check for other plugins and their capabilities as much as I can.

This works fine for Yoast SEO capabilities on the backend since my PR #7937 but this doesn't work on the frontend. Since the adminbar is also loaded on the frontend when logged in I'm also loading thirdparty capabilities there.
Example for the Yoast SEO caps: https://github.com/JoryHogeveen/view-admin-as/blob/8b94155b042aa4feaaae8b5c84eb3e807fdb867d/includes/class-compat.php#L331-L352

Technical info

  • WordPress version: Not relevant
  • Yoast SEO version: 5.8+
@JoryHogeveen
Copy link
Contributor Author

I can make a PR for this if you want. I just need to know where you would like to put this.

I think it would be best to create a centralized method for this purpose. WPSEO_Utils::get_capabilities() or something. Or maybe just a function: wpseo_get_capabilities()..

@moorscode
Copy link
Contributor

That would be awesome!
Please make a wpseo_get_capabilities function (inc/wpseo-functions.php) which provides this functionality.

We can always change the actual logic that fetches the capabilities and provide this easy API for other plugins, like yours, to use.

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

No branches or pull requests

6 participants