Skip to content

Instantly share code, notes, and snippets.

View unzip_file_use_ziparchive.php
<?php
add_filter( 'unzip_file_use_ziparchive', '__return_false' );
View pewc-rest-api.html
<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:
View woocommerce_save_product_variation.php
<?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' );
View wcmo_is_restricted_redirect.php
<?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 ) ) {
View wcmo_is_content_restricted.php
<?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();
View bfwc_max_bookings_in_cart.php
<?php
/**
* Allow more than one booking in the cart
*/
function prefix_max_bookings_in_cart() {
return 99;
}
add_filter( 'bfwc_max_bookings_in_cart', 'prefix_max_bookings_in_cart' );
View prefix_enable_image_editing.php
<?php
/**
* Enable image editing for certain products
*/
function prefix_enable_image_editing( $enabled ) {
$product_id = get_the_ID();
if( in_array( $product_id, array( 123, 456, 789 ) ) ) {
$enabled = 'yes';
}
return $enabled;
View pewc_rename_uploaded_file.php
<?php
/**
* Fix issue with Divi compatibility
*/
remove_filter( 'sanitize_file_name', 'pewc_rename_uploaded_file' );
View ptuwc_placeholder_label.php
<?php
/**
* Filter the 'Product tags' placeholder
*/
function prefix_ptuwc_taxonomy_label( $label, $filterable_column ) {
if( $filterable_column == 'product_tag' ) {
$label = 'My new placeholder';
}
return $label;
}
View bfwc_auto_set_end.php
<?php
/**
* Display a single calendar
* Only for use with single day bookings
*/
function prefix_auto_set_end( $auto, $product_id ) {
return 'yes';
}
add_filter( 'bfwc_auto_set_end', 'prefix_auto_set_end', 10, 2 );