Skip to content

Instantly share code, notes, and snippets.

UPDATE wp_postmeta SET meta_value=concat(meta_value, ' %%sep%% %%sitename%%') WHERE meta_key ='_yoast_wpseo_title';
@barrd
barrd / no-fouc.html
Last active February 26, 2021 19:57 — forked from johnpolacek/gist:3827270
Prevent FOUC (flash of unstyled content)
<!-- @see http://johnpolacek.com/2012/10/03/help-prevent-fouc -->
<!-- WordPress implementation -->
<!-- Add to header -->
<style type="text/css">
.no-fouc {display: none;}
</style>
<script>
document.documentElement.className = 'no-fouc';
</script>
@barrd
barrd / .gitconfig
Created September 2, 2019 17:23
barrd .gitconfig
[user]
name = Dave Barr
email = foo@bar.com
[color]
ui = true
[core]
editor = code --wait
excludesfile = /Users/barrd/.gitignore_global
[filter "lfs"]
clean = git-lfs clean -- %f
@barrd
barrd / keybase.md
Created October 15, 2019 19:29
Keybase

Keybase proof

I hereby claim:

  • I am barrd on github.
  • I am barrd (https://keybase.io/barrd) on keybase.
  • I have a public key ASC1QtWlWxuAejZQSil1Jv3oiWemVVrnEHgntyrjJt0CvQo

To claim this, I am signing this object:

@barrd
barrd / wp-enable-avif-as-a-file-type.php
Last active March 3, 2023 14:29
WordPress enable AVIF file type
<?php
/**
* Enable AVIF types
*
* @see https://developer.wordpress.org/reference/functions/wp_check_filetype_and_ext/
*/
function barrd_enable_avif_types( $types, $file, $filename, $mimes ) {
if ( false !== strpos( $filename, '.avif' ) ) {
$types['ext'] = 'avif';
$types['type'] = 'image/avif';
@barrd
barrd / wp-hide-jquery-migration-notice.php
Created February 18, 2021 07:31
WordPress hide jQuery migration notice and disable admin email
<?php
/**
 * Hide jQuery Migration notice
 *
 * Temp fix until plugin can be removed
 *
 * @return void
 */
function removes_migrate_warning() {
@barrd
barrd / wp-load-all-required-dependencies.php
Last active April 16, 2021 18:51
WordPress load all required theme dependencies using RecursiveDirectoryIterator from inc
<?php
/**
* Required Dependencies
*/
// Construct the iterator.
$rdi = new RecursiveDirectoryIterator( get_template_directory() . '/inc' );
// Loop through PHP files.
foreach ( new RecursiveIteratorIterator( $rdi ) as $file ) {
if ( $file->getExtension() === 'php' ) {
@barrd
barrd / .gitignore
Created February 24, 2021 17:48
WordPress (Vanilla) Git Ignore File
# ---------------------------------------------------------------------
# Vanilla WordPress Git Ignore File
# ---------------------------------------------------------------------
# Ignore everything in root except wp-content dir & wp-config
/*
!wp-content/
!wp-config*
wp-config-sample.php
@barrd
barrd / wordpress-search-functions.php
Last active February 6, 2022 11:34
WordPress Search Functions
<?php
/**
* Exclude posts by ID
*
* @param array $query The WP_Query instance.
*/
function exclude_posts_from_search( $query ) {
if ( $query->is_main_query() && is_search() ) {
// Add post IDs into array.
$post_ids = array( 10, 11, 12 );
@barrd
barrd / reuseable-blocks-admin-menu.php
Created May 2, 2021 11:17
WordPress - Add reusable blocks into admin menu
<?php
/**
* Add reusable blocks into admin menu
*
* @link https://www.jemjabella.co.uk/2021/6-things-i-do-to-make-gutenberg-development-easier
*/
function add_reusable_blocks_admin_menu() {
add_menu_page(
'Reusable Blocks',
'Reusable Blocks',