Is there a way to programmatically enable a plugin?

Yes, there’s activate_plugin() defined in wp-admin/includes/plugin.php (which isn’t normally loaded from non-admin code, and note that obviously a PHP plugin file can’t activate itself) wp-cli wp plugin activate if you meant activate from the command line without using the admin site (and at a pinch you could edit the active_plugins value in wp_options in the … Read more

Does WordPress support WebP images?

On July 20th 2021, assuming everything goes to plan, WordPress 5.8 will be released with full support for WebP images. You can read all about that here: https://make.wordpress.org/core/2021/06/07/wordpress-5-8-adds-webp-support/ If you like you can use the beta testing plugin to test it out on your WordPress site if you can’t wait until it’s released.

query users by role

You can use this function: // get users with specified roles function getUsersWithRole( $roles ) { global $wpdb; if ( ! is_array( $roles ) ) $roles = array_walk( explode( “,”, $roles ), ‘trim’ ); $sql=” SELECT ID, display_name FROM ” . $wpdb->users . ‘ INNER JOIN ‘ . $wpdb->usermeta . ‘ ON ‘ . $wpdb->users … Read more

How do I add a custom sublevel menu specified in one directory to a custom top level menu specified in another directory?

It sounds as if you’re having problems adding submenus from a plugin to a parent item registered in another plugin. Add priorities to your admin_menu actions to make sure the parent(top level) item exists at the point your additional plugins attempt to add items to that menu.. Add top level add_action(‘admin_menu’, ‘main_menu’, 100 ); Add … Read more