This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 1. Deactivate the default WooCommerce cleanup draft orders cron | |
add_action( 'init', 'deactivate_woocommerce_cleanup_draft_orders' ); | |
function deactivate_woocommerce_cleanup_draft_orders() { | |
if ( function_exists( 'as_next_scheduled_action' ) ) { | |
$timestamp = as_next_scheduled_action( 'woocommerce_cleanup_draft_orders' ); | |
if ( $timestamp ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('terms_clauses', function ( $pieces, $taxonomies, $args ) { | |
if (!isset($args['wpse_exclude_top']) || 1 !== $args['wpse_exclude_top'] | |
) | |
return $pieces; | |
$pieces['where'] .= ' AND tt.parent > 0'; | |
return $pieces; | |
}, 10, 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (WC()->session->get('shipping_for_package_0')['rates'] as $method_id => $rate) { | |
if (WC()->session->get('chosen_shipping_methods')[0] == $method_id) { | |
$rate_label = $rate->label; // The shipping method label name | |
$rate_cost_excl_tax = floatval($rate->cost); // The cost excluding tax | |
// The taxes cost | |
$rate_taxes = 0; | |
foreach ($rate->taxes as $rate_tax) | |
$rate_taxes += floatval($rate_tax); | |
// The cost including tax |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$columns: ( | |
1: 100%, | |
2: 50%, | |
3: 33.33%, | |
4: 25%, | |
5: 20%, | |
6: 16.66%, | |
7: 14.28%, | |
8: 12.5%, | |
9: 11.11% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wc_varb_price_range( $wcv_price, $product ) { | |
$prefix = sprintf('%s: ', __('From', 'wcvp_range')); | |
$wcv_reg_min_price = $product->get_variation_regular_price( 'min', true ); | |
$wcv_min_sale_price = $product->get_variation_sale_price( 'min', true ); | |
$wcv_max_price = $product->get_variation_price( 'max', true ); | |
$wcv_min_price = $product->get_variation_price( 'min', true ); | |
$wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tl_save_error() { | |
update_option( 'plugin_error', ob_get_contents() ); | |
} | |
add_action( 'activated_plugin', 'tl_save_error' ); | |
/* Then to display the error message: */ | |
echo get_option( 'plugin_error' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The template for displaying archive pages | |
* | |
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/ | |
* | |
* @package WordPress | |
* @subpackage Twenty_Nineteen | |
* @since 1.0.0 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_sale_flash', 'wc_custom_replace_sale_text' ); | |
function wc_custom_replace_sale_text( $html ) { | |
return str_replace( __( 'Sale!', 'woocommerce' ), __( 'My sale text!', 'woocommerce' ), $html ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// functions.php | |
class themeslug_walker_nav_menu extends Walker_Nav_Menu { | |
// add classes to ul sub-menus | |
function start_lvl(&$output, $depth) { | |
// depth dependent classes | |
$indent = ( $depth > 0 ? str_repeat("\t", $depth) : '' ); // code indent | |
$display_depth = ( $depth + 1); // because it counts the first submenu as 0 | |
$classes = array( | |
'sub-menu', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_remove_filter($tag, $function_name, $priority = 10){ | |
global $wp_filter; | |
if( isset($wp_filter[$tag]->callbacks[$priority]) and !empty($wp_filter[$tag]->callbacks[$priority]) ){ | |
$wp_filter[$tag]->callbacks[$priority] = array_filter($wp_filter[$tag]->callbacks[$priority], function($v, $k) use ($function_name){ | |
return ( stripos($k, $function_name) === false ); |
NewerOlder