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
@nathan-roberts
nathan-roberts / function.php
Created November 8, 2023 23:27
ACF JSON - Save Specific Groups within Plugin
// Save ACF JSON for specific field groups only
add_filter('acf/update_field_group', 'hof_acf_json_save_for_specific_groups', 10, 1);
function hof_acf_json_save_for_specific_groups($field_group)
{
// Define your allowed field groups
$allowed_field_groups = array('group_650da9580c565'); // Replace with your actual field group keys
// Check if the current field group is allowed
@nathan-roberts
nathan-roberts / .gitignore
Created July 22, 2023 05:52
WordPress Gitignore
# WP Config
wp-config.php
# ignore these plugins
wp-content/plugins/hello.php
# ignore specific themes
wp-content/themes/twenty*/
span.number span {
padding: 10px 5px;
/* border: 1px solid #ccc; */
/* border-radius: 5px; */
display: inline-block;
/* cursor: move; */
}
.popup {
width: 100%;
@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:
@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 / 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 / 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 / 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 / .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 / 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) {