Skip to content

Instantly share code, notes, and snippets.

View Willem-Siebe's full-sized avatar

Willem-Siebe

View GitHub Profile
@Willem-Siebe
Willem-Siebe / functions.php
Last active September 7, 2020 10:56
Replace the 'x' in WooCommerce cart.php with text because 'x' is not helpfull at all for screenreader users. I give a extra class to the text so that it can be hidden with CSS for visual browsers, because I replace that link with Font Awesome icon using :before. See also: https://github.com/woothemes/woocommerce/issues/5725.
// Replace the 'x' in WooCommerce cart.php with text because 'x' is not helpfull at all for screenreader users, see https://gist.github.com/Willem-Siebe/dc34719917e77fcecbc6.
function wsis_woocommerce_remove_item( $wsis_html, $cart_item_key ) {
$cart_item_key = $cart_item_key;
$wsis_html = sprintf( '<a href="%s" class="remove" title="%s"><span class="wsis-remove-item">%s</span></a>', esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'woocommerce' ), __( 'Remove this item', 'woocommerce' ));
return $wsis_html;
}
add_filter ( 'woocommerce_cart_item_remove_link', 'wsis_woocommerce_remove_item', 10, 2 );
@Willem-Siebe
Willem-Siebe / wp-config.php
Last active September 3, 2019 19:15
Increase WP_MEMORY_LIMIT. See: http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP. PDF Invoices plugin (http://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/) needs 128MB for optimal performance. WooCommerce needs 64MB.
/** Increase PHP Memory, see https://gist.github.com/Willem-Siebe/8a7d17c5f82859129f32.
*
* Please note, this has to be put before wp-settings.php inclusion.
*/
define( 'WP_MEMORY_LIMIT', '128M' );
// Administration tasks require much memory than usual operation. When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
// Remove CSS and/or JS for Select2 used by WooCommerce, see https://gist.github.com/Willem-Siebe/c6d798ccba249d5bf080.
add_action( 'wp_enqueue_scripts', 'wsis_dequeue_stylesandscripts_select2', 100 );
function wsis_dequeue_stylesandscripts_select2() {
if ( class_exists( 'woocommerce' ) ) {
wp_dequeue_style( 'select2' );
wp_deregister_style( 'select2' );
wp_dequeue_script( 'select2');
@Willem-Siebe
Willem-Siebe / functions.php
Created May 20, 2014 15:41
Remove TablePress plugin CSS in favor of using LESS from Twitter Bootstrap, see http://wordpress.org/support/topic/disable-standard-tablepress-css?replies=10.
// Remove TablePress plugin CSS in favor of using LESS from Twitter Bootstrap, see https://gist.github.com/Willem-Siebe/ba6428a1dcd6b767a818.
add_filter( 'tablepress_use_default_css', '__return_false' );
// Remove CSS and JS from Jetpack plugin, see https://gist.github.com/Willem-Siebe/3f6bff80b01973a21467.
function wsis_remove_jetpack_assets() {
// devicepx-jetpack.js, used to optionally load retina/HiDPI versions of files (Gravatars etc) which are known to support it, for devices that run at a higher resolution.
wp_dequeue_script( 'devicepx' );
}
add_action( 'wp_enqueue_scripts', 'wsis_remove_jetpack_assets', 20 );
@Willem-Siebe
Willem-Siebe / invoice.php
Last active October 16, 2017 12:19
Add the three custom fields available in WooCommerce PDF Invoices & Packing Slips to your own custom invoice template, see http://wordpress.org/support/topic/adding-text-field-below-the-table.
<!-- Add the first custom fields available in WooCommerce PDF Invoices & Packing Slips to your own custom invoice template, see https://gist.github.com/Willem-Siebe/cf8474b5ca4e72880a04. -->
<?php if ( $wpo_wcpdf->get_extra_1() ): ?>
<div id="extra1">
<?php $wpo_wcpdf->extra_1(); ?>
</div>
<?php endif; ?>
<!-- Add the second custom fields available in WooCommerce PDF Invoices & Packing Slips to your own custom invoice template, see https://gist.github.com/Willem-Siebe/cf8474b5ca4e72880a04. -->
@Willem-Siebe
Willem-Siebe / functions.php
Last active July 9, 2017 13:36
Display WooCommerce shop, category and tag description also on next pages. I can only changing it by declaring the same function name in my own functions.php, so that is what I did.
// Display WooCommerce shop, category and tag description also on next pages, see https://gist.github.com/Willem-Siebe/c883eeb2eefb5eea82ab.
function woocommerce_product_archive_description() {
if ( is_post_type_archive( 'product' ) && get_query_var( 'paged' ) >= 0 ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
$description = apply_filters( 'the_content', $shop_page->post_content );
if ( $description ) {
echo '<div class="page-description">' . $description . '</div>';
}
@Willem-Siebe
Willem-Siebe / functions.php
Last active July 9, 2017 13:35
Remove CSS from WooCommerce 2.1 and further, see http://jameskoster.co.uk/snippets/disable-woocommerce-styles/.
// Remove CSS from WooCommerce after version 2.1, see https://gist.github.com/Willem-Siebe/8c29bcfa791316165127.
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
@Willem-Siebe
Willem-Siebe / functions.php
Created May 23, 2014 08:09
The return to shop button in WooCommerce empty-cart.php goes to the shop archive page. However, if we don't want a shop page and leave this option unset in WooCommerce settings, we need this button to go to our homepage. See http://codex.wordpress.org/Function_Reference/get_home_url. For help on filters see http://dev.themeblvd.com/tutorial/filt…
// The return to shop button in WooCommerce empty-cart.php goes to the shop archive page. However, if we don't want a shop page and leave this option unset in WooCommerce settings, we need this button to go to our homepage. See https://gist.github.com/Willem-Siebe/c1d70aeef75a3e60ab15.
function wsis_woocommerce_return_to_shop_redirect() {
return get_home_url();
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wsis_woocommerce_return_to_shop_redirect' );
@Willem-Siebe
Willem-Siebe / invoice.php
Last active July 9, 2017 13:34
Add Order number besides invoicenumber to invoice (WooCommerce PDF Invoices & Packing Slips plugin), see http://wordpress.org/support/topic/invoice-number-vs-invoice-order?replies=27#post-5434747.
<!-- Add Order number besides invoicenumber to invoice (WooCommerce PDF Invoices & Packing Slips plugin), see https://gist.github.com/Willem-Siebe/c05bd7d2938e951b54bc -->
<span class="order-number-label"><?php _e( 'Order Number:', 'wpo_wcpdf' ); ?></span>
<span class="order-number"><?php $wpo_wcpdf->order_number(); ?></span><br />