PHP Класс WPCOM_JSON_API_Endpoint, jetpack

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$allow_cross_origin_request Set to true if the endpoint accepts all cross origin requests. You probably should not set this flag.
$allow_jetpack_site_auth Set to true if the endpoint should accept site based (not user based) authentication.
$allow_unauthorized_request Set to true if the endpoint can recieve unauthorized POST requests.
$allowed_if_flagged Is this endpoint still allowed if the site in question is flagged?
$allowed_if_red_flagged Is this endpoint allowed if the site is red flagged?
$api The API Object
$custom_fields_filtering Set to true if the endpoint implements its own filtering instead of the standard fields query method
$description One liner.
$example_request Example request to make
$example_request_data Example request data (for POST methods)
$example_response Example response from $example_request
$group Object Grouping For Documentation (Users, Posts, Comments)
$in_testing Is this endpoint still in testing phase? If so, not available to the public.
$links The link-generating utility class
$max_version Maximum version of the api for which to serve this endpoint
$method HTTP Method
$min_version Minimum version of the api for which to serve this endpoint
$pass_wpcom_user_details
$path Path at which to serve this endpoint: sprintf() format.
$path_labels Identifiers to fill sprintf() formatted $path
$query Accepted query parameters
$request_format Request format
$response_format Response format
$stat Stats extra value to bump
$version Version of the API

Открытые методы

Метод Описание
__construct ( $args )
add_http_build_query_to_php_content_example ( $matches )
allow_video_uploads ( $mimes )
allows_cross_origin_requests ( )
allows_unauthorized_requests ( $origin, $complete_access_origins )
callback ( $path = '' ) Return endpoint response
cast_and_filter ( $data, $documentation, $return_default_values = false, $for_output = false )
cast_and_filter_item ( &$return, $type, $key, $value, $types = [], $for_output = false ) Casts $value according to $type.
copy_hooks ( $from_hook, $to_hook, $base_paths )
current_user_can_access_post_type ( string $post_type, string $context = 'display' ) : boolean Check whether a user can view or edit a post type
document ( $show_description = true ) Auto generates documentation based on description, method, path, path_labels, and query parameters.
format_date ( $date_gmt, $date = null ) : string Returns ISO 8601 formatted datetime: 2011-12-08T01:15:36-08:00
format_taxonomy ( $taxonomy, $taxonomy_type, $context )
generate_doc_description ( $item ) Recursively generates the
's to document item descriptions.
generate_documentation ( ) Auto generates documentation based on description, method, path, path_labels, and query parameters.
get_author ( $author, $show_email = false ) : (object) Returns author object.
get_media_item ( $media_id )
get_media_item_v1_1 ( $media_id )
get_platform ( )
get_reflection ( $callback )
get_taxonomy ( $taxonomy_id, $taxonomy_type, $context )
handle_media_creation_v1_1 ( $media_files, $media_urls, $media_attrs = [], $force_parent_id = false )
handle_media_sideload ( $url, $parent_post_id, $type = 'any' )
input ( $return_default_values = true, $cast_and_filter = true ) Get POST body data
is_current_site_multi_user ( )
is_post_type_allowed ( $post_type )
is_publicly_documentable ( ) Checks if the endpoint is publicly displayable
load_theme_functions ( ) Load the functions.php file for the current theme to get its post formats, CPTs, etc.
parse_date ( $date_string ) : array( Parses a date string and returns the local and GMT representations of that date & time in 'YYYY-MM-DD HH:MM:SS' format without timezones or offsets. If the parsed datetime was not localized to a particular timezone or offset we will assume it was given in GMT relative to now and will convert it to local time using either the timezone set in the options table for the blog or the GMT offset.
parse_types ( $text )
query_args ( $return_default_values = true, $cast_and_filter = true ) Get all query args. Prefill with defaults
user_can_view_post ( $post_id )

Защищенные методы

Метод Описание
_get_whitelisted_post_types ( ) : array Gets the whitelisted post types that JP should allow access to.
is_file_supported_for_sideloading ( string $file ) : boolean Checks that the mime type of the specified file is among those in a filterable list of mime types.

Описание методов

__construct() публичный Метод

public __construct ( $args )

_get_whitelisted_post_types() защищенный Метод

Gets the whitelisted post types that JP should allow access to.
protected _get_whitelisted_post_types ( ) : array
Результат array Whitelisted post types.

add_http_build_query_to_php_content_example() публичный Метод

allow_video_uploads() публичный Метод

public allow_video_uploads ( $mimes )

allows_cross_origin_requests() публичный Метод

allows_unauthorized_requests() публичный Метод

public allows_unauthorized_requests ( $origin, $complete_access_origins )

callback() абстрактный публичный Метод

Return endpoint response
abstract public callback ( $path = '' )

cast_and_filter() публичный Метод

public cast_and_filter ( $data, $documentation, $return_default_values = false, $for_output = false )

cast_and_filter_item() публичный Метод

Handles fallbacks for certain values of $type when $value is not that $type Currently, only handles fallback between string <-> array (two way), from string -> false (one way), and from object -> false (one way), and string -> object (one way) Handles "child types" - array:URL, object:category array:URL means an array of URLs object:category means a hash of categories Handles object typing - object>post means an object of type post
public cast_and_filter_item ( &$return, $type, $key, $value, $types = [], $for_output = false )

copy_hooks() публичный Метод

public copy_hooks ( $from_hook, $to_hook, $base_paths )

current_user_can_access_post_type() публичный Метод

Check whether a user can view or edit a post type
public current_user_can_access_post_type ( string $post_type, string $context = 'display' ) : boolean
$post_type string post type to check
$context string 'display' or 'edit'
Результат boolean

document() публичный Метод

Echoes HTML.
public document ( $show_description = true )

format_date() публичный Метод

Returns ISO 8601 formatted datetime: 2011-12-08T01:15:36-08:00
public format_date ( $date_gmt, $date = null ) : string
$date_gmt (string) GMT datetime string.
$date (string) Optional. Used to calculate the offset from GMT.
Результат string

format_taxonomy() публичный Метод

public format_taxonomy ( $taxonomy, $taxonomy_type, $context )

generate_doc_description() публичный Метод

Echoes HTML.
public generate_doc_description ( $item )

generate_documentation() публичный Метод

Echoes HTML.

get_author() публичный Метод

Returns author object.
public get_author ( $author, $show_email = false ) : (object)
$author user ID, user row, WP_User object, comment row, post row
$show_email output the author's email address?
Результат (object)

get_media_item() публичный Метод

public get_media_item ( $media_id )

get_media_item_v1_1() публичный Метод

public get_media_item_v1_1 ( $media_id )

get_platform() публичный Метод

public get_platform ( )

get_reflection() публичный Метод

public get_reflection ( $callback )

get_taxonomy() публичный Метод

public get_taxonomy ( $taxonomy_id, $taxonomy_type, $context )

handle_media_creation_v1_1() публичный Метод

public handle_media_creation_v1_1 ( $media_files, $media_urls, $media_attrs = [], $force_parent_id = false )

handle_media_sideload() публичный Метод

public handle_media_sideload ( $url, $parent_post_id, $type = 'any' )

input() публичный Метод

Get POST body data
public input ( $return_default_values = true, $cast_and_filter = true )

is_current_site_multi_user() публичный Метод

is_file_supported_for_sideloading() защищенный Метод

Checks that the mime type of the specified file is among those in a filterable list of mime types.
protected is_file_supported_for_sideloading ( string $file ) : boolean
$file string Path to file to get its mime type.
Результат boolean

is_post_type_allowed() публичный Метод

public is_post_type_allowed ( $post_type )

is_publicly_documentable() публичный Метод

Checks if the endpoint is publicly displayable

load_theme_functions() публичный Метод

Load the functions.php file for the current theme to get its post formats, CPTs, etc.

parse_date() публичный Метод

Parses a date string and returns the local and GMT representations of that date & time in 'YYYY-MM-DD HH:MM:SS' format without timezones or offsets. If the parsed datetime was not localized to a particular timezone or offset we will assume it was given in GMT relative to now and will convert it to local time using either the timezone set in the options table for the blog or the GMT offset.
public parse_date ( $date_string ) : array(
Результат array(

parse_types() публичный Метод

public parse_types ( $text )

query_args() публичный Метод

Get all query args. Prefill with defaults
public query_args ( $return_default_values = true, $cast_and_filter = true )

user_can_view_post() публичный Метод

public user_can_view_post ( $post_id )

Описание свойств

$allow_cross_origin_request публичное свойство

Set to true if the endpoint accepts all cross origin requests. You probably should not set this flag.
public $allow_cross_origin_request

$allow_jetpack_site_auth публичное свойство

Set to true if the endpoint should accept site based (not user based) authentication.
public $allow_jetpack_site_auth

$allow_unauthorized_request публичное свойство

Set to true if the endpoint can recieve unauthorized POST requests.
public $allow_unauthorized_request

$allowed_if_flagged публичное свойство

Is this endpoint still allowed if the site in question is flagged?
public $allowed_if_flagged

$allowed_if_red_flagged публичное свойство

Is this endpoint allowed if the site is red flagged?
public $allowed_if_red_flagged

$api публичное свойство

The API Object
public $api

$custom_fields_filtering публичное свойство

Set to true if the endpoint implements its own filtering instead of the standard fields query method
public $custom_fields_filtering

$description публичное свойство

One liner.
public $description

$example_request публичное свойство

Example request to make
public $example_request

$example_request_data публичное свойство

Example request data (for POST methods)
public $example_request_data

$example_response публичное свойство

Example response from $example_request
public $example_response

$group публичное свойство

Object Grouping For Documentation (Users, Posts, Comments)
public $group

$in_testing публичное свойство

Is this endpoint still in testing phase? If so, not available to the public.
public $in_testing

$max_version публичное свойство

Maximum version of the api for which to serve this endpoint
public $max_version

$method публичное свойство

HTTP Method
public $method

$min_version публичное свойство

Minimum version of the api for which to serve this endpoint
public $min_version

$pass_wpcom_user_details публичное свойство

public $pass_wpcom_user_details

$path публичное свойство

Path at which to serve this endpoint: sprintf() format.
public $path

$path_labels публичное свойство

Identifiers to fill sprintf() formatted $path
public $path_labels

$query публичное свойство

Accepted query parameters
public $query

$request_format публичное свойство

Request format
public $request_format

$response_format публичное свойство

Response format
public $response_format

$stat публичное свойство

Stats extra value to bump
public $stat

$version публичное свойство

Version of the API
public $version