Skip to content

Instantly share code, notes, and snippets.

@poguez
Created April 16, 2021 10:10
Show Gist options
  • Save poguez/948f24dec4a79b1a06b4c94bd0dd5641 to your computer and use it in GitHub Desktop.
Save poguez/948f24dec4a79b1a06b4c94bd0dd5641 to your computer and use it in GitHub Desktop.
How I initialize the routes for the plugin
class Glassbox_Initializer {
public function __construct() {
}
public function run() {
foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
if ( post_type_supports( $post_type->name, 'revisions' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'class-glassbox-controller.php';
$revisions_controller = new WP_REST_Glassbox_Controller( $post_type->name );
$revisions_controller->register_routes();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment