Skip to content

Instantly share code, notes, and snippets.

View nathan-roberts's full-sized avatar
💭
Building

Nathan Roberts nathan-roberts

💭
Building
View GitHub Profile
<?php
// Template Logic
function twt_trailer_archive_template($original_template)
{
// Set our post type
$post_type = 'trailer';
// Set the expected path for a override template within the site theme
$file = trailingslashit(get_template_directory()) . "archive-$post_type.php";
@nathan-roberts
nathan-roberts / disable_core_blocks.php
Last active May 19, 2022 03:40
Remove Core Gutenberg Blocks
<?php
// Disable core WordPress Gutenberg Blocks
add_filter('allowed_block_types', 'misha_allowed_block_types');
function misha_allowed_block_types($allowed_blocks)
{
$allowed_blocks = [];
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();
@nathan-roberts
nathan-roberts / disable-core-blocks.php
Last active May 19, 2022 03:47
Disable Core Gutenberg Blocks
add_filter('allowed_block_types', 'ca_allowed_block_types');
function ca_allowed_block_types($allowed_blocks)
{
$allowed_blocks = [];
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();
$blocks = array_keys($block_types);
foreach ($blocks as $block => $block_name) {
@nathan-roberts
nathan-roberts / codeable-dark-style.css
Last active May 24, 2022 06:36
Dark Mode Stylesheet For Codeable.io
body,
code {
background-color: #10282E;
color: #c9d1d9;
}
nav.navigation .navigation-link,
nav.navigation {
@nathan-roberts
nathan-roberts / gutenberg-disable-fullscreen.php
Created July 28, 2022 08:45
Disable Fullscreen Gutenberg
<?php
/**
* Disable Fullscreen Gutenberg.
*/
if (is_admin()) {
function ca_disable_editor_fullscreen_by_default()
{
$script = "jQuery( window ).load(function() { const isFullscreenMode = wp.data.select( 'core/edit-post' ).isFeatureActive( 'fullscreenMode' ); if ( isFullscreenMode ) { wp.data.dispatch( 'core/edit-post' ).toggleFeature( 'fullscreenMode' ); } });";
wp_add_inline_script('wp-blocks', $script);
}
@nathan-roberts
nathan-roberts / meta-query.sql
Last active August 5, 2022 07:10
WP SQL Meta Query
SELECT
wp_posts.ID,
wp_posts.post_title,
bill.meta_value AS bill,
year.meta_value AS year,
chapter.meta_value AS chapter,
house.meta_value AS house
FROM
wp_posts
LEFT JOIN wp_postmeta AS bill ON wp_posts.ID = bill.post_id
@nathan-roberts
nathan-roberts / .zshrc
Last active September 26, 2022 17:18
.ZSHRC
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# ZSH=/usr/share/oh-my-zsh/
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
@nathan-roberts
nathan-roberts / background.js
Created November 4, 2022 00:30 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@nathan-roberts
nathan-roberts / query.php
Created November 8, 2022 02:09
Query posts by users roles
<?php
/**
* Get all the user ID's for the specified user roles
*
* @param array $role
* @return array User ID's
*/
function get_all_user_ids_by_user_roles($role)
{
@nathan-roberts
nathan-roberts / deploy.yml
Created July 14, 2023 16:07
Build SASS and Deploy via SSH
name: SCSS Build and Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build: