Skip to content

Instantly share code, notes, and snippets.

@circlecube
Last active April 4, 2025 20:09
Show Gist options
  • Save circlecube/3330eaba952d1f8778f46f3f0d24624b to your computer and use it in GitHub Desktop.
Save circlecube/3330eaba952d1f8778f46f3f0d24624b to your computer and use it in GitHub Desktop.
Solutions Filter for Local Development
<?php
/**
* Plugin Name: Solutions Filter
* Description: Solutions Filter for WordPress
* Version: 1.0.0
* Author: Newfold Labs
* Author URI: https://www.newfold.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
add_filter( 'pre_transient_newfold_solutions',
function () {
// Use a json fixture rather than hiive entitlement endpoint response
$allowed_solutions = array( 'commerce', 'service', 'creator', 'none' );
if ( in_array( $_GET['solution'], $allowed_solutions ) ) {
$fixture = NFD_SOLUTIONS_DIR . '/tests/cypress/fixtures/' . $_GET['solution'] . '.json';
if ( file_exists( $fixture ) && is_readable( $fixture ) ) {
return json_decode( file_get_contents( $fixture ), true );
}
}
return false;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment