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 August 29, 2015 14:00
Loads the Pinterest JavaScript asynchronously. I add this to my WordPress website with wp_head, but you can copy and paste this snippet anywhere on your page. You only need to load this script once per page, no matter how many buttons or widgets you use. See: https://developers.pinterest.com/pin_it/. I also added a line to set the data-pin-hover…
// Add Pinterest Javascript to your website, see https://gist.github.com/Willem-Siebe/11351787.
function wsis_add_pinterest_script() {
?>
<script type="text/javascript">
(function(d){
var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
p.type = 'text/javascript';
p.async = true;
p.setAttribute('data-pin-hover', true);
@Willem-Siebe
Willem-Siebe / robots.txt
Last active August 29, 2015 14:00
The ideal Robots.txt for your WordPress website (staging and development sites as well). See http://spoelstra.ws/crawlen-indexeren-robots-txt-wordpress/ (in Dutch).
# The ideal Robots.txt for your WordPress website, see https://gist.github.com/Willem-Siebe/11368429.
User-Agent: *
Disallow: /wp-content/plugins/
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:00
Don't load the WPML Language selector CSS. See http://wpml.org/forums/topic/language-selector-cssv3-1-4/.
// Don't load the WPML Language selector CSS, see https://gist.github.com/Willem-Siebe/751d2a2a9cedf6036256.
define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);
@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 WooCommerce breadcrumbs, see https://gist.github.com/Willem-Siebe/65d59638d503682fa67a.
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
@Willem-Siebe
Willem-Siebe / functions.php
Last active July 8, 2017 19:29
Remove Shop page from WordPress SEO (Yoast) WooCommerce breadcrumb on is_product page, see http://wpquestions.com/question/showChrono/id/8603.
// Remove Shop page from WooCommerce breadcrumb on is_product page, see https://gist.github.com/Willem-Siebe/6f43704e8536fc308fc3.
function wsis_wpseo_breadcrumb_output( $output ){
if( is_product() ){
$from = ' » <span typeof="v:Breadcrumb"><a href="http://yoururl.com/shop/" rel="v:url" property="v:title">Producten</a></span>';
$to = '';
$output = str_replace( $from, $to, $output );
@Willem-Siebe
Willem-Siebe / functions.php
Last active September 8, 2016 11:12
Translate Date format multilangual website using WPML, see http://wpml.org/forums/topic/date-formatting-issue/.
// Translate Date format multilingual website using WPML, see https://gist.github.com/Willem-Siebe/5eb063c04dda7b6863e8.
/**
* WPML and Toolset Support Team.
* Register date_format option in string translations.
*
* @param string $format Initial format stored in database.
*
* @return string Translated format.
*/
@Willem-Siebe
Willem-Siebe / functions.php
Last active August 29, 2015 14:01
Integrate WooCommerce in your custom theme, see http://docs.woothemes.com/document/third-party-custom-theme-compatibility/. Be aware that if your parent theme uses "woocommerce.php" to remove or rename this file (this change will be lost when updating the theme).
// WooCommerce theme integration, see https://gist.github.com/Willem-Siebe/9cd10326c07f5e3e8076.
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields' );
function custom_woocommerce_billing_fields( $fields ) {
// Over-ride a single label
$fields['billing_first_name']['label'] = 'Your label';
// Over-ride a single required value
$fields['billing_first_name']['required'] = false;
@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 />