Skip to content

Instantly share code, notes, and snippets.

@igorbenic
igorbenic / add_metabox.php
Last active February 26, 2025 20:47
How to use the WordPress Code Editor in your Plugins or Themes | https://www.ibenic.com/wordpress-code-editor
<?php
add_action( 'add_meta_boxes', 'add_page_scripts' );
/**
* Register the metabox
*/
function add_page_scripts() {
add_meta_box( 'page-scripts', __( 'Page Scripts & Styles', 'textdomain' ), 'add_page_metabox_scripts_html', 'page', 'advanced' );
}
@RadGH
RadGH / wc-exclude-outofstock-query.php
Last active July 24, 2022 10:17
Exclude out of stock and hidden products from WooCommerce query with pre_get_posts (plus equivalent filter for Ajax Load More)
<?php
/*
Solution based on a Stack Overflow answer by patrickzdb:
https://stackoverflow.com/a/24514985/470480
Tax query solution for hidden products based on a WordPress Stack Exchange answer by kalle:
https://wordpress.stackexchange.com/a/262628/19105
Please note:
This file includes two functions/filters.
@derekashauer
derekashauer / custom-featured-image-size.php
Last active August 22, 2023 10:23
WordPress: Make unique custom image size ONLY for featured image of a post
@Xunnamius
Xunnamius / cloudflare.conf
Last active April 7, 2025 06:23
Fail2ban action.d for Cloudflare meant to replace the version that ships with fail2ban currently. This updated version of the action uses Cloudflare's 2023 v4 API (free tier WAF + free tier WAF lists) to ban hostile IPs.
# This version works with CF WAF (using zone rulesets) and obsoletes previous
# versions. This works will all CF account types. This action depends on curl
# and jp and will add/remove IPs from the $known_hostile_ips list. Creating the
# WAF rules need only be done once per zone. Creating the list need only be done
# once per account.
#
# Author: Bernard Dickens III (Xunnamius)
#
# Inspired by work from: Mike Rushton
# https://github.com/fail2ban/fail2ban/blob/master/config/action.d/cloudflare.conf