Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php class WP_REST_Terms_Controller extends WP_REST_Controller { protected $taxonomy; pr..
Decoded Output download
<?php
class WP_REST_Terms_Controller extends WP_REST_Controller { protected $taxonomy; protected $meta; protected $sort_column; protected $total_terms; protected $allow_batch = array("v1" => true); public function __construct($taxonomy) { $this->taxonomy = $taxonomy; $tax_obj = get_taxonomy($taxonomy); $this->rest_base = !empty($tax_obj->rest_base) ? $tax_obj->rest_base : $tax_obj->name; $this->namespace = !empty($tax_obj->rest_namespace) ? $tax_obj->rest_namespace : "wp/v2"; $this->meta = new WP_REST_Term_Meta_Fields($taxonomy); } public function register_routes() { register_rest_route($this->namespace, "/" . $this->rest_base, array(array("methods" => WP_REST_Server::READABLE, "callback" => array($this, "get_items"), "permission_callback" => array($this, "get_items_permissions_check"), "args" => $this->get_collection_params()), array("methods" => WP_REST_Server::CREATABLE, "callback" => array($this, "create_item"), "permission_callback" => array($this, "create_item_permissions_check"), "args" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE)), "allow_batch" => $this->allow_batch, "schema" => array($this, "get_public_item_schema"))); register_rest_route($this->namespace, "/" . $this->rest_base . "/(?P<id>[\d]+)", array("args" => array("id" => array("description" => __("Unique identifier for the term."), "type" => "integer")), array("methods" => WP_REST_Server::READABLE, "callback" => array($this, "get_item"), "permission_callback" => array($this, "get_item_permissions_check"), "args" => array("context" => $this->get_context_param(array("default" => "view")))), array("methods" => WP_REST_Server::EDITABLE, "callback" => array($this, "update_item"), "permission_callback" => array($this, "update_item_permissions_check"), "args" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE)), array("methods" => WP_REST_Server::DELETABLE, "callback" => array($this, "delete_item"), "permission_callback" => array($this, "delete_item_permissions_check"), "args" => array("force" => array("type" => "boolean", "default" => false, "description" => __("Required to be true, as terms do not support trashing.")))), "allow_batch" => $this->allow_batch, "schema" => array($this, "get_public_item_schema"))); } public function check_read_terms_permission_for_post($post, $request) { if (!is_object_in_taxonomy($post->post_type, $this->taxonomy)) { return false; } if (is_post_publicly_viewable($post)) { return true; } if (current_user_can("read_post", $post->ID)) { return true; } return false; } public function get_items_permissions_check($request) { $tax_obj = get_taxonomy($this->taxonomy); if (!$tax_obj || !$this->check_is_taxonomy_allowed($this->taxonomy)) { return false; } if ("edit" === $request["context"] && !current_user_can($tax_obj->cap->edit_terms)) { return new WP_Error("rest_forbidden_context", __("Sorry, you are not allowed to edit terms in this taxonomy."), array("status" => rest_authorization_required_code())); } if (!empty($request["post"])) { $post = get_post($request["post"]); if (!$post) { return new WP_Error("rest_post_invalid_id", __("Invalid post ID."), array("status" => 400)); } if (!$this->check_read_terms_permission_for_post($post, $request)) { return new WP_Error("rest_forbidden_context", __("Sorry, you are not allowed to view terms for this post."), array("status" => rest_authorization_required_code())); } } return true; } public function get_items($request) { $registered = $this->get_collection_params(); $parameter_mappings = array("exclude" => "exclude", "include" => "include", "order" => "order", "orderby" => "orderby", "post" => "post", "hide_empty" => "hide_empty", "per_page" => "number", "search" => "search", "slug" => "slug"); $prepared_args = array("taxonomy" => $this->taxonomy); foreach ($parameter_mappings as $api_param => $wp_param) { if (isset($registered[$api_param], $request[$api_param])) { $prepared_args[$wp_param] = $request[$api_param]; } } if (isset($prepared_args["orderby"]) && isset($request["orderby"])) { $orderby_mappings = array("include_slugs" => "slug__in"); if (isset($orderby_mappings[$request["orderby"]])) { $prepared_args["orderby"] = $orderby_mappings[$request["orderby"]]; } } if (isset($registered["offset"]) && !empty($request["offset"])) { $prepared_args["offset"] = $request["offset"]; } else { $prepared_args["offset"] = ($request["page"] - 1) * $prepared_args["number"]; } $taxonomy_obj = get_taxonomy($this->taxonomy); if ($taxonomy_obj->hierarchical && isset($registered["parent"], $request["parent"])) { if (0 === $request["parent"]) { $prepared_args["parent"] = 0; } else { if ($request["parent"]) { $prepared_args["parent"] = $request["parent"]; } } } $prepared_args = apply_filters("rest_{$this->taxonomy}_query", $prepared_args, $request); if (!empty($prepared_args["post"])) { $query_result = wp_get_object_terms($prepared_args["post"], $this->taxonomy, $prepared_args); $prepared_args["object_ids"] = $prepared_args["post"]; } else { $query_result = get_terms($prepared_args); } $count_args = $prepared_args; unset($count_args["number"], $count_args["offset"]); $total_terms = wp_count_terms($count_args); if (!$total_terms) { $total_terms = 0; } $response = array(); foreach ($query_result as $term) { $data = $this->prepare_item_for_response($term, $request); $response[] = $this->prepare_response_for_collection($data); } $response = rest_ensure_response($response); $per_page = (int) $prepared_args["number"]; $page = (int) ceil((int) $prepared_args["offset"] / $per_page + 1); $response->header("X-WP-Total", (int) $total_terms); $max_pages = (int) ceil($total_terms / $per_page); $response->header("X-WP-TotalPages", $max_pages); $request_params = $request->get_query_params(); $collection_url = rest_url(rest_get_route_for_taxonomy_items($this->taxonomy)); $base = add_query_arg(urlencode_deep($request_params), $collection_url); if ($page > 1) { $prev_page = $page - 1; if ($prev_page > $max_pages) { $prev_page = $max_pages; } $prev_link = add_query_arg("page", $prev_page, $base); $response->link_header("prev", $prev_link); } if ($max_pages > $page) { $next_page = $page + 1; $next_link = add_query_arg("page", $next_page, $base); $response->link_header("next", $next_link); } return $response; } protected function get_term($id) { $error = new WP_Error("rest_term_invalid", __("Term does not exist."), array("status" => 404)); if (!$this->check_is_taxonomy_allowed($this->taxonomy)) { return $error; } if ((int) $id <= 0) { return $error; } $term = get_term((int) $id, $this->taxonomy); if (empty($term) || $term->taxonomy !== $this->taxonomy) { return $error; } return $term; } public function get_item_permissions_check($request) { $term = $this->get_term($request["id"]); if (is_wp_error($term)) { return $term; } if ("edit" === $request["context"] && !current_user_can("edit_term", $term->term_id)) { return new WP_Error("rest_forbidden_context", __("Sorry, you are not allowed to edit this term."), array("status" => rest_authorization_required_code())); } return true; } public function get_item($request) { $term = $this->get_term($request["id"]); if (is_wp_error($term)) { return $term; } $response = $this->prepare_item_for_response($term, $request); return rest_ensure_response($response); } public function create_item_permissions_check($request) { if (!$this->check_is_taxonomy_allowed($this->taxonomy)) { return false; } $taxonomy_obj = get_taxonomy($this->taxonomy); if (is_taxonomy_hierarchical($this->taxonomy) && !current_user_can($taxonomy_obj->cap->edit_terms) || !is_taxonomy_hierarchical($this->taxonomy) && !current_user_can($taxonomy_obj->cap->assign_terms)) { return new WP_Error("rest_cannot_create", __("Sorry, you are not allowed to create terms in this taxonomy."), array("status" => rest_authorization_required_code())); } return true; } public function create_item($request) { if (isset($request["parent"])) { if (!is_taxonomy_hierarchical($this->taxonomy)) { return new WP_Error("rest_taxonomy_not_hierarchical", __("Cannot set parent term, taxonomy is not hierarchical."), array("status" => 400)); } $parent = get_term((int) $request["parent"], $this->taxonomy); if (!$parent) { return new WP_Error("rest_term_invalid", __("Parent term does not exist."), array("status" => 400)); } } $prepared_term = $this->prepare_item_for_database($request); $term = wp_insert_term(wp_slash($prepared_term->name), $this->taxonomy, wp_slash((array) $prepared_term)); if (is_wp_error($term)) { $term_id = $term->get_error_data("term_exists"); if ($term_id) { $existing_term = get_term($term_id, $this->taxonomy); $term->add_data($existing_term->term_id, "term_exists"); $term->add_data(array("status" => 400, "term_id" => $term_id)); } return $term; } $term = get_term($term["term_id"], $this->taxonomy); do_action("rest_insert_{$this->taxonomy}", $term, $request, true); $schema = $this->get_item_schema(); if (!empty($schema["properties"]["meta"]) && isset($request["meta"])) { $meta_update = $this->meta->update_value($request["meta"], $term->term_id); if (is_wp_error($meta_update)) { return $meta_update; } } $fields_update = $this->update_additional_fields_for_object($term, $request); if (is_wp_error($fields_update)) { return $fields_update; } $request->set_param("context", "edit"); do_action("rest_after_insert_{$this->taxonomy}", $term, $request, true); $response = $this->prepare_item_for_response($term, $request); $response = rest_ensure_response($response); $response->set_status(201); $response->header("Location", rest_url($this->namespace . "/" . $this->rest_base . "/" . $term->term_id)); return $response; } public function update_item_permissions_check($request) { $term = $this->get_term($request["id"]); if (is_wp_error($term)) { return $term; } if (!current_user_can("edit_term", $term->term_id)) { return new WP_Error("rest_cannot_update", __("Sorry, you are not allowed to edit this term."), array("status" => rest_authorization_required_code())); } return true; } public function update_item($request) { $term = $this->get_term($request["id"]); if (is_wp_error($term)) { return $term; } if (isset($request["parent"])) { if (!is_taxonomy_hierarchical($this->taxonomy)) { return new WP_Error("rest_taxonomy_not_hierarchical", __("Cannot set parent term, taxonomy is not hierarchical."), array("status" => 400)); } $parent = get_term((int) $request["parent"], $this->taxonomy); if (!$parent) { return new WP_Error("rest_term_invalid", __("Parent term does not exist."), array("status" => 400)); } } $prepared_term = $this->prepare_item_for_database($request); if (!empty($prepared_term)) { $update = wp_update_term($term->term_id, $term->taxonomy, wp_slash((array) $prepared_term)); if (is_wp_error($update)) { return $update; } } $term = get_term($term->term_id, $this->taxonomy); do_action("rest_insert_{$this->taxonomy}", $term, $request, false); $schema = $this->get_item_schema(); if (!empty($schema["properties"]["meta"]) && isset($request["meta"])) { $meta_update = $this->meta->update_value($request["meta"], $term->term_id); if (is_wp_error($meta_update)) { return $meta_update; } } $fields_update = $this->update_additional_fields_for_object($term, $request); if (is_wp_error($fields_update)) { return $fields_update; } $request->set_param("context", "edit"); do_action("rest_after_insert_{$this->taxonomy}", $term, $request, false); $response = $this->prepare_item_for_response($term, $request); return rest_ensure_response($response); } public function delete_item_permissions_check($request) { $term = $this->get_term($request["id"]); if (is_wp_error($term)) { return $term; } if (!current_user_can("delete_term", $term->term_id)) { return new WP_Error("rest_cannot_delete", __("Sorry, you are not allowed to delete this term."), array("status" => rest_authorization_required_code())); } return true; } public function delete_item($request) { $term = $this->get_term($request["id"]); if (is_wp_error($term)) { return $term; } $force = isset($request["force"]) ? (bool) $request["force"] : false; if (!$force) { return new WP_Error("rest_trash_not_supported", sprintf(__("Terms do not support trashing. Set '%s' to delete."), "force=true"), array("status" => 501)); } $request->set_param("context", "view"); $previous = $this->prepare_item_for_response($term, $request); $retval = wp_delete_term($term->term_id, $term->taxonomy); if (!$retval) { return new WP_Error("rest_cannot_delete", __("The term cannot be deleted."), array("status" => 500)); } $response = new WP_REST_Response(); $response->set_data(array("deleted" => true, "previous" => $previous->get_data())); do_action("rest_delete_{$this->taxonomy}", $term, $response, $request); return $response; } public function prepare_item_for_database($request) { $prepared_term = new stdClass(); $schema = $this->get_item_schema(); if (isset($request["name"]) && !empty($schema["properties"]["name"])) { $prepared_term->name = $request["name"]; } if (isset($request["slug"]) && !empty($schema["properties"]["slug"])) { $prepared_term->slug = $request["slug"]; } if (isset($request["taxonomy"]) && !empty($schema["properties"]["taxonomy"])) { $prepared_term->taxonomy = $request["taxonomy"]; } if (isset($request["description"]) && !empty($schema["properties"]["description"])) { $prepared_term->description = $request["description"]; } if (isset($request["parent"]) && !empty($schema["properties"]["parent"])) { $parent_term_id = 0; $requested_parent = (int) $request["parent"]; if ($requested_parent) { $parent_term = get_term($requested_parent, $this->taxonomy); if ($parent_term instanceof WP_Term) { $parent_term_id = $parent_term->term_id; } } $prepared_term->parent = $parent_term_id; } return apply_filters("rest_pre_insert_{$this->taxonomy}", $prepared_term, $request); } public function prepare_item_for_response($item, $request) { $fields = $this->get_fields_for_response($request); $data = array(); if (in_array("id", $fields, true)) { $data["id"] = (int) $item->term_id; } if (in_array("count", $fields, true)) { $data["count"] = (int) $item->count; } if (in_array("description", $fields, true)) { $data["description"] = $item->description; } if (in_array("link", $fields, true)) { $data["link"] = get_term_link($item); } if (in_array("name", $fields, true)) { $data["name"] = $item->name; } if (in_array("slug", $fields, true)) { $data["slug"] = $item->slug; } if (in_array("taxonomy", $fields, true)) { $data["taxonomy"] = $item->taxonomy; } if (in_array("parent", $fields, true)) { $data["parent"] = (int) $item->parent; } if (in_array("meta", $fields, true)) { $data["meta"] = $this->meta->get_value($item->term_id, $request); } $context = !empty($request["context"]) ? $request["context"] : "view"; $data = $this->add_additional_fields_to_object($data, $request); $data = $this->filter_response_by_context($data, $context); $response = rest_ensure_response($data); if (rest_is_field_included("_links", $fields) || rest_is_field_included("_embedded", $fields)) { $response->add_links($this->prepare_links($item)); } return apply_filters("rest_prepare_{$this->taxonomy}", $response, $item, $request); } protected function prepare_links($term) { $links = array("self" => array("href" => rest_url(rest_get_route_for_term($term))), "collection" => array("href" => rest_url(rest_get_route_for_taxonomy_items($this->taxonomy))), "about" => array("href" => rest_url(sprintf("wp/v2/taxonomies/%s", $this->taxonomy)))); if ($term->parent) { $parent_term = get_term((int) $term->parent, $term->taxonomy); if ($parent_term) { $links["up"] = array("href" => rest_url(rest_get_route_for_term($parent_term)), "embeddable" => true); } } $taxonomy_obj = get_taxonomy($term->taxonomy); if (empty($taxonomy_obj->object_type)) { return $links; } $post_type_links = array(); foreach ($taxonomy_obj->object_type as $type) { $rest_path = rest_get_route_for_post_type_items($type); if (empty($rest_path)) { continue; } $post_type_links[] = array("href" => add_query_arg($this->rest_base, $term->term_id, rest_url($rest_path))); } if (!empty($post_type_links)) { $links["https://api.w.org/post_type"] = $post_type_links; } return $links; } public function get_item_schema() { if ($this->schema) { return $this->add_additional_fields_schema($this->schema); } $schema = array("$schema" => "http://json-schema.org/draft-04/schema#", "title" => "post_tag" === $this->taxonomy ? "tag" : $this->taxonomy, "type" => "object", "properties" => array("id" => array("description" => __("Unique identifier for the term."), "type" => "integer", "context" => array("view", "embed", "edit"), "readonly" => true), "count" => array("description" => __("Number of published posts for the term."), "type" => "integer", "context" => array("view", "edit"), "readonly" => true), "description" => array("description" => __("HTML description of the term."), "type" => "string", "context" => array("view", "edit")), "link" => array("description" => __("URL of the term."), "type" => "string", "format" => "uri", "context" => array("view", "embed", "edit"), "readonly" => true), "name" => array("description" => __("HTML title for the term."), "type" => "string", "context" => array("view", "embed", "edit"), "arg_options" => array("sanitize_callback" => "sanitize_text_field"), "required" => true), "slug" => array("description" => __("An alphanumeric identifier for the term unique to its type."), "type" => "string", "context" => array("view", "embed", "edit"), "arg_options" => array("sanitize_callback" => array($this, "sanitize_slug"))), "taxonomy" => array("description" => __("Type attribution for the term."), "type" => "string", "enum" => array($this->taxonomy), "context" => array("view", "embed", "edit"), "readonly" => true))); $taxonomy = get_taxonomy($this->taxonomy); if ($taxonomy->hierarchical) { $schema["properties"]["parent"] = array("description" => __("The parent term ID."), "type" => "integer", "context" => array("view", "edit")); } $schema["properties"]["meta"] = $this->meta->get_field_schema(); $this->schema = $schema; return $this->add_additional_fields_schema($this->schema); } public function get_collection_params() { $query_params = parent::get_collection_params(); $taxonomy = get_taxonomy($this->taxonomy); $query_params["context"]["default"] = "view"; $query_params["exclude"] = array("description" => __("Ensure result set excludes specific IDs."), "type" => "array", "items" => array("type" => "integer"), "default" => array()); $query_params["include"] = array("description" => __("Limit result set to specific IDs."), "type" => "array", "items" => array("type" => "integer"), "default" => array()); if (!$taxonomy->hierarchical) { $query_params["offset"] = array("description" => __("Offset the result set by a specific number of items."), "type" => "integer"); } $query_params["order"] = array("description" => __("Order sort attribute ascending or descending."), "type" => "string", "default" => "asc", "enum" => array("asc", "desc")); $query_params["orderby"] = array("description" => __("Sort collection by term attribute."), "type" => "string", "default" => "name", "enum" => array("id", "include", "name", "slug", "include_slugs", "term_group", "description", "count")); $query_params["hide_empty"] = array("description" => __("Whether to hide terms not assigned to any posts."), "type" => "boolean", "default" => false); if ($taxonomy->hierarchical) { $query_params["parent"] = array("description" => __("Limit result set to terms assigned to a specific parent."), "type" => "integer"); } $query_params["post"] = array("description" => __("Limit result set to terms assigned to a specific post."), "type" => "integer", "default" => null); $query_params["slug"] = array("description" => __("Limit result set to terms with one or more specific slugs."), "type" => "array", "items" => array("type" => "string")); return apply_filters("rest_{$this->taxonomy}_collection_params", $query_params, $taxonomy); } protected function check_is_taxonomy_allowed($taxonomy) { $taxonomy_obj = get_taxonomy($taxonomy); if ($taxonomy_obj && !empty($taxonomy_obj->show_in_rest)) { return true; } return false; } } ?>
Did this file decode correctly?
Original Code
<?php
class WP_REST_Terms_Controller extends WP_REST_Controller { protected $taxonomy; protected $meta; protected $sort_column; protected $total_terms; protected $allow_batch = array("\166\x31" => true); public function __construct($taxonomy) { $this->taxonomy = $taxonomy; $tax_obj = get_taxonomy($taxonomy); $this->rest_base = !empty($tax_obj->rest_base) ? $tax_obj->rest_base : $tax_obj->name; $this->namespace = !empty($tax_obj->rest_namespace) ? $tax_obj->rest_namespace : "\167\x70\57\x76\62"; $this->meta = new WP_REST_Term_Meta_Fields($taxonomy); } public function register_routes() { register_rest_route($this->namespace, "\x2f" . $this->rest_base, array(array("\155\145\164\x68\x6f\144\163" => WP_REST_Server::READABLE, "\x63\x61\x6c\154\142\x61\x63\x6b" => array($this, "\x67\x65\164\x5f\151\164\145\155\x73"), "\160\x65\162\155\151\163\x73\x69\x6f\156\137\x63\141\154\154\142\x61\x63\x6b" => array($this, "\x67\145\x74\137\x69\x74\145\x6d\x73\x5f\x70\x65\162\155\x69\x73\x73\151\157\156\163\x5f\143\x68\145\143\x6b"), "\141\162\x67\x73" => $this->get_collection_params()), array("\x6d\145\164\150\x6f\144\x73" => WP_REST_Server::CREATABLE, "\x63\141\x6c\154\142\x61\143\x6b" => array($this, "\143\x72\x65\x61\x74\x65\137\x69\164\145\x6d"), "\160\x65\x72\155\x69\x73\x73\151\x6f\x6e\137\x63\141\154\x6c\x62\x61\x63\153" => array($this, "\143\162\145\x61\x74\145\x5f\151\x74\145\155\x5f\160\145\x72\x6d\151\x73\163\x69\x6f\156\163\137\143\150\145\x63\153"), "\141\162\147\163" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE)), "\x61\x6c\x6c\157\x77\x5f\142\x61\164\x63\x68" => $this->allow_batch, "\163\143\x68\145\x6d\141" => array($this, "\147\145\x74\x5f\x70\165\x62\154\151\x63\x5f\x69\164\145\155\137\163\x63\150\x65\155\141"))); register_rest_route($this->namespace, "\x2f" . $this->rest_base . "\x2f\x28\77\120\74\x69\144\76\133\134\x64\135\x2b\51", array("\141\162\147\163" => array("\x69\x64" => array("\x64\145\x73\x63\x72\151\160\164\x69\x6f\156" => __("\x55\x6e\x69\x71\x75\145\x20\151\144\145\156\x74\151\146\151\145\x72\x20\146\x6f\162\40\x74\150\145\40\164\x65\x72\155\56"), "\164\x79\160\145" => "\151\x6e\x74\x65\x67\x65\x72")), array("\x6d\x65\164\150\x6f\144\x73" => WP_REST_Server::READABLE, "\x63\141\x6c\x6c\x62\x61\143\x6b" => array($this, "\x67\145\164\137\x69\164\x65\155"), "\160\x65\x72\155\x69\163\x73\151\157\x6e\x5f\143\141\x6c\x6c\x62\x61\x63\x6b" => array($this, "\x67\145\x74\x5f\151\164\x65\155\137\x70\x65\x72\155\151\163\163\x69\x6f\156\x73\x5f\x63\x68\x65\143\x6b"), "\x61\162\x67\x73" => array("\143\157\156\x74\x65\170\x74" => $this->get_context_param(array("\x64\145\146\x61\x75\x6c\164" => "\x76\151\145\x77")))), array("\x6d\145\x74\150\157\x64\163" => WP_REST_Server::EDITABLE, "\x63\x61\x6c\x6c\142\x61\143\153" => array($this, "\x75\160\x64\141\x74\145\137\x69\164\x65\x6d"), "\160\145\x72\155\151\163\163\x69\x6f\156\x5f\143\x61\154\154\x62\x61\x63\153" => array($this, "\165\x70\144\141\164\145\x5f\x69\164\145\x6d\137\160\145\x72\x6d\x69\x73\x73\x69\157\156\163\x5f\143\150\x65\x63\x6b"), "\x61\x72\147\163" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE)), array("\x6d\145\x74\150\157\144\x73" => WP_REST_Server::DELETABLE, "\x63\141\x6c\154\x62\141\143\153" => array($this, "\144\x65\x6c\x65\x74\145\137\151\x74\145\155"), "\x70\x65\162\x6d\151\163\x73\151\157\156\137\x63\x61\x6c\154\x62\x61\x63\153" => array($this, "\144\145\x6c\145\x74\x65\x5f\x69\x74\x65\155\x5f\x70\145\162\155\x69\x73\x73\151\157\156\x73\x5f\x63\150\145\143\x6b"), "\141\x72\147\x73" => array("\x66\x6f\162\x63\145" => array("\164\171\x70\x65" => "\142\x6f\x6f\154\x65\141\x6e", "\144\x65\x66\x61\165\x6c\164" => false, "\144\x65\163\143\162\x69\160\164\151\x6f\x6e" => __("\122\145\161\x75\151\x72\x65\144\40\164\x6f\40\142\x65\x20\x74\x72\165\x65\54\40\141\163\x20\x74\145\162\x6d\163\x20\x64\157\40\156\157\164\40\163\x75\160\160\x6f\162\x74\40\164\162\141\x73\150\151\x6e\x67\56")))), "\141\154\154\157\x77\137\x62\x61\164\x63\150" => $this->allow_batch, "\x73\143\150\x65\155\141" => array($this, "\147\145\x74\137\x70\x75\x62\x6c\x69\x63\137\151\164\x65\155\x5f\x73\x63\150\x65\155\x61"))); } public function check_read_terms_permission_for_post($post, $request) { if (!is_object_in_taxonomy($post->post_type, $this->taxonomy)) { return false; } if (is_post_publicly_viewable($post)) { return true; } if (current_user_can("\162\145\141\144\x5f\x70\x6f\163\x74", $post->ID)) { return true; } return false; } public function get_items_permissions_check($request) { $tax_obj = get_taxonomy($this->taxonomy); if (!$tax_obj || !$this->check_is_taxonomy_allowed($this->taxonomy)) { return false; } if ("\x65\x64\151\164" === $request["\x63\157\x6e\x74\x65\x78\164"] && !current_user_can($tax_obj->cap->edit_terms)) { return new WP_Error("\x72\x65\x73\164\137\x66\157\x72\142\151\x64\x64\x65\x6e\137\x63\x6f\156\x74\x65\x78\164", __("\x53\157\x72\x72\171\x2c\40\x79\x6f\165\40\x61\162\x65\x20\x6e\157\x74\40\141\x6c\154\157\x77\145\x64\40\x74\157\40\x65\144\x69\164\40\164\145\162\x6d\x73\x20\151\156\40\x74\150\x69\163\40\x74\x61\x78\x6f\156\157\x6d\171\x2e"), array("\163\164\x61\x74\165\163" => rest_authorization_required_code())); } if (!empty($request["\x70\157\x73\164"])) { $post = get_post($request["\160\x6f\163\164"]); if (!$post) { return new WP_Error("\x72\x65\163\x74\137\x70\x6f\x73\164\137\151\x6e\166\x61\154\151\x64\137\151\x64", __("\x49\x6e\x76\141\x6c\x69\144\40\x70\157\163\164\40\111\104\x2e"), array("\163\x74\141\164\165\x73" => 400)); } if (!$this->check_read_terms_permission_for_post($post, $request)) { return new WP_Error("\x72\x65\x73\164\137\146\157\x72\142\151\x64\x64\x65\156\x5f\x63\x6f\x6e\164\145\x78\164", __("\123\x6f\162\162\x79\x2c\x20\x79\x6f\165\x20\x61\162\x65\40\156\157\164\x20\x61\154\x6c\x6f\x77\145\144\40\x74\x6f\x20\166\151\145\x77\x20\x74\x65\162\x6d\x73\40\146\x6f\x72\40\164\x68\151\x73\x20\160\x6f\x73\x74\x2e"), array("\163\164\141\x74\165\x73" => rest_authorization_required_code())); } } return true; } public function get_items($request) { $registered = $this->get_collection_params(); $parameter_mappings = array("\x65\170\143\x6c\165\x64\145" => "\x65\x78\x63\154\x75\x64\x65", "\151\156\x63\x6c\x75\x64\145" => "\x69\x6e\x63\x6c\165\x64\145", "\157\162\x64\x65\162" => "\x6f\x72\144\145\162", "\x6f\162\144\x65\162\x62\171" => "\157\162\144\x65\x72\x62\171", "\x70\x6f\x73\x74" => "\x70\x6f\x73\164", "\x68\151\144\145\137\x65\x6d\160\164\171" => "\x68\151\144\145\137\x65\x6d\160\x74\x79", "\x70\145\x72\x5f\160\x61\x67\x65" => "\156\165\155\142\x65\x72", "\x73\145\141\x72\143\x68" => "\163\x65\x61\x72\x63\x68", "\163\154\165\147" => "\x73\x6c\165\147"); $prepared_args = array("\164\x61\170\x6f\x6e\x6f\x6d\171" => $this->taxonomy); foreach ($parameter_mappings as $api_param => $wp_param) { if (isset($registered[$api_param], $request[$api_param])) { $prepared_args[$wp_param] = $request[$api_param]; } } if (isset($prepared_args["\x6f\x72\144\145\162\142\171"]) && isset($request["\x6f\x72\144\145\162\142\171"])) { $orderby_mappings = array("\x69\x6e\x63\x6c\x75\144\x65\137\x73\154\x75\147\163" => "\163\154\165\x67\137\137\x69\x6e"); if (isset($orderby_mappings[$request["\157\x72\x64\x65\x72\x62\x79"]])) { $prepared_args["\157\162\x64\145\162\142\171"] = $orderby_mappings[$request["\157\x72\144\x65\x72\142\171"]]; } } if (isset($registered["\x6f\x66\146\x73\145\x74"]) && !empty($request["\157\x66\x66\x73\145\164"])) { $prepared_args["\157\x66\x66\163\x65\164"] = $request["\x6f\x66\146\163\145\164"]; } else { $prepared_args["\157\146\x66\x73\145\x74"] = ($request["\x70\141\x67\145"] - 1) * $prepared_args["\156\165\155\142\x65\x72"]; } $taxonomy_obj = get_taxonomy($this->taxonomy); if ($taxonomy_obj->hierarchical && isset($registered["\x70\141\162\x65\x6e\164"], $request["\160\141\162\145\156\x74"])) { if (0 === $request["\x70\x61\162\x65\156\164"]) { $prepared_args["\x70\x61\x72\x65\x6e\x74"] = 0; } else { if ($request["\x70\141\162\x65\156\x74"]) { $prepared_args["\x70\x61\x72\145\156\164"] = $request["\160\x61\x72\145\156\164"]; } } } $prepared_args = apply_filters("\162\145\x73\x74\x5f{$this->taxonomy}\137\x71\165\x65\162\171", $prepared_args, $request); if (!empty($prepared_args["\x70\157\163\164"])) { $query_result = wp_get_object_terms($prepared_args["\160\157\163\164"], $this->taxonomy, $prepared_args); $prepared_args["\x6f\x62\x6a\145\143\x74\137\x69\x64\x73"] = $prepared_args["\x70\x6f\163\164"]; } else { $query_result = get_terms($prepared_args); } $count_args = $prepared_args; unset($count_args["\156\x75\155\x62\145\x72"], $count_args["\x6f\146\x66\163\145\164"]); $total_terms = wp_count_terms($count_args); if (!$total_terms) { $total_terms = 0; } $response = array(); foreach ($query_result as $term) { $data = $this->prepare_item_for_response($term, $request); $response[] = $this->prepare_response_for_collection($data); } $response = rest_ensure_response($response); $per_page = (int) $prepared_args["\x6e\165\155\x62\x65\x72"]; $page = (int) ceil((int) $prepared_args["\157\146\x66\x73\x65\164"] / $per_page + 1); $response->header("\x58\55\x57\x50\55\x54\x6f\164\x61\154", (int) $total_terms); $max_pages = (int) ceil($total_terms / $per_page); $response->header("\130\55\x57\x50\x2d\124\157\x74\141\154\x50\x61\x67\x65\x73", $max_pages); $request_params = $request->get_query_params(); $collection_url = rest_url(rest_get_route_for_taxonomy_items($this->taxonomy)); $base = add_query_arg(urlencode_deep($request_params), $collection_url); if ($page > 1) { $prev_page = $page - 1; if ($prev_page > $max_pages) { $prev_page = $max_pages; } $prev_link = add_query_arg("\160\x61\x67\145", $prev_page, $base); $response->link_header("\x70\x72\x65\166", $prev_link); } if ($max_pages > $page) { $next_page = $page + 1; $next_link = add_query_arg("\x70\141\x67\145", $next_page, $base); $response->link_header("\x6e\x65\x78\x74", $next_link); } return $response; } protected function get_term($id) { $error = new WP_Error("\x72\145\163\164\137\x74\x65\x72\x6d\137\x69\x6e\166\141\154\x69\144", __("\x54\x65\x72\155\x20\144\157\145\163\x20\x6e\x6f\x74\40\145\x78\x69\163\x74\x2e"), array("\163\164\141\164\x75\x73" => 404)); if (!$this->check_is_taxonomy_allowed($this->taxonomy)) { return $error; } if ((int) $id <= 0) { return $error; } $term = get_term((int) $id, $this->taxonomy); if (empty($term) || $term->taxonomy !== $this->taxonomy) { return $error; } return $term; } public function get_item_permissions_check($request) { $term = $this->get_term($request["\151\144"]); if (is_wp_error($term)) { return $term; } if ("\145\144\151\x74" === $request["\x63\157\156\164\x65\170\x74"] && !current_user_can("\145\x64\151\x74\137\x74\x65\162\x6d", $term->term_id)) { return new WP_Error("\162\145\163\x74\137\146\157\162\142\151\x64\x64\145\156\x5f\143\x6f\156\x74\x65\x78\164", __("\x53\157\162\162\171\x2c\40\x79\x6f\x75\x20\x61\x72\x65\x20\156\157\164\40\x61\154\x6c\x6f\167\x65\x64\x20\164\x6f\x20\x65\144\x69\164\40\x74\x68\x69\x73\x20\164\145\162\155\56"), array("\163\164\x61\164\x75\x73" => rest_authorization_required_code())); } return true; } public function get_item($request) { $term = $this->get_term($request["\x69\x64"]); if (is_wp_error($term)) { return $term; } $response = $this->prepare_item_for_response($term, $request); return rest_ensure_response($response); } public function create_item_permissions_check($request) { if (!$this->check_is_taxonomy_allowed($this->taxonomy)) { return false; } $taxonomy_obj = get_taxonomy($this->taxonomy); if (is_taxonomy_hierarchical($this->taxonomy) && !current_user_can($taxonomy_obj->cap->edit_terms) || !is_taxonomy_hierarchical($this->taxonomy) && !current_user_can($taxonomy_obj->cap->assign_terms)) { return new WP_Error("\162\x65\x73\x74\x5f\143\x61\156\156\157\164\x5f\x63\162\x65\141\x74\145", __("\x53\157\162\162\x79\x2c\40\x79\157\165\x20\x61\x72\x65\x20\156\157\x74\40\141\x6c\154\157\167\x65\x64\40\x74\x6f\x20\x63\x72\x65\x61\164\x65\40\x74\x65\x72\155\x73\x20\x69\156\40\x74\150\151\x73\x20\x74\x61\170\157\156\x6f\155\171\x2e"), array("\x73\164\141\164\x75\163" => rest_authorization_required_code())); } return true; } public function create_item($request) { if (isset($request["\x70\141\162\x65\156\x74"])) { if (!is_taxonomy_hierarchical($this->taxonomy)) { return new WP_Error("\x72\145\x73\x74\137\x74\x61\x78\157\x6e\x6f\155\x79\x5f\156\x6f\164\x5f\x68\x69\145\162\x61\x72\143\150\x69\143\x61\x6c", __("\103\x61\156\x6e\157\x74\40\163\145\x74\x20\x70\141\x72\145\x6e\x74\40\x74\145\162\155\54\40\x74\x61\x78\x6f\156\x6f\x6d\171\x20\x69\x73\x20\156\157\x74\40\x68\151\145\162\x61\162\x63\150\151\143\141\154\56"), array("\163\x74\x61\x74\x75\163" => 400)); } $parent = get_term((int) $request["\160\x61\162\145\x6e\164"], $this->taxonomy); if (!$parent) { return new WP_Error("\162\x65\163\164\x5f\x74\145\x72\155\137\151\156\166\141\x6c\151\x64", __("\120\x61\162\145\x6e\164\40\x74\145\162\155\40\144\157\x65\163\x20\x6e\x6f\164\40\145\170\x69\x73\x74\x2e"), array("\x73\164\x61\164\x75\x73" => 400)); } } $prepared_term = $this->prepare_item_for_database($request); $term = wp_insert_term(wp_slash($prepared_term->name), $this->taxonomy, wp_slash((array) $prepared_term)); if (is_wp_error($term)) { $term_id = $term->get_error_data("\x74\145\162\x6d\x5f\145\170\x69\163\164\x73"); if ($term_id) { $existing_term = get_term($term_id, $this->taxonomy); $term->add_data($existing_term->term_id, "\x74\145\162\155\137\145\x78\x69\163\x74\163"); $term->add_data(array("\163\x74\x61\164\x75\x73" => 400, "\x74\145\x72\155\137\151\144" => $term_id)); } return $term; } $term = get_term($term["\x74\x65\x72\155\137\151\144"], $this->taxonomy); do_action("\162\145\x73\x74\137\x69\156\163\145\x72\x74\x5f{$this->taxonomy}", $term, $request, true); $schema = $this->get_item_schema(); if (!empty($schema["\x70\x72\x6f\x70\145\x72\x74\x69\x65\x73"]["\155\145\164\141"]) && isset($request["\x6d\145\164\x61"])) { $meta_update = $this->meta->update_value($request["\x6d\145\x74\141"], $term->term_id); if (is_wp_error($meta_update)) { return $meta_update; } } $fields_update = $this->update_additional_fields_for_object($term, $request); if (is_wp_error($fields_update)) { return $fields_update; } $request->set_param("\x63\157\x6e\x74\x65\x78\164", "\x65\x64\x69\164"); do_action("\162\x65\163\164\137\141\x66\164\145\x72\x5f\x69\x6e\x73\x65\162\x74\137{$this->taxonomy}", $term, $request, true); $response = $this->prepare_item_for_response($term, $request); $response = rest_ensure_response($response); $response->set_status(201); $response->header("\114\x6f\x63\x61\164\151\157\x6e", rest_url($this->namespace . "\57" . $this->rest_base . "\57" . $term->term_id)); return $response; } public function update_item_permissions_check($request) { $term = $this->get_term($request["\x69\x64"]); if (is_wp_error($term)) { return $term; } if (!current_user_can("\145\x64\151\164\x5f\x74\x65\x72\x6d", $term->term_id)) { return new WP_Error("\x72\x65\x73\164\x5f\x63\x61\156\156\x6f\x74\137\165\x70\x64\x61\x74\145", __("\123\x6f\162\x72\x79\x2c\x20\171\x6f\165\x20\141\162\145\40\156\x6f\x74\x20\x61\154\x6c\157\167\145\144\40\164\x6f\x20\145\x64\151\164\40\164\x68\151\x73\x20\164\145\x72\155\56"), array("\163\x74\x61\164\165\163" => rest_authorization_required_code())); } return true; } public function update_item($request) { $term = $this->get_term($request["\151\x64"]); if (is_wp_error($term)) { return $term; } if (isset($request["\x70\141\x72\145\x6e\164"])) { if (!is_taxonomy_hierarchical($this->taxonomy)) { return new WP_Error("\x72\145\x73\x74\x5f\164\x61\x78\157\x6e\x6f\x6d\x79\x5f\156\157\164\x5f\x68\151\145\x72\x61\162\x63\x68\x69\x63\141\x6c", __("\103\x61\156\x6e\x6f\164\40\x73\145\x74\40\160\x61\x72\145\156\164\x20\164\x65\x72\155\x2c\40\x74\141\170\157\156\157\x6d\171\40\151\x73\40\x6e\157\164\x20\x68\151\145\162\141\162\143\x68\x69\143\x61\154\56"), array("\163\164\141\x74\x75\163" => 400)); } $parent = get_term((int) $request["\160\x61\x72\x65\x6e\164"], $this->taxonomy); if (!$parent) { return new WP_Error("\162\x65\x73\164\x5f\x74\145\162\x6d\x5f\151\x6e\166\141\x6c\151\x64", __("\x50\x61\162\145\156\x74\40\164\x65\x72\155\x20\x64\x6f\145\x73\x20\x6e\x6f\x74\40\145\170\x69\x73\x74\56"), array("\163\x74\x61\x74\165\163" => 400)); } } $prepared_term = $this->prepare_item_for_database($request); if (!empty($prepared_term)) { $update = wp_update_term($term->term_id, $term->taxonomy, wp_slash((array) $prepared_term)); if (is_wp_error($update)) { return $update; } } $term = get_term($term->term_id, $this->taxonomy); do_action("\162\x65\163\x74\137\151\156\x73\145\162\x74\137{$this->taxonomy}", $term, $request, false); $schema = $this->get_item_schema(); if (!empty($schema["\x70\162\x6f\x70\x65\x72\x74\x69\145\x73"]["\155\x65\164\141"]) && isset($request["\155\x65\x74\x61"])) { $meta_update = $this->meta->update_value($request["\155\x65\x74\141"], $term->term_id); if (is_wp_error($meta_update)) { return $meta_update; } } $fields_update = $this->update_additional_fields_for_object($term, $request); if (is_wp_error($fields_update)) { return $fields_update; } $request->set_param("\143\157\x6e\x74\x65\x78\x74", "\145\x64\x69\164"); do_action("\x72\145\x73\x74\137\141\x66\x74\x65\x72\x5f\x69\156\x73\x65\x72\164\137{$this->taxonomy}", $term, $request, false); $response = $this->prepare_item_for_response($term, $request); return rest_ensure_response($response); } public function delete_item_permissions_check($request) { $term = $this->get_term($request["\151\144"]); if (is_wp_error($term)) { return $term; } if (!current_user_can("\144\x65\154\x65\164\145\137\x74\x65\x72\x6d", $term->term_id)) { return new WP_Error("\162\x65\x73\164\x5f\x63\141\x6e\x6e\x6f\164\x5f\144\145\154\x65\x74\145", __("\123\157\162\162\x79\x2c\40\171\x6f\165\x20\x61\x72\x65\40\156\157\164\40\141\154\x6c\157\167\x65\x64\40\x74\157\x20\x64\145\x6c\x65\x74\x65\40\x74\150\151\163\40\x74\x65\162\155\x2e"), array("\163\164\141\164\165\163" => rest_authorization_required_code())); } return true; } public function delete_item($request) { $term = $this->get_term($request["\x69\144"]); if (is_wp_error($term)) { return $term; } $force = isset($request["\x66\157\x72\143\x65"]) ? (bool) $request["\146\157\x72\143\145"] : false; if (!$force) { return new WP_Error("\x72\145\163\x74\x5f\x74\162\141\163\x68\137\x6e\157\x74\x5f\163\x75\x70\160\x6f\x72\164\x65\x64", sprintf(__("\124\145\162\155\163\x20\x64\x6f\x20\156\x6f\164\40\x73\165\x70\x70\157\x72\164\40\164\162\x61\163\150\151\156\x67\56\40\x53\145\164\40\47\45\163\x27\40\164\157\x20\x64\x65\x6c\145\x74\x65\56"), "\x66\x6f\162\143\x65\75\x74\x72\x75\145"), array("\x73\164\x61\164\165\x73" => 501)); } $request->set_param("\x63\157\x6e\164\145\170\x74", "\166\151\145\167"); $previous = $this->prepare_item_for_response($term, $request); $retval = wp_delete_term($term->term_id, $term->taxonomy); if (!$retval) { return new WP_Error("\162\145\163\164\137\143\x61\156\156\x6f\164\x5f\144\x65\x6c\145\164\145", __("\124\150\145\40\164\x65\x72\155\x20\x63\x61\x6e\156\x6f\164\40\x62\145\x20\144\x65\154\x65\x74\x65\x64\x2e"), array("\x73\x74\x61\164\165\163" => 500)); } $response = new WP_REST_Response(); $response->set_data(array("\x64\145\x6c\x65\164\145\144" => true, "\x70\162\x65\166\151\157\x75\x73" => $previous->get_data())); do_action("\162\145\163\x74\137\144\145\x6c\x65\164\x65\x5f{$this->taxonomy}", $term, $response, $request); return $response; } public function prepare_item_for_database($request) { $prepared_term = new stdClass(); $schema = $this->get_item_schema(); if (isset($request["\x6e\141\x6d\x65"]) && !empty($schema["\160\162\157\160\145\x72\x74\151\x65\x73"]["\156\x61\x6d\145"])) { $prepared_term->name = $request["\x6e\x61\x6d\x65"]; } if (isset($request["\163\x6c\x75\147"]) && !empty($schema["\160\x72\157\160\145\162\164\x69\145\x73"]["\x73\154\x75\147"])) { $prepared_term->slug = $request["\163\154\x75\x67"]; } if (isset($request["\x74\x61\170\157\x6e\157\x6d\171"]) && !empty($schema["\x70\162\157\160\145\162\x74\x69\145\163"]["\x74\141\x78\x6f\156\x6f\x6d\x79"])) { $prepared_term->taxonomy = $request["\164\141\170\x6f\156\x6f\155\x79"]; } if (isset($request["\144\x65\163\143\162\151\160\x74\151\x6f\x6e"]) && !empty($schema["\160\162\x6f\x70\145\162\x74\x69\145\x73"]["\144\x65\x73\143\162\151\x70\164\x69\157\156"])) { $prepared_term->description = $request["\144\145\x73\143\x72\151\160\164\151\x6f\156"]; } if (isset($request["\160\x61\162\x65\x6e\x74"]) && !empty($schema["\160\162\x6f\160\x65\x72\x74\151\x65\x73"]["\160\x61\x72\145\156\164"])) { $parent_term_id = 0; $requested_parent = (int) $request["\160\x61\162\145\156\164"]; if ($requested_parent) { $parent_term = get_term($requested_parent, $this->taxonomy); if ($parent_term instanceof WP_Term) { $parent_term_id = $parent_term->term_id; } } $prepared_term->parent = $parent_term_id; } return apply_filters("\x72\x65\163\x74\137\160\x72\x65\x5f\x69\x6e\x73\145\x72\164\x5f{$this->taxonomy}", $prepared_term, $request); } public function prepare_item_for_response($item, $request) { $fields = $this->get_fields_for_response($request); $data = array(); if (in_array("\151\144", $fields, true)) { $data["\x69\144"] = (int) $item->term_id; } if (in_array("\143\x6f\x75\156\x74", $fields, true)) { $data["\x63\157\x75\156\164"] = (int) $item->count; } if (in_array("\x64\145\163\x63\x72\151\160\x74\151\157\156", $fields, true)) { $data["\x64\145\163\143\x72\x69\160\164\151\x6f\x6e"] = $item->description; } if (in_array("\x6c\151\156\x6b", $fields, true)) { $data["\x6c\x69\156\x6b"] = get_term_link($item); } if (in_array("\156\141\x6d\x65", $fields, true)) { $data["\x6e\x61\155\145"] = $item->name; } if (in_array("\x73\x6c\165\x67", $fields, true)) { $data["\163\x6c\x75\x67"] = $item->slug; } if (in_array("\x74\x61\170\157\156\157\x6d\171", $fields, true)) { $data["\x74\x61\x78\x6f\156\157\x6d\x79"] = $item->taxonomy; } if (in_array("\x70\141\x72\x65\x6e\x74", $fields, true)) { $data["\x70\141\x72\x65\x6e\164"] = (int) $item->parent; } if (in_array("\155\145\x74\x61", $fields, true)) { $data["\x6d\145\164\x61"] = $this->meta->get_value($item->term_id, $request); } $context = !empty($request["\143\157\x6e\164\145\x78\164"]) ? $request["\x63\157\x6e\x74\x65\x78\164"] : "\x76\x69\145\167"; $data = $this->add_additional_fields_to_object($data, $request); $data = $this->filter_response_by_context($data, $context); $response = rest_ensure_response($data); if (rest_is_field_included("\137\154\151\156\x6b\x73", $fields) || rest_is_field_included("\x5f\145\x6d\x62\145\x64\144\x65\144", $fields)) { $response->add_links($this->prepare_links($item)); } return apply_filters("\x72\x65\x73\164\137\160\x72\145\x70\141\x72\x65\137{$this->taxonomy}", $response, $item, $request); } protected function prepare_links($term) { $links = array("\163\x65\x6c\x66" => array("\150\162\x65\x66" => rest_url(rest_get_route_for_term($term))), "\x63\x6f\154\154\145\143\x74\x69\x6f\156" => array("\x68\162\x65\146" => rest_url(rest_get_route_for_taxonomy_items($this->taxonomy))), "\141\142\157\x75\164" => array("\150\162\x65\x66" => rest_url(sprintf("\167\x70\x2f\x76\x32\x2f\x74\x61\x78\x6f\156\x6f\x6d\x69\145\163\57\45\163", $this->taxonomy)))); if ($term->parent) { $parent_term = get_term((int) $term->parent, $term->taxonomy); if ($parent_term) { $links["\165\x70"] = array("\x68\162\x65\146" => rest_url(rest_get_route_for_term($parent_term)), "\x65\x6d\142\145\144\x64\141\x62\x6c\145" => true); } } $taxonomy_obj = get_taxonomy($term->taxonomy); if (empty($taxonomy_obj->object_type)) { return $links; } $post_type_links = array(); foreach ($taxonomy_obj->object_type as $type) { $rest_path = rest_get_route_for_post_type_items($type); if (empty($rest_path)) { continue; } $post_type_links[] = array("\150\x72\x65\x66" => add_query_arg($this->rest_base, $term->term_id, rest_url($rest_path))); } if (!empty($post_type_links)) { $links["\150\164\x74\160\163\72\x2f\x2f\141\x70\151\x2e\167\x2e\157\x72\x67\x2f\x70\x6f\163\164\137\x74\171\x70\145"] = $post_type_links; } return $links; } public function get_item_schema() { if ($this->schema) { return $this->add_additional_fields_schema($this->schema); } $schema = array("\44\163\x63\150\145\x6d\x61" => "\x68\164\164\x70\72\x2f\x2f\x6a\x73\157\156\x2d\163\x63\x68\145\155\141\56\157\162\x67\57\144\x72\141\x66\164\55\60\x34\x2f\x73\143\150\145\155\x61\x23", "\164\x69\x74\x6c\145" => "\x70\157\163\x74\137\164\141\147" === $this->taxonomy ? "\164\x61\x67" : $this->taxonomy, "\164\171\x70\145" => "\157\x62\152\x65\x63\164", "\160\x72\x6f\x70\x65\x72\x74\151\x65\x73" => array("\x69\144" => array("\x64\145\163\x63\x72\x69\160\x74\151\x6f\156" => __("\125\x6e\x69\161\165\x65\x20\151\x64\x65\156\x74\x69\x66\x69\145\162\40\146\x6f\162\40\164\150\x65\40\x74\x65\162\155\x2e"), "\164\x79\160\x65" => "\x69\x6e\x74\x65\147\x65\162", "\x63\157\x6e\x74\145\x78\x74" => array("\x76\x69\x65\167", "\x65\155\x62\145\144", "\145\x64\x69\x74"), "\162\145\141\x64\157\156\x6c\171" => true), "\143\x6f\x75\156\164" => array("\144\145\163\143\162\151\160\164\x69\157\156" => __("\116\x75\155\x62\x65\162\x20\157\x66\40\160\165\x62\x6c\x69\163\x68\x65\144\40\x70\x6f\x73\164\163\x20\x66\x6f\162\40\164\x68\x65\40\x74\x65\x72\155\56"), "\164\x79\x70\145" => "\x69\156\164\x65\x67\x65\162", "\143\x6f\x6e\x74\145\x78\164" => array("\166\151\x65\x77", "\x65\x64\151\164"), "\x72\x65\x61\144\x6f\x6e\154\171" => true), "\x64\145\163\x63\x72\x69\x70\164\x69\157\x6e" => array("\x64\x65\x73\x63\162\151\160\164\x69\157\x6e" => __("\x48\x54\x4d\114\40\x64\x65\163\x63\162\x69\160\x74\x69\x6f\156\x20\x6f\x66\40\x74\150\x65\40\x74\x65\162\155\x2e"), "\164\x79\160\x65" => "\x73\x74\x72\151\x6e\x67", "\143\157\156\x74\145\x78\x74" => array("\166\151\145\x77", "\145\144\x69\x74")), "\x6c\x69\156\x6b" => array("\144\145\x73\x63\x72\151\x70\164\151\157\156" => __("\x55\122\x4c\x20\157\146\40\164\150\x65\x20\x74\145\x72\155\x2e"), "\164\x79\x70\x65" => "\163\164\162\151\156\147", "\x66\157\162\155\x61\164" => "\165\162\x69", "\x63\x6f\156\x74\x65\x78\164" => array("\x76\x69\145\x77", "\x65\155\x62\145\x64", "\x65\x64\151\164"), "\162\145\x61\144\x6f\156\154\x79" => true), "\x6e\141\155\x65" => array("\x64\x65\163\143\x72\151\160\x74\x69\157\156" => __("\110\124\x4d\114\x20\x74\151\164\x6c\x65\40\146\157\x72\x20\x74\x68\x65\40\164\145\x72\x6d\56"), "\164\x79\160\x65" => "\163\164\162\x69\156\147", "\x63\157\156\164\145\x78\164" => array("\166\151\x65\x77", "\x65\x6d\142\x65\144", "\145\144\x69\x74"), "\x61\162\147\x5f\x6f\x70\x74\x69\157\x6e\163" => array("\163\x61\x6e\x69\164\x69\172\145\137\143\141\154\154\x62\141\x63\153" => "\163\x61\156\x69\x74\x69\172\145\137\164\145\170\164\137\146\x69\145\154\x64"), "\162\145\x71\x75\x69\162\x65\x64" => true), "\163\x6c\165\147" => array("\x64\145\163\x63\162\151\x70\164\151\x6f\x6e" => __("\101\x6e\x20\141\154\x70\150\x61\156\165\155\145\162\x69\143\x20\151\x64\x65\x6e\164\151\146\151\x65\x72\x20\x66\x6f\162\40\x74\x68\145\x20\x74\x65\x72\x6d\40\x75\156\151\x71\x75\x65\40\x74\x6f\40\151\164\163\x20\x74\171\x70\x65\56"), "\164\x79\160\145" => "\x73\x74\162\151\156\147", "\x63\x6f\156\164\x65\170\164" => array("\166\151\145\x77", "\x65\155\142\x65\144", "\x65\x64\151\164"), "\x61\162\147\137\157\x70\164\x69\157\x6e\x73" => array("\163\x61\156\x69\x74\151\x7a\x65\x5f\143\x61\154\x6c\142\x61\x63\x6b" => array($this, "\x73\x61\x6e\151\164\x69\x7a\x65\137\163\x6c\x75\147"))), "\x74\x61\x78\157\156\x6f\155\x79" => array("\144\145\x73\143\x72\x69\x70\164\x69\157\x6e" => __("\124\171\160\x65\40\141\x74\x74\162\151\142\x75\164\x69\157\156\40\x66\157\162\40\164\x68\145\x20\164\145\x72\x6d\56"), "\x74\x79\x70\145" => "\163\x74\162\x69\x6e\147", "\145\x6e\165\x6d" => array($this->taxonomy), "\x63\157\156\164\145\x78\164" => array("\166\151\x65\167", "\x65\x6d\142\x65\x64", "\x65\144\x69\x74"), "\x72\145\141\144\x6f\x6e\154\x79" => true))); $taxonomy = get_taxonomy($this->taxonomy); if ($taxonomy->hierarchical) { $schema["\160\162\157\160\x65\x72\164\x69\x65\163"]["\x70\x61\162\145\x6e\x74"] = array("\144\x65\163\x63\162\x69\x70\x74\x69\x6f\x6e" => __("\124\x68\x65\x20\160\x61\162\145\x6e\164\x20\164\x65\162\x6d\40\111\104\56"), "\x74\171\x70\x65" => "\x69\156\x74\145\x67\x65\x72", "\143\157\156\x74\145\x78\164" => array("\x76\x69\x65\x77", "\x65\x64\151\x74")); } $schema["\160\x72\157\x70\145\162\x74\151\145\163"]["\155\145\x74\x61"] = $this->meta->get_field_schema(); $this->schema = $schema; return $this->add_additional_fields_schema($this->schema); } public function get_collection_params() { $query_params = parent::get_collection_params(); $taxonomy = get_taxonomy($this->taxonomy); $query_params["\143\x6f\x6e\164\x65\x78\164"]["\x64\145\146\x61\x75\154\164"] = "\x76\x69\x65\x77"; $query_params["\x65\x78\x63\x6c\x75\144\145"] = array("\144\x65\x73\x63\x72\151\x70\x74\x69\x6f\156" => __("\x45\156\x73\165\x72\145\40\162\x65\163\165\x6c\164\x20\x73\145\x74\x20\x65\x78\x63\x6c\165\x64\x65\x73\x20\x73\160\x65\x63\x69\146\x69\x63\40\111\104\x73\56"), "\x74\171\160\x65" => "\x61\162\162\x61\171", "\151\x74\x65\x6d\x73" => array("\x74\x79\x70\x65" => "\151\x6e\164\145\x67\145\162"), "\x64\x65\146\141\x75\154\x74" => array()); $query_params["\x69\156\143\x6c\x75\x64\145"] = array("\144\145\163\x63\162\x69\160\164\x69\157\x6e" => __("\114\x69\155\x69\164\40\162\x65\x73\x75\x6c\x74\x20\x73\x65\164\x20\164\157\40\163\160\x65\143\x69\146\151\143\40\x49\104\163\56"), "\164\x79\160\145" => "\141\162\162\141\x79", "\x69\x74\145\155\x73" => array("\x74\x79\x70\x65" => "\151\156\164\x65\147\x65\162"), "\144\x65\146\x61\165\x6c\x74" => array()); if (!$taxonomy->hierarchical) { $query_params["\x6f\146\x66\x73\x65\x74"] = array("\144\x65\x73\143\x72\151\x70\x74\151\x6f\x6e" => __("\117\146\x66\163\x65\x74\x20\x74\x68\145\40\162\145\163\165\x6c\164\40\163\145\x74\x20\142\x79\40\141\x20\x73\160\145\x63\151\146\x69\x63\40\156\165\x6d\x62\x65\162\40\x6f\x66\x20\x69\164\x65\x6d\163\56"), "\164\171\160\145" => "\x69\156\x74\145\147\x65\x72"); } $query_params["\x6f\x72\x64\x65\x72"] = array("\x64\145\163\x63\x72\151\160\x74\x69\157\156" => __("\x4f\x72\x64\145\x72\x20\x73\x6f\162\164\40\141\x74\164\x72\x69\x62\165\164\x65\40\141\163\143\145\156\144\x69\x6e\147\x20\x6f\x72\40\x64\145\163\x63\x65\156\144\151\x6e\147\56"), "\x74\171\160\145" => "\163\164\x72\151\156\147", "\144\x65\x66\141\x75\154\164" => "\x61\163\143", "\x65\x6e\x75\155" => array("\x61\x73\x63", "\144\x65\163\143")); $query_params["\157\162\144\145\162\142\171"] = array("\x64\145\163\x63\x72\151\160\164\x69\x6f\156" => __("\123\x6f\x72\164\40\x63\x6f\154\154\145\143\x74\x69\157\x6e\40\x62\171\40\x74\145\162\155\40\x61\x74\164\162\x69\x62\165\x74\145\56"), "\x74\x79\160\145" => "\163\x74\162\x69\x6e\147", "\144\145\146\141\165\154\164" => "\156\141\155\145", "\x65\x6e\x75\x6d" => array("\151\144", "\151\x6e\143\x6c\x75\x64\145", "\156\x61\x6d\145", "\x73\x6c\165\147", "\151\x6e\x63\x6c\165\144\145\137\x73\x6c\165\147\163", "\164\145\162\x6d\137\x67\162\x6f\x75\160", "\x64\145\x73\x63\x72\151\160\x74\x69\x6f\156", "\143\x6f\x75\156\x74")); $query_params["\150\151\x64\145\137\145\x6d\160\164\x79"] = array("\144\x65\163\x63\x72\151\x70\x74\x69\157\156" => __("\127\150\145\164\150\145\x72\x20\164\x6f\x20\x68\x69\x64\145\x20\x74\145\162\x6d\x73\40\156\157\164\40\x61\x73\x73\151\x67\x6e\x65\x64\40\x74\x6f\40\x61\x6e\171\x20\160\x6f\163\164\163\56"), "\164\x79\x70\145" => "\142\x6f\157\154\x65\141\x6e", "\144\x65\x66\141\165\154\x74" => false); if ($taxonomy->hierarchical) { $query_params["\160\x61\162\145\x6e\164"] = array("\x64\x65\163\x63\162\x69\x70\x74\x69\157\156" => __("\114\151\x6d\x69\164\40\x72\x65\163\165\154\164\x20\163\145\164\x20\x74\x6f\x20\x74\x65\162\x6d\163\x20\141\163\163\x69\147\x6e\x65\144\40\164\157\x20\x61\40\x73\160\x65\x63\x69\146\x69\143\40\x70\x61\x72\145\x6e\164\56"), "\x74\x79\x70\x65" => "\151\x6e\x74\145\147\x65\162"); } $query_params["\160\157\163\164"] = array("\144\x65\163\143\162\151\x70\164\x69\x6f\156" => __("\x4c\151\x6d\x69\164\40\x72\x65\163\165\154\164\x20\163\x65\x74\x20\x74\157\40\164\x65\162\155\163\x20\x61\163\163\x69\147\156\145\x64\x20\164\x6f\40\141\40\x73\x70\145\x63\151\x66\x69\x63\x20\x70\x6f\163\x74\56"), "\164\x79\160\145" => "\x69\156\164\145\147\x65\x72", "\144\145\x66\141\165\154\x74" => null); $query_params["\x73\154\165\147"] = array("\144\x65\x73\x63\162\x69\160\164\151\157\x6e" => __("\114\x69\155\151\164\40\x72\x65\163\x75\154\x74\x20\x73\x65\x74\40\x74\157\x20\x74\x65\162\155\x73\40\x77\x69\164\150\40\x6f\x6e\145\x20\x6f\x72\x20\x6d\x6f\x72\145\x20\163\160\145\143\x69\146\151\143\x20\x73\154\x75\147\163\56"), "\x74\171\x70\x65" => "\141\x72\x72\141\x79", "\151\x74\145\155\x73" => array("\164\x79\160\145" => "\163\x74\162\151\156\x67")); return apply_filters("\162\x65\163\164\137{$this->taxonomy}\137\x63\x6f\154\x6c\145\x63\164\151\x6f\x6e\137\160\141\162\141\x6d\x73", $query_params, $taxonomy); } protected function check_is_taxonomy_allowed($taxonomy) { $taxonomy_obj = get_taxonomy($taxonomy); if ($taxonomy_obj && !empty($taxonomy_obj->show_in_rest)) { return true; } return false; } }
Function Calls
None |
Stats
MD5 | 2748ae106a0765c3ead0f774bb8f829f |
Eval Count | 0 |
Decode Time | 267 ms |