Skip to content

Instantly share code, notes, and snippets.

View spasicm's full-sized avatar

Milos Spasic spasicm

View GitHub Profile
@spasicm
spasicm / functions.php
Last active October 4, 2023 15:43
WooCoommerce Delete Expired Coupons Automatically
/** WooCommerce automatically delete expired coupons */
// WP Crone adding new interval schedule
add_filter( 'cron_schedules', 'cron_add_custom_interval' );
function cron_add_custom_interval( $schedules ) {
// Adds custom time interval to the existing schedules
$schedules['custominterval'] = array(
'interval' => 86400, // in seconds
'display' => __( 'Custom interval' )
);
@spasicm
spasicm / do-not-use-plugin-on-page.php
Created October 13, 2021 10:14
WordPress disable plugin on specific page
<?php
// To make this plugin to work, you must put this file in "wp-content/mu-plugins" directory.
// You can read mora about WordPress MU (Must Use) Plugins on the link -> https://wordpress.org/support/article/must-use-plugins/
add_filter( 'option_active_plugins', 'disable_specific_plugin' );
function disable_specific_plugin($plugins){
if( $_SERVER['REQUEST_URI'] == '/some-url' ) { // Change "/some-url" with url of page you want to disable plugin (without domain).
$key = array_search( 'some-plugin/some-plugin.php' , $plugins ); // Change "some-plugin/some-plugin.php" with the directory name and main .php file name of the plugin you want to disable.
if ( false !== $key ) unset( $plugins[$key] );
}
return $plugins;
@spasicm
spasicm / functions.php
Created October 5, 2021 10:17
Woocommerce append a text to total price on the "Cart", "Check out", "Thank you" pages & "Order recived" email
<?php
// This code should be added to your WordPress child theme functions.php
// Woocommerce append a text to total price on the "Cart" & "Check out" page
add_filter( 'woocommerce_cart_totals_order_total_html', 'eworkshop_custom_total_message_html', 10, 1 );
function eworkshop_custom_total_message_html( $value ) {
$value .= __('<br>some custom TXT') . '<br>';
return $value;
}
@spasicm
spasicm / functionality-plugin.php
Last active September 27, 2021 15:17
WooCommerce Brands - display brand image on single product page
<?php
// This is add-on for official WooCommerce Brands plugin -> https://woocommerce.com/products/brands/
// To make this add-on to work, all code must be added to WP functionality plugin -> https://css-tricks.com/wordpress-functionality-plugins/
add_action( 'init', 'eworkshop_remove_actions' );
function eworkshop_remove_actions() {
// WooCommerce remove brand from single product page
remove_action( 'woocommerce_product_meta_end', array( $GLOBALS['WC_Brands'], 'show_brand' ) );
}
// WooCommerce display brand image on single product page