Skip to content

Instantly share code, notes, and snippets.

View danmeade's full-sized avatar

Dan Meade danmeade

View GitHub Profile
@yanknudtskov
yanknudtskov / functions.php
Created June 25, 2020 14:55
Remove ACF validation for administrators
<?php
// Disable Ready Only for Administrators
// add_filter( 'acf/load_field', 'yanco_acf_disable_read_only', 10000 );
function yanco_acf_disable_read_only( $field ) {
// Applies to administrators
if( is_admin() && get_post_type() == 'afrapportering' ) {
global $pagenow;
@yanknudtskov
yanknudtskov / functions.php
Created September 8, 2020 09:44
Adjust Facebook for WooCommerce Feed Regeneration Interval
<?php
/*
* Adjust the interval that the feed file is generated.
*/
add_filter( 'wc_facebook_feed_generation_interval', 'yanco_wc_facebook_feed_generation_interval', 10, 1 );
function yanco_wc_facebook_feed_generation_interval( $interval ) {
return 60 * 30;
}
@yanknudtskov
yanknudtskov / functions.php
Created November 4, 2020 12:00
WooCommerce Subscriptions: Also send Subscription Cancelled email to customer
<?php
add_action('woocommerce_subscription_status_pending-cancel', 'yanco_woocommerce_subscription_status_pending_cancel', 10, 3 );
function yanco_woocommerce_subscription_status_pending_cancel( $subscription ) {
$customer_email = $subscription->get_billing_email();
$wc_emails = WC()->mailer()->get_emails();
$admin_email = $wc_emails['WCS_Email_Cancelled_Subscription']->recipient;
$wc_emails['WCS_Email_Cancelled_Subscription']->trigger( $subscription );
@yanknudtskov
yanknudtskov / functions.php
Created November 20, 2020 11:37
Add a WooCommerce Checkbox at Checkout to accept privacy policy.
<?php
/**
* Add privacy policy tick box at checkout
*/
add_action( 'woocommerce_review_order_before_submit', 'yanco_add_checkout_privacy_policy', 9 );
function yanco_add_checkout_privacy_policy() {
woocommerce_form_field( 'privacy_policy', array(
'type' => 'checkbox',
'class' => array('form-row privacy'),