Changeset 2768599
- Timestamp:
- 08/09/2022 10:45:51 PM (4 years ago)
- Location:
- setary
- Files:
-
- 2 added
- 8 edited
- 1 copied
-
tags/0.2.0 (copied) (copied from setary/trunk)
-
tags/0.2.0/README.md (modified) (2 diffs)
-
tags/0.2.0/inc/bootstrap.php (modified) (1 diff)
-
tags/0.2.0/inc/class-product-controller.php (added)
-
tags/0.2.0/inc/class-products-with-variations.php (modified) (5 diffs)
-
tags/0.2.0/setary.php (modified) (3 diffs)
-
trunk/README.md (modified) (2 diffs)
-
trunk/inc/bootstrap.php (modified) (1 diff)
-
trunk/inc/class-product-controller.php (added)
-
trunk/inc/class-products-with-variations.php (modified) (5 diffs)
-
trunk/setary.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
setary/tags/0.2.0/README.md
r2767149 r2768599 3 3 Tested up to: 6.0.1 4 4 Requires PHP: 5.6 5 Stable tag: 0. 1.15 Stable tag: 0.2.0 6 6 License: MIT 7 7 License URI: https://opensource.org/licenses/MIT … … 53 53 54 54 == Changelog == 55 = v0.2.0 (2022-08-09) = 56 * [new] Ability to [edit product categories](https://setary.com/docs/update-product-categories/?utm_source=setary&utm_medium=changelog). 57 55 58 = v0.1.1 (2022-08-03) = 56 59 * [fix] Correct permission check when first connecting to Setary. -
setary/tags/0.2.0/inc/bootstrap.php
r2767149 r2768599 17 17 function init() { 18 18 add_filter( 'woocommerce_rest_api_get_rest_namespaces', __NAMESPACE__ . '\\get_rest_namespaces' ); 19 20 $product_controller = new Product_Controller(); 21 22 add_filter( 'woocommerce_rest_pre_insert_product_object', array( $product_controller, 'pre_insert_product_object' ), 10, 3 ); 23 add_filter( 'woocommerce_rest_pre_insert_product_variation_object', array( $product_controller, 'pre_insert_product_object' ), 10, 3 ); 24 add_filter( 'rest_exposed_cors_headers', array( $product_controller, 'rest_exposed_cors_headers' ) ); 19 25 } 20 26 -
setary/tags/0.2.0/inc/class-products-with-variations.php
r2767149 r2768599 73 73 */ 74 74 protected function get_product_data( $product, $context = 'view' ) { 75 76 75 $request = new \WP_REST_Request( '', '', [ 'context' => $context ] ); 77 76 … … 163 162 unset( $item['variations'] ); 164 163 164 $item['formatted_categories'] = $this->format_categories( $item ); 165 165 166 return $item; 166 167 } … … 175 176 protected function prepare_links( $object, $request ) { 176 177 // Remove links from response. 177 return null;178 return array(); 178 179 } 179 180 … … 219 220 $response->header( 'X-WP-Total', $query_results['total'] ); 220 221 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 222 $response->header( 'X-Setary-PluginVersion', SETARY_VERSION ); 221 223 222 224 $base = $this->rest_base; … … 252 254 return $response; 253 255 } 256 257 /** 258 * Format categories for response. 259 * 260 * @return string 261 */ 262 public function format_categories( $item = array() ) { 263 // Get a formatted list of categories for the product. Display hierarchical categories like "Parent Category > Child Category". 264 $categories = []; 265 266 foreach ( $item['categories'] as $category ) { 267 $category_structure = array( 268 $category['name'], 269 ); 270 271 $parents = get_ancestors( $category['id'], 'product_cat' ); 272 273 if ( ! empty( $parents ) ) { 274 foreach( $parents as $parent ) { 275 $category_structure[] = get_term( $parent, 'product_cat' )->name; 276 } 277 } 278 279 $category_structure = array_reverse( $category_structure ); 280 281 $categories[] = implode( ' > ', $category_structure ); 282 } 283 284 return implode( ' | ', $categories ); 285 } 254 286 } -
setary/tags/0.2.0/setary.php
r2767149 r2768599 10 10 * Author: Setary 11 11 * 12 * Version: 0. 1.112 * Version: 0.2.0 13 13 * Requires at least: 5.7 14 14 * Tested up to: 6.0.1 … … 22 22 define( 'SETARY_PATH', \plugin_dir_path( __FILE__ ) ); 23 23 define( 'SETARY_URL', \plugins_url( '/', __FILE__ ) ); 24 define( 'SETARY_VERSION', '0. 1.1' );24 define( 'SETARY_VERSION', '0.2.0' ); 25 25 26 26 add_action( 'plugins_loaded', __NAMESPACE__ . '\\plugins_loaded' ); … … 36 36 } 37 37 38 include_once __DIR__ . '/inc/class-product-controller.php'; 38 39 include_once __DIR__ . '/inc/class-products-with-variations.php'; 39 40 include_once __DIR__ . '/inc/class-info.php'; -
setary/trunk/README.md
r2767149 r2768599 3 3 Tested up to: 6.0.1 4 4 Requires PHP: 5.6 5 Stable tag: 0. 1.15 Stable tag: 0.2.0 6 6 License: MIT 7 7 License URI: https://opensource.org/licenses/MIT … … 53 53 54 54 == Changelog == 55 = v0.2.0 (2022-08-09) = 56 * [new] Ability to [edit product categories](https://setary.com/docs/update-product-categories/?utm_source=setary&utm_medium=changelog). 57 55 58 = v0.1.1 (2022-08-03) = 56 59 * [fix] Correct permission check when first connecting to Setary. -
setary/trunk/inc/bootstrap.php
r2767149 r2768599 17 17 function init() { 18 18 add_filter( 'woocommerce_rest_api_get_rest_namespaces', __NAMESPACE__ . '\\get_rest_namespaces' ); 19 20 $product_controller = new Product_Controller(); 21 22 add_filter( 'woocommerce_rest_pre_insert_product_object', array( $product_controller, 'pre_insert_product_object' ), 10, 3 ); 23 add_filter( 'woocommerce_rest_pre_insert_product_variation_object', array( $product_controller, 'pre_insert_product_object' ), 10, 3 ); 24 add_filter( 'rest_exposed_cors_headers', array( $product_controller, 'rest_exposed_cors_headers' ) ); 19 25 } 20 26 -
setary/trunk/inc/class-products-with-variations.php
r2767149 r2768599 73 73 */ 74 74 protected function get_product_data( $product, $context = 'view' ) { 75 76 75 $request = new \WP_REST_Request( '', '', [ 'context' => $context ] ); 77 76 … … 163 162 unset( $item['variations'] ); 164 163 164 $item['formatted_categories'] = $this->format_categories( $item ); 165 165 166 return $item; 166 167 } … … 175 176 protected function prepare_links( $object, $request ) { 176 177 // Remove links from response. 177 return null;178 return array(); 178 179 } 179 180 … … 219 220 $response->header( 'X-WP-Total', $query_results['total'] ); 220 221 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 222 $response->header( 'X-Setary-PluginVersion', SETARY_VERSION ); 221 223 222 224 $base = $this->rest_base; … … 252 254 return $response; 253 255 } 256 257 /** 258 * Format categories for response. 259 * 260 * @return string 261 */ 262 public function format_categories( $item = array() ) { 263 // Get a formatted list of categories for the product. Display hierarchical categories like "Parent Category > Child Category". 264 $categories = []; 265 266 foreach ( $item['categories'] as $category ) { 267 $category_structure = array( 268 $category['name'], 269 ); 270 271 $parents = get_ancestors( $category['id'], 'product_cat' ); 272 273 if ( ! empty( $parents ) ) { 274 foreach( $parents as $parent ) { 275 $category_structure[] = get_term( $parent, 'product_cat' )->name; 276 } 277 } 278 279 $category_structure = array_reverse( $category_structure ); 280 281 $categories[] = implode( ' > ', $category_structure ); 282 } 283 284 return implode( ' | ', $categories ); 285 } 254 286 } -
setary/trunk/setary.php
r2767149 r2768599 10 10 * Author: Setary 11 11 * 12 * Version: 0. 1.112 * Version: 0.2.0 13 13 * Requires at least: 5.7 14 14 * Tested up to: 6.0.1 … … 22 22 define( 'SETARY_PATH', \plugin_dir_path( __FILE__ ) ); 23 23 define( 'SETARY_URL', \plugins_url( '/', __FILE__ ) ); 24 define( 'SETARY_VERSION', '0. 1.1' );24 define( 'SETARY_VERSION', '0.2.0' ); 25 25 26 26 add_action( 'plugins_loaded', __NAMESPACE__ . '\\plugins_loaded' ); … … 36 36 } 37 37 38 include_once __DIR__ . '/inc/class-product-controller.php'; 38 39 include_once __DIR__ . '/inc/class-products-with-variations.php'; 39 40 include_once __DIR__ . '/inc/class-info.php';
Note: See TracChangeset
for help on using the changeset viewer.