This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Attempts to list PRs merged since a given tag was created. | |
# | |
# Run from within the repo you are interested in (of course fetch/pull | |
# down all the latest changes from remote). | |
# | |
# Usage: prs-merged-since <tag_name> | |
# Example: prs-merged-since v1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* When the product permalink structure is `product/%product_cat%`, WooCommerce (9.3.x or earlier) | |
* accepts any value as the `%product_cat%`, which is not always desirable. | |
* | |
* This snippet attempts to detect this situation, and will redirect to the canonical URL as needed. | |
* You can add it as a mu-plugin. For example: | |
* | |
* wp-content/mu-plugins/canonical-product-redirect.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Removes the 'site visibility badge' from the WordPress admin bar. | |
* | |
* Intended for use with WooCommerce 9.3.1, can be used via a code | |
* snippet manager or else you may wish to add as a mu-plugin, ie: | |
* | |
* wp-content/mu-plugin/disable-site-visibility-badge.php | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( | |
'rest_post_dispatch', | |
function ( $response, $server, $request ) { | |
if ( | |
$request->get_route() === '/wc/v3/orders' | |
&& $request->get_param( '_fields' ) === [ 'id' ] | |
&& $request->get_param( '_vendor' ) === 'flag' | |
) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tests = [ | |
true, | |
false, | |
-1, | |
0, | |
1, | |
-5.0, | |
1.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Simple approach showing a structured approach to associating arbitrary, ephemeral | |
* (non-persisted) data with individual product objects and other entities. | |
* | |
* Benefits include avoidance of collisions between two plugins using the same key, | |
* the range of checks that can be applied to stored values, etc. | |
* | |
* @link https://github.com/woocommerce/woocommerce/issues/45286 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Assigns currently unassigned product attribute terms to products, to try and | |
* replicate the problem in the linked issue. Also generates new unassigned terms | |
* on each request, to further exacerbate things. | |
* | |
* We deliberately do not use the WooCommerce API, because in this case we are | |
* try to circumvent WC's cache invalidation logic. | |
* | |
* @see https://github.com/woocommerce/woocommerce/issues/17355 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin name: Detect Legacy REST API Usage (WooCommerce) | |
* Description: Attempts to detect and log usage of WooCommerce's legacy REST API. | |
* Version: 2023-11-24.1 | |
*/ | |
function detect_and_log_wc_legacy_api_requests() { | |
global $wp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The top-seller query (used for the WooCommerce Status dashboard widget) | |
* runs on every dashboard request. | |
* | |
* It can effectively be nullified using this snippet, if the performance | |
* impact is too great. | |
* | |
* (Tested with WC 8.0.2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Modify /wp-json/wc/store/v1/products/<ID> so that it returns more complete data about each variation. | |
* | |
* Not extensively tested, just captures an idea about how we might do this. | |
*/ | |
add_filter( 'rest_request_after_callbacks', function ( $response, $handler, $request ) { | |
// If this is not a Store API product request, do not interfere. | |
if ( ! str_starts_with( $request->get_route(), '/wc/store/v1/products/' ) || $request->get_method() !== 'GET' ) { |
NewerOlder