Skip to content

Instantly share code, notes, and snippets.

@nathaningram
nathaningram / cfdash.php
Last active April 14, 2024 08:56
Creating a Starter Site - Custom Functions - Dashboard
<?php
/*
Plugin Name: Custom Dashboard Functions
Plugin URI: https://nathaningram.com
Description: Customize the WP Admin
Version: 2023.11
Author: Nathan Ingram
Author URI: https://nathaningram.com
License: GPL2
*/
@nathaningram
nathaningram / wp-config.php
Last active November 28, 2023 19:28
Creating a Starter Site - Customized wp-config
<?php
/* Debug Options */
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', false );
/* MySQL Settings */
define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'username_here' );
@nathaningram
nathaningram / placeholder.css
Created August 5, 2022 17:56
Highlight Placeholder Images
/* Add Border to Images with PLACEHOLDER in filename */
img[src*="PLACEHOLDER"] {
border:10px #FF0000 solid !important;
}
@nathaningram
nathaningram / remove-gb-icon.php
Created May 16, 2022 19:42
Remove Gridbuilder Icon from TinyMCE
// Removes Gridbuilder icon from TinyMCE
add_filter(
'mce_buttons',
function( $buttons ) {
$key = array_search( 'wpgb', $buttons, true );
unset( $buttons[ $key ] );
return $buttons;
}, 99
);
@nathaningram
nathaningram / default-tax.php
Created May 10, 2022 21:50
Set a Default Taxonomy for CPTs
// Set "Upcoming" as Default Tax for Events (this applies on publish)
// Source: https://gist.github.com/mayeenulislam/f208b4fd408fd4742c06
function ni_set_default_object_terms( $post_id, $post ) {
if ( 'publish' === $post->post_status ) {
$defaults = array(
'post_tag' => array( 'event' ),
'event-status' => array( 'upcoming' ),
);
$taxonomies = get_object_taxonomies( $post->post_type );
@nathaningram
nathaningram / cpt-title.php
Last active April 22, 2022 17:18
Change Title Placeholder Text for Custom Post Types
// Change Placeholder Text in Title for CPT
function ni_change_cpt_title_text( $title ){
$screen = get_current_screen();
if ( 'team' == $screen->post_type ) {
$title = 'Enter Team Member Name ';
}
if ( 'service' == $screen->post_type ) {
$title = 'Enter Service Name ';
} //continue replicating these if statements for as many CPTs as you like
@nathaningram
nathaningram / enable-bvb-svgs.php
Created April 7, 2022 19:56
Enable SVG Uploads in Beaver Builder Modules
// Enable SVG Uploads in Beaver Builder Modules
add_filter( 'fl_module_upload_regex', function( $regex, $type, $ext, $file ) {
$regex['photo'] = '#(jpe?g|png|gif|bmp|tiff?|svg)#i';
return $regex;
}, 10, 4 );
@nathaningram
nathaningram / remove-slug.php
Created April 7, 2022 19:55
Remove Slug from CPT URLs
//Removes Slugs from CPT URLs
function na_remove_slug( $post_link, $post, $leavename ) {
if ( 'linked_article' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
@nathaningram
nathaningram / layout.htm
Created March 30, 2022 19:28
Events Calendar Custom Layout
<div class="event-wrapper">
<a class="event-link" href="[wpbb post:url]">
<div class="event-date-outer-wrapper mobilehide">
<div class="event-date-wrapper">
<div class="event-month">
[wpbb post:the_events_calendar_start_date format='M']
</div>
<div class="event-day">
[wpbb post:the_events_calendar_start_date format='j']
</div>
@nathaningram
nathaningram / behind-the-site.php
Last active April 1, 2022 20:54
Behind the Site Code Snippets
////////// Snippets from Behind the Site March 2022 //////////
// Add to the functions.php of your active child theme or a custom functions plugin
/////////////// WooCommerce Modifications ///////////////
//Show FREE rather than $0.00
//Source: https://www.businessbloomer.com/woocommerce-display-free-instead-0-00-empty-price/