Skip to content

Instantly share code, notes, and snippets.

@nathaningram
nathaningram / alpha-settings.php
Created May 2, 2023 17:28
Sort WP Admin Settings Menu Alphabetically
// Function to sort settings menu items alphabetically
function ni_sort_settings_menu_items_alphabetically() {
global $submenu;
// Check if the settings menu exists
if (isset($submenu['options-general.php']) && is_array($submenu['options-general.php'])) {
// Sort the items under the settings menu alphabetically
usort($submenu['options-general.php'], function ($a, $b) {
// Ensure both array elements have the 0-index set and are strings
if (isset($a[0]) && isset($b[0]) && is_string($a[0]) && is_string($b[0])) {
@nathaningram
nathaningram / hidecat.php
Created April 26, 2023 19:42
Hide Categories from WooCommerce Loop
// Add the code to your theme's functions.php file
function exclude_categories_from_shop_page( $query ) {
if ( ! is_admin() && is_shop() && $query->is_main_query() ) {
$tax_query = array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array('unlimited-power', 'weapons'),
'operator' => 'NOT IN'
@nathaningram
nathaningram / noshow.php
Created April 25, 2023 19:47
No Show WooCommerce Tag
//Hide Products with tag noshow from Shop Page
add_action( 'woocommerce_product_query', 'exclude_noshow_products' );
function exclude_noshow_products( $query ) {
if ( $query->is_main_query() && is_shop() ) {
$tax_query = array(
array(
'taxonomy' => 'product_tag',
'field' => 'slug',
@nathaningram
nathaningram / itsec-captcha-style.php
Created February 9, 2023 21:50
Add Stye to iThemes Security Captcha Agree Box
// Add Style to iTSec Captcha Agree Text
function bww_itsec_captcha_style() { ?>
<style type="text/css">
.itsec-recaptcha-opt-in {
border: 4px dashed #ff0000 !important;
background: #ffffff !important;
}
.itsec-recaptcha-opt-in::before {
@nathaningram
nathaningram / cpt-blocks.php
Created February 7, 2023 15:15
Convert to Block Support Per Post Type
// Adds Convert to Block Support Per Post Type
// Used along with Convert to Blocks plugin by 10up
// https://wordpress.org/plugins/convert-to-blocks/
add_filter( 'post_type_supports_convert_to_blocks', function( $supports, $post_type ) {
if ( $post_type === 'YOUR_CPT_SLUG_HERE' ) {
return true;
}
return $supports;
}, 10, 2 );
@nathaningram
nathaningram / styles.css
Last active December 17, 2023 01:47
Optimizing Your Starter Site - CSS Samples
/********* Kadence Menu *********/
/* Hides the underline on current menu items in underline style */
.header-navigation-style-underline .current-menu-item a:after,
.header-navigation-style-underline .menu-item-has-children a:after {
display: none;
}
.header-navigation-style-underline .current-menu-item a:hover:after {
@nathaningram
nathaningram / bb-delete-cache.php
Created November 2, 2022 18:58
Creating a Starter Site 2022 - MU Beaver Builder Delete Cache
<?php
/*
Plugin Name: BB delete cache
Plugin URI: http://www.wearewp.pro
Description: Add delete beaver builder cache button in admin bar
Contributors: wearewp, thierrypigot
Author: WeAreWP
Author URI: http://www.wearewp.pro
Text Domain: bb-delete-cache
Domain Path: /languages/
@nathaningram
nathaningram / cfdashwidgets.php
Last active April 14, 2024 14:10
Creating a Starter Site - Custom Functions - Dashboard Widgets
<?php
/*
Plugin Name: Custom Dashboard Widgets
Plugin URI: https://nathaningram.com
Description: Creates Custom Dashboard Widgets for Client Websites
Version: 2023.11
Author: Nathan Ingram
Author URI: https://nathaningram.com
License: GPL2
*/
@nathaningram
nathaningram / mu-shortcodes.php
Last active November 21, 2024 19:47
Starter Site 2024 Course - MU Shortcodes
<?php
/*
Plugin Name: Custom Shortcodes
Description: Add Custom Shortcodes
Plugin URI: https://wpnathan.com
Version: 2024.11
Author: Nathan Ingram
Author URI: https://wpnathan.com
License: GPL2
*/
@nathaningram
nathaningram / cfmedia.php
Last active April 14, 2024 12:00
Creating a Starter Site 2022 - Custom Functions - Media Handling
<?php
/*
Plugin Name: Custom Media Handling Fuctions
Plugin URI: https://nathaningram.com
Description: Customize WordPress Default Media Behavior
Version: 2023.11
Author: Nathan Ingram
Author URI: https://nathaningram.com
License: GPL2
*/