Note in the example use of
apply_filters() to unify data sent to
In contrast, notice the difference in this version of the plugin, where the REST API is used instead of
newData. Notice especially line 71, where
wp_json_encode() is no longer called for data output by the REST API — JSON encoding is handled automatically. Also notice use of get_rest_url() on line 16 — this resolves the path to
/wp-json/ even if the JSON endpoint has been modified with the rest_url_prefix filter.