Skip to content

Instantly share code, notes, and snippets.

View jtleathers's full-sized avatar

Jonathon jtleathers

View GitHub Profile
@jtleathers
jtleathers / .gitignore
Created December 23, 2024 07:28
.gitignore file for a WordPress block theme
# OS generated files #
######################
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
@jtleathers
jtleathers / create-terms.php
Last active October 10, 2024 21:25
Programmatically add Taxonomy Terms after Publishing Posts
<?php
/**
* Create and update terms when a post is saved.
* Based on the example here: https://brennaobrien.com/blog/2013/11/autopopulating-wordpress-taxonomies.html
*
* @param int $post_id ID of the post being saved.
*/
function fwd_update_terms_on_save( $post_id ) {
// Only update terms if the post being saved is in a specific post type.
@jtleathers
jtleathers / _mixins.scss
Created April 11, 2024 23:57
Fix _mixins.scss in _s
// Center block
@mixin center-block {
display: block;
margin-left: auto;
margin-right: auto;
}
// Column width with margin
@mixin column-width($numberColumns: 3) {
width: calc( map-get($columns, $numberColumns) - ( ( $columns__margin * ( $numberColumns - 1 ) ) / $numberColumns ) );
@jtleathers
jtleathers / Add_a_Local_Git_Repository_to_GitHub.md
Last active January 9, 2024 08:20 — forked from alexpchin/Add_Existing_Project_To_Git.md
Add a Local Git Repository to GitHub

Adding an existing project to GitHub using the command line

Simple steps to add existing project to GitHub.

1. Create a new repository on GitHub.

In Terminal, point to the folder you want to track with Git.

2. Initialize the local directory as a Git repository.

git init
@jtleathers
jtleathers / .htaccess
Created January 9, 2023 08:01
React.js + Apache Refresh Fix -- Root Directory
# Use this code if your React App will be in the root directory on the server
# Create a .htaccess file in the root directory (public_html folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
@jtleathers
jtleathers / .htaccess
Last active March 5, 2024 22:13
React.js + Apache Refresh Fix -- Subdirectory
# Use this code if your React App will be in a subdirectory/folder on the server
# Create a .htaccess file in that subdirectory/folder and copy this code
# Replace the word SUBDIRECTORY on lines 6 and 11 with the subdirectory/folder name
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /SUBDIRECTORY/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
@jtleathers
jtleathers / .htaccess
Created August 23, 2021 21:18
Force HTTPS
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@jtleathers
jtleathers / remove-admin-links.php
Last active May 7, 2025 16:35
Remove WordPress admin menu links
@jtleathers
jtleathers / customize-wp-admin-menu.php
Last active March 23, 2022 19:36
Customize the WordPress Admin Menu
<?php
// Customize the WordPress Admin Menu
function fwd_custom_menu_order( $menu_ord ) {
if ( !$menu_ord ) return true;
// Modify the following array to reorder the menu
// Add links, remove links, reorder links
return array(
'index.php', // Dashboard
'separator1', // First separator
@jtleathers
jtleathers / move-yoast-metabox.php
Last active November 6, 2020 21:38
Move Yoast Metabox to Bottom
<?php
/**
* Lower Yoast SEO Metabox location
*/
function yoast_to_bottom(){
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoast_to_bottom' );