My WordPress site uses custom template pages like this one:
<php
/*Â
Template Name : project_costs
/*
get_header ();
// set default vars or user received
require("my_forms.php");
// pull data from db and calculate
require("project_calculation. php");
// create page
require("content. php");
...
My custom page project_costs.php
 performing the steps :
- Receive and set user entered vars from page forms (POST/GET).
- Pull data from database.
- Do some calculations and changes.
- Creates page for user.Â
I want to integrate angular.js with the WP-API plugin. The plugin just pulls raw data from database (step 2) and sends it to front end (step 4). So pages and templates not in use as page didn’t reload.
I want to pass data to my php class first (step 3), then pass changed data to WP-API.
Is there any function in WP-API to call my PHP file or function?Â
Any advice, samples or links would be highly appreciated.
Thanks.
So I’m working on a huge project which includes several API/Angular replacement parts for #WordPress. One file is a custom endpoint-boilerplate.php. It works like a charm so far but any input would be appreciated.
Just follow the structure and use the
my_awesome_function
to return do anything you’d like. Then the namespace and route from the hook will be available, using data from my_awesome_func.So your call will then be a
get
tohttp://yourproject.com/wp-json/custom-endpoint/v2/author/1