Add to your __construct
function:
add_action( 'rest_api_init',[$this, 'register_routes'] );
And the rest api will take it from there. No need to process routes in your activation functions, and no need to flush the rules.
The $wp_rest_server
is constructed after the plugins are loaded. Hence it is null when you instantiate your class in the plugin.
Related Posts:
- REST-API: extend media-endpoint
- How to modify WCMP Rest API response?
- wp_remote_get() returns 403 while file_get_contents() does not
- how to do login using woocommerce rest api From android
- How to create WordPress custom end point with multiple parameters?
- Seperate plugin and theme files
- wc_get_template_part doesnt display the content [duplicate]
- Getting all woocommerce products from REST API call in plugin
- is it possible to fetch data from a remote api while admin is writing a new post?
- add tags to wordpress post using REST API
- Showing how many times is plugin activated or deactivated
- Can’t access 3rd party API, code works on local server but not on wordpress
- Extend WordPress REST API with Scheme Pro Plugin
- wordpress Ajax success doesn’t return the value
- How can I send api calls from my plugin?
- Is it possible to create post in wordpress using postman?
- Accessing Correct Database to Create REST API Endpoint
- Redesigning Custom Post Type “Add New” page
- Notify Admins about Plugin Merge
- Adding Featured Image in Post List
- Why does including a file in theme’s functions.php not work?
- WooCommerce – Call to undefined function is_woocommerce()
- OEmbed from Pinterest
- How can I add a custom header to a custom template in a plugin without using the theme folders
- Trying to avoid including wp-load.php
- Custom values are not translated
- Add Top-Level Menu that opens URL
- Change the name of an installed plugin
- Issue with post request to admin-post.php
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- like to keep reading plugin
- Check if email address exists front end with AJAX in a plugin
- Avoiding Duplicate function names in Post Loop (WP_Footer script)
- Global matrix for shortcodes/content for every page
- How to add class in plugin only for network site?
- Plugin Development sqlite or WordPress’ database
- How to write a plugin to add users to a mail list
- WordPress plugin for activating other plugins
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- New User Form – Custom Menu Page
- AJAX search posts and pages
- Combine scripts from all extensions of the plugin when an extension is activated
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- How can I prevent my plugin go development trunk [closed]
- Access WordPress data from external PHP application.
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- Checkbox conflict in my custom plugin admin page
- How to create a code editor for my plugin .?
- How to create a custom shortcode based on the layout?
- Manually set a custom admin sub-menu selected?
- Can a Plugin Override New User Default Role Type
- How to test ‘upgrader_process_complete’ hook in plugin development?
- How to let user store a file in plugin directory but not have it get deleted on update?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Plugins ignored a line breaks or tag in the WordPress comment functions
- How to get path or root of plugin folder, not file or dir?
- plugins_url() works everywhere but wp_reqister_script()
- Integrating boxtal PHP library into a custom WordPress Plugin
- Images under 1MB are not being compressed
- Sanitize $_GET variable when comparing
- Where can I save plugin data?
- show my own admin_notices after a post has been published
- How to add a WordPress Nonce for this form to avoid CSRF
- Overriding current theme files via plugin
- How to create a plugin that includes all the other plugins?
- How to add update function to plugin without adding it to https://wordpress.org/plugins/ [closed]
- Plugin option default value
- How to edit link for comment count
- Integrating Custom Database with WordPress
- specific rows style for in custom list table using WP_List_Table
- How to add the search page link to the anchor tag?
- Need to know if my approach to designing a geneaology plug-in for wordpress makes sense
- Creating one user access account for all the multiple sites
- Using id to show item
- I am Getting Sorry, no posts matched your criteria on form submit only for certain page [duplicate]
- Is it possible to custom set query for a WordPress REST API response?
- wpdb update method is updating but not refreshing the current page data
- Shortcode and WP query using category attributes
- Dynamic input fields in WordPress Plugin
- Custom role not listed
- Is admin section completely customizable in terms of styling?
- Better way to run heavy scripts using WordPress database
- how to check plugin name unique or not?
- WP Rest API v2.0 user profile update issue
- Change default url to plugin custom post type
- Creating a user ‘add custom field’ section
- WordPress ajax not working in registration
- How to show post attachment image
- Can a developer adopt a plugin marked as “not updated in over 2 years”?
- Making a Custom Post Type Publish Loop
- How wordpress plugin hooks works? [duplicate]
- Post curl function save twice using plugin hook function wordpress
- Someone Comment 1000 times in a Day in My WordPress Site, What Can i Do
- get_option returning a different value from what’s saved
- Plugin: Custom menu item problem
- Getting warning of Missing argument 2 for wpdb::prepare()
- Filter custom post type returned from REST api
- WP Elementor Pro causing crtical failure on website
- Display Any Field fromAdmin Panel in Frontend via Shortcode?