PHP Класс Jetpack_Core_Json_Api_Endpoints, jetpack

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

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

Свойство Тип Описание
$stats_roles Roles that can access Stats once they're granted access.
$user_permissions_error_msg Generic error message when user is not allowed to perform an action.

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

Метод Описание
activate_plugins_permission_check ( ) : boolean Verify that user can view Jetpack admin page and can activate plugins.
build_connect_url ( ) : string | WP_Error Gets a new connect raw URL with fresh nonce.
cast_value ( mixed $value, array $definition ) : boolean | float | integer | string Perform a casting to the value specified in the option definition.
configure_modules_permission_check ( ) : boolean Verify that user can update Jetpack modules.
confirm_safe_mode ( ) : boolean Handles identity crisis mitigation, confirming safe mode for this site.
connect_url_permission_callback ( ) : boolean | WP_Error Verify that the user can get a connect/link URL
disconnect_site ( $data ) : boolean | WP_Error Disconnects Jetpack from the WordPress.com Servers
disconnect_site_permission_callback ( ) : boolean | WP_Error Verify that the user can disconnect the site.
dismiss_notice ( $data ) : array | wp-error Handles dismissing of Jetpack Notices
get_module_requested ( string $route = '/module/(?P<slug>[a-z\-]+)' ) : array Get the currently accessed route and return the module slug in it.
get_plugin ( WP_REST_Request $data ) : boolean | WP_Error Get data about the queried plugin. Currently it only returns whether the plugin is active or not.
get_plugin_update_count ( ) : mixed | WP_Error Get number of plugin updates available.
get_plugins ( ) : WP_REST_Response | WP_Error Get plugins data in site.
get_remote_value ( string $module, string $option ) : boolean Get a value not saved locally.
get_settings ( ) : object Get miscellaneous settings for this Jetpack installation, like Holiday Snow.
get_site_data ( ) : array Get site data, including for example, the site's current plan.
get_updateable_data_list ( string | array $selector = '' ) : array Returns a list of module options or general settings that can be updated.
get_updateable_parameters ( string $selector = '' ) : array Get the query parameters to update module options or general settings.
get_user_connection_data ( ) : object Get miscellaneous user data related to the connection. Similar data available in old "My Jetpack".
get_user_connection_data_permission_callback ( ) : boolean | WP_Error Verify that a user can get the data about the current user.
holiday_snow_option_name ( ) : string Returns the proper name for Jetpack Holiday Snow setting.
identity_crisis_mitigation_permission_check ( ) : boolean Verify that user can mitigate an identity crisis.
jetpack_connection_status ( ) : boolean Get connection status for this Jetpack site.
jumpstart_activate ( WP_REST_Request $data ) : boolean | WP_Error Activates a series of valid Jetpack modules and initializes some options.
jumpstart_deactivate ( WP_REST_Request $data ) : boolean | WP_Error Dismisses Jumpstart so user is not prompted to go through it again.
jumpstart_toggle ( WP_REST_Request $data ) : boolean | WP_Error Toggles activation or deactivation of the JumpStart
manage_modules_permission_check ( ) : boolean Verify that user can manage Jetpack modules.
migrate_stats_and_subscribers ( ) : boolean Handles identity crisis mitigation, migrating stats and subscribers from old url to this, new url.
prepare_modules_for_response ( string $modules = '', null | string $slug = null ) : array Adds extra information for modules.
prepare_options_for_response ( string $module = '' ) : array Remove 'validate_callback' item from options available for module.
register_endpoints ( ) Declare the Jetpack REST API endpoints.
reset_jetpack_options ( WP_REST_Request $data ) : boolean | WP_Error Reset Jetpack options
rest_authorization_required_code ( ) : integer Contextual HTTP error code for authorization failure.
route ( $path, $classname, $method, $constructor_arguments = NULL, $endpoint_arguments = NULL )
sanitize_stats_allowed_roles ( string | boolean $value ) : boolean If for some reason the roles allowed to see Stats are empty (for example, user tampering with checkboxes), return an array with only 'administrator' as the allowed role and save it for 'roles' option.
split_options ( array $separate_options, array $grouped_options, string $prefix = '' ) : array Splits module options saved as arrays like relatedposts or verification_services_codes into separate options to be returned in the response.
start_fresh_connection ( ) : boolean | WP_Error This IDC resolution will disconnect the site and re-connect to a completely new and separate shadow site than the original.
unlink_user ( $data ) : boolean | WP_Error Unlinks current user from the WordPress.com Servers.
unlink_user_permission_callback ( ) : boolean | WP_Error Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked.
update_setting ( WP_REST_Request $data ) : object Update a single miscellaneous setting for this Jetpack installation, like Holiday Snow.
update_settings_permission_check ( ) : boolean Verify that user can update Jetpack general settings.
validate_alphanum ( string $value = '', WP_REST_Request $request, string $param ) : boolean Validates that the parameter is an alphanumeric or empty string (to be able to clear the field).
validate_boolean ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean Validates that the parameter is either a pure boolean or a numeric string that can be mapped to a boolean.
validate_custom_service ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean Validates that the parameter has enough information to build a custom sharing button.
validate_custom_service_id ( string $value = '', WP_REST_Request $request, string $param ) : boolean Validates that the parameter is a custom sharing service ID like 'custom-1461976264'.
validate_list_item ( string $value = '', WP_REST_Request $request, string $param ) : boolean Validates that the parameter belongs to a list of admitted values.
validate_module_list ( string $value = '', WP_REST_Request $request, string $param ) : boolean Validates that the parameter belongs to a list of admitted values.
validate_posint ( integer $value, WP_REST_Request $request, string $param ) : boolean Validates that the parameter is a positive integer.
validate_services ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean Validates that the parameter is among the views where the Sharing can be displayed.
validate_sharing_show ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean Validates that the parameter is among the views where the Sharing can be displayed.
validate_stats_roles ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean Validates that the parameter is among the roles allowed for Stats.
validate_string ( string $value = '', WP_REST_Request $request, string $param ) : boolean Validates that the parameter is a string.
validate_twitter_username ( string $value = '', WP_REST_Request $request, string $param ) : boolean Validates that the parameter is a Twitter username or empty string (to be able to clear the field).
view_admin_page_permission_check ( ) : boolean Verify that user can view Jetpack admin page.

Приватные методы

Метод Описание
core_get_plugins ( ) : array Returns a list of all plugins in the site.
core_is_plugin_active ( $plugin ) : boolean Checks if the queried plugin is active.

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

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

Verify that user can view Jetpack admin page and can activate plugins.
С версии: 4.3.0
public static activate_plugins_permission_check ( ) : boolean
Результат boolean Whether user has the capability 'jetpack_admin_page' and 'activate_plugins'.

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

Gets a new connect raw URL with fresh nonce.
С версии: 4.3.0
public static build_connect_url ( ) : string | WP_Error
Результат string | WP_Error A raw URL if the connection URL could be built; error message otherwise.

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

Perform a casting to the value specified in the option definition.
С версии: 4.3.0
public static cast_value ( mixed $value, array $definition ) : boolean | float | integer | string
$value mixed Value to cast to the proper type.
$definition array Type to cast the value to.
Результат boolean | float | integer | string

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

Verify that user can update Jetpack modules.
С версии: 4.3.0
public static configure_modules_permission_check ( ) : boolean
Результат boolean Whether user has the capability 'jetpack_configure_modules'.

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

Handles identity crisis mitigation, confirming safe mode for this site.
С версии: 4.4.0
public static confirm_safe_mode ( ) : boolean
Результат boolean | WP_Error True if option is properly set.

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

Verify that the user can get a connect/link URL
С версии: 4.3.0
public static connect_url_permission_callback ( ) : boolean | WP_Error
Результат boolean | WP_Error True if user is able to disconnect the site.

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

Disconnects Jetpack from the WordPress.com Servers
С версии: 4.3.0
public static disconnect_site ( $data ) : boolean | WP_Error
Результат boolean | WP_Error True if Jetpack successfully disconnected.

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

Verify that the user can disconnect the site.
С версии: 4.3.0
public static disconnect_site_permission_callback ( ) : boolean | WP_Error
Результат boolean | WP_Error True if user is able to disconnect the site.

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

Handles dismissing of Jetpack Notices
С версии: 4.3.0
public static dismiss_notice ( $data ) : array | wp-error
Результат array | wp-error

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

Get the currently accessed route and return the module slug in it.
С версии: 4.3.0
public static get_module_requested ( string $route = '/module/(?P<slug>[a-z\-]+)' ) : array
$route string Regular expression for the endpoint with the module slug to return.
Результат array

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

Get data about the queried plugin. Currently it only returns whether the plugin is active or not.
С версии: 4.2.0
public static get_plugin ( WP_REST_Request $data ) : boolean | WP_Error
$data WP_REST_Request { Array of parameters received by request. @type string $slug Plugin slug with the syntax 'plugin-directory/plugin-main-file.php'. }
Результат boolean | WP_Error True if module was activated. Otherwise, a WP_Error instance with the corresponding error.

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

Get number of plugin updates available.
С версии: 4.3.0
public static get_plugin_update_count ( ) : mixed | WP_Error
Результат mixed | WP_Error Number of plugin updates available. Otherwise, a WP_Error instance with the corresponding error.

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

Get plugins data in site.
С версии: 4.2.0
public static get_plugins ( ) : WP_REST_Response | WP_Error
Результат WP_REST_Response | WP_Error List of plugins in the site. Otherwise, a WP_Error instance with the corresponding error.

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

Get a value not saved locally.
С версии: 4.3.0
public static get_remote_value ( string $module, string $option ) : boolean
$module string Module slug.
$option string Option name.
Результат boolean Whether user is receiving notifications or not.

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

Get miscellaneous settings for this Jetpack installation, like Holiday Snow.
С версии: 4.3.0
public static get_settings ( ) : object
Результат object $response { Array of miscellaneous settings. @type bool $holiday-snow Did Jack steal Christmas? }

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

Get site data, including for example, the site's current plan.
С версии: 4.3.0
public static get_site_data ( ) : array
Результат array Array of Jetpack modules.

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

Returns a list of module options or general settings that can be updated.
С версии: 4.3.0
С версии: 4.4.0 Accepts 'any' as a parameter which will make it return the entire list.
public static get_updateable_data_list ( string | array $selector = '' ) : array
$selector string | array Module slug, 'any', or an array of parameters. If empty, it's assumed we're updating a module and we'll try to get its slug. If 'any' the full list is returned. If it's an array of parameters, includes the elements by matching keys.
Результат array

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

Get the query parameters to update module options or general settings.
С версии: 4.3.0
С версии: 4.4.0 Accepts a $selector parameter.
public static get_updateable_parameters ( string $selector = '' ) : array
$selector string Selects a set of options to update, Can be empty, a module slug or 'any'.
Результат array

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

Information about the master/primary user. Information about the current user.
С версии: 4.3.0
public static get_user_connection_data ( ) : object
Результат object

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

Only those who can connect.
С версии: 4.3.0
public static get_user_connection_data_permission_callback ( ) : boolean | WP_Error
Результат boolean | WP_Error True if user is able to unlink.

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

When the REST route starts, the holiday-snow.php file where jetpack_holiday_snow_option_name() function is defined is not loaded, so where using this to replicate it and have the same functionality.
С версии: 4.4.0
public static holiday_snow_option_name ( ) : string
Результат string

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

Verify that user can mitigate an identity crisis.
С версии: 4.4.0
public static identity_crisis_mitigation_permission_check ( ) : boolean
Результат boolean Whether user has capability 'jetpack_disconnect'.

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

Get connection status for this Jetpack site.
С версии: 4.3.0
public static jetpack_connection_status ( ) : boolean
Результат boolean True if site is connected

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

Activates a series of valid Jetpack modules and initializes some options.
С версии: 4.3.0
public static jumpstart_activate ( WP_REST_Request $data ) : boolean | WP_Error
$data WP_REST_Request { Array of parameters received by request. }
Результат boolean | WP_Error True if Jumpstart succeeded. Otherwise, a WP_Error instance with the corresponding error.

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

Dismisses Jumpstart so user is not prompted to go through it again.
С версии: 4.3.0
public static jumpstart_deactivate ( WP_REST_Request $data ) : boolean | WP_Error
$data WP_REST_Request { Array of parameters received by request. }
Результат boolean | WP_Error True if Jumpstart was disabled or was nothing to dismiss. Otherwise, a WP_Error instance with a message.

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

Toggles activation or deactivation of the JumpStart
С версии: 4.3.0
public static jumpstart_toggle ( WP_REST_Request $data ) : boolean | WP_Error
$data WP_REST_Request { Array of parameters received by request. }
Результат boolean | WP_Error True if toggling Jumpstart succeeded. Otherwise, a WP_Error instance with the corresponding error.

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

Verify that user can manage Jetpack modules.
С версии: 4.3.0
public static manage_modules_permission_check ( ) : boolean
Результат boolean Whether user has the capability 'jetpack_manage_modules'.

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

Handles identity crisis mitigation, migrating stats and subscribers from old url to this, new url.
С версии: 4.4.0
public static migrate_stats_and_subscribers ( ) : boolean
Результат boolean | WP_Error True if option is properly set.

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

Adds extra information for modules.
С версии: 4.3.0
public static prepare_modules_for_response ( string $modules = '', null | string $slug = null ) : array
$modules string Can be a single module or a list of modules.
$slug null | string Slug of the module in the first parameter.
Результат array

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

Fetch current option value and add to array of module options. Prepare values of module options that need special handling, like those saved in wpcom.
С версии: 4.3.0
public static prepare_options_for_response ( string $module = '' ) : array
$module string Module slug.
Результат array

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

Declare the Jetpack REST API endpoints.
С версии: 4.3.0
public static register_endpoints ( )

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

Reset Jetpack options
С версии: 4.3.0
public static reset_jetpack_options ( WP_REST_Request $data ) : boolean | WP_Error
$data WP_REST_Request { Array of parameters received by request. @type string $options Available options to reset are options|modules }
Результат boolean | WP_Error True if options were reset. Otherwise, a WP_Error instance with the corresponding error.

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

Taken from rest_authorization_required_code() in WP-API plugin until is added to core.
См. также: https://github.com/WP-API/WP-API/commit/7ba0ae6fe4f605d5ffe4ee85b1cd5f9fb46900a6
С версии: 4.3.0
public static rest_authorization_required_code ( ) : integer
Результат integer

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

public static route ( $path, $classname, $method, $constructor_arguments = NULL, $endpoint_arguments = NULL )

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

If for some reason the roles allowed to see Stats are empty (for example, user tampering with checkboxes), return an array with only 'administrator' as the allowed role and save it for 'roles' option.
С версии: 4.3.0
public static sanitize_stats_allowed_roles ( string | boolean $value ) : boolean
$value string | boolean Value to check.
Результат boolean

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

Splits module options saved as arrays like relatedposts or verification_services_codes into separate options to be returned in the response.
С версии: 4.3.0
public static split_options ( array $separate_options, array $grouped_options, string $prefix = '' ) : array
$separate_options array Array of options admitted by the module.
$grouped_options array Option saved as array to be splitted.
$prefix string Optional prefix for the separate option keys.
Результат array

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

It will first will disconnect the site without phoning home as to not disturb the production site. It then builds a fresh connection URL and sends it back along with the response.
С версии: 4.4.0
public static start_fresh_connection ( ) : boolean | WP_Error
Результат boolean | WP_Error

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

Update a single miscellaneous setting for this Jetpack installation, like Holiday Snow.
С версии: 4.3.0
public static update_setting ( WP_REST_Request $data ) : object
$data WP_REST_Request
Результат object Jetpack miscellaneous settings.

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

Verify that user can update Jetpack general settings.
С версии: 4.3.0
public static update_settings_permission_check ( ) : boolean
Результат boolean Whether user has the capability 'update_settings_permission_check'.

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

Validates that the parameter is an alphanumeric or empty string (to be able to clear the field).
С версии: 4.3.0
public static validate_alphanum ( string $value = '', WP_REST_Request $request, string $param ) : boolean
$value string Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is either a pure boolean or a numeric string that can be mapped to a boolean.
С версии: 4.3.0
public static validate_boolean ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean
$value string | boolean Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter has enough information to build a custom sharing button.
С версии: 4.3.0
public static validate_custom_service ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean
$value string | boolean Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is a custom sharing service ID like 'custom-1461976264'.
С версии: 4.3.0
public static validate_custom_service_id ( string $value = '', WP_REST_Request $request, string $param ) : boolean
$value string Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter belongs to a list of admitted values.
С версии: 4.3.0
public static validate_list_item ( string $value = '', WP_REST_Request $request, string $param ) : boolean
$value string Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter belongs to a list of admitted values.
С версии: 4.3.0
public static validate_module_list ( string $value = '', WP_REST_Request $request, string $param ) : boolean
$value string Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is a positive integer.
С версии: 4.3.0
public static validate_posint ( integer $value, WP_REST_Request $request, string $param ) : boolean
$value integer Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is among the views where the Sharing can be displayed.
С версии: 4.3.0
public static validate_services ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean
$value string | boolean { Value to check received by request. @type array $visible List of slug of services to share to that are displayed directly in the page. @type array $hidden List of slug of services to share to that are concealed in a folding menu. }
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is among the views where the Sharing can be displayed.
С версии: 4.3.0
public static validate_sharing_show ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean
$value string | boolean Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is among the roles allowed for Stats.
С версии: 4.3.0
public static validate_stats_roles ( string | boolean $value, WP_REST_Request $request, string $param ) : boolean
$value string | boolean Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is a string.
С версии: 4.3.0
public static validate_string ( string $value = '', WP_REST_Request $request, string $param ) : boolean
$value string Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Validates that the parameter is a Twitter username or empty string (to be able to clear the field).
С версии: 4.3.0
public static validate_twitter_username ( string $value = '', WP_REST_Request $request, string $param ) : boolean
$value string Value to check.
$request WP_REST_Request
$param string Name of the parameter passed to endpoint holding $value.
Результат boolean

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

Verify that user can view Jetpack admin page.
С версии: 4.3.0
public static view_admin_page_permission_check ( ) : boolean
Результат boolean Whether user has the capability 'jetpack_admin_page'.

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

$stats_roles публичное статическое свойство

Roles that can access Stats once they're granted access.
public static $stats_roles

$user_permissions_error_msg публичное статическое свойство

Generic error message when user is not allowed to perform an action.
public static $user_permissions_error_msg