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 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())); } 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 = ceil((int) $prepared_args["offset"] / $per_page + 1); $response->header("X-WP-Total", (int) $total_terms); $max_pages = ceil($total_terms / $per_page); $response->header("X-WP-TotalPages", (int) $max_pages); $base = add_query_arg(urlencode_deep($request->get_query_params()), rest_url($this->namespace . "/" . $this->rest_base)); 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); $response->add_links($this->prepare_links($item)); return apply_filters("rest_prepare_{$this->taxonomy}", $response, $item, $request); } protected function prepare_links($term) { $base = $this->namespace . "/" . $this->rest_base; $links = array("self" => array("href" => rest_url(trailingslashit($base) . $term->term_id)), "collection" => array("href" => rest_url($base)), "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(trailingslashit($base) . $parent_term->term_id), "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\160\x2f\x76\x32"; $this->meta = new WP_REST_Term_Meta_Fields($taxonomy); } public function register_routes() { register_rest_route($this->namespace, "\57" . $this->rest_base, array(array("\155\x65\164\x68\157\x64\x73" => WP_REST_Server::READABLE, "\x63\x61\154\x6c\142\x61\143\153" => array($this, "\x67\145\164\x5f\151\164\x65\x6d\163"), "\x70\145\162\x6d\x69\x73\x73\151\x6f\156\x5f\143\141\x6c\154\x62\x61\x63\x6b" => array($this, "\x67\145\x74\x5f\x69\164\145\155\163\x5f\160\145\162\x6d\x69\163\x73\151\157\156\x73\137\x63\150\145\143\153"), "\141\162\147\x73" => $this->get_collection_params()), array("\x6d\x65\164\x68\157\x64\x73" => WP_REST_Server::CREATABLE, "\x63\x61\x6c\154\x62\x61\143\x6b" => array($this, "\143\x72\x65\x61\164\145\x5f\x69\x74\145\x6d"), "\x70\x65\162\155\x69\163\x73\x69\157\x6e\x5f\x63\141\154\x6c\142\141\x63\x6b" => array($this, "\143\162\x65\x61\x74\x65\x5f\x69\x74\145\155\x5f\x70\x65\x72\155\x69\x73\163\x69\x6f\156\x73\x5f\143\x68\x65\143\x6b"), "\141\162\147\163" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE)), "\141\x6c\x6c\157\167\x5f\x62\141\164\x63\x68" => $this->allow_batch, "\x73\x63\150\x65\x6d\141" => array($this, "\147\145\164\x5f\x70\165\142\x6c\151\x63\137\x69\164\x65\155\137\163\143\x68\145\155\x61"))); register_rest_route($this->namespace, "\57" . $this->rest_base . "\57\50\77\x50\74\x69\144\76\133\134\x64\135\53\x29", array("\141\162\147\163" => array("\151\x64" => array("\144\x65\x73\x63\x72\151\160\164\x69\x6f\156" => __("\x55\156\151\x71\165\145\40\151\x64\x65\x6e\x74\x69\146\151\145\162\x20\x66\x6f\162\x20\164\150\145\40\x74\x65\162\x6d\x2e"), "\x74\x79\160\145" => "\151\x6e\x74\145\x67\x65\162")), array("\155\x65\164\x68\157\x64\163" => WP_REST_Server::READABLE, "\143\141\x6c\154\x62\x61\143\x6b" => array($this, "\x67\145\164\137\x69\164\145\155"), "\x70\145\x72\x6d\x69\163\163\x69\x6f\x6e\x5f\x63\141\x6c\154\x62\141\x63\153" => array($this, "\x67\x65\164\137\x69\x74\145\155\x5f\160\145\162\x6d\x69\x73\x73\x69\157\x6e\x73\x5f\x63\150\145\143\153"), "\x61\162\147\x73" => array("\143\x6f\156\164\x65\x78\x74" => $this->get_context_param(array("\144\x65\146\x61\165\154\x74" => "\x76\x69\x65\x77")))), array("\x6d\145\164\x68\x6f\x64\163" => WP_REST_Server::EDITABLE, "\x63\x61\154\154\x62\x61\143\x6b" => array($this, "\x75\160\x64\x61\x74\145\137\x69\164\145\x6d"), "\x70\x65\x72\x6d\x69\163\163\x69\x6f\x6e\137\143\141\154\x6c\x62\x61\x63\153" => array($this, "\x75\x70\x64\x61\x74\x65\x5f\151\164\x65\x6d\x5f\x70\x65\x72\x6d\151\163\x73\x69\x6f\x6e\x73\x5f\143\150\145\x63\153"), "\x61\162\x67\163" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE)), array("\155\145\164\150\x6f\x64\163" => WP_REST_Server::DELETABLE, "\x63\x61\x6c\x6c\142\x61\143\153" => array($this, "\144\x65\154\x65\164\145\x5f\x69\x74\x65\155"), "\160\145\x72\155\151\x73\x73\151\x6f\156\137\x63\x61\x6c\154\142\x61\x63\153" => array($this, "\144\145\154\145\164\145\137\x69\164\x65\155\x5f\x70\x65\162\x6d\151\163\x73\151\157\156\x73\x5f\x63\150\145\x63\x6b"), "\x61\162\147\163" => array("\146\x6f\162\x63\x65" => array("\164\x79\160\145" => "\x62\x6f\157\x6c\x65\x61\156", "\x64\145\x66\141\x75\x6c\164" => false, "\144\145\163\143\x72\x69\x70\164\x69\x6f\x6e" => __("\122\x65\161\x75\151\x72\145\x64\x20\x74\x6f\x20\142\x65\40\x74\162\165\145\54\x20\141\x73\x20\x74\145\x72\x6d\x73\40\144\x6f\x20\x6e\x6f\164\x20\x73\x75\x70\x70\157\x72\164\x20\164\162\141\x73\150\x69\x6e\x67\56")))), "\141\x6c\x6c\157\167\137\142\141\164\x63\150" => $this->allow_batch, "\163\143\x68\x65\155\x61" => array($this, "\x67\145\164\x5f\x70\x75\x62\x6c\151\x63\137\x69\164\x65\x6d\x5f\163\143\150\x65\x6d\x61"))); } 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 ("\145\144\x69\164" === $request["\143\157\x6e\x74\x65\170\164"] && !current_user_can($tax_obj->cap->edit_terms)) { return new WP_Error("\162\x65\x73\164\x5f\146\157\x72\x62\151\x64\x64\x65\156\x5f\x63\x6f\x6e\164\x65\170\164", __("\x53\x6f\x72\162\x79\x2c\40\171\157\165\40\141\162\145\40\x6e\157\164\40\141\x6c\154\157\x77\x65\144\x20\164\x6f\40\145\144\151\x74\40\164\x65\x72\155\163\40\x69\x6e\40\x74\x68\x69\x73\x20\164\141\170\x6f\156\x6f\x6d\x79\56"), array("\163\x74\141\x74\165\x73" => rest_authorization_required_code())); } return true; } public function get_items($request) { $registered = $this->get_collection_params(); $parameter_mappings = array("\145\x78\x63\154\x75\144\145" => "\x65\170\143\154\165\x64\145", "\151\156\x63\154\165\x64\145" => "\x69\x6e\143\154\x75\144\x65", "\157\162\144\x65\x72" => "\157\162\x64\x65\162", "\x6f\x72\144\145\162\142\171" => "\157\x72\x64\145\162\142\x79", "\x70\157\163\x74" => "\x70\x6f\163\x74", "\x68\151\x64\145\x5f\145\x6d\160\164\x79" => "\150\151\144\x65\x5f\145\x6d\x70\x74\171", "\160\x65\x72\137\160\141\x67\x65" => "\x6e\x75\x6d\142\x65\162", "\x73\145\x61\162\143\x68" => "\163\145\141\x72\x63\x68", "\x73\x6c\165\x67" => "\163\x6c\165\147"); $prepared_args = array("\x74\x61\x78\157\x6e\157\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["\157\x72\144\x65\x72\142\x79"]) && isset($request["\x6f\162\144\145\162\x62\x79"])) { $orderby_mappings = array("\x69\x6e\143\154\165\x64\x65\137\x73\154\x75\x67\x73" => "\163\154\x75\147\x5f\x5f\x69\156"); if (isset($orderby_mappings[$request["\x6f\162\144\145\162\142\x79"]])) { $prepared_args["\x6f\x72\144\x65\x72\142\171"] = $orderby_mappings[$request["\x6f\x72\x64\145\162\142\171"]]; } } if (isset($registered["\x6f\x66\x66\163\145\x74"]) && !empty($request["\x6f\146\146\163\x65\x74"])) { $prepared_args["\157\x66\146\x73\145\164"] = $request["\x6f\146\146\163\x65\164"]; } else { $prepared_args["\157\x66\146\163\145\x74"] = ($request["\x70\141\x67\x65"] - 1) * $prepared_args["\x6e\165\155\142\145\x72"]; } $taxonomy_obj = get_taxonomy($this->taxonomy); if ($taxonomy_obj->hierarchical && isset($registered["\x70\141\162\145\x6e\164"], $request["\x70\141\x72\x65\x6e\164"])) { if (0 === $request["\x70\x61\162\x65\156\164"]) { $prepared_args["\x70\x61\x72\x65\156\164"] = 0; } else { if ($request["\160\141\162\145\x6e\164"]) { $prepared_args["\x70\x61\x72\x65\156\x74"] = $request["\160\x61\162\145\x6e\x74"]; } } } $prepared_args = apply_filters("\162\145\x73\x74\137{$this->taxonomy}\137\161\165\145\162\x79", $prepared_args, $request); if (!empty($prepared_args["\160\157\163\x74"])) { $query_result = wp_get_object_terms($prepared_args["\160\x6f\163\164"], $this->taxonomy, $prepared_args); $prepared_args["\157\142\x6a\x65\143\164\x5f\151\x64\163"] = $prepared_args["\x70\157\163\x74"]; } else { $query_result = get_terms($prepared_args); } $count_args = $prepared_args; unset($count_args["\156\165\155\x62\x65\162"], $count_args["\x6f\146\146\x73\145\x74"]); $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\x75\155\x62\145\x72"]; $page = ceil((int) $prepared_args["\x6f\x66\x66\163\145\164"] / $per_page + 1); $response->header("\130\x2d\127\x50\x2d\x54\157\164\x61\x6c", (int) $total_terms); $max_pages = ceil($total_terms / $per_page); $response->header("\x58\55\x57\120\55\124\157\164\141\154\120\141\147\x65\x73", (int) $max_pages); $base = add_query_arg(urlencode_deep($request->get_query_params()), rest_url($this->namespace . "\57" . $this->rest_base)); if ($page > 1) { $prev_page = $page - 1; if ($prev_page > $max_pages) { $prev_page = $max_pages; } $prev_link = add_query_arg("\160\141\x67\x65", $prev_page, $base); $response->link_header("\x70\x72\145\x76", $prev_link); } if ($max_pages > $page) { $next_page = $page + 1; $next_link = add_query_arg("\160\141\147\145", $next_page, $base); $response->link_header("\x6e\145\170\164", $next_link); } return $response; } protected function get_term($id) { $error = new WP_Error("\x72\x65\163\x74\137\164\x65\162\x6d\x5f\151\156\x76\x61\154\x69\x64", __("\124\x65\162\x6d\x20\x64\157\145\x73\40\156\x6f\164\x20\145\170\x69\x73\164\x2e"), array("\163\x74\x61\x74\165\163" => 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["\x69\144"]); if (is_wp_error($term)) { return $term; } if ("\x65\144\151\164" === $request["\x63\x6f\156\x74\x65\x78\164"] && !current_user_can("\145\144\x69\x74\137\164\x65\x72\155", $term->term_id)) { return new WP_Error("\162\x65\x73\x74\137\x66\157\x72\x62\x69\x64\x64\x65\x6e\137\x63\157\156\x74\x65\x78\x74", __("\x53\x6f\162\162\x79\54\x20\x79\157\x75\x20\x61\x72\145\x20\156\x6f\164\x20\x61\x6c\x6c\157\x77\145\x64\x20\x74\157\40\145\144\x69\x74\x20\164\150\x69\163\x20\164\145\162\x6d\56"), array("\x73\164\141\164\165\163" => rest_authorization_required_code())); } return true; } public function get_item($request) { $term = $this->get_term($request["\151\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("\x72\145\x73\164\137\143\141\x6e\156\157\x74\x5f\x63\162\x65\x61\164\x65", __("\x53\157\162\x72\171\x2c\40\x79\157\x75\40\141\x72\x65\40\156\x6f\164\x20\x61\154\x6c\x6f\167\145\x64\40\x74\x6f\40\143\x72\145\141\164\x65\40\x74\145\x72\155\x73\x20\x69\x6e\40\164\150\151\163\x20\164\x61\x78\157\x6e\157\x6d\x79\56"), array("\x73\x74\141\164\165\163" => rest_authorization_required_code())); } return true; } public function create_item($request) { if (isset($request["\x70\141\x72\x65\156\x74"])) { if (!is_taxonomy_hierarchical($this->taxonomy)) { return new WP_Error("\x72\x65\x73\164\137\x74\141\x78\157\x6e\x6f\x6d\x79\x5f\156\x6f\164\x5f\150\151\145\x72\141\x72\143\150\151\x63\141\154", __("\x43\141\156\156\157\164\40\x73\145\x74\40\x70\x61\162\145\156\164\40\x74\145\x72\x6d\x2c\40\164\141\170\x6f\x6e\x6f\x6d\x79\x20\x69\163\40\156\x6f\x74\x20\x68\x69\x65\162\141\x72\143\x68\151\x63\141\x6c\56"), array("\163\164\x61\x74\165\x73" => 400)); } $parent = get_term((int) $request["\x70\x61\x72\x65\x6e\x74"], $this->taxonomy); if (!$parent) { return new WP_Error("\162\x65\163\x74\x5f\164\x65\x72\x6d\x5f\151\x6e\x76\141\154\x69\144", __("\120\141\162\145\x6e\164\x20\x74\x65\162\x6d\x20\x64\157\x65\163\40\x6e\x6f\x74\40\x65\x78\151\163\164\56"), 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("\164\x65\x72\155\x5f\x65\170\151\163\164\x73"); if ($term_id) { $existing_term = get_term($term_id, $this->taxonomy); $term->add_data($existing_term->term_id, "\164\145\x72\155\137\x65\x78\151\163\164\x73"); $term->add_data(array("\163\164\x61\164\165\x73" => 400, "\164\x65\x72\155\137\151\144" => $term_id)); } return $term; } $term = get_term($term["\164\145\x72\155\x5f\151\144"], $this->taxonomy); do_action("\x72\x65\x73\x74\x5f\x69\156\163\x65\x72\164\137{$this->taxonomy}", $term, $request, true); $schema = $this->get_item_schema(); if (!empty($schema["\x70\162\157\x70\145\x72\164\x69\145\163"]["\155\x65\164\141"]) && isset($request["\155\x65\x74\141"])) { $meta_update = $this->meta->update_value($request["\x6d\145\x74\x61"], $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\x6f\x6e\164\145\x78\x74", "\145\144\x69\x74"); do_action("\162\145\x73\x74\137\x61\x66\164\x65\x72\137\x69\156\163\145\162\x74\x5f{$this->taxonomy}", $term, $request, true); $response = $this->prepare_item_for_response($term, $request); $response = rest_ensure_response($response); $response->set_status(201); $response->header("\x4c\x6f\143\141\x74\151\x6f\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\144"]); if (is_wp_error($term)) { return $term; } if (!current_user_can("\x65\144\x69\x74\x5f\164\x65\x72\x6d", $term->term_id)) { return new WP_Error("\x72\145\163\x74\137\143\x61\x6e\x6e\x6f\x74\x5f\x75\160\x64\x61\164\145", __("\x53\x6f\x72\162\x79\x2c\40\x79\157\165\x20\141\162\x65\40\x6e\x6f\x74\x20\x61\154\154\157\x77\145\144\x20\x74\x6f\40\145\144\x69\x74\x20\x74\150\x69\163\40\x74\x65\162\155\x2e"), array("\x73\x74\x61\164\165\x73" => rest_authorization_required_code())); } return true; } public function update_item($request) { $term = $this->get_term($request["\x69\x64"]); if (is_wp_error($term)) { return $term; } if (isset($request["\160\x61\162\x65\x6e\164"])) { if (!is_taxonomy_hierarchical($this->taxonomy)) { return new WP_Error("\x72\145\x73\x74\x5f\x74\141\x78\x6f\156\157\155\171\x5f\x6e\x6f\164\137\150\x69\145\162\x61\162\143\150\x69\x63\141\x6c", __("\103\141\156\x6e\x6f\164\x20\163\145\x74\x20\160\x61\x72\x65\x6e\164\40\x74\x65\162\x6d\x2c\40\x74\141\170\x6f\x6e\157\x6d\171\x20\151\x73\40\x6e\157\164\40\150\151\145\162\x61\x72\143\x68\x69\143\141\154\x2e"), array("\x73\x74\141\164\165\163" => 400)); } $parent = get_term((int) $request["\x70\141\x72\x65\x6e\164"], $this->taxonomy); if (!$parent) { return new WP_Error("\162\145\163\164\137\164\145\162\x6d\137\151\156\x76\x61\x6c\151\x64", __("\x50\141\x72\145\x6e\x74\40\x74\145\162\155\x20\x64\157\x65\x73\x20\156\x6f\164\x20\145\x78\151\x73\x74\56"), array("\x73\x74\x61\x74\x75\x73" => 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\x73\164\137\151\156\x73\x65\x72\x74\x5f{$this->taxonomy}", $term, $request, false); $schema = $this->get_item_schema(); if (!empty($schema["\x70\162\157\x70\x65\x72\164\x69\145\x73"]["\155\x65\164\141"]) && isset($request["\155\x65\164\141"])) { $meta_update = $this->meta->update_value($request["\155\x65\164\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\x6f\156\164\x65\170\164", "\145\144\151\164"); do_action("\162\145\x73\x74\137\x61\x66\164\x65\162\x5f\x69\x6e\x73\145\162\x74\x5f{$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["\x69\144"]); if (is_wp_error($term)) { return $term; } if (!current_user_can("\144\x65\x6c\x65\x74\x65\x5f\x74\x65\x72\x6d", $term->term_id)) { return new WP_Error("\x72\x65\x73\x74\x5f\x63\141\156\x6e\x6f\x74\137\x64\x65\154\x65\x74\x65", __("\x53\x6f\x72\x72\171\x2c\x20\x79\157\165\x20\141\x72\145\40\156\x6f\x74\40\141\154\x6c\157\x77\x65\144\x20\x74\157\40\144\x65\154\145\x74\x65\40\x74\150\151\x73\x20\164\x65\x72\x6d\x2e"), array("\163\164\141\164\x75\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\x6f\x72\143\x65"]) ? (bool) $request["\x66\157\162\143\145"] : false; if (!$force) { return new WP_Error("\x72\x65\163\x74\x5f\164\x72\141\163\x68\137\156\x6f\x74\x5f\x73\x75\x70\160\x6f\162\164\145\x64", sprintf(__("\x54\145\162\155\163\x20\x64\157\x20\x6e\157\164\40\163\165\160\160\x6f\162\x74\40\164\x72\141\163\x68\151\156\147\56\x20\x53\x65\x74\40\x27\45\163\47\x20\x74\x6f\40\144\x65\154\145\x74\x65\x2e"), "\x66\x6f\162\143\145\x3d\164\x72\x75\x65"), array("\163\164\x61\x74\x75\163" => 501)); } $request->set_param("\x63\157\x6e\x74\x65\x78\x74", "\166\151\x65\x77"); $previous = $this->prepare_item_for_response($term, $request); $retval = wp_delete_term($term->term_id, $term->taxonomy); if (!$retval) { return new WP_Error("\x72\x65\163\164\x5f\143\141\156\x6e\x6f\x74\137\144\145\154\145\x74\x65", __("\x54\150\x65\x20\x74\x65\162\155\40\x63\141\156\156\x6f\x74\40\x62\x65\x20\x64\x65\x6c\x65\x74\x65\144\56"), array("\x73\x74\x61\x74\165\x73" => 500)); } $response = new WP_REST_Response(); $response->set_data(array("\144\145\154\145\164\x65\144" => true, "\160\162\x65\x76\151\x6f\x75\163" => $previous->get_data())); do_action("\x72\x65\163\x74\137\144\x65\x6c\145\x74\145\137{$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["\156\141\x6d\x65"]) && !empty($schema["\160\162\157\x70\145\x72\164\x69\145\x73"]["\x6e\x61\x6d\145"])) { $prepared_term->name = $request["\x6e\x61\x6d\145"]; } if (isset($request["\163\x6c\165\x67"]) && !empty($schema["\160\x72\x6f\160\x65\162\x74\x69\x65\x73"]["\163\x6c\165\x67"])) { $prepared_term->slug = $request["\163\154\x75\147"]; } if (isset($request["\164\x61\x78\157\x6e\x6f\155\x79"]) && !empty($schema["\x70\162\x6f\160\x65\x72\164\x69\145\x73"]["\164\x61\170\x6f\156\x6f\155\x79"])) { $prepared_term->taxonomy = $request["\x74\x61\x78\157\x6e\157\155\x79"]; } if (isset($request["\144\145\163\143\x72\151\x70\x74\151\157\156"]) && !empty($schema["\x70\x72\157\x70\145\162\x74\151\145\163"]["\144\x65\x73\143\x72\x69\x70\x74\151\157\x6e"])) { $prepared_term->description = $request["\x64\x65\163\143\x72\x69\x70\164\151\x6f\156"]; } if (isset($request["\160\x61\x72\x65\x6e\x74"]) && !empty($schema["\x70\162\157\160\145\x72\x74\151\145\x73"]["\x70\141\x72\x65\156\x74"])) { $parent_term_id = 0; $requested_parent = (int) $request["\160\x61\x72\x65\x6e\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\x73\x74\137\x70\162\145\137\151\156\163\145\x72\164\137{$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("\x69\x64", $fields, true)) { $data["\x69\144"] = (int) $item->term_id; } if (in_array("\x63\x6f\165\x6e\164", $fields, true)) { $data["\x63\x6f\x75\x6e\164"] = (int) $item->count; } if (in_array("\x64\145\163\x63\x72\151\x70\x74\151\157\x6e", $fields, true)) { $data["\x64\x65\163\143\162\151\160\164\x69\x6f\156"] = $item->description; } if (in_array("\x6c\x69\156\x6b", $fields, true)) { $data["\154\x69\156\153"] = get_term_link($item); } if (in_array("\156\x61\155\x65", $fields, true)) { $data["\x6e\141\x6d\145"] = $item->name; } if (in_array("\163\154\165\x67", $fields, true)) { $data["\x73\x6c\165\x67"] = $item->slug; } if (in_array("\x74\141\x78\x6f\x6e\x6f\x6d\x79", $fields, true)) { $data["\x74\141\170\x6f\x6e\157\155\171"] = $item->taxonomy; } if (in_array("\x70\141\x72\145\x6e\x74", $fields, true)) { $data["\x70\141\162\145\156\x74"] = (int) $item->parent; } if (in_array("\155\x65\x74\141", $fields, true)) { $data["\155\145\164\x61"] = $this->meta->get_value($item->term_id, $request); } $context = !empty($request["\143\157\156\164\x65\170\x74"]) ? $request["\x63\157\156\x74\145\170\x74"] : "\166\x69\x65\x77"; $data = $this->add_additional_fields_to_object($data, $request); $data = $this->filter_response_by_context($data, $context); $response = rest_ensure_response($data); $response->add_links($this->prepare_links($item)); return apply_filters("\162\x65\x73\x74\x5f\160\x72\145\x70\141\162\x65\137{$this->taxonomy}", $response, $item, $request); } protected function prepare_links($term) { $base = $this->namespace . "\x2f" . $this->rest_base; $links = array("\163\145\154\146" => array("\x68\162\x65\146" => rest_url(trailingslashit($base) . $term->term_id)), "\143\157\154\154\x65\143\x74\x69\x6f\156" => array("\150\162\145\146" => rest_url($base)), "\x61\x62\157\x75\x74" => array("\150\x72\145\x66" => rest_url(sprintf("\167\160\57\166\x32\x2f\x74\x61\170\x6f\x6e\x6f\x6d\x69\145\163\57\x25\163", $this->taxonomy)))); if ($term->parent) { $parent_term = get_term((int) $term->parent, $term->taxonomy); if ($parent_term) { $links["\165\160"] = array("\150\x72\x65\146" => rest_url(trailingslashit($base) . $parent_term->term_id), "\x65\155\142\x65\144\144\x61\x62\x6c\x65" => 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("\x68\x72\x65\146" => add_query_arg($this->rest_base, $term->term_id, rest_url($rest_path))); } if (!empty($post_type_links)) { $links["\x68\164\164\x70\x73\72\57\57\141\x70\151\56\167\56\157\x72\x67\57\160\157\x73\x74\137\164\x79\160\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\x73\143\x68\x65\x6d\141" => "\x68\164\164\160\72\57\x2f\152\x73\x6f\x6e\x2d\x73\x63\150\x65\x6d\141\56\x6f\x72\x67\57\x64\x72\141\146\x74\x2d\60\x34\57\x73\x63\x68\145\x6d\x61\43", "\164\x69\164\x6c\145" => "\x70\157\x73\x74\x5f\x74\x61\x67" === $this->taxonomy ? "\164\141\147" : $this->taxonomy, "\164\171\160\x65" => "\157\142\152\x65\x63\164", "\160\x72\x6f\x70\x65\162\x74\x69\x65\x73" => array("\x69\x64" => array("\144\145\163\143\162\x69\160\164\151\157\156" => __("\125\156\x69\x71\165\145\40\151\x64\145\x6e\164\x69\x66\151\x65\x72\x20\x66\157\162\40\164\x68\x65\40\164\145\162\x6d\x2e"), "\164\x79\160\145" => "\x69\x6e\x74\x65\147\145\162", "\x63\157\156\164\145\x78\x74" => array("\x76\151\x65\167", "\x65\x6d\x62\x65\x64", "\145\144\151\164"), "\x72\x65\x61\144\157\x6e\x6c\x79" => true), "\x63\157\x75\x6e\164" => array("\x64\145\x73\143\x72\151\160\x74\151\x6f\x6e" => __("\x4e\x75\155\142\145\162\40\x6f\146\x20\160\165\x62\x6c\x69\163\150\x65\144\40\160\x6f\163\x74\x73\x20\x66\x6f\x72\40\164\150\145\40\164\x65\162\x6d\56"), "\164\171\160\145" => "\x69\156\164\145\x67\145\x72", "\143\x6f\x6e\x74\x65\x78\164" => array("\166\x69\145\167", "\x65\144\x69\164"), "\162\x65\141\144\157\156\154\171" => true), "\x64\145\x73\x63\162\151\160\x74\x69\157\156" => array("\144\x65\x73\x63\162\151\x70\x74\x69\157\x6e" => __("\x48\124\x4d\x4c\40\144\145\163\x63\162\151\160\164\x69\x6f\x6e\40\x6f\x66\40\164\150\x65\x20\164\x65\x72\155\x2e"), "\x74\x79\160\145" => "\x73\x74\162\151\156\147", "\143\157\156\164\145\170\x74" => array("\166\x69\x65\167", "\145\144\x69\x74")), "\154\151\156\x6b" => array("\x64\x65\x73\x63\162\151\160\x74\151\157\156" => __("\125\x52\114\40\x6f\146\x20\x74\150\145\40\x74\x65\162\155\x2e"), "\164\171\x70\145" => "\163\164\x72\x69\x6e\x67", "\x66\157\162\x6d\141\x74" => "\x75\x72\151", "\143\x6f\x6e\x74\x65\x78\164" => array("\x76\151\145\x77", "\x65\x6d\142\x65\x64", "\145\x64\x69\x74"), "\162\145\141\x64\157\x6e\154\x79" => true), "\156\x61\x6d\x65" => array("\144\145\x73\143\162\x69\160\x74\151\157\156" => __("\110\124\x4d\x4c\40\164\x69\x74\x6c\x65\x20\146\x6f\x72\x20\x74\x68\x65\x20\x74\145\162\x6d\x2e"), "\164\171\160\145" => "\x73\x74\x72\151\x6e\x67", "\x63\157\x6e\x74\x65\x78\x74" => array("\166\x69\x65\167", "\145\x6d\142\145\x64", "\145\x64\x69\x74"), "\x61\x72\147\x5f\x6f\x70\x74\151\x6f\x6e\x73" => array("\163\x61\x6e\x69\164\151\x7a\x65\x5f\143\x61\x6c\x6c\142\x61\143\x6b" => "\163\141\156\151\x74\151\172\x65\137\164\x65\x78\x74\137\146\x69\x65\x6c\x64"), "\x72\x65\161\165\x69\x72\145\x64" => true), "\163\154\x75\x67" => array("\x64\x65\x73\x63\x72\x69\160\164\151\157\x6e" => __("\101\156\x20\141\154\x70\150\141\156\x75\155\x65\162\x69\x63\x20\151\x64\x65\x6e\164\151\146\x69\145\x72\x20\146\x6f\162\40\164\150\x65\x20\164\145\162\x6d\40\165\156\151\x71\x75\x65\x20\164\x6f\x20\151\x74\x73\40\164\171\x70\x65\56"), "\164\171\160\145" => "\163\x74\x72\151\x6e\147", "\x63\x6f\x6e\x74\x65\170\164" => array("\x76\151\145\x77", "\x65\x6d\x62\145\144", "\145\x64\151\x74"), "\x61\x72\147\x5f\157\160\164\x69\157\156\x73" => array("\x73\141\x6e\x69\164\x69\172\145\137\143\141\154\154\142\x61\x63\153" => array($this, "\163\141\x6e\x69\x74\x69\x7a\x65\x5f\x73\154\x75\x67"))), "\164\x61\170\x6f\156\x6f\x6d\x79" => array("\144\145\x73\143\162\x69\160\164\x69\157\x6e" => __("\124\x79\160\x65\40\x61\164\x74\162\x69\x62\165\x74\x69\x6f\x6e\40\146\x6f\162\x20\164\150\145\40\164\x65\162\x6d\x2e"), "\x74\171\160\x65" => "\x73\164\162\151\156\147", "\x65\156\x75\155" => array($this->taxonomy), "\x63\x6f\x6e\x74\x65\x78\164" => array("\166\x69\x65\x77", "\145\x6d\x62\145\144", "\x65\x64\151\164"), "\162\145\x61\144\x6f\156\154\171" => true))); $taxonomy = get_taxonomy($this->taxonomy); if ($taxonomy->hierarchical) { $schema["\x70\x72\x6f\x70\x65\162\164\x69\145\163"]["\160\x61\x72\x65\x6e\x74"] = array("\x64\x65\163\143\162\x69\160\x74\151\157\156" => __("\124\x68\145\x20\x70\141\162\x65\156\x74\x20\x74\145\x72\155\40\x49\104\x2e"), "\164\171\x70\x65" => "\151\156\164\145\x67\x65\162", "\x63\157\x6e\x74\145\170\164" => array("\x76\151\x65\x77", "\145\144\x69\x74")); } $schema["\x70\162\x6f\x70\x65\x72\164\x69\145\163"]["\155\x65\164\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\157\x6e\164\x65\170\x74"]["\x64\145\x66\x61\165\154\x74"] = "\166\151\145\167"; $query_params["\x65\170\143\154\165\144\145"] = array("\x64\145\163\143\x72\x69\160\164\x69\x6f\156" => __("\105\x6e\x73\x75\x72\145\40\162\x65\x73\165\x6c\164\x20\x73\x65\164\40\145\170\143\x6c\x75\144\x65\163\40\x73\x70\145\x63\x69\x66\x69\x63\x20\x49\x44\x73\x2e"), "\x74\171\x70\x65" => "\x61\x72\x72\x61\x79", "\x69\x74\x65\155\163" => array("\164\171\x70\145" => "\x69\156\164\145\x67\145\162"), "\x64\145\146\x61\x75\x6c\164" => array()); $query_params["\151\x6e\143\154\x75\144\145"] = array("\144\x65\163\143\162\151\160\164\x69\x6f\x6e" => __("\114\x69\155\x69\x74\40\x72\145\163\x75\x6c\x74\40\163\x65\x74\x20\x74\157\40\163\x70\145\x63\151\x66\151\143\x20\111\104\163\x2e"), "\x74\171\x70\145" => "\141\x72\162\x61\x79", "\151\x74\x65\155\x73" => array("\164\x79\160\145" => "\151\156\164\145\147\145\162"), "\x64\145\x66\x61\165\154\x74" => array()); if (!$taxonomy->hierarchical) { $query_params["\x6f\146\x66\163\145\164"] = array("\144\x65\x73\143\162\x69\x70\164\151\157\x6e" => __("\117\x66\146\x73\x65\164\x20\x74\150\145\40\162\x65\163\165\x6c\164\x20\x73\x65\x74\40\x62\171\40\x61\40\163\160\x65\143\x69\146\x69\143\40\x6e\x75\x6d\x62\x65\x72\x20\157\146\40\151\x74\x65\155\x73\x2e"), "\164\x79\x70\145" => "\151\156\164\145\147\145\162"); } $query_params["\157\162\x64\x65\162"] = array("\144\x65\x73\143\x72\151\160\x74\x69\x6f\x6e" => __("\117\x72\x64\x65\162\x20\163\x6f\162\x74\40\141\164\164\162\151\x62\x75\164\x65\x20\x61\x73\x63\x65\156\x64\151\x6e\147\40\157\162\40\x64\145\163\x63\x65\x6e\x64\x69\156\147\x2e"), "\x74\x79\160\x65" => "\163\164\x72\151\156\x67", "\144\x65\x66\x61\165\x6c\164" => "\x61\163\143", "\145\x6e\165\x6d" => array("\141\x73\143", "\x64\145\163\143")); $query_params["\x6f\x72\x64\145\x72\142\x79"] = array("\x64\145\x73\143\162\151\160\x74\151\157\156" => __("\123\x6f\x72\164\40\x63\157\154\x6c\145\143\x74\x69\157\x6e\x20\x62\x79\x20\164\145\x72\x6d\40\x61\x74\164\x72\x69\x62\x75\x74\x65\56"), "\164\x79\x70\x65" => "\163\164\x72\151\x6e\147", "\x64\x65\146\x61\165\x6c\164" => "\x6e\141\x6d\x65", "\x65\x6e\165\155" => array("\x69\x64", "\151\156\143\x6c\x75\x64\x65", "\156\141\155\x65", "\x73\x6c\165\147", "\x69\156\143\154\x75\144\x65\x5f\x73\154\x75\147\x73", "\x74\x65\162\x6d\137\x67\x72\x6f\165\x70", "\x64\145\x73\143\x72\x69\160\164\151\157\156", "\x63\x6f\x75\156\164")); $query_params["\150\151\144\x65\x5f\x65\155\x70\x74\x79"] = array("\144\x65\x73\143\x72\x69\160\164\x69\157\x6e" => __("\127\x68\145\164\x68\145\x72\x20\164\157\40\x68\151\x64\x65\40\x74\x65\162\x6d\x73\x20\x6e\157\x74\40\141\163\163\151\x67\156\145\144\40\x74\157\x20\141\x6e\x79\40\x70\x6f\163\x74\163\56"), "\x74\x79\x70\145" => "\142\x6f\157\x6c\x65\x61\156", "\x64\x65\146\x61\x75\x6c\164" => false); if ($taxonomy->hierarchical) { $query_params["\x70\141\162\145\156\164"] = array("\x64\x65\x73\x63\162\151\160\164\x69\157\x6e" => __("\x4c\151\x6d\151\164\x20\162\145\x73\165\154\x74\40\163\x65\164\x20\x74\157\40\x74\x65\x72\x6d\x73\40\x61\163\x73\151\147\156\x65\144\x20\164\157\x20\x61\x20\163\160\x65\x63\x69\146\151\143\40\x70\141\162\x65\156\164\x2e"), "\x74\x79\x70\145" => "\151\x6e\x74\x65\x67\145\162"); } $query_params["\160\157\163\164"] = array("\144\145\163\x63\x72\x69\160\x74\151\x6f\156" => __("\x4c\151\x6d\x69\x74\x20\x72\145\x73\x75\x6c\x74\40\x73\145\x74\40\164\157\x20\x74\145\162\155\163\x20\141\163\163\x69\147\156\145\x64\40\164\x6f\x20\141\40\163\160\145\x63\151\146\151\143\40\160\157\x73\164\x2e"), "\164\171\160\145" => "\x69\156\x74\x65\147\x65\x72", "\x64\145\146\x61\x75\154\x74" => null); $query_params["\163\154\165\147"] = array("\144\145\163\143\x72\x69\160\164\151\x6f\x6e" => __("\x4c\151\x6d\151\164\x20\162\x65\x73\165\154\164\x20\163\145\164\x20\x74\x6f\40\164\145\162\x6d\x73\x20\x77\x69\164\x68\40\x6f\x6e\145\x20\157\162\x20\x6d\157\x72\145\40\x73\x70\145\143\x69\x66\151\x63\40\x73\154\x75\147\163\56"), "\164\x79\x70\145" => "\x61\162\x72\141\171", "\151\x74\145\155\x73" => array("\x74\x79\x70\x65" => "\x73\x74\x72\x69\x6e\147")); return apply_filters("\162\145\x73\164\137{$this->taxonomy}\x5f\143\157\154\x6c\x65\143\164\151\157\156\137\x70\141\162\x61\155\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 | 23b03c4ab76b1954db4c88194f083567 |
Eval Count | 0 |
Decode Time | 134 ms |