[wp-trac] [WordPress Trac] #44745: REST API: incorrect slashes in url if parent empty
WordPress Trac
noreply at wordpress.org
Sun Oct 25 18:25:11 UTC 2020
#44745: REST API: incorrect slashes in url if parent empty
--------------------------+------------------------------
Reporter: nicomollet | Owner: adamsilverstein
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.9.8
Severity: normal | Resolution:
Keywords: has-patch | Focuses: javascript
--------------------------+------------------------------
Comment (by adamsilverstein):
Testing instructions:
* Install woocommerce plugin.
* Create some categories, with parents, use short category names like "AA"
and "BB" going several levels deep.
* Enqueue wp-api script, in your themes functions.php add
{{{#!php
add_action( 'admin_enqueue_scripts', function() {
wp_enqueue_script( 'wp-api' );
} );
}}}
* Load any admin page and in the console enter:
{{{#!js
wp.api.init({'versionString': 'wc/v2/'});
var productcategories = new wp.api.collections.ProductsCategories();
productcategories.fetch().done( function() {
productcategories.each( function( productcategory ) {
console.log( productcategory.attributes );
} );
} );
}}}
Result before patch: JS error. Result after patch: list of categories.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44745#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list