Getting user roles in plugin files

Figured my comment would actually make a better answer, so here we go. You can hook other methods within the plugin class onto admin_init (for the admin side) within the constructor, like so: class Plugin_Class { public function __construct() { add_action( ‘admin_init’, array( $this, ‘some_other_method’ ) ); } public function some_other_method() { // do something … Read more

CMB2 installation – cannot get it to work

Step#1: Using git clone the latest CMB2 resources to your working project. Step#2: Rename the CMB2-master (or anything else) folder to cmb. Step#3: In your project’s functions.php simply use the following code: if( !class_exists(“CMB2″) ){ require_once( dirname(__FILE__).”/libs/cmb/init.php” ); } (I put all my external libraries to /themes/my-theme/libs/ so I called it so) Step#4: You can … Read more

WordPress Social Login > Post to a users Facebook wall

Im no expert on this but here goes: After reading some code and doing a global search of the filter, its not a filter at all, the only time that filter is called is in a do_action // HOOKABLE: This action runs just before logging the user in (before creating a WP cookie) do_action( “wsl_hook_process_login_before_wp_set_auth_cookie”, … Read more

How to Know if a Plugin can be used with my Theme [closed]

So in theory WordPress extensions are all using its APIs to peacefully and happily coexist. In practice the landscape of WordPress extensions is a brutal mess, with literally tens of thousands of them, produced by developers of drastically different qualification. The two basic practices to mitigate and save your sanity: If you are in a … Read more

Appery.io and WordPress

If you’re using WordPress 4.6, you can use the REST API without the need for the plugin by simply using the following: add_action(‘rest_api_init’, function() { $namespace=”myapi”; register_rest_route($namespace, ‘/myroute’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘handle_my_route’ ), true); function handle_my_route() { return ‘Hello World!’; } } Then, going to: yourwebsite/wp-json/myapi/myroute would return the callback value, which … Read more