Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Filter Bookings discount rates
*/
function prefix_discount_rates( $rates, $product_id ) {
$rates = array(
array(
'rate' => 3,
'after' => 10,
'from' => 'all'
/* Disable checkboxes */
.pewc-group-checkbox .pewc-item-field-wrapper {
pointer-events: none;
}
<?php
/**
* Display remaining quantity on Bookings page
*/
function prefix_display_remaining_quantity() {
$remaining = bfwc_get_max_bookings( get_the_ID() );
printf(
'Places remaining: %s',
$remaining
);
/* Display field labels and values in columns */
span.pewc-summary-panel-product-name {
width: 60%;
display: inline-block;
}
span.pewc-summary-panel-product-value {
display: inline-block;
width: 30%;
}
td.pewc-summary-panel-price {
<?php
/**
* Bypass all transients
*/
add_filter( 'pewc_disable_all_transients', '__return_true' );
<?php
add_filter( 'unzip_file_use_ziparchive', '__return_false' );
<html>
<head>
<title>Product Add-Ons Ultimate REST API Tester</title>
</head>
<body>
<script src='wp-includes/js/jquery/jquery.min.js'></script>
<p>API Key: <input type="text" id="wc_api_key" value="" size="50"></p>
<p>API Secret: <input type="text" id="wc_api_secret" value="" size="50"></p>
<p>API Method:
<?php
/**
* Save cancelled roles field for variations
*/
function prefix_save_product_variation( $variation_id, $index ) {
if( isset( $_POST['wcmo_product_sub_cancelled_roles'][$variation_id] ) ) {
update_post_meta( $variation_id, 'wcmo_product_sub_cancelled_roles', $_POST['wcmo_product_sub_cancelled_roles'][$variation_id] );
} else {
delete_post_meta( $variation_id, 'wcmo_product_sub_cancelled_roles' );
<?php
/**
* Filter restriction by page ID for user roles
*/
function prefix_is_restricted_redirect( $is_restricted ) {
$restricted_page_ids = array( 2, 10 );
if( is_page() ) {
$page_id = get_the_ID();
if( in_array( $page_id, $restricted_page_ids ) ) {
<?php
/**
* Restrict access to pages by log-in status
*/
function prefix_is_post_restricted( $is_restricted, $restricted_content ) {
// Edit the page IDs below
$restricted_page_ids = array( 2, 10 );
if( is_page() ) {
$page_id = get_the_ID();