Book Image

WordPress Web Application Development

By : Rakhitha Nimesh Ratnayake
Book Image

WordPress Web Application Development

By: Rakhitha Nimesh Ratnayake

Overview of this book

Table of Contents (19 chapters)
WordPress Web Application Development Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Providing the API documentation


Typically, most popular APIs provide complete documentation for accessing the API methods. Alternatively, we can use a new API method to provide details about all the other API methods and parameters. This allows third-party users to request an API method and get the details about all the other functions.

Tip

WordPress uses the API method called system.listMethods for listing all the existing methods inside the API. Here, we will take one step further by providing the parameters of API methods with the complete list.

We can start the process by adding another API method to the xml_rpc_api function, as shown in the following code:

public function xml_rpc_api($methods) {
  $methods['wpwa.subscribeToDevelopers'] = array($this, 'developer_subscriptions');
  $methods['wpwa.getDevelopers'] = array($this, 'developers_list');
  $methods['wpwa.apiDoc'] = array($this, 'wpwa_api_doc');
  return $methods;
}

Once updated, we can use the following code to provide details about...