Created
April 16, 2021 10:10
-
-
Save poguez/948f24dec4a79b1a06b4c94bd0dd5641 to your computer and use it in GitHub Desktop.
How I initialize the routes for the plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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