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
- REST API – filters not working inside plugin class
- CRUD and Frontend show from a custom table without shortcode
- How to get specific setting by settings_fields()?
- Save / Show multi line text in metabox
- Creating mySQL procedure with $wpdb
- how to disable blockrenderAppender inside all Innerblocks?
- why doesn’t this update part of this plugin work? it take me to nothing here page
- Redirection of users away from wp-admin (but not administrators)
- WordPress Gutenberg react make import of __experimentalUseInnerBlocksProps which is no more experimetal
- Using a custom plugin to capture input data via Ajax and PHP
- Python with wordpress plugin
- Display post lists in 2nd paragraph
- Map Custom Registration Fields to WordPress User Roles
- Not able to add option in Sub-Menu under page
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- Using a post-signup hook to get user details
- How to save generated JWT token to cookies on login?
- How to apply a patch via plugin?
- Fixing WordPress’s Bug (failed to send buffer of zlib output compression) results in “White Screen of Death”
- Disable woocommerce cookies and delete cart data automatically
- Ajax contact form widget plugin data not insert in database
- link bbpress forum discussion to blogposts
- Install Plugin via Code
- code is working properly in Core PHP but writing coding in WordPress
- Combine scripts from all extensions of the plugin when an extension is activated
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- wp_get_post_terms is difference obj model than the one in rest api response
- Prevent duplicate records in plugin table
- Send Custom welcome email to specific user group
- woocommerce payment gateway callback not firing [closed]
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- White page by using filter template_include
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Making a Template for a CPT created by a plugin
- Woocommerce dependent plugin
- WordPress.org Plugin Directory doesn’t recognise screenshots [closed]
- External CSS in WordPress Plugin [closed]
- How to check current user before all actions and filters?
- Owl Carousel2 image not displaying full width when using Stretch row and content, Stretch row and content(no padding) in wordpress
- User Session and Stored Cookies not get removed
- New databes tables with – WooCommerce – for developers [closed]
- How can I prevent my plugin go development trunk [closed]
- Plugin-generated pages use Not Found or Pages Archive templates?
- How can I make 2 plugins that include different versions of a framework to both use the latest version?
- creating html reusable blocks via shortcodes
- Add Plugin options as subpage to Theme options page
- Is there any kind of theme on WordPress to sell my own movies?
- Image upload and download from front-end
- Create a navbar filter that filters by a custom field
- Change commission_status paid when withdraw_status vendor is completed
- Passing an array from shortcode-function to filter-function
- custom payment gateway in woocommerce failed to connect to remote api server
- Single API call exposed via shortcode with params
- Plugin options page with live preview?
- Using SVN to upload plugin created with gutenberg blocks
- Force quit running background job
- Modifying Author Link to add Author Meta in URL
- How to output CMB2 select options from repeated groups select elements?
- Ability to make API calls out of WordPress as well as executing SQL?
- Access WordPress data from external PHP application.
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- Get Time Taken By Each Action Hook in WordPress
- How to export post 2 posts WordPress plugin data [closed]
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- 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?
- get 404 when accessing wp-admin/plugin-install.php
- What can be reason for no plugin-strings available under stable section on translate.wordpress.org?
- Plugin: register_deactivation_hook works perfectly well, while register_activation_hook suddenly stopped working
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Limit post creation by role
- I want to auto populate data in three fields if one drop down is selected
- Best place for if/else piece of code related to custom plugin?
- How do you assign a UUID to posts/products/comments/reviews?
- Best way to initiate a class in a WP plugin?
- correct way to include a library(and its dependent libraries) in wordpress development
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- Issue Tracker from pre exsisting table [closed]
- How to make a implement queue for scheduling tasks in WordPress?
- Session destroyed on page redirect
- WordPress Plugin [closed]
- wp.media javascript issue with on select
- Is there a way to test that readme looks in other language before submitting translation?