Skip to content

Instantly share code, notes, and snippets.

View thetwopct's full-sized avatar

James Hunt thetwopct

View GitHub Profile
@thetwopct
thetwopct / bash.sh
Last active January 15, 2021 00:08
Loading quick WordPress environment via wp-env
# make directory.
mkdir XXX
# go in to directory.
cd XXX
# Initialise NPM.
npm init
# Install wp-env.
@thetwopct
thetwopct / wp-config.php
Created January 11, 2021 13:09
Prevent WordPress theme editing in the WordPress Admin dashboard
# Disable theme editing in WordPress.
define( 'DISALLOW_FILE_EDIT', true );
@thetwopct
thetwopct / cli.sh
Last active March 18, 2021 00:20
Make a Gutenberg Block Plugin via @WordPress scripts
npx @wordpress/create-block --namespace "lf" --title "Name" --short-description "Description" --wp-scripts --category "design" name-slug
@thetwopct
thetwopct / create-block.sh
Last active May 22, 2022 04:30
Building a new Gutenberg block editor block
# npx create-block
# go to root of plugins folder
# run the following to create a directory with scripts in it
npx @wordpress/create-block --namespace "ttp" --title "Block Name" --short-description "Something" --category "common" --wp-scripts some-directory-name
# --namespace <value> internal namespace for the block name
# --title <value> display title for the block and the WordPress plugin
# --short-description <value> short description for the block and the WordPress plugin
# --category <name> category name for the block - common, formatting, layout, widgets, embed
@thetwopct
thetwopct / functions.php
Last active September 22, 2020 07:26
Switch out YouTube embeds to use YouTube no cookie domain
// Add "nocookie" To WordPress oEmbeded Youtube Videos
function make_youtube_nocookie_oembed( $html ) {
return str_replace( 'youtube.com', 'youtube-nocookie.com', $html );
}
add_filter( 'embed_oembed_html', 'make_youtube_nocookie_oembed' );
// Note - previously embedded youtube videos store embed information in transients, so for best results when testing, use a new video URL each time.
@thetwopct
thetwopct / php-extensions.txt
Last active September 29, 2023 11:58
PHP 7.4 cPanel PHP Extension Settings
# PHP 7.4 cPanel PHP Extension Settings
dom
fileinfo
gd
imagick
intl
json
mbstring
mysqli
@thetwopct
thetwopct / functions.php
Last active August 11, 2020 22:10
Disable WordPress Block Directory
<?php
// Disable Block Directory
add_action(
'plugins_loaded',
function() {
remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
remove_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
}
);
@thetwopct
thetwopct / functions.php
Last active August 11, 2020 22:10
Disable Sitemap in WordPress (5.5+)
<?php
// Disable Sitemap - WordPress (5.5+)
add_filter('wp_sitemaps_enabled', '__return_false');
@thetwopct
thetwopct / functions.php
Created August 3, 2020 09:53
Remove (Gutenberg) Block Directory from WordPress 5.5+
add_action(
'plugins_loaded',
function() {
remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
remove_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
}
);
<?php
/**
* Newsletter
*
* @package WordPress
* @subpackage lf-theme
* @since 1.0.0
*/
?>