diff --git a/src/Controllers/Version4/AbstractController.php b/src/Controllers/Version4/AbstractController.php index 9c409257981..ff2be035ec4 100644 --- a/src/Controllers/Version4/AbstractController.php +++ b/src/Controllers/Version4/AbstractController.php @@ -49,15 +49,6 @@ abstract class AbstractController extends WP_REST_Controller { */ protected $resource_type = ''; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = ''; - /** * Register route for items requests. * @@ -294,17 +285,17 @@ abstract class AbstractController extends WP_REST_Controller { * @param mixed $item Object used to create response. * @param \WP_REST_Request $request Request object. */ - return apply_filters( 'woocommerce_rest_prepare_' . $this->get_hook_suffix( $item ), $response, $item, $request ); + return apply_filters( 'woocommerce_rest_prepare_' . $this->get_hook_suffix(), $response, $item, $request ); } /** * Return suffix for item action hooks. * - * @param mixed $item Object used to create response. * @return string */ - protected function get_hook_suffix( $item ) { - return $this->singular; + protected function get_hook_suffix() { + $schema = $this->get_item_schema(); + return $schema['title']; } /** diff --git a/src/Controllers/Version4/AbstractObjectsController.php b/src/Controllers/Version4/AbstractObjectsController.php index a4827d4b663..c5a723ba5b8 100644 --- a/src/Controllers/Version4/AbstractObjectsController.php +++ b/src/Controllers/Version4/AbstractObjectsController.php @@ -827,10 +827,9 @@ abstract class AbstractObjectsController extends AbstractController { /** * Return suffix for item action hooks. * - * @param mixed $item Object used to create response. * @return string */ - protected function get_hook_suffix( $item ) { + protected function get_hook_suffix() { return $this->post_type . '_object'; } } diff --git a/src/Controllers/Version4/AbstractTermsContoller.php b/src/Controllers/Version4/AbstractTermsContoller.php index e5916460e6e..42169be5682 100644 --- a/src/Controllers/Version4/AbstractTermsContoller.php +++ b/src/Controllers/Version4/AbstractTermsContoller.php @@ -753,10 +753,9 @@ abstract class AbstractTermsContoller extends AbstractController { /** * Return suffix for item action hooks. * - * @param mixed $item Object used to create response. * @return string */ - protected function get_hook_suffix( $item ) { + protected function get_hook_suffix() { return $this->taxonomy; } } diff --git a/src/Controllers/Version4/CustomerDownloads.php b/src/Controllers/Version4/CustomerDownloads.php index dfe04d6baa5..342d5fdbba7 100644 --- a/src/Controllers/Version4/CustomerDownloads.php +++ b/src/Controllers/Version4/CustomerDownloads.php @@ -32,15 +32,6 @@ class CustomerDownloads extends AbstractController { */ protected $resource_type = 'customers'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'customer_download'; - /** * Register the routes for customers. */ diff --git a/src/Controllers/Version4/Customers.php b/src/Controllers/Version4/Customers.php index 59ac1250ac7..8d6796053fa 100644 --- a/src/Controllers/Version4/Customers.php +++ b/src/Controllers/Version4/Customers.php @@ -34,15 +34,6 @@ class Customers extends AbstractController { */ protected $resource_type = 'customers'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'customer'; - /** * Register the routes for customers. */ diff --git a/src/Controllers/Version4/Data.php b/src/Controllers/Version4/Data.php index 3e7965e376b..d34bf73736c 100644 --- a/src/Controllers/Version4/Data.php +++ b/src/Controllers/Version4/Data.php @@ -30,15 +30,6 @@ class Data extends AbstractController { */ protected $resource_type = 'settings'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'data'; - /** * Register routes. * diff --git a/src/Controllers/Version4/Data/Continents.php b/src/Controllers/Version4/Data/Continents.php index 23212b3f160..3341425033e 100644 --- a/src/Controllers/Version4/Data/Continents.php +++ b/src/Controllers/Version4/Data/Continents.php @@ -25,15 +25,6 @@ class Continents extends DataController { */ protected $rest_base = 'data/continents'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'continent'; - /** * Register routes. * @@ -234,7 +225,7 @@ class Continents extends DataController { public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'data_continents', + 'title' => 'continent', 'type' => 'object', 'properties' => array( 'code' => array( diff --git a/src/Controllers/Version4/Data/Countries.php b/src/Controllers/Version4/Data/Countries.php index 197ccda374a..13136317950 100644 --- a/src/Controllers/Version4/Data/Countries.php +++ b/src/Controllers/Version4/Data/Countries.php @@ -25,15 +25,6 @@ class Countries extends DataController { */ protected $rest_base = 'data/countries'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'country'; - /** * Register routes. * @@ -183,7 +174,7 @@ class Countries extends DataController { public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'data_countries', + 'title' => 'country', 'type' => 'object', 'properties' => array( 'code' => array( diff --git a/src/Controllers/Version4/Data/Currencies.php b/src/Controllers/Version4/Data/Currencies.php index c5bbdac098d..de52a531b24 100644 --- a/src/Controllers/Version4/Data/Currencies.php +++ b/src/Controllers/Version4/Data/Currencies.php @@ -25,15 +25,6 @@ class Currencies extends DataController { */ protected $rest_base = 'data/currencies'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'currency'; - /** * Register routes. */ @@ -189,7 +180,7 @@ class Currencies extends DataController { public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'data_currencies', + 'title' => 'currency', 'type' => 'object', 'properties' => array( 'code' => array( diff --git a/src/Controllers/Version4/Data/DownloadIPs.php b/src/Controllers/Version4/Data/DownloadIPs.php index 02b4d8c84c8..47d4cbdc97d 100644 --- a/src/Controllers/Version4/Data/DownloadIPs.php +++ b/src/Controllers/Version4/Data/DownloadIPs.php @@ -25,15 +25,6 @@ class DownloadIPs extends DataController { */ protected $rest_base = 'data/download-ips'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'download_ip'; - /** * Register routes. * @@ -141,7 +132,7 @@ class DownloadIPs extends DataController { public function get_item_schema() { $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'data_download_ips', + 'title' => 'download_ip', 'type' => 'object', 'properties' => array( 'user_ip_address' => array( diff --git a/src/Controllers/Version4/OrderNotes.php b/src/Controllers/Version4/OrderNotes.php index f6791a6e340..01a96b214b4 100644 --- a/src/Controllers/Version4/OrderNotes.php +++ b/src/Controllers/Version4/OrderNotes.php @@ -32,15 +32,6 @@ class OrderNotes extends AbstractController { */ protected $post_type = 'shop_order'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'order_note'; - /** * Register the routes for order notes. */ diff --git a/src/Controllers/Version4/PaymentGateways.php b/src/Controllers/Version4/PaymentGateways.php index 176dc43a035..8c1df3c60b4 100644 --- a/src/Controllers/Version4/PaymentGateways.php +++ b/src/Controllers/Version4/PaymentGateways.php @@ -33,15 +33,6 @@ class PaymentGateways extends AbstractController { */ protected $resource_type = 'payment_gateways'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'payment_gateway'; - /** * Register the route for /payment_gateways and /payment_gateways/ */ diff --git a/src/Controllers/Version4/ProductAttributes.php b/src/Controllers/Version4/ProductAttributes.php index b13ac14dfad..8ddb0af6317 100644 --- a/src/Controllers/Version4/ProductAttributes.php +++ b/src/Controllers/Version4/ProductAttributes.php @@ -37,15 +37,6 @@ class ProductAttributes extends AbstractController { */ protected $attribute = ''; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'product_attribute'; - /** * Register the routes for product attributes. */ diff --git a/src/Controllers/Version4/ProductCategories.php b/src/Controllers/Version4/ProductCategories.php index b263423fa8f..ba8e27a02cc 100644 --- a/src/Controllers/Version4/ProductCategories.php +++ b/src/Controllers/Version4/ProductCategories.php @@ -30,15 +30,6 @@ class ProductCategories extends AbstractTermsContoller { */ protected $taxonomy = 'product_cat'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'product_cat'; - /** * Get data for this object in the format of this endpoint's schema. * diff --git a/src/Controllers/Version4/ProductReviews.php b/src/Controllers/Version4/ProductReviews.php index 263e9818f0e..071c9b240e5 100644 --- a/src/Controllers/Version4/ProductReviews.php +++ b/src/Controllers/Version4/ProductReviews.php @@ -33,15 +33,6 @@ class ProductReviews extends AbstractController { */ protected $resource_type = 'product_reviews'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'product_reviews'; - /** * Register the routes for product reviews. */ diff --git a/src/Controllers/Version4/ProductShippingClasses.php b/src/Controllers/Version4/ProductShippingClasses.php index e2a693df692..4c55791ed50 100644 --- a/src/Controllers/Version4/ProductShippingClasses.php +++ b/src/Controllers/Version4/ProductShippingClasses.php @@ -30,15 +30,6 @@ class ProductShippingClasses extends AbstractTermsContoller { */ protected $taxonomy = 'product_shipping_class'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'product_shipping_class'; - /** * Get data for this object in the format of this endpoint's schema. * diff --git a/src/Controllers/Version4/ProductTags.php b/src/Controllers/Version4/ProductTags.php index ba70253a7a4..5c3b5f01826 100644 --- a/src/Controllers/Version4/ProductTags.php +++ b/src/Controllers/Version4/ProductTags.php @@ -30,15 +30,6 @@ class ProductTags extends AbstractTermsContoller { */ protected $taxonomy = 'product_tag'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'product_tag'; - /** * Get data for this object in the format of this endpoint's schema. * diff --git a/src/Controllers/Version4/ProductVariations.php b/src/Controllers/Version4/ProductVariations.php index da66cdc8878..b791cbda69b 100644 --- a/src/Controllers/Version4/ProductVariations.php +++ b/src/Controllers/Version4/ProductVariations.php @@ -34,15 +34,6 @@ class ProductVariations extends Products { */ protected $post_type = 'product_variation'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'product_variation'; - /** * Register the routes for products. */ diff --git a/src/Controllers/Version4/Products.php b/src/Controllers/Version4/Products.php index 2308f2c0e7d..cfe86fd63cd 100644 --- a/src/Controllers/Version4/Products.php +++ b/src/Controllers/Version4/Products.php @@ -41,15 +41,6 @@ class Products extends AbstractObjectsController { */ protected $hierarchical = true; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'product'; - /** * Get the Product's schema, conforming to JSON Schema. * diff --git a/src/Controllers/Version4/Settings.php b/src/Controllers/Version4/Settings.php index 8a1cefd176f..c32e924c526 100644 --- a/src/Controllers/Version4/Settings.php +++ b/src/Controllers/Version4/Settings.php @@ -30,15 +30,6 @@ class Settings extends AbstractController { */ protected $resource_type = 'settings'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'setting'; - /** * Register routes. * diff --git a/src/Controllers/Version4/SettingsOptions.php b/src/Controllers/Version4/SettingsOptions.php index 7389c316257..94d57ccce94 100644 --- a/src/Controllers/Version4/SettingsOptions.php +++ b/src/Controllers/Version4/SettingsOptions.php @@ -33,15 +33,6 @@ class SettingsOptions extends AbstractController { */ protected $rest_base = 'settings/(?P[\w-]+)'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'setting_option'; - /** * Register routes. * diff --git a/src/Controllers/Version4/ShippingMethods.php b/src/Controllers/Version4/ShippingMethods.php index cb2f27b3af0..9176f01bbab 100644 --- a/src/Controllers/Version4/ShippingMethods.php +++ b/src/Controllers/Version4/ShippingMethods.php @@ -30,15 +30,6 @@ class ShippingMethods extends AbstractController { */ protected $resource_type = 'shipping_methods'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'shipping_method'; - /** * Register the route for /shipping_methods and /shipping_methods/ */ diff --git a/src/Controllers/Version4/ShippingZoneLocations.php b/src/Controllers/Version4/ShippingZoneLocations.php index 201712f52b4..f9c2a96d09c 100644 --- a/src/Controllers/Version4/ShippingZoneLocations.php +++ b/src/Controllers/Version4/ShippingZoneLocations.php @@ -16,15 +16,6 @@ defined( 'ABSPATH' ) || exit; */ class ShippingZoneLocations extends AbstractShippingZonesController { - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'shipping_zone_location'; - /** * Register the routes for Shipping Zone Locations. */ diff --git a/src/Controllers/Version4/ShippingZoneMethods.php b/src/Controllers/Version4/ShippingZoneMethods.php index b4e4211ed4b..19ab78a9f47 100644 --- a/src/Controllers/Version4/ShippingZoneMethods.php +++ b/src/Controllers/Version4/ShippingZoneMethods.php @@ -19,15 +19,6 @@ use \WooCommerce\RestApi\Controllers\Version4\Utilities\SettingsTrait; class ShippingZoneMethods extends AbstractShippingZonesController { use SettingsTrait; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'shipping_zone_method'; - /** * Register the routes for Shipping Zone Methods. */ diff --git a/src/Controllers/Version4/ShippingZones.php b/src/Controllers/Version4/ShippingZones.php index d26886dfb78..3869551bb4a 100644 --- a/src/Controllers/Version4/ShippingZones.php +++ b/src/Controllers/Version4/ShippingZones.php @@ -16,15 +16,6 @@ defined( 'ABSPATH' ) || exit; */ class ShippingZones extends AbstractShippingZonesController { - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'shipping_zone'; - /** * Register the routes for Shipping Zones. */ diff --git a/src/Controllers/Version4/SystemStatus.php b/src/Controllers/Version4/SystemStatus.php index d22521d1911..07512d8e949 100644 --- a/src/Controllers/Version4/SystemStatus.php +++ b/src/Controllers/Version4/SystemStatus.php @@ -30,15 +30,6 @@ class SystemStatus extends AbstractController { */ protected $resource_type = 'system_status'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'system_status'; - /** * Register the route for /system_status */ diff --git a/src/Controllers/Version4/SystemStatusTools.php b/src/Controllers/Version4/SystemStatusTools.php index a82ce813dea..4c7a932de37 100644 --- a/src/Controllers/Version4/SystemStatusTools.php +++ b/src/Controllers/Version4/SystemStatusTools.php @@ -30,15 +30,6 @@ class SystemStatusTools extends AbstractController { */ protected $resource_type = 'system_status'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'system_status_tool'; - /** * Register the routes for /system_status/tools/*. */ diff --git a/src/Controllers/Version4/TaxClasses.php b/src/Controllers/Version4/TaxClasses.php index c6ff2e99bc4..460bfc6db79 100644 --- a/src/Controllers/Version4/TaxClasses.php +++ b/src/Controllers/Version4/TaxClasses.php @@ -30,15 +30,6 @@ class TaxClasses extends AbstractController { */ protected $resource_type = 'settings'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'tax_class'; - /** * Register the routes for tax classes. */ diff --git a/src/Controllers/Version4/Taxes.php b/src/Controllers/Version4/Taxes.php index bcb588cbae0..4cddea1b2a4 100644 --- a/src/Controllers/Version4/Taxes.php +++ b/src/Controllers/Version4/Taxes.php @@ -30,15 +30,6 @@ class Taxes extends AbstractController { */ protected $resource_type = 'settings'; - /** - * Singular name for resource type. - * - * Used in filter/action names for single resources. - * - * @var string - */ - protected $singular = 'tax'; - /** * Register the routes for taxes. */ diff --git a/src/Controllers/Version4/Webhooks.php b/src/Controllers/Version4/Webhooks.php index 667f5d09693..10f8a5ebac5 100644 --- a/src/Controllers/Version4/Webhooks.php +++ b/src/Controllers/Version4/Webhooks.php @@ -693,10 +693,9 @@ class Webhooks extends AbstractController { /** * Return suffix for item action hooks. * - * @param mixed $item Object used to create response. * @return string */ - protected function get_hook_suffix( $item ) { + protected function get_hook_suffix() { return $this->post_type; } }