AI
1 year ago
RateLimits
4 weeks ago
Reports
4 weeks ago
Templates
3 years ago
views
4 weeks ago
AnalyticsImports.php
5 months ago
Coupons.php
4 years ago
CustomAttributeTraits.php
4 years ago
Customers.php
4 years ago
Data.php
4 years ago
DataCountries.php
4 years ago
DataDownloadIPs.php
4 years ago
Experiments.php
4 years ago
Features.php
4 years ago
Init.php
4 weeks ago
LaunchYourStore.php
1 year ago
Leaderboards.php
1 year ago
Marketing.php
2 months ago
MarketingCampaignTypes.php
3 years ago
MarketingCampaigns.php
2 years ago
MarketingChannels.php
3 years ago
MarketingOverview.php
2 months ago
MarketingRecommendations.php
2 years ago
MobileAppMagicLink.php
3 years ago
MobileAppQRLogin.php
4 weeks ago
NoteActions.php
4 weeks ago
Notes.php
4 weeks ago
Notice.php
1 year ago
OnboardingFreeExtensions.php
1 year ago
OnboardingPlugins.php
4 weeks ago
OnboardingProductTypes.php
4 years ago
OnboardingProducts.php
2 years ago
OnboardingProfile.php
1 year ago
OnboardingTasks.php
9 months ago
OnboardingThemes.php
9 months ago
Options.php
4 weeks ago
Orders.php
1 year ago
PaymentGatewaySuggestions.php
2 months ago
Plugins.php
2 months ago
ProductAttributeTerms.php
4 years ago
ProductAttributes.php
4 years ago
ProductCategories.php
4 years ago
ProductForm.php
3 years ago
ProductReviews.php
4 years ago
ProductVariations.php
1 year ago
Products.php
1 year ago
ProductsLowInStock.php
4 months ago
SettingOptions.php
3 years ago
ShippingPartnerSuggestions.php
1 month ago
Taxes.php
4 years ago
Themes.php
2 years ago
ProductReviews.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * REST API Product Reviews Controller |
| 4 | * |
| 5 | * Handles requests to /products/reviews. |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Admin\API; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * Product reviews controller. |
| 14 | * |
| 15 | * @internal |
| 16 | * @extends WC_REST_Product_Reviews_Controller |
| 17 | */ |
| 18 | class ProductReviews extends \WC_REST_Product_Reviews_Controller { |
| 19 | /** |
| 20 | * Endpoint namespace. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | protected $namespace = 'wc-analytics'; |
| 25 | |
| 26 | /** |
| 27 | * Prepare links for the request. |
| 28 | * |
| 29 | * @param WP_Comment $review Product review object. |
| 30 | * @return array Links for the given product review. |
| 31 | */ |
| 32 | protected function prepare_links( $review ) { |
| 33 | $links = array( |
| 34 | 'self' => array( |
| 35 | 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $review->comment_ID ) ), |
| 36 | ), |
| 37 | 'collection' => array( |
| 38 | 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ), |
| 39 | ), |
| 40 | ); |
| 41 | if ( 0 !== (int) $review->comment_post_ID ) { |
| 42 | $links['up'] = array( |
| 43 | 'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $review->comment_post_ID ) ), |
| 44 | 'embeddable' => true, |
| 45 | ); |
| 46 | } |
| 47 | if ( 0 !== (int) $review->user_id ) { |
| 48 | $links['reviewer'] = array( |
| 49 | 'href' => rest_url( 'wp/v2/users/' . $review->user_id ), |
| 50 | 'embeddable' => true, |
| 51 | ); |
| 52 | } |
| 53 | return $links; |
| 54 | } |
| 55 | } |
| 56 |