This is a file from the Wikimedia Commons

File:DNS Tree.svg

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Original file(SVG file, nominally 1,464 × 858 pixels, file size: 52 KB)

<?php /**

* Grab latest post title by an author!
*
* @param array $data Options for the function.
* @return string|null Post title for the latest,
* or null if none.
*/

function my_awesome_func( $data ) {

 $posts = get_posts( array(
   'author' => $data['id'],
 ) );
 if ( empty( $posts ) ) {
   return new WP_Error( 'no_author', 'Invalid author', array( 'status' => 404 ) );
 }
 return $posts[0]->post_title;

}<?php add_action( 'rest_api_init', function () {

 register_rest_route( 'myplugin/v1', '/author/(?P<id>\d+)', array(
   'methods' => 'GET',
   'callback' => 'my_awesome_func',
   'args' => array(
     'id' => array(
       'validate_callback' => function($param, $request, $key) {
         return is_numeric( $param );
       }
     ),
   ),
 ) );

} );<?php function my_awesome_func( WP_REST_Request $request ) {

 // You can access parameters via direct array access on the object:
 $param = $request['some_param'];
 // Or via the helper method:
 $param = $request->get_param( 'some_param' );
 // You can get the combined, merged set of parameters:
 $parameters = $request->get_params();
 // The individual sets of parameters are also available, if needed:
 $parameters = $request->get_url_params();
 $parameters = $request->get_query_params();
 $parameters = $request->get_body_params();
 $parameters = $request->get_json_params();
 $parameters = $request->get_default_params();
 // Uploads aren't merged in, but can be accessed separately:
 $parameters = $request->get_file_params();

}{

 "name": "WordPress Site",
 "description": "Just another WordPress site",
 "url": "http://example.com/",
 "namespaces": [
   "wp/v2",
   "vendor/v1",
   "myplugin/v1",
   "myplugin/v2",
 ]

}http://example.com/wp-json/myplugin/v1/author/(?P\d+)`.http://example.com/wp-json/myplugin/v1/author/

Summary

Description An illustration depicting the DNS tree hierarchy.
Date
Source Own work
Author Sylvain Leroux (talk)
Other versions Derivative works of this file:  DNS Tree el.svg

Licensing

I, the copyright holder of this work, hereby publish it under the following licenses:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
You may select the license of your choice.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

28 April 2011

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current13:30, 28 April 2011Thumbnail for version as of 13:30, 28 April 20111,464 × 858 (52 KB)Sylvain LerouxFixed problems regarding colors in the text labels
13:19, 28 April 2011Thumbnail for version as of 13:19, 28 April 20111,464 × 858 (52 KB)Sylvain Leroux{{Information |Description=An illustration depicting the DNS tree hierarchy. |Date=2011, 28 April |Source={{own}} |Author= ~~~ |Permission= |other_versions= }}

Global file usage