Skip to content

Instantly share code, notes, and snippets.

View benhuson's full-sized avatar

Ben Huson benhuson

View GitHub Profile
@benhuson
benhuson / attributes-as-options.php
Created August 23, 2022 16:16 — forked from dazecoop/attributes-as-options.php
WooCommerce product attributes as selectable options without variations
<?php
/**
* List available attributes on product page in a drop-down selection
*/
add_action('woocommerce_before_add_to_cart_button', 'list_attributes_on_product_page');
function list_attributes_on_product_page() {
global $product;
$attributes = $product->get_attributes();
@benhuson
benhuson / X-Poedit-KeywordsList
Last active June 6, 2019 09:37
WordPress Plugin Language .pot X-Poedit-KeywordsList
__;
_e;
_x:1,2c;
_ex:1,2c;
esc_html__;
esc_html_e;
esc_html_x:1,2c;
esc_attr__;
esc_attr_e;
esc_attr_x:1,2c
@benhuson
benhuson / .htaccess
Created May 22, 2019 10:08
.htaccess block IP behind load balancer
Order Deny,Allow
Deny from all
SetEnvIf X-Forwarded-For "^1\.1\.1\.1" AllowAccess
Allow from env=AllowAccess
@benhuson
benhuson / .htaccess
Created September 14, 2016 11:42
Disable HTTP Strict Transport Security (HSTS) in .htaccess
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=0; includeSubDomains; preload" env=HTTPS
</IfModule>
@benhuson
benhuson / all-category-post-permalink.php
Last active May 20, 2016 19:01
All Category Post Permalink
<?php
/**
* All Category Post Permalink
*
* When using %category% in permalinks, this allows you to substitute
* an alternative slug "all" to replace the category. By default this
* is not permitted - the post page is force redirected to a URL
* with a valid category.
*/
# WordPress Project .gitignore
# Ignore system files
.DS_Store
# Ignore all files by default except `.gitignore` and `site` folder
/*
!/.gitignore
!/site/
@benhuson
benhuson / remove_posts_page_admin_notice.php
Created November 17, 2015 16:20
Remove WordPress Posts Page Admin Notice
<?php
/**
* Remove Posts Page Admin Notice
*
* Since WordPress 4.2, if you edit the page used as the Posts page
* and there was no content saved for that page, the editor functionality
* is removed and a message displayed instead.
*
* The following function re-enables the editor on this page.
Index: trunk/taxonomy-images.php
===================================================================
--- trunk/taxonomy-images.php (revision 752123)
+++ trunk/taxonomy-images.php (working copy)
@@ -798,10 +798,13 @@
$term = get_term( $term_id, $taxonomy->name );
+ $nonce = wp_create_nonce( 'taxonomy-image-plugin-create-association' );
+ $nonce_remove = wp_create_nonce( 'taxonomy-image-plugin-remove-association' );
@benhuson
benhuson / google-tag-manager.patch
Created September 8, 2015 08:20
Google Tag Manager Patch - Only output tag once. https://wordpress.org/plugins/google-tag-manager/
Index: trunk/google-tag-manager.php
===================================================================
--- trunk/google-tag-manager.php (revision 1182053)
+++ trunk/google-tag-manager.php (working copy)
@@ -11,6 +11,8 @@
class google_tag_manager {
+ public static $output_once = false;
+
@benhuson
benhuson / intelligent-post-terms.php
Created September 3, 2015 17:02
Intelligent Post Terms - use most appropriate category for WordPress post links.
<?php
/**
* Intelligent Post Terms
*
* If the post category is included in the permalink for posts
* we can be clever and detect when a post is displayed or linked to
* which is the most suitable category to use in the URL.
*
* @version 1.0