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 defined("\x41\102\x53\x50\101\x54\x48") || die; class WC_REST_Product_Reviews_Contr..

Decoded Output download

<?php
 defined("ABSPATH") || die; class WC_REST_Product_Reviews_Controller extends WC_REST_Controller { protected $namespace = "wc/v3"; protected $rest_base = "products/reviews"; 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" => array_merge($this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE), array("product_id" => array("required" => true, "description" => __("Unique identifier for the product.", "woocommerce"), "type" => "integer"), "review" => array("required" => true, "type" => "string", "description" => __("Review content.", "woocommerce")), "reviewer" => array("required" => true, "type" => "string", "description" => __("Name of the reviewer.", "woocommerce")), "reviewer_email" => array("required" => true, "type" => "string", "description" => __("Email of the reviewer.", "woocommerce"))))), "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 resource.", "woocommerce"), "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("default" => false, "type" => "boolean", "description" => __("Whether to bypass trash and force deletion.", "woocommerce")))), "schema" => array($this, "get_public_item_schema"))); register_rest_route($this->namespace, "/" . $this->rest_base . "/batch", array(array("methods" => WP_REST_Server::EDITABLE, "callback" => array($this, "batch_items"), "permission_callback" => array($this, "batch_items_permissions_check"), "args" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE)), "schema" => array($this, "get_public_batch_schema"))); } public function get_items_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("read")) { return new WP_Error("woocommerce_rest_cannot_view", __("Sorry, you cannot list resources.", "woocommerce"), array("status" => rest_authorization_required_code())); } return true; } public function get_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("read", (int) $request["id"])) { return new WP_Error("woocommerce_rest_cannot_view", __("Sorry, you cannot view this resource.", "woocommerce"), array("status" => rest_authorization_required_code())); } return true; } public function create_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("create")) { return new WP_Error("woocommerce_rest_cannot_create", __("Sorry, you are not allowed to create resources.", "woocommerce"), array("status" => rest_authorization_required_code())); } return true; } public function update_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("edit", (int) $request["id"])) { return new WP_Error("woocommerce_rest_cannot_edit", __("Sorry, you cannot edit this resource.", "woocommerce"), array("status" => rest_authorization_required_code())); } return true; } public function delete_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("delete", (int) $request["id"])) { return new WP_Error("woocommerce_rest_cannot_delete", __("Sorry, you cannot delete this resource.", "woocommerce"), array("status" => rest_authorization_required_code())); } return true; } public function batch_items_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("batch")) { return new WP_Error("woocommerce_rest_cannot_batch", __("Sorry, you are not allowed to batch manipulate this resource.", "woocommerce"), array("status" => rest_authorization_required_code())); } return true; } public function get_items($request) { $registered = $this->get_collection_params(); $parameter_mappings = array("reviewer" => "author__in", "reviewer_email" => "author_email", "reviewer_exclude" => "author__not_in", "exclude" => "comment__not_in", "include" => "comment__in", "offset" => "offset", "order" => "order", "per_page" => "number", "product" => "post__in", "search" => "search", "status" => "status"); $prepared_args = array(); foreach ($parameter_mappings as $api_param => $wp_param) { if (isset($registered[$api_param], $request[$api_param])) { $prepared_args[$wp_param] = $request[$api_param]; } } foreach (array("author_email", "search") as $param) { if (!isset($prepared_args[$param])) { $prepared_args[$param] = ''; } } if (isset($registered["orderby"])) { $prepared_args["orderby"] = $this->normalize_query_param($request["orderby"]); } if (isset($prepared_args["status"])) { $prepared_args["status"] = "approved" === $prepared_args["status"] ? "approve" : $prepared_args["status"]; } $prepared_args["no_found_rows"] = false; $prepared_args["date_query"] = array(); if (isset($registered["before"], $request["before"])) { $prepared_args["date_query"][0]["before"] = $request["before"]; } if (isset($registered["after"], $request["after"])) { $prepared_args["date_query"][0]["after"] = $request["after"]; } if (isset($registered["page"]) && empty($request["offset"])) { $prepared_args["offset"] = $prepared_args["number"] * (absint($request["page"]) - 1); } $prepared_args = apply_filters("woocommerce_rest_product_review_query", $prepared_args, $request); $prepared_args["type"] = "review"; $query = new WP_Comment_Query(); $query_result = $query->query($prepared_args); $reviews = array(); foreach ($query_result as $review) { if (!wc_rest_check_product_reviews_permissions("read", $review->comment_ID)) { continue; } $data = $this->prepare_item_for_response($review, $request); $reviews[] = $this->prepare_response_for_collection($data); } $total_reviews = (int) $query->found_comments; $max_pages = (int) $query->max_num_pages; if ($total_reviews < 1) { unset($prepared_args["number"], $prepared_args["offset"]); $query = new WP_Comment_Query(); $prepared_args["count"] = true; $total_reviews = $query->query($prepared_args); $max_pages = ceil($total_reviews / $request["per_page"]); } $response = rest_ensure_response($reviews); $response->header("X-WP-Total", $total_reviews); $response->header("X-WP-TotalPages", $max_pages); $base = add_query_arg($request->get_query_params(), rest_url(sprintf("%s/%s", $this->namespace, $this->rest_base))); if ($request["page"] > 1) { $prev_page = $request["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 > $request["page"]) { $next_page = $request["page"] + 1; $next_link = add_query_arg("page", $next_page, $base); $response->link_header("next", $next_link); } return $response; } public function create_item($request) { if (!empty($request["id"])) { return new WP_Error("woocommerce_rest_review_exists", __("Cannot create existing product review.", "woocommerce"), array("status" => 400)); } $product_id = (int) $request["product_id"]; if ("product" !== get_post_type($product_id)) { return new WP_Error("woocommerce_rest_product_invalid_id", __("Invalid product ID.", "woocommerce"), array("status" => 404)); } $prepared_review = $this->prepare_item_for_database($request); if (is_wp_error($prepared_review)) { return $prepared_review; } $prepared_review["comment_type"] = "review"; if (empty($prepared_review["comment_content"])) { return new WP_Error("woocommerce_rest_review_content_invalid", __("Invalid review content.", "woocommerce"), array("status" => 400)); } if (!isset($prepared_review["comment_date_gmt"])) { $prepared_review["comment_date_gmt"] = current_time("mysql", true); } if (!empty($_SERVER["REMOTE_ADDR"]) && rest_is_ip_address(wp_unslash($_SERVER["REMOTE_ADDR"]))) { $prepared_review["comment_author_IP"] = wc_clean(wp_unslash($_SERVER["REMOTE_ADDR"])); } else { $prepared_review["comment_author_IP"] = "127.0.0.1"; } if (!empty($request["author_user_agent"])) { $prepared_review["comment_agent"] = $request["author_user_agent"]; } elseif ($request->get_header("user_agent")) { $prepared_review["comment_agent"] = $request->get_header("user_agent"); } else { $prepared_review["comment_agent"] = ''; } $check_comment_lengths = wp_check_comment_data_max_lengths($prepared_review); if (is_wp_error($check_comment_lengths)) { $error_code = str_replace(array("comment_author", "comment_content"), array("reviewer", "review_content"), $check_comment_lengths->get_error_code()); return new WP_Error("woocommerce_rest_" . $error_code, __("Product review field exceeds maximum length allowed.", "woocommerce"), array("status" => 400)); } $prepared_review["comment_parent"] = 0; $prepared_review["comment_author_url"] = ''; $prepared_review["comment_approved"] = wp_allow_comment($prepared_review, true); if (is_wp_error($prepared_review["comment_approved"])) { $error_code = $prepared_review["comment_approved"]->get_error_code(); $error_message = $prepared_review["comment_approved"]->get_error_message(); if ("comment_duplicate" === $error_code) { return new WP_Error("woocommerce_rest_" . $error_code, $error_message, array("status" => 409)); } if ("comment_flood" === $error_code) { return new WP_Error("woocommerce_rest_" . $error_code, $error_message, array("status" => 400)); } return $prepared_review["comment_approved"]; } $prepared_review = apply_filters("woocommerce_rest_pre_insert_product_review", $prepared_review, $request); if (is_wp_error($prepared_review)) { return $prepared_review; } $review_id = wp_insert_comment(wp_filter_comment(wp_slash((array) $prepared_review))); if (!$review_id) { return new WP_Error("woocommerce_rest_review_failed_create", __("Creating product review failed.", "woocommerce"), array("status" => 500)); } if (isset($request["status"])) { $this->handle_status_param($request["status"], $review_id); } update_comment_meta($review_id, "rating", !empty($request["rating"]) ? $request["rating"] : "0"); $review = get_comment($review_id); do_action("woocommerce_rest_insert_product_review", $review, $request, true); $fields_update = $this->update_additional_fields_for_object($review, $request); if (is_wp_error($fields_update)) { return $fields_update; } $context = current_user_can("moderate_comments") ? "edit" : "view"; $request->set_param("context", $context); $response = $this->prepare_item_for_response($review, $request); $response = rest_ensure_response($response); $response->set_status(201); $response->header("Location", rest_url(sprintf("%s/%s/%d", $this->namespace, $this->rest_base, $review_id))); return $response; } public function get_item($request) { $review = $this->get_review($request["id"]); if (is_wp_error($review)) { return $review; } $data = $this->prepare_item_for_response($review, $request); $response = rest_ensure_response($data); return $response; } public function update_item($request) { $review = $this->get_review($request["id"]); if (is_wp_error($review)) { return $review; } $id = (int) $review->comment_ID; if (isset($request["type"]) && "review" !== get_comment_type($id)) { return new WP_Error("woocommerce_rest_review_invalid_type", __("Sorry, you are not allowed to change the comment type.", "woocommerce"), array("status" => 404)); } $prepared_args = $this->prepare_item_for_database($request); if (is_wp_error($prepared_args)) { return $prepared_args; } if (!empty($prepared_args["comment_post_ID"])) { if ("product" !== get_post_type((int) $prepared_args["comment_post_ID"])) { return new WP_Error("woocommerce_rest_product_invalid_id", __("Invalid product ID.", "woocommerce"), array("status" => 404)); } } if (empty($prepared_args) && isset($request["status"])) { $change = $this->handle_status_param($request["status"], $id); if (!$change) { return new WP_Error("woocommerce_rest_review_failed_edit", __("Updating review status failed.", "woocommerce"), array("status" => 500)); } } elseif (!empty($prepared_args)) { if (is_wp_error($prepared_args)) { return $prepared_args; } if (isset($prepared_args["comment_content"]) && empty($prepared_args["comment_content"])) { return new WP_Error("woocommerce_rest_review_content_invalid", __("Invalid review content.", "woocommerce"), array("status" => 400)); } $prepared_args["comment_ID"] = $id; $check_comment_lengths = wp_check_comment_data_max_lengths($prepared_args); if (is_wp_error($check_comment_lengths)) { $error_code = str_replace(array("comment_author", "comment_content"), array("reviewer", "review_content"), $check_comment_lengths->get_error_code()); return new WP_Error("woocommerce_rest_" . $error_code, __("Product review field exceeds maximum length allowed.", "woocommerce"), array("status" => 400)); } $updated = wp_update_comment(wp_slash((array) $prepared_args)); if (false === $updated) { return new WP_Error("woocommerce_rest_comment_failed_edit", __("Updating review failed.", "woocommerce"), array("status" => 500)); } if (isset($request["status"])) { $this->handle_status_param($request["status"], $id); } } if (!empty($request["rating"])) { update_comment_meta($id, "rating", $request["rating"]); } $review = get_comment($id); do_action("woocommerce_rest_insert_product_review", $review, $request, false); $fields_update = $this->update_additional_fields_for_object($review, $request); if (is_wp_error($fields_update)) { return $fields_update; } $request->set_param("context", "edit"); $response = $this->prepare_item_for_response($review, $request); return rest_ensure_response($response); } public function delete_item($request) { $review = $this->get_review($request["id"]); if (is_wp_error($review)) { return $review; } $force = isset($request["force"]) ? (bool) $request["force"] : false; $supports_trash = apply_filters("woocommerce_rest_product_review_trashable", EMPTY_TRASH_DAYS > 0, $review); $request->set_param("context", "edit"); if ($force) { $previous = $this->prepare_item_for_response($review, $request); $result = wp_delete_comment($review->comment_ID, true); $response = new WP_REST_Response(); $response->set_data(array("deleted" => true, "previous" => $previous->get_data())); } else { if (!$supports_trash) { return new WP_Error("woocommerce_rest_trash_not_supported", sprintf(__("The object does not support trashing. Set '%s' to delete.", "woocommerce"), "force=true"), array("status" => 501)); } if ("trash" === $review->comment_approved) { return new WP_Error("woocommerce_rest_already_trashed", __("The object has already been trashed.", "woocommerce"), array("status" => 410)); } $result = wp_trash_comment($review->comment_ID); $review = get_comment($review->comment_ID); $response = $this->prepare_item_for_response($review, $request); } if (!$result) { return new WP_Error("woocommerce_rest_cannot_delete", __("The object cannot be deleted.", "woocommerce"), array("status" => 500)); } do_action("woocommerce_rest_delete_review", $review, $response, $request); return $response; } public function prepare_item_for_response($review, $request) { $context = !empty($request["context"]) ? $request["context"] : "view"; $fields = $this->get_fields_for_response($request); $data = array(); if (in_array("id", $fields, true)) { $data["id"] = (int) $review->comment_ID; } if (in_array("date_created", $fields, true)) { $data["date_created"] = wc_rest_prepare_date_response($review->comment_date); } if (in_array("date_created_gmt", $fields, true)) { $data["date_created_gmt"] = wc_rest_prepare_date_response($review->comment_date_gmt); } if (in_array("product_id", $fields, true)) { $data["product_id"] = (int) $review->comment_post_ID; } if (in_array("product_name", $fields, true)) { $data["product_name"] = get_the_title((int) $review->comment_post_ID); } if (in_array("product_permalink", $fields, true)) { $data["product_permalink"] = get_permalink((int) $review->comment_post_ID); } if (in_array("status", $fields, true)) { $data["status"] = $this->prepare_status_response((string) $review->comment_approved); } if (in_array("reviewer", $fields, true)) { $data["reviewer"] = $review->comment_author; } if (in_array("reviewer_email", $fields, true)) { $data["reviewer_email"] = $review->comment_author_email; } if (in_array("review", $fields, true)) { $data["review"] = "view" === $context ? wpautop($review->comment_content) : $review->comment_content; } if (in_array("rating", $fields, true)) { $data["rating"] = (int) get_comment_meta($review->comment_ID, "rating", true); } if (in_array("verified", $fields, true)) { $data["verified"] = wc_review_is_from_verified_owner($review->comment_ID); } if (in_array("reviewer_avatar_urls", $fields, true)) { $data["reviewer_avatar_urls"] = rest_get_avatar_urls($review->comment_author_email); } $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($review)); return apply_filters("woocommerce_rest_prepare_product_review", $response, $review, $request); } protected function prepare_item_for_database($request) { $prepared_review = array(); if (isset($request["id"])) { $prepared_review["comment_ID"] = (int) $request["id"]; } if (isset($request["review"])) { $prepared_review["comment_content"] = $request["review"]; } if (isset($request["product_id"])) { $prepared_review["comment_post_ID"] = (int) $request["product_id"]; } if (isset($request["reviewer"])) { $prepared_review["comment_author"] = $request["reviewer"]; } if (isset($request["reviewer_email"])) { $prepared_review["comment_author_email"] = $request["reviewer_email"]; } if (!empty($request["date_created"])) { $date_data = rest_get_date_with_gmt($request["date_created"]); if (!empty($date_data)) { list($prepared_review["comment_date"], $prepared_review["comment_date_gmt"]) = $date_data; } } elseif (!empty($request["date_created_gmt"])) { $date_data = rest_get_date_with_gmt($request["date_created_gmt"], true); if (!empty($date_data)) { list($prepared_review["comment_date"], $prepared_review["comment_date_gmt"]) = $date_data; } } return apply_filters("woocommerce_rest_preprocess_product_review", $prepared_review, $request); } protected function prepare_links($review) { $links = array("self" => array("href" => rest_url(sprintf("/%s/%s/%d", $this->namespace, $this->rest_base, $review->comment_ID))), "collection" => array("href" => rest_url(sprintf("/%s/%s", $this->namespace, $this->rest_base)))); if (0 !== (int) $review->comment_post_ID) { $links["up"] = array("href" => rest_url(sprintf("/%s/products/%d", $this->namespace, $review->comment_post_ID))); } if (0 !== (int) $review->user_id) { $links["reviewer"] = array("href" => rest_url("wp/v2/users/" . $review->user_id), "embeddable" => true); } return $links; } public function get_item_schema() { $schema = array("$schema" => "http://json-schema.org/draft-04/schema#", "title" => "product_review", "type" => "object", "properties" => array("id" => array("description" => __("Unique identifier for the resource.", "woocommerce"), "type" => "integer", "context" => array("view", "edit"), "readonly" => true), "date_created" => array("description" => __("The date the review was created, in the site's timezone.", "woocommerce"), "type" => "date-time", "context" => array("view", "edit"), "readonly" => true), "date_created_gmt" => array("description" => __("The date the review was created, as GMT.", "woocommerce"), "type" => "date-time", "context" => array("view", "edit"), "readonly" => true), "product_id" => array("description" => __("Unique identifier for the product that the review belongs to.", "woocommerce"), "type" => "integer", "context" => array("view", "edit")), "product_name" => array("description" => __("Product name.", "woocommerce"), "type" => "string", "context" => array("view", "edit")), "product_permalink" => array("description" => __("Product URL.", "woocommerce"), "type" => "string", "format" => "uri", "context" => array("view", "edit"), "readonly" => true), "status" => array("description" => __("Status of the review.", "woocommerce"), "type" => "string", "default" => "approved", "enum" => array("approved", "hold", "spam", "unspam", "trash", "untrash"), "context" => array("view", "edit")), "reviewer" => array("description" => __("Reviewer name.", "woocommerce"), "type" => "string", "context" => array("view", "edit")), "reviewer_email" => array("description" => __("Reviewer email.", "woocommerce"), "type" => "string", "format" => "email", "context" => array("view", "edit")), "review" => array("description" => __("The content of the review.", "woocommerce"), "type" => "string", "context" => array("view", "edit"), "arg_options" => array("sanitize_callback" => "wp_filter_post_kses")), "rating" => array("description" => __("Review rating (0 to 5).", "woocommerce"), "type" => "integer", "context" => array("view", "edit")), "verified" => array("description" => __("Shows if the reviewer bought the product or not.", "woocommerce"), "type" => "boolean", "context" => array("view", "edit"), "readonly" => true))); if (get_option("show_avatars")) { $avatar_properties = array(); $avatar_sizes = rest_get_avatar_sizes(); foreach ($avatar_sizes as $size) { $avatar_properties[$size] = array("description" => sprintf(__("Avatar URL with image size of %d pixels.", "woocommerce"), $size), "type" => "string", "format" => "uri", "context" => array("embed", "view", "edit")); } $schema["properties"]["reviewer_avatar_urls"] = array("description" => __("Avatar URLs for the object reviewer.", "woocommerce"), "type" => "object", "context" => array("view", "edit"), "readonly" => true, "properties" => $avatar_properties); } return $this->add_additional_fields_schema($schema); } public function get_collection_params() { $params = parent::get_collection_params(); $params["context"]["default"] = "view"; $params["after"] = array("description" => __("Limit response to resources published after a given ISO8601 compliant date.", "woocommerce"), "type" => "string", "format" => "date-time"); $params["before"] = array("description" => __("Limit response to reviews published before a given ISO8601 compliant date.", "woocommerce"), "type" => "string", "format" => "date-time"); $params["exclude"] = array("description" => __("Ensure result set excludes specific IDs.", "woocommerce"), "type" => "array", "items" => array("type" => "integer"), "default" => array()); $params["include"] = array("description" => __("Limit result set to specific IDs.", "woocommerce"), "type" => "array", "items" => array("type" => "integer"), "default" => array()); $params["offset"] = array("description" => __("Offset the result set by a specific number of items.", "woocommerce"), "type" => "integer"); $params["order"] = array("description" => __("Order sort attribute ascending or descending.", "woocommerce"), "type" => "string", "default" => "desc", "enum" => array("asc", "desc")); $params["orderby"] = array("description" => __("Sort collection by object attribute.", "woocommerce"), "type" => "string", "default" => "date_gmt", "enum" => array("date", "date_gmt", "id", "include", "product")); $params["reviewer"] = array("description" => __("Limit result set to reviews assigned to specific user IDs.", "woocommerce"), "type" => "array", "items" => array("type" => "integer")); $params["reviewer_exclude"] = array("description" => __("Ensure result set excludes reviews assigned to specific user IDs.", "woocommerce"), "type" => "array", "items" => array("type" => "integer")); $params["reviewer_email"] = array("default" => null, "description" => __("Limit result set to that from a specific author email.", "woocommerce"), "format" => "email", "type" => "string"); $params["product"] = array("default" => array(), "description" => __("Limit result set to reviews assigned to specific product IDs.", "woocommerce"), "type" => "array", "items" => array("type" => "integer")); $params["status"] = array("default" => "approved", "description" => __("Limit result set to reviews assigned a specific status.", "woocommerce"), "sanitize_callback" => "sanitize_key", "type" => "string", "enum" => array("all", "hold", "approved", "spam", "trash")); return apply_filters("woocommerce_rest_product_review_collection_params", $params); } protected function get_review($id) { $id = (int) $id; $error = new WP_Error("woocommerce_rest_review_invalid_id", __("Invalid review ID.", "woocommerce"), array("status" => 404)); if (0 >= $id) { return $error; } $review = get_comment($id); if (empty($review)) { return $error; } if (!empty($review->comment_post_ID)) { $post = get_post((int) $review->comment_post_ID); if ("product" !== get_post_type((int) $review->comment_post_ID)) { return new WP_Error("woocommerce_rest_product_invalid_id", __("Invalid product ID.", "woocommerce"), array("status" => 404)); } } return $review; } protected function normalize_query_param($query_param) { $prefix = "comment_"; switch ($query_param) { case "id": $normalized = $prefix . "ID"; break; case "product": $normalized = $prefix . "post_ID"; break; case "include": $normalized = "comment__in"; break; default: $normalized = $prefix . $query_param; break; } return $normalized; } protected function prepare_status_response($comment_approved) { switch ($comment_approved) { case "hold": case "0": $status = "hold"; break; case "approve": case "1": $status = "approved"; break; case "spam": case "trash": default: $status = $comment_approved; break; } return $status; } protected function handle_status_param($new_status, $id) { $old_status = wp_get_comment_status($id); if ($new_status === $old_status) { return false; } switch ($new_status) { case "approved": case "approve": case "1": $changed = wp_set_comment_status($id, "approve"); break; case "hold": case "0": $changed = wp_set_comment_status($id, "hold"); break; case "spam": $changed = wp_spam_comment($id); break; case "unspam": $changed = wp_unspam_comment($id); break; case "trash": $changed = wp_trash_comment($id); break; case "untrash": $changed = wp_untrash_comment($id); break; default: $changed = false; break; } return $changed; } } ?>

Did this file decode correctly?

Original Code

<?php
 defined("\x41\102\x53\x50\101\x54\x48") || die; class WC_REST_Product_Reviews_Controller extends WC_REST_Controller { protected $namespace = "\167\x63\57\166\63"; protected $rest_base = "\x70\x72\157\144\x75\143\164\x73\x2f\162\145\166\151\x65\x77\x73"; public function register_routes() { register_rest_route($this->namespace, "\57" . $this->rest_base, array(array("\x6d\145\164\x68\157\144\x73" => WP_REST_Server::READABLE, "\143\x61\154\154\142\x61\x63\153" => array($this, "\147\145\x74\137\x69\164\145\x6d\x73"), "\x70\145\162\x6d\x69\x73\163\151\x6f\156\137\143\141\154\x6c\142\x61\143\153" => array($this, "\x67\145\x74\137\x69\x74\145\155\x73\137\160\145\x72\x6d\151\x73\163\x69\157\x6e\x73\137\x63\x68\x65\143\153"), "\x61\162\x67\163" => $this->get_collection_params()), array("\155\x65\x74\150\157\144\x73" => WP_REST_Server::CREATABLE, "\143\x61\x6c\x6c\142\141\143\153" => array($this, "\143\x72\145\141\x74\145\137\151\164\x65\x6d"), "\160\x65\162\x6d\151\163\163\151\157\x6e\x5f\x63\141\x6c\154\x62\x61\x63\x6b" => array($this, "\x63\x72\x65\141\164\x65\137\x69\164\145\x6d\137\160\145\162\155\151\163\x73\x69\157\x6e\163\x5f\x63\x68\145\143\153"), "\x61\162\x67\x73" => array_merge($this->get_endpoint_args_for_item_schema(WP_REST_Server::CREATABLE), array("\x70\x72\x6f\x64\165\x63\164\137\x69\x64" => array("\162\x65\161\165\x69\x72\x65\x64" => true, "\x64\x65\163\143\162\x69\x70\x74\x69\157\x6e" => __("\x55\156\151\161\x75\145\x20\151\x64\x65\x6e\164\x69\x66\151\145\162\x20\x66\x6f\162\x20\164\150\145\x20\x70\x72\157\144\x75\143\164\56", "\x77\157\157\143\157\x6d\x6d\x65\x72\x63\145"), "\x74\x79\160\145" => "\151\x6e\x74\x65\x67\145\162"), "\162\145\x76\151\145\x77" => array("\x72\x65\x71\x75\x69\162\145\144" => true, "\164\171\x70\145" => "\x73\x74\x72\x69\x6e\147", "\144\145\163\143\162\151\160\x74\x69\157\156" => __("\122\145\x76\151\x65\167\x20\143\157\156\164\x65\156\164\56", "\x77\x6f\x6f\143\157\x6d\x6d\145\x72\143\145")), "\x72\145\x76\x69\145\x77\145\x72" => array("\x72\x65\161\x75\x69\x72\145\x64" => true, "\164\x79\x70\x65" => "\163\x74\162\x69\x6e\x67", "\x64\x65\x73\143\x72\x69\x70\164\151\157\x6e" => __("\x4e\141\x6d\x65\x20\157\146\40\164\150\x65\40\162\145\x76\x69\x65\x77\145\x72\x2e", "\167\157\157\x63\157\155\155\145\x72\x63\145")), "\x72\145\166\x69\145\x77\x65\162\x5f\145\155\141\x69\x6c" => array("\162\x65\x71\165\151\x72\145\x64" => true, "\x74\171\160\145" => "\163\164\x72\151\156\x67", "\144\x65\163\143\x72\151\160\164\x69\x6f\x6e" => __("\105\155\141\x69\154\40\157\x66\x20\164\x68\x65\x20\162\x65\x76\x69\x65\167\145\x72\x2e", "\167\x6f\157\x63\x6f\x6d\x6d\145\162\143\145"))))), "\x73\143\x68\145\155\141" => array($this, "\x67\x65\x74\137\160\165\142\154\151\143\x5f\x69\164\145\x6d\137\x73\143\150\145\x6d\x61"))); register_rest_route($this->namespace, "\57" . $this->rest_base . "\57\50\77\x50\x3c\x69\x64\76\x5b\134\x64\135\53\51", array("\x61\x72\x67\x73" => array("\151\144" => array("\x64\145\x73\143\162\x69\160\x74\x69\x6f\x6e" => __("\125\x6e\151\161\165\x65\40\x69\x64\145\156\x74\x69\146\x69\145\162\40\146\157\x72\x20\x74\150\x65\40\x72\x65\x73\x6f\165\x72\143\145\56", "\167\157\x6f\143\x6f\155\x6d\x65\162\143\145"), "\164\x79\160\145" => "\151\156\x74\x65\x67\145\162")), array("\x6d\145\x74\x68\x6f\x64\163" => WP_REST_Server::READABLE, "\143\x61\154\154\142\141\143\153" => array($this, "\x67\145\164\x5f\x69\164\x65\x6d"), "\x70\145\162\155\151\x73\x73\x69\157\x6e\137\x63\x61\154\x6c\142\x61\143\153" => array($this, "\x67\x65\164\x5f\151\164\145\x6d\x5f\x70\145\x72\x6d\151\163\x73\x69\157\x6e\x73\137\x63\x68\145\x63\153"), "\x61\x72\147\x73" => array("\143\x6f\x6e\x74\x65\170\x74" => $this->get_context_param(array("\144\145\146\141\x75\154\x74" => "\166\x69\145\x77")))), array("\155\145\x74\150\157\x64\x73" => WP_REST_Server::EDITABLE, "\x63\x61\154\x6c\x62\x61\143\x6b" => array($this, "\x75\160\144\x61\x74\145\x5f\x69\x74\x65\155"), "\x70\x65\162\155\151\x73\163\151\x6f\156\x5f\143\x61\x6c\154\142\141\x63\153" => array($this, "\165\160\144\141\164\x65\137\x69\x74\145\155\137\x70\145\x72\x6d\151\163\163\151\x6f\156\x73\137\143\x68\x65\143\153"), "\141\x72\x67\163" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE)), array("\x6d\x65\164\x68\x6f\144\x73" => WP_REST_Server::DELETABLE, "\143\x61\x6c\x6c\x62\x61\x63\x6b" => array($this, "\144\145\154\x65\x74\x65\137\x69\164\145\x6d"), "\x70\x65\x72\x6d\151\163\x73\151\157\x6e\x5f\143\x61\154\154\142\141\x63\x6b" => array($this, "\144\x65\154\x65\164\x65\x5f\151\164\x65\155\137\x70\145\162\155\151\163\163\151\x6f\156\x73\137\143\x68\145\143\153"), "\141\x72\147\x73" => array("\x66\x6f\x72\x63\145" => array("\x64\145\x66\x61\x75\x6c\164" => false, "\x74\171\160\x65" => "\x62\157\x6f\x6c\145\141\156", "\144\145\163\143\x72\x69\x70\164\x69\x6f\156" => __("\x57\x68\x65\164\150\x65\x72\40\164\x6f\x20\142\x79\160\141\x73\x73\x20\x74\162\141\x73\150\40\141\156\x64\40\146\157\162\143\x65\x20\x64\x65\x6c\x65\164\151\157\156\56", "\x77\157\x6f\x63\x6f\x6d\155\145\162\x63\145")))), "\163\143\150\x65\x6d\141" => array($this, "\147\x65\x74\137\160\165\x62\154\x69\x63\137\x69\x74\x65\x6d\137\x73\143\150\145\155\141"))); register_rest_route($this->namespace, "\57" . $this->rest_base . "\57\x62\x61\164\143\150", array(array("\x6d\x65\164\150\x6f\144\x73" => WP_REST_Server::EDITABLE, "\x63\141\154\154\x62\x61\143\153" => array($this, "\x62\x61\164\x63\150\137\151\164\x65\155\163"), "\x70\145\x72\155\151\x73\x73\151\x6f\x6e\x5f\143\141\154\154\x62\141\x63\x6b" => array($this, "\x62\141\x74\143\150\137\x69\x74\145\155\x73\137\160\145\x72\155\151\163\x73\x69\x6f\x6e\x73\x5f\x63\x68\x65\143\x6b"), "\x61\162\x67\x73" => $this->get_endpoint_args_for_item_schema(WP_REST_Server::EDITABLE)), "\163\x63\150\x65\x6d\x61" => array($this, "\x67\x65\164\137\x70\165\x62\154\151\x63\137\142\x61\164\x63\x68\x5f\163\x63\x68\x65\155\141"))); } public function get_items_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("\x72\145\x61\144")) { return new WP_Error("\167\x6f\x6f\143\x6f\x6d\x6d\145\162\143\145\x5f\162\x65\x73\x74\137\x63\141\x6e\156\157\x74\137\166\x69\x65\x77", __("\x53\157\x72\162\171\x2c\x20\x79\x6f\165\40\143\x61\x6e\156\x6f\x74\x20\x6c\x69\x73\164\x20\x72\x65\x73\x6f\165\162\143\x65\x73\56", "\167\x6f\157\143\x6f\155\x6d\x65\x72\143\x65"), array("\x73\164\x61\164\165\x73" => rest_authorization_required_code())); } return true; } public function get_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("\x72\145\141\144", (int) $request["\x69\144"])) { return new WP_Error("\167\x6f\157\143\157\x6d\x6d\145\x72\x63\145\137\162\x65\163\164\x5f\143\x61\x6e\x6e\157\164\x5f\166\x69\145\x77", __("\x53\x6f\x72\x72\171\54\40\x79\157\x75\40\143\141\x6e\156\x6f\x74\x20\x76\x69\145\x77\x20\x74\x68\151\163\40\162\x65\163\157\x75\x72\x63\145\x2e", "\167\157\157\143\157\155\155\x65\162\143\145"), array("\163\x74\141\x74\165\x73" => rest_authorization_required_code())); } return true; } public function create_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("\x63\162\x65\x61\x74\x65")) { return new WP_Error("\167\157\x6f\143\157\x6d\x6d\x65\162\x63\145\137\162\x65\163\x74\x5f\x63\141\156\x6e\157\164\137\143\x72\145\x61\x74\145", __("\123\157\162\162\171\x2c\40\171\157\165\x20\x61\162\145\x20\156\157\164\40\141\154\x6c\157\167\x65\x64\40\164\x6f\40\x63\162\x65\141\x74\x65\40\x72\x65\163\x6f\x75\162\x63\145\163\x2e", "\x77\157\x6f\x63\157\155\x6d\145\162\x63\x65"), array("\x73\164\x61\x74\165\163" => rest_authorization_required_code())); } return true; } public function update_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("\x65\x64\x69\x74", (int) $request["\151\x64"])) { return new WP_Error("\167\157\157\x63\157\155\x6d\x65\x72\x63\x65\137\162\145\x73\164\137\143\x61\156\156\x6f\x74\x5f\145\x64\x69\x74", __("\123\x6f\162\x72\x79\54\40\x79\x6f\165\x20\143\x61\x6e\156\157\164\x20\145\x64\x69\x74\x20\164\150\x69\163\x20\162\145\163\x6f\x75\162\x63\x65\x2e", "\167\x6f\x6f\x63\157\155\155\x65\162\x63\x65"), array("\x73\164\x61\x74\165\163" => rest_authorization_required_code())); } return true; } public function delete_item_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("\144\145\154\145\164\145", (int) $request["\151\144"])) { return new WP_Error("\x77\x6f\157\x63\157\155\155\x65\x72\143\x65\x5f\x72\145\x73\164\137\143\141\x6e\156\157\164\x5f\144\145\154\145\x74\x65", __("\123\157\162\x72\171\54\x20\x79\157\x75\x20\x63\x61\x6e\x6e\x6f\x74\x20\144\145\x6c\145\164\x65\x20\164\150\x69\163\x20\162\x65\x73\x6f\x75\162\143\x65\56", "\167\157\157\x63\157\x6d\x6d\x65\162\x63\x65"), array("\x73\164\141\164\165\163" => rest_authorization_required_code())); } return true; } public function batch_items_permissions_check($request) { if (!wc_rest_check_product_reviews_permissions("\142\141\164\143\x68")) { return new WP_Error("\x77\x6f\157\143\157\155\x6d\x65\x72\143\x65\x5f\x72\x65\x73\164\x5f\143\x61\x6e\156\157\x74\137\142\x61\x74\x63\150", __("\x53\x6f\162\162\171\x2c\40\171\157\165\40\141\162\145\x20\156\x6f\164\40\141\154\x6c\x6f\x77\x65\x64\40\164\157\40\142\141\x74\143\150\x20\x6d\x61\x6e\x69\160\x75\154\141\164\145\x20\x74\x68\151\x73\x20\162\x65\163\157\165\162\143\x65\56", "\x77\x6f\x6f\143\x6f\155\x6d\145\162\x63\x65"), array("\163\164\141\x74\x75\x73" => rest_authorization_required_code())); } return true; } public function get_items($request) { $registered = $this->get_collection_params(); $parameter_mappings = array("\162\145\166\151\145\167\x65\162" => "\x61\x75\164\x68\157\162\x5f\137\x69\x6e", "\162\x65\x76\151\x65\x77\x65\162\x5f\x65\155\x61\x69\154" => "\x61\x75\164\x68\157\x72\x5f\x65\155\141\x69\154", "\162\x65\x76\151\x65\167\145\x72\137\x65\x78\143\x6c\165\x64\145" => "\141\x75\164\x68\157\x72\x5f\x5f\x6e\x6f\164\137\151\156", "\x65\170\143\154\x75\144\x65" => "\x63\x6f\x6d\155\145\156\x74\137\x5f\x6e\157\164\137\151\156", "\151\156\143\154\x75\x64\145" => "\x63\x6f\155\155\x65\156\x74\137\137\151\x6e", "\157\146\146\x73\x65\164" => "\157\x66\146\163\x65\164", "\x6f\x72\144\145\162" => "\157\162\x64\145\162", "\x70\145\x72\x5f\160\x61\x67\x65" => "\x6e\165\155\142\145\162", "\160\x72\x6f\144\165\x63\164" => "\160\x6f\x73\x74\137\x5f\x69\156", "\x73\145\141\x72\143\x68" => "\x73\145\x61\x72\143\150", "\163\164\x61\164\165\163" => "\163\x74\x61\164\165\163"); $prepared_args = array(); foreach ($parameter_mappings as $api_param => $wp_param) { if (isset($registered[$api_param], $request[$api_param])) { $prepared_args[$wp_param] = $request[$api_param]; } } foreach (array("\141\165\x74\x68\157\162\x5f\145\x6d\141\x69\x6c", "\x73\x65\x61\162\143\x68") as $param) { if (!isset($prepared_args[$param])) { $prepared_args[$param] = ''; } } if (isset($registered["\x6f\162\144\145\162\x62\171"])) { $prepared_args["\157\x72\x64\x65\162\142\x79"] = $this->normalize_query_param($request["\x6f\x72\x64\145\x72\142\x79"]); } if (isset($prepared_args["\163\x74\141\x74\165\x73"])) { $prepared_args["\163\164\141\x74\x75\x73"] = "\x61\160\160\162\157\166\x65\144" === $prepared_args["\163\164\141\164\165\163"] ? "\x61\x70\x70\162\x6f\166\x65" : $prepared_args["\163\164\141\x74\x75\x73"]; } $prepared_args["\156\157\137\x66\157\165\156\144\137\162\157\167\x73"] = false; $prepared_args["\144\x61\x74\x65\137\x71\165\145\162\171"] = array(); if (isset($registered["\x62\145\146\x6f\162\x65"], $request["\x62\145\146\157\x72\x65"])) { $prepared_args["\144\x61\164\x65\137\x71\165\x65\162\171"][0]["\142\x65\x66\x6f\x72\x65"] = $request["\x62\145\146\157\x72\x65"]; } if (isset($registered["\141\146\164\145\162"], $request["\x61\146\164\x65\x72"])) { $prepared_args["\144\x61\164\145\x5f\161\165\145\x72\x79"][0]["\x61\146\164\145\162"] = $request["\141\146\x74\145\162"]; } if (isset($registered["\x70\x61\147\x65"]) && empty($request["\157\146\x66\x73\x65\x74"])) { $prepared_args["\157\x66\x66\x73\145\x74"] = $prepared_args["\x6e\165\x6d\142\x65\162"] * (absint($request["\160\141\147\145"]) - 1); } $prepared_args = apply_filters("\x77\157\x6f\143\157\155\x6d\x65\162\x63\x65\137\162\x65\163\x74\x5f\x70\162\157\144\165\x63\164\x5f\x72\x65\x76\x69\x65\x77\x5f\x71\x75\145\x72\x79", $prepared_args, $request); $prepared_args["\x74\171\160\145"] = "\162\x65\x76\x69\x65\167"; $query = new WP_Comment_Query(); $query_result = $query->query($prepared_args); $reviews = array(); foreach ($query_result as $review) { if (!wc_rest_check_product_reviews_permissions("\162\145\141\x64", $review->comment_ID)) { continue; } $data = $this->prepare_item_for_response($review, $request); $reviews[] = $this->prepare_response_for_collection($data); } $total_reviews = (int) $query->found_comments; $max_pages = (int) $query->max_num_pages; if ($total_reviews < 1) { unset($prepared_args["\156\165\155\142\145\162"], $prepared_args["\x6f\x66\x66\163\145\164"]); $query = new WP_Comment_Query(); $prepared_args["\143\157\x75\156\x74"] = true; $total_reviews = $query->query($prepared_args); $max_pages = ceil($total_reviews / $request["\x70\145\x72\x5f\x70\x61\147\x65"]); } $response = rest_ensure_response($reviews); $response->header("\130\x2d\x57\x50\55\x54\x6f\164\141\154", $total_reviews); $response->header("\x58\x2d\x57\x50\55\124\x6f\164\x61\154\x50\x61\x67\145\x73", $max_pages); $base = add_query_arg($request->get_query_params(), rest_url(sprintf("\x25\163\x2f\45\x73", $this->namespace, $this->rest_base))); if ($request["\160\141\x67\145"] > 1) { $prev_page = $request["\x70\x61\147\145"] - 1; if ($prev_page > $max_pages) { $prev_page = $max_pages; } $prev_link = add_query_arg("\x70\141\147\145", $prev_page, $base); $response->link_header("\x70\x72\x65\166", $prev_link); } if ($max_pages > $request["\x70\x61\x67\x65"]) { $next_page = $request["\x70\x61\147\145"] + 1; $next_link = add_query_arg("\x70\141\147\145", $next_page, $base); $response->link_header("\156\x65\170\164", $next_link); } return $response; } public function create_item($request) { if (!empty($request["\151\144"])) { return new WP_Error("\x77\x6f\x6f\x63\x6f\155\x6d\145\x72\x63\x65\x5f\x72\145\163\164\137\x72\x65\x76\x69\x65\x77\137\145\x78\x69\163\x74\163", __("\x43\x61\156\156\157\x74\40\x63\x72\145\x61\x74\x65\40\145\x78\151\163\164\151\156\x67\40\160\162\x6f\x64\165\143\x74\x20\x72\x65\x76\x69\x65\x77\x2e", "\167\157\157\143\x6f\155\155\145\x72\143\x65"), array("\163\x74\141\x74\x75\163" => 400)); } $product_id = (int) $request["\160\x72\157\144\165\x63\164\137\151\x64"]; if ("\160\162\x6f\144\x75\x63\x74" !== get_post_type($product_id)) { return new WP_Error("\167\157\157\143\157\x6d\x6d\x65\x72\x63\x65\137\162\x65\163\x74\137\160\x72\157\144\165\143\164\x5f\x69\x6e\166\141\x6c\x69\x64\x5f\151\x64", __("\111\156\166\x61\154\x69\x64\x20\x70\162\x6f\144\x75\x63\164\40\111\x44\56", "\167\x6f\157\143\x6f\155\155\145\x72\143\x65"), array("\163\x74\x61\164\165\163" => 404)); } $prepared_review = $this->prepare_item_for_database($request); if (is_wp_error($prepared_review)) { return $prepared_review; } $prepared_review["\x63\157\x6d\x6d\145\x6e\164\x5f\164\171\x70\145"] = "\162\x65\166\151\145\167"; if (empty($prepared_review["\143\157\155\x6d\x65\156\164\x5f\143\x6f\x6e\x74\x65\x6e\x74"])) { return new WP_Error("\167\x6f\x6f\x63\157\x6d\155\x65\x72\143\145\137\x72\x65\x73\164\137\x72\145\166\x69\x65\x77\x5f\x63\x6f\156\164\x65\156\164\x5f\x69\156\166\x61\154\x69\144", __("\x49\156\166\x61\154\x69\144\x20\x72\145\166\151\145\167\40\x63\157\156\x74\x65\x6e\x74\56", "\167\157\x6f\x63\157\x6d\155\x65\162\x63\145"), array("\x73\x74\x61\x74\165\x73" => 400)); } if (!isset($prepared_review["\143\157\155\155\145\x6e\164\x5f\x64\141\164\145\x5f\147\x6d\164"])) { $prepared_review["\143\157\155\x6d\145\x6e\x74\137\144\141\164\145\137\147\155\164"] = current_time("\x6d\x79\x73\161\x6c", true); } if (!empty($_SERVER["\x52\x45\x4d\117\124\x45\137\101\x44\x44\x52"]) && rest_is_ip_address(wp_unslash($_SERVER["\122\x45\115\117\x54\x45\137\101\104\104\122"]))) { $prepared_review["\143\157\x6d\x6d\x65\x6e\x74\x5f\x61\165\164\150\x6f\x72\137\x49\x50"] = wc_clean(wp_unslash($_SERVER["\122\105\x4d\x4f\x54\105\x5f\x41\x44\104\x52"])); } else { $prepared_review["\x63\x6f\x6d\x6d\x65\156\164\137\141\x75\164\x68\x6f\162\x5f\111\x50"] = "\x31\62\x37\56\60\x2e\x30\56\61"; } if (!empty($request["\x61\165\164\x68\157\x72\x5f\x75\163\x65\162\137\x61\x67\145\156\164"])) { $prepared_review["\x63\157\x6d\x6d\x65\x6e\x74\137\x61\147\x65\156\164"] = $request["\141\x75\x74\150\x6f\x72\x5f\165\x73\x65\x72\x5f\141\147\145\x6e\164"]; } elseif ($request->get_header("\x75\x73\x65\x72\137\141\x67\x65\156\x74")) { $prepared_review["\x63\157\x6d\x6d\145\156\x74\137\x61\147\145\156\164"] = $request->get_header("\x75\163\145\x72\x5f\141\147\x65\x6e\164"); } else { $prepared_review["\143\157\155\155\145\156\x74\137\x61\147\145\x6e\164"] = ''; } $check_comment_lengths = wp_check_comment_data_max_lengths($prepared_review); if (is_wp_error($check_comment_lengths)) { $error_code = str_replace(array("\143\157\x6d\155\145\x6e\x74\x5f\x61\x75\164\x68\x6f\162", "\143\x6f\155\x6d\x65\x6e\164\137\x63\157\x6e\x74\x65\156\164"), array("\162\145\x76\151\145\x77\x65\162", "\162\x65\x76\x69\x65\167\137\143\157\156\164\145\x6e\164"), $check_comment_lengths->get_error_code()); return new WP_Error("\167\x6f\157\x63\157\155\x6d\x65\x72\x63\145\137\x72\x65\163\164\x5f" . $error_code, __("\x50\162\157\x64\165\143\x74\40\162\145\x76\x69\x65\x77\x20\x66\151\x65\154\144\x20\x65\170\143\x65\x65\144\x73\40\x6d\x61\x78\x69\155\165\155\x20\154\x65\156\x67\164\150\40\141\154\x6c\x6f\167\145\144\56", "\167\x6f\157\x63\157\155\155\x65\x72\143\145"), array("\x73\164\141\164\165\x73" => 400)); } $prepared_review["\x63\157\x6d\x6d\145\x6e\x74\137\x70\x61\x72\145\156\164"] = 0; $prepared_review["\143\157\x6d\x6d\145\x6e\x74\x5f\x61\165\164\150\157\x72\x5f\x75\x72\154"] = ''; $prepared_review["\x63\157\x6d\x6d\145\156\x74\137\141\x70\x70\x72\x6f\166\x65\x64"] = wp_allow_comment($prepared_review, true); if (is_wp_error($prepared_review["\x63\157\155\x6d\145\x6e\x74\137\141\x70\x70\x72\x6f\x76\145\144"])) { $error_code = $prepared_review["\x63\x6f\x6d\x6d\x65\156\164\x5f\141\x70\160\162\157\x76\145\x64"]->get_error_code(); $error_message = $prepared_review["\x63\157\155\x6d\x65\x6e\164\x5f\141\x70\x70\x72\157\166\145\x64"]->get_error_message(); if ("\x63\x6f\x6d\155\x65\x6e\164\137\144\165\x70\x6c\151\143\141\164\145" === $error_code) { return new WP_Error("\167\x6f\x6f\143\157\x6d\155\x65\162\143\x65\137\x72\145\x73\x74\137" . $error_code, $error_message, array("\163\164\141\164\165\163" => 409)); } if ("\x63\x6f\155\155\145\156\x74\x5f\146\154\x6f\x6f\144" === $error_code) { return new WP_Error("\167\157\x6f\x63\x6f\x6d\x6d\x65\x72\x63\x65\x5f\162\x65\x73\x74\137" . $error_code, $error_message, array("\x73\x74\141\164\165\163" => 400)); } return $prepared_review["\143\157\155\x6d\145\x6e\164\x5f\141\x70\160\162\x6f\166\x65\144"]; } $prepared_review = apply_filters("\167\x6f\x6f\x63\x6f\155\x6d\x65\x72\x63\145\x5f\162\x65\163\x74\x5f\160\x72\x65\x5f\151\156\163\145\x72\164\137\x70\x72\157\144\x75\143\x74\x5f\162\145\x76\151\x65\x77", $prepared_review, $request); if (is_wp_error($prepared_review)) { return $prepared_review; } $review_id = wp_insert_comment(wp_filter_comment(wp_slash((array) $prepared_review))); if (!$review_id) { return new WP_Error("\167\157\x6f\143\157\x6d\x6d\x65\162\x63\145\137\162\x65\163\x74\137\x72\x65\x76\x69\x65\167\137\146\x61\151\154\145\144\137\143\162\x65\141\164\145", __("\x43\162\145\141\x74\151\x6e\x67\x20\x70\162\157\144\165\x63\x74\40\x72\x65\x76\151\145\167\40\x66\141\151\154\145\x64\56", "\x77\157\x6f\143\x6f\x6d\155\x65\162\x63\145"), array("\x73\x74\141\x74\165\163" => 500)); } if (isset($request["\x73\x74\x61\x74\x75\163"])) { $this->handle_status_param($request["\163\x74\x61\164\x75\163"], $review_id); } update_comment_meta($review_id, "\x72\x61\x74\x69\x6e\x67", !empty($request["\162\141\x74\x69\x6e\x67"]) ? $request["\x72\x61\164\x69\156\147"] : "\60"); $review = get_comment($review_id); do_action("\167\x6f\x6f\x63\157\x6d\x6d\145\162\143\x65\x5f\162\x65\x73\164\137\x69\156\x73\x65\x72\164\137\160\162\x6f\144\x75\143\164\137\162\x65\166\x69\x65\167", $review, $request, true); $fields_update = $this->update_additional_fields_for_object($review, $request); if (is_wp_error($fields_update)) { return $fields_update; } $context = current_user_can("\155\x6f\144\145\162\141\164\x65\137\x63\x6f\155\x6d\145\x6e\x74\163") ? "\145\144\151\164" : "\166\151\145\167"; $request->set_param("\x63\157\156\x74\145\170\x74", $context); $response = $this->prepare_item_for_response($review, $request); $response = rest_ensure_response($response); $response->set_status(201); $response->header("\114\x6f\143\141\x74\x69\157\x6e", rest_url(sprintf("\x25\163\x2f\x25\x73\57\x25\x64", $this->namespace, $this->rest_base, $review_id))); return $response; } public function get_item($request) { $review = $this->get_review($request["\151\144"]); if (is_wp_error($review)) { return $review; } $data = $this->prepare_item_for_response($review, $request); $response = rest_ensure_response($data); return $response; } public function update_item($request) { $review = $this->get_review($request["\x69\144"]); if (is_wp_error($review)) { return $review; } $id = (int) $review->comment_ID; if (isset($request["\164\171\x70\145"]) && "\162\145\166\151\145\167" !== get_comment_type($id)) { return new WP_Error("\x77\x6f\x6f\x63\x6f\155\155\145\x72\x63\145\x5f\x72\x65\x73\x74\137\162\145\166\151\145\x77\x5f\151\156\166\141\154\151\144\137\x74\171\160\145", __("\123\157\162\x72\x79\54\40\x79\x6f\165\x20\141\x72\145\x20\156\157\164\40\x61\x6c\154\x6f\167\145\x64\x20\164\157\40\143\x68\141\156\x67\145\x20\x74\150\145\x20\143\157\x6d\x6d\145\156\x74\x20\164\x79\160\x65\56", "\x77\157\x6f\143\x6f\x6d\x6d\145\162\x63\x65"), array("\163\x74\141\x74\165\x73" => 404)); } $prepared_args = $this->prepare_item_for_database($request); if (is_wp_error($prepared_args)) { return $prepared_args; } if (!empty($prepared_args["\143\157\155\x6d\145\x6e\164\x5f\x70\157\x73\x74\137\x49\104"])) { if ("\160\162\157\144\165\x63\x74" !== get_post_type((int) $prepared_args["\x63\157\x6d\155\x65\x6e\164\x5f\x70\x6f\x73\x74\137\111\104"])) { return new WP_Error("\167\157\x6f\143\157\x6d\155\145\162\143\145\x5f\162\x65\163\x74\x5f\160\x72\x6f\x64\x75\x63\x74\137\x69\156\166\141\154\151\144\137\x69\144", __("\111\x6e\x76\141\154\x69\144\x20\x70\162\157\144\x75\x63\164\x20\x49\104\56", "\x77\157\x6f\143\157\x6d\155\x65\x72\143\x65"), array("\163\164\141\x74\165\x73" => 404)); } } if (empty($prepared_args) && isset($request["\163\x74\141\164\165\163"])) { $change = $this->handle_status_param($request["\163\x74\x61\x74\x75\163"], $id); if (!$change) { return new WP_Error("\x77\157\157\x63\157\x6d\155\x65\162\x63\x65\x5f\x72\x65\x73\164\137\162\x65\166\151\145\x77\137\146\141\x69\154\x65\x64\137\x65\x64\x69\164", __("\x55\x70\144\x61\x74\x69\156\x67\40\x72\145\x76\151\x65\x77\40\x73\x74\141\x74\165\163\40\x66\141\151\x6c\x65\x64\x2e", "\167\157\x6f\x63\x6f\155\155\x65\x72\x63\145"), array("\x73\164\141\164\165\163" => 500)); } } elseif (!empty($prepared_args)) { if (is_wp_error($prepared_args)) { return $prepared_args; } if (isset($prepared_args["\x63\x6f\155\x6d\145\x6e\164\x5f\143\157\x6e\x74\145\x6e\164"]) && empty($prepared_args["\x63\157\x6d\x6d\x65\156\x74\137\143\x6f\156\164\x65\x6e\164"])) { return new WP_Error("\167\x6f\157\x63\157\155\155\145\x72\143\x65\x5f\x72\145\163\x74\x5f\x72\x65\x76\x69\x65\x77\137\x63\x6f\x6e\164\x65\156\164\x5f\151\x6e\x76\x61\x6c\151\x64", __("\x49\156\x76\x61\154\x69\144\x20\x72\145\x76\151\x65\x77\40\x63\x6f\x6e\x74\145\x6e\164\56", "\167\x6f\x6f\x63\157\155\155\x65\x72\x63\145"), array("\163\164\141\164\x75\x73" => 400)); } $prepared_args["\x63\x6f\x6d\x6d\x65\156\164\x5f\111\104"] = $id; $check_comment_lengths = wp_check_comment_data_max_lengths($prepared_args); if (is_wp_error($check_comment_lengths)) { $error_code = str_replace(array("\143\x6f\x6d\x6d\x65\x6e\x74\137\x61\x75\164\150\x6f\162", "\x63\157\155\x6d\x65\x6e\x74\x5f\x63\157\x6e\164\145\x6e\x74"), array("\162\x65\166\151\x65\167\145\x72", "\x72\145\x76\x69\145\167\137\x63\x6f\156\164\x65\156\164"), $check_comment_lengths->get_error_code()); return new WP_Error("\x77\x6f\157\143\157\x6d\155\x65\x72\143\x65\137\x72\x65\x73\x74\137" . $error_code, __("\120\162\157\x64\x75\x63\164\x20\162\x65\166\x69\x65\x77\x20\146\151\145\154\144\x20\x65\170\143\145\145\144\x73\x20\155\x61\170\151\155\x75\x6d\x20\154\145\156\147\x74\x68\40\141\154\x6c\x6f\x77\145\144\56", "\167\x6f\x6f\x63\x6f\155\155\x65\162\143\145"), array("\x73\x74\x61\164\x75\x73" => 400)); } $updated = wp_update_comment(wp_slash((array) $prepared_args)); if (false === $updated) { return new WP_Error("\167\x6f\157\x63\157\x6d\155\x65\162\143\x65\x5f\162\x65\163\164\137\143\x6f\x6d\x6d\145\x6e\x74\137\146\141\151\x6c\x65\x64\137\145\144\x69\164", __("\125\160\x64\x61\x74\x69\156\147\40\162\145\166\x69\x65\x77\40\x66\141\151\154\x65\x64\x2e", "\x77\157\x6f\x63\157\155\155\x65\162\x63\145"), array("\163\164\x61\x74\165\163" => 500)); } if (isset($request["\163\x74\141\x74\165\x73"])) { $this->handle_status_param($request["\x73\x74\141\x74\165\163"], $id); } } if (!empty($request["\x72\x61\164\x69\x6e\x67"])) { update_comment_meta($id, "\162\x61\164\x69\156\x67", $request["\162\x61\x74\151\156\x67"]); } $review = get_comment($id); do_action("\167\x6f\x6f\x63\x6f\x6d\x6d\145\162\143\145\x5f\162\x65\x73\164\137\151\156\x73\x65\x72\164\137\160\162\157\144\165\143\164\137\162\x65\166\151\x65\x77", $review, $request, false); $fields_update = $this->update_additional_fields_for_object($review, $request); if (is_wp_error($fields_update)) { return $fields_update; } $request->set_param("\x63\x6f\x6e\164\145\x78\164", "\x65\144\x69\x74"); $response = $this->prepare_item_for_response($review, $request); return rest_ensure_response($response); } public function delete_item($request) { $review = $this->get_review($request["\x69\x64"]); if (is_wp_error($review)) { return $review; } $force = isset($request["\146\x6f\162\x63\x65"]) ? (bool) $request["\146\157\162\143\145"] : false; $supports_trash = apply_filters("\x77\x6f\x6f\x63\157\155\155\x65\162\143\145\137\162\145\x73\164\x5f\160\162\x6f\144\165\x63\x74\137\162\145\x76\x69\145\167\x5f\164\x72\141\163\x68\141\x62\x6c\145", EMPTY_TRASH_DAYS > 0, $review); $request->set_param("\143\157\156\164\x65\x78\x74", "\x65\144\151\164"); if ($force) { $previous = $this->prepare_item_for_response($review, $request); $result = wp_delete_comment($review->comment_ID, true); $response = new WP_REST_Response(); $response->set_data(array("\144\145\x6c\145\x74\145\144" => true, "\x70\162\x65\x76\x69\157\x75\x73" => $previous->get_data())); } else { if (!$supports_trash) { return new WP_Error("\167\157\x6f\x63\157\155\155\x65\x72\x63\x65\x5f\x72\x65\163\164\x5f\x74\162\x61\163\150\137\156\x6f\164\137\x73\x75\x70\160\x6f\x72\164\x65\x64", sprintf(__("\x54\x68\145\x20\x6f\x62\152\145\143\164\x20\x64\x6f\x65\x73\40\156\x6f\164\40\163\x75\x70\x70\x6f\162\164\x20\x74\x72\x61\163\x68\x69\x6e\147\56\x20\x53\x65\164\40\x27\45\x73\x27\40\164\x6f\x20\x64\145\154\145\x74\x65\56", "\x77\157\x6f\143\x6f\x6d\x6d\145\162\143\x65"), "\146\x6f\162\143\x65\75\164\x72\x75\145"), array("\x73\164\x61\x74\165\x73" => 501)); } if ("\x74\162\x61\163\150" === $review->comment_approved) { return new WP_Error("\x77\x6f\x6f\143\x6f\x6d\155\145\x72\143\145\137\162\x65\x73\164\137\141\154\162\145\x61\144\x79\137\x74\x72\141\x73\150\145\x64", __("\x54\150\x65\40\157\x62\152\x65\143\x74\x20\150\141\x73\40\141\154\162\145\x61\x64\x79\40\142\145\145\156\x20\164\x72\141\163\x68\x65\144\56", "\167\x6f\x6f\143\x6f\x6d\155\145\162\143\x65"), array("\163\164\141\164\165\x73" => 410)); } $result = wp_trash_comment($review->comment_ID); $review = get_comment($review->comment_ID); $response = $this->prepare_item_for_response($review, $request); } if (!$result) { return new WP_Error("\167\157\157\143\157\155\155\x65\x72\x63\145\x5f\162\x65\x73\164\x5f\143\x61\x6e\x6e\157\164\137\x64\145\x6c\x65\x74\x65", __("\124\x68\145\x20\157\x62\152\x65\x63\164\x20\143\141\156\x6e\157\x74\x20\x62\x65\40\x64\x65\154\145\164\145\144\x2e", "\167\x6f\x6f\x63\157\155\155\145\x72\143\x65"), array("\x73\x74\x61\164\x75\x73" => 500)); } do_action("\x77\x6f\157\x63\157\155\155\x65\162\x63\x65\x5f\x72\x65\163\164\x5f\x64\x65\154\145\x74\x65\137\x72\145\x76\151\145\x77", $review, $response, $request); return $response; } public function prepare_item_for_response($review, $request) { $context = !empty($request["\143\157\156\x74\x65\170\x74"]) ? $request["\x63\x6f\x6e\x74\145\x78\x74"] : "\166\151\145\167"; $fields = $this->get_fields_for_response($request); $data = array(); if (in_array("\x69\x64", $fields, true)) { $data["\x69\144"] = (int) $review->comment_ID; } if (in_array("\144\141\164\145\137\x63\162\145\141\164\145\144", $fields, true)) { $data["\x64\x61\164\x65\x5f\143\162\x65\x61\164\145\144"] = wc_rest_prepare_date_response($review->comment_date); } if (in_array("\144\141\164\x65\x5f\143\162\x65\141\x74\145\x64\x5f\147\x6d\x74", $fields, true)) { $data["\144\x61\x74\145\x5f\143\x72\x65\141\x74\x65\x64\x5f\147\155\x74"] = wc_rest_prepare_date_response($review->comment_date_gmt); } if (in_array("\160\162\x6f\144\x75\143\164\137\151\144", $fields, true)) { $data["\x70\x72\157\144\x75\143\164\x5f\151\x64"] = (int) $review->comment_post_ID; } if (in_array("\160\162\x6f\144\165\143\164\x5f\156\x61\155\x65", $fields, true)) { $data["\x70\x72\157\144\x75\143\x74\x5f\156\x61\x6d\145"] = get_the_title((int) $review->comment_post_ID); } if (in_array("\160\162\157\x64\x75\x63\164\137\160\145\x72\x6d\141\154\x69\x6e\153", $fields, true)) { $data["\x70\x72\x6f\144\165\143\x74\x5f\x70\145\162\x6d\x61\154\151\x6e\153"] = get_permalink((int) $review->comment_post_ID); } if (in_array("\163\x74\141\164\165\x73", $fields, true)) { $data["\163\164\141\164\165\163"] = $this->prepare_status_response((string) $review->comment_approved); } if (in_array("\x72\145\x76\151\x65\167\145\162", $fields, true)) { $data["\162\x65\166\x69\x65\167\x65\x72"] = $review->comment_author; } if (in_array("\162\145\x76\x69\145\x77\x65\x72\137\145\155\x61\x69\x6c", $fields, true)) { $data["\x72\145\166\x69\145\x77\x65\162\137\x65\155\141\x69\154"] = $review->comment_author_email; } if (in_array("\162\145\x76\x69\145\x77", $fields, true)) { $data["\162\145\x76\151\145\x77"] = "\x76\x69\145\167" === $context ? wpautop($review->comment_content) : $review->comment_content; } if (in_array("\x72\x61\164\151\156\x67", $fields, true)) { $data["\162\x61\164\x69\x6e\x67"] = (int) get_comment_meta($review->comment_ID, "\x72\141\164\151\156\x67", true); } if (in_array("\166\x65\162\x69\146\x69\145\144", $fields, true)) { $data["\166\x65\162\151\146\x69\x65\x64"] = wc_review_is_from_verified_owner($review->comment_ID); } if (in_array("\x72\145\166\151\x65\x77\145\162\x5f\x61\166\141\x74\141\162\x5f\165\x72\154\163", $fields, true)) { $data["\162\145\x76\x69\145\x77\x65\162\137\141\x76\x61\x74\x61\x72\137\x75\162\154\163"] = rest_get_avatar_urls($review->comment_author_email); } $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($review)); return apply_filters("\x77\x6f\157\x63\x6f\x6d\x6d\x65\x72\x63\145\x5f\162\145\163\x74\137\160\x72\x65\160\141\162\145\137\160\x72\157\144\x75\143\x74\137\162\145\166\151\145\167", $response, $review, $request); } protected function prepare_item_for_database($request) { $prepared_review = array(); if (isset($request["\x69\x64"])) { $prepared_review["\x63\x6f\155\x6d\x65\x6e\164\x5f\x49\104"] = (int) $request["\x69\x64"]; } if (isset($request["\162\145\x76\x69\x65\167"])) { $prepared_review["\143\157\x6d\x6d\145\156\x74\137\x63\157\156\164\145\156\164"] = $request["\162\145\166\x69\x65\167"]; } if (isset($request["\x70\x72\157\x64\x75\143\x74\137\x69\144"])) { $prepared_review["\x63\x6f\x6d\x6d\x65\156\x74\x5f\x70\157\x73\x74\137\111\104"] = (int) $request["\x70\162\x6f\x64\165\x63\x74\x5f\x69\x64"]; } if (isset($request["\162\x65\x76\151\145\167\x65\162"])) { $prepared_review["\143\x6f\155\155\x65\156\164\x5f\141\x75\x74\150\157\x72"] = $request["\162\x65\x76\151\145\x77\x65\162"]; } if (isset($request["\162\145\x76\x69\x65\x77\x65\x72\x5f\145\155\x61\x69\x6c"])) { $prepared_review["\143\157\x6d\x6d\x65\156\164\x5f\141\165\164\x68\157\162\x5f\x65\155\x61\x69\x6c"] = $request["\162\145\x76\151\145\167\145\x72\137\x65\155\141\x69\154"]; } if (!empty($request["\144\141\164\x65\x5f\143\x72\145\141\x74\x65\x64"])) { $date_data = rest_get_date_with_gmt($request["\x64\141\164\145\137\x63\162\x65\x61\164\145\144"]); if (!empty($date_data)) { list($prepared_review["\143\x6f\x6d\x6d\145\x6e\x74\x5f\144\x61\164\145"], $prepared_review["\x63\x6f\155\155\145\156\164\x5f\144\141\x74\145\137\147\155\x74"]) = $date_data; } } elseif (!empty($request["\144\141\164\145\x5f\x63\x72\145\141\x74\145\144\137\147\x6d\x74"])) { $date_data = rest_get_date_with_gmt($request["\144\141\x74\145\x5f\143\x72\145\141\x74\145\x64\137\147\155\x74"], true); if (!empty($date_data)) { list($prepared_review["\143\x6f\x6d\155\x65\156\164\137\144\x61\x74\x65"], $prepared_review["\143\x6f\x6d\155\x65\156\164\x5f\144\141\164\x65\x5f\147\155\164"]) = $date_data; } } return apply_filters("\x77\157\x6f\x63\x6f\155\x6d\x65\x72\x63\145\137\162\145\x73\x74\x5f\160\x72\145\160\x72\157\x63\145\163\x73\x5f\x70\162\157\x64\x75\x63\x74\137\162\x65\x76\151\x65\167", $prepared_review, $request); } protected function prepare_links($review) { $links = array("\x73\145\154\146" => array("\150\x72\x65\146" => rest_url(sprintf("\x2f\45\x73\57\45\x73\x2f\x25\144", $this->namespace, $this->rest_base, $review->comment_ID))), "\143\157\154\x6c\145\143\x74\x69\157\x6e" => array("\150\x72\x65\146" => rest_url(sprintf("\57\45\163\x2f\45\x73", $this->namespace, $this->rest_base)))); if (0 !== (int) $review->comment_post_ID) { $links["\x75\160"] = array("\x68\x72\145\146" => rest_url(sprintf("\x2f\x25\x73\57\x70\x72\x6f\x64\165\x63\x74\163\x2f\45\144", $this->namespace, $review->comment_post_ID))); } if (0 !== (int) $review->user_id) { $links["\162\145\166\151\145\167\145\x72"] = array("\150\162\145\x66" => rest_url("\167\160\x2f\166\62\x2f\x75\x73\145\x72\x73\x2f" . $review->user_id), "\145\155\x62\145\144\x64\141\142\154\x65" => true); } return $links; } public function get_item_schema() { $schema = array("\x24\163\x63\150\145\x6d\141" => "\150\x74\164\160\x3a\57\57\152\163\157\x6e\x2d\163\x63\150\145\155\x61\56\157\x72\147\57\x64\x72\x61\x66\164\55\x30\64\57\163\x63\150\145\155\141\43", "\x74\151\x74\x6c\x65" => "\160\x72\157\x64\x75\x63\x74\137\x72\x65\166\151\x65\x77", "\164\x79\x70\145" => "\x6f\x62\152\145\143\164", "\160\x72\157\x70\145\162\164\151\x65\x73" => array("\x69\x64" => array("\x64\145\163\x63\x72\151\x70\164\x69\157\x6e" => __("\x55\156\151\161\165\x65\x20\x69\x64\145\x6e\164\x69\x66\151\x65\x72\x20\x66\x6f\162\x20\164\x68\145\40\162\x65\x73\157\x75\162\x63\x65\x2e", "\x77\x6f\157\x63\157\x6d\x6d\x65\x72\x63\x65"), "\164\171\x70\145" => "\151\x6e\164\x65\147\145\x72", "\x63\x6f\156\164\x65\x78\164" => array("\x76\x69\x65\x77", "\145\144\151\x74"), "\x72\x65\141\144\x6f\x6e\x6c\171" => true), "\144\x61\x74\145\137\x63\x72\145\141\164\x65\144" => array("\144\x65\163\x63\162\151\x70\x74\151\x6f\x6e" => __("\124\150\145\x20\x64\x61\164\145\40\164\x68\145\40\162\145\166\151\x65\167\40\x77\141\x73\x20\x63\x72\145\x61\164\145\x64\x2c\40\151\156\40\x74\x68\145\x20\163\x69\x74\145\x27\163\x20\164\151\155\145\x7a\x6f\x6e\x65\x2e", "\167\157\x6f\143\x6f\155\155\x65\x72\143\x65"), "\164\x79\160\x65" => "\x64\141\x74\x65\x2d\x74\x69\x6d\x65", "\143\x6f\156\164\x65\x78\164" => array("\166\151\x65\167", "\x65\144\151\164"), "\162\145\x61\144\x6f\156\x6c\171" => true), "\x64\141\x74\x65\137\x63\162\x65\x61\x74\145\x64\137\147\155\164" => array("\144\x65\163\x63\162\x69\160\x74\151\157\156" => __("\124\x68\145\40\x64\141\164\x65\x20\x74\x68\x65\40\162\x65\166\x69\x65\167\x20\167\141\163\x20\x63\162\145\141\x74\145\144\54\40\x61\x73\40\x47\x4d\x54\x2e", "\167\x6f\x6f\x63\x6f\x6d\155\x65\x72\x63\145"), "\164\171\x70\x65" => "\x64\141\164\x65\55\x74\x69\155\145", "\143\157\156\x74\x65\170\x74" => array("\x76\x69\x65\167", "\x65\x64\x69\x74"), "\162\x65\x61\144\157\156\154\171" => true), "\x70\162\x6f\x64\x75\x63\x74\x5f\x69\144" => array("\144\x65\163\x63\162\x69\x70\164\x69\157\x6e" => __("\125\156\x69\x71\165\145\40\151\144\x65\x6e\164\x69\146\151\x65\x72\40\x66\x6f\x72\40\164\150\145\40\160\162\x6f\144\x75\143\164\40\x74\x68\x61\x74\40\x74\150\x65\x20\x72\x65\x76\x69\x65\167\40\x62\x65\x6c\157\x6e\x67\x73\x20\164\x6f\x2e", "\x77\157\157\x63\x6f\155\x6d\x65\x72\143\x65"), "\164\x79\x70\x65" => "\151\x6e\x74\145\147\x65\x72", "\x63\x6f\x6e\164\145\170\164" => array("\x76\151\145\x77", "\145\x64\x69\164")), "\160\x72\x6f\144\165\x63\x74\137\156\x61\x6d\145" => array("\144\x65\x73\143\x72\151\x70\164\151\157\156" => __("\x50\x72\157\144\x75\x63\164\40\x6e\x61\155\145\x2e", "\x77\157\x6f\143\x6f\155\x6d\x65\162\x63\145"), "\x74\x79\160\145" => "\163\164\162\151\x6e\x67", "\x63\x6f\x6e\x74\145\170\164" => array("\166\151\x65\167", "\x65\x64\x69\x74")), "\x70\162\x6f\x64\x75\x63\164\137\160\x65\x72\155\141\154\151\x6e\x6b" => array("\144\145\163\x63\162\151\160\x74\x69\157\156" => __("\120\162\x6f\144\x75\143\x74\x20\125\122\114\x2e", "\x77\157\157\x63\157\155\155\145\x72\143\x65"), "\164\171\x70\145" => "\163\164\162\151\x6e\x67", "\x66\157\x72\x6d\x61\164" => "\165\x72\151", "\143\157\x6e\164\x65\x78\x74" => array("\166\151\x65\x77", "\145\x64\x69\164"), "\162\145\x61\x64\157\x6e\x6c\171" => true), "\x73\164\141\x74\165\163" => array("\144\x65\163\x63\162\151\x70\x74\151\157\156" => __("\123\x74\141\164\165\163\40\157\x66\40\x74\x68\145\x20\162\x65\x76\x69\x65\x77\x2e", "\x77\x6f\x6f\x63\157\155\x6d\x65\162\143\x65"), "\164\x79\160\x65" => "\x73\x74\x72\151\156\x67", "\x64\145\146\x61\x75\x6c\x74" => "\x61\x70\160\162\x6f\166\145\144", "\x65\x6e\165\x6d" => array("\141\160\160\162\157\166\x65\x64", "\x68\157\154\x64", "\x73\160\141\x6d", "\x75\156\x73\x70\x61\x6d", "\x74\x72\141\x73\x68", "\165\x6e\x74\x72\x61\163\x68"), "\x63\x6f\x6e\x74\x65\170\x74" => array("\x76\x69\x65\167", "\145\x64\x69\x74")), "\x72\x65\x76\151\145\167\145\162" => array("\144\145\x73\x63\162\151\x70\x74\151\x6f\x6e" => __("\x52\x65\166\151\x65\167\145\162\x20\x6e\141\x6d\145\56", "\x77\157\x6f\x63\x6f\155\155\145\x72\x63\x65"), "\x74\171\160\x65" => "\163\164\x72\151\156\147", "\x63\157\156\164\145\x78\x74" => array("\x76\151\145\x77", "\x65\x64\151\164")), "\162\145\166\151\145\x77\x65\x72\x5f\145\x6d\141\x69\154" => array("\x64\x65\x73\143\162\x69\x70\164\x69\157\156" => __("\x52\x65\166\151\145\167\145\162\40\145\155\141\x69\x6c\x2e", "\167\x6f\157\x63\x6f\x6d\155\145\x72\x63\145"), "\x74\x79\160\145" => "\163\x74\x72\x69\x6e\147", "\146\157\x72\155\x61\164" => "\145\155\x61\151\154", "\x63\x6f\156\164\x65\170\164" => array("\166\151\145\167", "\145\144\x69\x74")), "\162\145\x76\x69\x65\167" => array("\144\x65\x73\x63\162\151\160\164\x69\157\x6e" => __("\124\150\x65\x20\x63\157\x6e\x74\x65\156\x74\40\x6f\146\40\164\x68\x65\40\x72\x65\x76\151\145\x77\56", "\x77\x6f\157\x63\157\x6d\155\145\x72\x63\x65"), "\164\x79\160\x65" => "\163\164\162\x69\x6e\x67", "\143\157\x6e\164\145\170\164" => array("\166\x69\145\167", "\x65\x64\151\x74"), "\x61\x72\x67\x5f\x6f\160\164\x69\x6f\156\163" => array("\x73\x61\156\151\164\x69\172\145\137\143\x61\154\x6c\x62\141\x63\x6b" => "\x77\160\x5f\x66\x69\154\164\x65\x72\x5f\x70\157\x73\164\137\x6b\x73\x65\x73")), "\x72\x61\x74\x69\x6e\147" => array("\144\x65\x73\143\162\x69\x70\164\151\157\156" => __("\122\x65\x76\x69\145\x77\40\x72\141\164\151\156\147\x20\x28\x30\x20\x74\157\40\x35\x29\x2e", "\167\157\x6f\x63\x6f\155\155\x65\162\143\145"), "\164\x79\160\x65" => "\151\x6e\164\x65\147\x65\x72", "\x63\x6f\x6e\164\145\170\164" => array("\x76\x69\x65\x77", "\x65\144\151\164")), "\166\145\x72\151\146\x69\145\x64" => array("\144\145\x73\x63\x72\151\x70\164\x69\157\156" => __("\x53\x68\x6f\x77\x73\40\x69\146\40\164\x68\145\x20\x72\x65\x76\151\145\x77\145\162\40\x62\x6f\x75\x67\x68\x74\40\x74\150\145\x20\x70\x72\157\x64\x75\143\x74\x20\157\x72\x20\156\x6f\164\x2e", "\167\157\157\x63\157\x6d\155\x65\x72\143\145"), "\164\x79\160\x65" => "\142\x6f\157\154\x65\141\x6e", "\143\x6f\156\x74\145\x78\x74" => array("\x76\151\145\x77", "\x65\144\151\164"), "\x72\x65\x61\x64\x6f\156\154\171" => true))); if (get_option("\163\150\x6f\167\x5f\x61\166\141\x74\141\x72\163")) { $avatar_properties = array(); $avatar_sizes = rest_get_avatar_sizes(); foreach ($avatar_sizes as $size) { $avatar_properties[$size] = array("\x64\x65\163\143\162\x69\160\x74\x69\157\156" => sprintf(__("\x41\x76\x61\164\x61\x72\40\125\122\x4c\40\x77\151\x74\150\x20\x69\155\x61\147\145\40\163\x69\172\x65\40\157\x66\x20\x25\144\40\x70\151\x78\x65\x6c\163\56", "\x77\x6f\157\143\x6f\155\155\x65\x72\x63\x65"), $size), "\x74\x79\x70\x65" => "\163\164\x72\x69\x6e\147", "\146\157\162\x6d\141\164" => "\x75\x72\151", "\x63\157\x6e\164\x65\170\164" => array("\x65\x6d\x62\x65\x64", "\166\x69\x65\167", "\145\x64\151\164")); } $schema["\x70\162\x6f\160\x65\162\x74\151\145\163"]["\x72\x65\x76\x69\145\x77\x65\162\137\x61\166\141\x74\x61\162\137\x75\x72\154\x73"] = array("\144\x65\163\x63\162\x69\160\x74\151\157\x6e" => __("\x41\166\x61\164\141\162\x20\x55\x52\114\x73\x20\x66\x6f\x72\x20\x74\x68\x65\x20\157\142\x6a\145\143\x74\x20\162\145\166\x69\x65\167\x65\162\56", "\167\x6f\157\x63\157\x6d\x6d\x65\162\143\145"), "\x74\171\160\x65" => "\157\x62\x6a\x65\x63\x74", "\x63\157\156\164\x65\170\x74" => array("\166\x69\145\x77", "\x65\144\151\x74"), "\162\x65\141\x64\157\156\x6c\x79" => true, "\160\x72\x6f\160\x65\x72\x74\x69\145\x73" => $avatar_properties); } return $this->add_additional_fields_schema($schema); } public function get_collection_params() { $params = parent::get_collection_params(); $params["\143\x6f\x6e\x74\145\x78\x74"]["\x64\x65\146\x61\x75\154\x74"] = "\166\x69\x65\167"; $params["\x61\x66\164\x65\162"] = array("\x64\x65\163\x63\162\x69\x70\164\x69\157\156" => __("\x4c\151\155\151\164\40\162\x65\x73\160\x6f\156\x73\145\40\164\x6f\x20\162\x65\x73\x6f\x75\162\x63\145\x73\x20\160\165\x62\154\151\163\150\145\x64\40\141\146\x74\x65\162\40\141\x20\147\151\166\145\x6e\40\x49\123\117\x38\66\x30\61\x20\143\157\x6d\160\154\x69\x61\x6e\164\x20\x64\x61\164\145\x2e", "\x77\x6f\x6f\x63\157\x6d\155\145\162\143\145"), "\x74\171\160\x65" => "\x73\x74\162\151\156\147", "\146\157\x72\x6d\141\x74" => "\144\141\x74\145\55\164\151\155\145"); $params["\x62\x65\146\x6f\x72\145"] = array("\144\x65\x73\x63\x72\151\x70\x74\151\x6f\x6e" => __("\114\151\155\x69\x74\40\162\x65\163\160\x6f\x6e\x73\145\x20\x74\x6f\x20\162\145\166\x69\x65\x77\163\40\160\x75\142\154\151\163\x68\x65\144\40\142\x65\x66\x6f\x72\145\40\x61\40\147\x69\166\x65\156\40\x49\x53\117\70\x36\x30\x31\40\143\157\155\160\x6c\151\141\x6e\164\x20\x64\141\x74\x65\56", "\167\157\157\143\157\155\x6d\145\x72\x63\x65"), "\164\171\160\145" => "\x73\x74\162\151\x6e\147", "\x66\157\x72\x6d\x61\x74" => "\144\x61\164\145\55\164\151\155\x65"); $params["\x65\170\x63\154\x75\144\145"] = array("\x64\x65\x73\x63\x72\x69\160\164\x69\x6f\x6e" => __("\x45\156\163\x75\162\145\40\x72\145\x73\165\x6c\x74\x20\163\x65\x74\x20\x65\x78\x63\154\x75\x64\x65\163\40\163\160\x65\x63\x69\146\151\143\x20\111\104\x73\56", "\167\157\157\143\x6f\x6d\155\x65\x72\143\145"), "\x74\x79\160\x65" => "\x61\x72\162\141\171", "\151\x74\145\155\163" => array("\x74\171\160\145" => "\151\x6e\x74\x65\x67\145\x72"), "\144\x65\x66\141\165\x6c\164" => array()); $params["\151\x6e\143\154\165\x64\x65"] = array("\x64\x65\163\x63\162\151\x70\164\151\157\156" => __("\x4c\151\x6d\x69\164\x20\162\145\x73\x75\x6c\x74\x20\x73\145\164\x20\x74\157\x20\x73\x70\145\143\x69\x66\x69\x63\40\x49\x44\163\56", "\167\157\157\143\x6f\155\155\x65\x72\x63\145"), "\164\x79\160\145" => "\x61\162\162\141\171", "\x69\164\145\155\163" => array("\164\171\x70\x65" => "\151\156\x74\145\x67\x65\162"), "\144\145\146\141\165\x6c\164" => array()); $params["\157\x66\146\x73\x65\x74"] = array("\144\145\x73\143\x72\151\160\x74\x69\x6f\156" => __("\x4f\x66\x66\x73\145\x74\x20\x74\150\145\40\x72\x65\163\x75\154\x74\x20\x73\145\164\40\x62\171\40\141\40\163\160\145\143\x69\146\x69\x63\40\x6e\x75\155\x62\x65\x72\x20\x6f\146\x20\151\x74\145\155\x73\56", "\167\157\157\143\157\x6d\x6d\x65\162\143\x65"), "\x74\171\160\145" => "\151\156\x74\145\147\x65\162"); $params["\157\x72\x64\145\x72"] = array("\x64\145\x73\143\x72\x69\160\x74\151\x6f\156" => __("\x4f\162\x64\145\x72\40\163\157\x72\x74\40\x61\164\x74\x72\151\x62\165\x74\145\40\x61\x73\x63\x65\x6e\x64\x69\x6e\x67\x20\x6f\x72\x20\144\x65\163\143\x65\x6e\144\151\156\x67\x2e", "\167\157\157\x63\157\155\x6d\x65\162\x63\x65"), "\x74\x79\x70\x65" => "\x73\164\x72\151\156\147", "\144\145\x66\x61\165\154\x74" => "\144\145\163\143", "\145\156\165\155" => array("\x61\163\x63", "\x64\145\163\143")); $params["\157\162\144\145\162\142\171"] = array("\x64\145\x73\143\162\151\160\164\151\x6f\x6e" => __("\123\x6f\162\x74\x20\x63\x6f\154\x6c\x65\143\164\x69\x6f\156\x20\x62\x79\40\x6f\x62\x6a\145\143\x74\40\141\164\164\x72\151\142\165\164\x65\56", "\167\x6f\157\x63\157\155\x6d\145\162\x63\145"), "\164\x79\160\x65" => "\x73\164\x72\x69\x6e\147", "\x64\145\x66\141\165\x6c\164" => "\144\141\x74\145\x5f\x67\155\164", "\145\x6e\165\x6d" => array("\144\x61\x74\145", "\144\141\164\x65\x5f\147\155\x74", "\151\x64", "\151\x6e\143\x6c\x75\144\145", "\160\162\157\x64\165\x63\164")); $params["\162\145\166\x69\145\x77\145\162"] = array("\144\x65\163\x63\162\x69\160\x74\x69\x6f\x6e" => __("\114\x69\155\x69\164\x20\x72\x65\x73\x75\154\164\x20\x73\145\x74\x20\164\157\40\162\x65\166\x69\145\167\x73\x20\x61\163\163\x69\147\x6e\145\144\x20\164\157\40\x73\160\x65\143\x69\146\151\143\40\x75\x73\x65\x72\40\x49\104\x73\56", "\167\157\157\x63\157\x6d\x6d\145\x72\143\x65"), "\x74\171\x70\145" => "\141\162\x72\x61\171", "\151\164\145\155\163" => array("\x74\x79\160\x65" => "\151\156\x74\x65\x67\145\x72")); $params["\x72\145\166\x69\x65\x77\145\x72\137\145\x78\x63\154\x75\144\145"] = array("\x64\145\x73\x63\162\x69\160\x74\x69\157\156" => __("\105\x6e\x73\x75\162\145\x20\x72\x65\x73\165\x6c\164\40\x73\x65\x74\40\145\x78\x63\154\x75\x64\145\x73\40\x72\x65\166\x69\x65\167\x73\x20\141\x73\x73\151\x67\x6e\145\144\40\164\157\x20\x73\x70\145\143\x69\x66\151\x63\40\165\163\145\x72\40\111\104\x73\x2e", "\167\x6f\x6f\x63\x6f\155\155\x65\162\143\x65"), "\164\x79\160\145" => "\141\162\x72\141\171", "\x69\x74\145\155\163" => array("\x74\x79\160\145" => "\151\x6e\164\145\147\x65\x72")); $params["\x72\x65\166\x69\x65\x77\x65\x72\137\145\x6d\x61\x69\154"] = array("\144\x65\x66\141\165\154\x74" => null, "\144\145\x73\143\x72\151\x70\164\151\157\x6e" => __("\114\x69\155\x69\x74\40\162\145\x73\165\x6c\x74\40\x73\145\x74\40\164\157\40\164\150\141\164\x20\x66\162\157\x6d\x20\x61\x20\x73\160\145\143\151\146\151\143\40\141\165\164\150\x6f\162\40\x65\x6d\141\151\154\x2e", "\167\157\157\x63\157\155\155\x65\x72\143\145"), "\146\157\162\x6d\141\x74" => "\145\x6d\141\151\154", "\x74\x79\160\145" => "\x73\x74\x72\x69\x6e\147"); $params["\160\162\157\144\165\x63\164"] = array("\144\145\x66\141\x75\154\164" => array(), "\x64\x65\163\143\162\151\160\164\151\157\156" => __("\114\151\x6d\x69\x74\x20\x72\x65\x73\165\x6c\164\x20\163\145\164\40\x74\x6f\40\162\145\x76\x69\145\167\163\40\141\163\163\151\147\156\145\144\40\164\157\40\163\x70\x65\x63\151\146\151\143\x20\160\x72\x6f\x64\165\x63\x74\x20\x49\x44\x73\56", "\167\157\157\143\x6f\x6d\x6d\x65\x72\x63\145"), "\164\171\160\145" => "\141\162\x72\x61\171", "\151\x74\x65\x6d\163" => array("\x74\171\x70\145" => "\151\x6e\x74\145\147\x65\x72")); $params["\x73\164\141\x74\165\163"] = array("\x64\145\x66\x61\165\x6c\x74" => "\141\160\160\x72\x6f\x76\145\144", "\144\145\x73\x63\x72\151\160\164\x69\x6f\156" => __("\x4c\x69\155\151\164\40\x72\145\x73\x75\x6c\164\40\x73\x65\x74\x20\164\x6f\40\162\145\x76\x69\x65\167\163\x20\141\163\x73\151\x67\x6e\x65\x64\x20\141\x20\163\160\x65\x63\x69\x66\151\x63\40\163\x74\x61\x74\165\163\x2e", "\167\x6f\x6f\x63\x6f\x6d\155\145\x72\143\x65"), "\x73\141\156\x69\x74\151\x7a\x65\x5f\x63\141\x6c\x6c\x62\x61\143\153" => "\163\x61\x6e\151\x74\151\x7a\145\x5f\153\145\x79", "\x74\x79\x70\x65" => "\163\x74\x72\x69\x6e\x67", "\145\156\165\x6d" => array("\x61\x6c\154", "\150\157\154\x64", "\141\x70\x70\162\x6f\x76\x65\144", "\163\x70\x61\x6d", "\x74\x72\x61\x73\x68")); return apply_filters("\167\x6f\x6f\143\157\x6d\x6d\x65\162\x63\145\x5f\162\x65\x73\x74\x5f\160\x72\x6f\x64\165\x63\164\137\162\x65\x76\151\145\x77\137\x63\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\137\x70\x61\162\x61\155\x73", $params); } protected function get_review($id) { $id = (int) $id; $error = new WP_Error("\x77\157\x6f\143\x6f\155\155\145\162\x63\x65\137\162\x65\x73\x74\x5f\162\x65\166\x69\145\x77\137\151\x6e\x76\141\x6c\151\144\x5f\x69\x64", __("\x49\156\166\x61\x6c\151\x64\40\x72\x65\166\x69\x65\167\x20\x49\x44\x2e", "\x77\x6f\x6f\143\157\155\x6d\145\x72\x63\145"), array("\163\164\x61\x74\165\x73" => 404)); if (0 >= $id) { return $error; } $review = get_comment($id); if (empty($review)) { return $error; } if (!empty($review->comment_post_ID)) { $post = get_post((int) $review->comment_post_ID); if ("\160\162\x6f\x64\x75\x63\164" !== get_post_type((int) $review->comment_post_ID)) { return new WP_Error("\167\157\157\143\x6f\x6d\x6d\x65\162\x63\x65\137\x72\x65\x73\x74\137\160\x72\x6f\144\165\x63\x74\x5f\x69\x6e\166\141\x6c\151\x64\x5f\151\144", __("\111\x6e\166\141\x6c\151\144\x20\x70\162\x6f\x64\165\x63\x74\40\111\104\x2e", "\x77\157\x6f\143\x6f\x6d\155\x65\x72\x63\x65"), array("\x73\x74\x61\x74\x75\163" => 404)); } } return $review; } protected function normalize_query_param($query_param) { $prefix = "\x63\157\155\155\x65\x6e\164\137"; switch ($query_param) { case "\151\144": $normalized = $prefix . "\111\104"; break; case "\160\x72\157\x64\x75\x63\164": $normalized = $prefix . "\x70\x6f\x73\x74\137\111\104"; break; case "\151\156\x63\154\x75\x64\x65": $normalized = "\143\157\x6d\x6d\x65\x6e\x74\137\137\151\x6e"; break; default: $normalized = $prefix . $query_param; break; } return $normalized; } protected function prepare_status_response($comment_approved) { switch ($comment_approved) { case "\150\157\154\x64": case "\x30": $status = "\150\157\x6c\x64"; break; case "\141\x70\160\162\157\166\x65": case "\61": $status = "\x61\160\160\162\157\x76\x65\x64"; break; case "\163\x70\141\155": case "\x74\162\x61\x73\150": default: $status = $comment_approved; break; } return $status; } protected function handle_status_param($new_status, $id) { $old_status = wp_get_comment_status($id); if ($new_status === $old_status) { return false; } switch ($new_status) { case "\x61\160\x70\x72\x6f\166\x65\x64": case "\x61\x70\160\162\x6f\166\x65": case "\61": $changed = wp_set_comment_status($id, "\141\x70\160\162\x6f\x76\x65"); break; case "\x68\157\x6c\144": case "\60": $changed = wp_set_comment_status($id, "\150\157\154\144"); break; case "\163\x70\141\x6d": $changed = wp_spam_comment($id); break; case "\165\x6e\163\x70\141\155": $changed = wp_unspam_comment($id); break; case "\x74\x72\141\x73\150": $changed = wp_trash_comment($id); break; case "\165\156\164\x72\141\x73\x68": $changed = wp_untrash_comment($id); break; default: $changed = false; break; } return $changed; } }

Function Calls

defined 1

Variables

None

Stats

MD5 008194b33c47cf52fda01930638e46bd
Eval Count 0
Decode Time 273 ms