Skip to content

Instantly share code, notes, and snippets.

View GarySwift's full-sized avatar

Gary Swift GarySwift

  • Waterford City, Ireland
View GitHub Profile
@ThatGuySam
ThatGuySam / allowed-block-types.php
Last active October 31, 2023 08:06
Limit allowed Gutenberg Blocks with full list of native Wordpress Blocks
<?php
// Hook up function to allowed_block_types filter
add_filter( 'allowed_block_types', 'set_allowed_block_types' );
/**
* Set allowed gutenburg block types
* https://rudrastyh.com/gutenberg/remove-default-blocks.html
*/
source ~/.profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# The inspiration for this file can be found: https://natelandau.com/my-mac-osx-bash_profile/
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
@MrTomek
MrTomek / EloquentCheatSheet.md
Last active June 27, 2024 08:43 — forked from avataru/EloquentCheatSheet.md
Eloquent relationships cheat sheet
@derweili
derweili / disable-acf-blocks-on-edit.js
Last active April 29, 2022 17:09
Disable Links in ACF Block-Edit Method
/*
* Wrap all ACF Blocks in Disabled block to disable all links in edit view
*/
const { createHigherOrderComponent } = wp.compose;
const { Fragment } = wp.element;
import { Disabled } from '@wordpress/components';
const withDisabledCompontent = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
@PoeHaH
PoeHaH / gist:ab9d8ac1b4ddee168d4d96c71797df31
Last active November 21, 2022 11:12
JSON representation of EU countries, 2 letter codes and VAT amounts. Good to check the EU VIES database
var euList =
[
{country:'Austria',code:'AT',vat:20},
{country:'Belgium',code:'BE',vat:21},
{country:'Bulgaria',code:'BG',vat:20},
{country:'Croatia',code:'HR',vat:25},
{country:'Cyprus',code:'CY',vat:19},
{country:'Czech Republic',code:'CZ',vat:21},
{country:'Denmark',code:'DK',vat:25},
{country:'Estonia',code:'EE',vat:20},
@carlodaniele
carlodaniele / custom_menu_admin.php
Last active May 26, 2022 20:32
A basic plugin showing how to add menu metaboxes to admin menu page
<?php
/**
* @package Custom_menu_admin
* @version 1.0
*/
/*
Plugin Name: Custom menu admin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@themepaint
themepaint / Woocommerce Price Filter CSS
Created February 2, 2016 08:20
Woocommerce Price Filter CSS
.price_slider{
margin-bottom: 1em;
}
.price_slider_amount {
text-align: right;
line-height: 2.4em;
font-size: 0.8751em;
}
@superbiche
superbiche / wp-autosave-not-draft.php
Created November 26, 2015 15:40
Wordpress save_post action, that doesn't fire when autosaving.
add_action('save_post', 'my_post_saved');
function my_post_saved($post_id, $post) {
if (isset($post->post_status) && 'auto-draft' == $post->post_status) {
return;
}
// Autosave, do nothing
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@nikolov-tmw
nikolov-tmw / custom-menu-panel.php
Last active February 22, 2024 21:29
This registers a custom meta box for nav menus and renders it. Obviously $my_items would ideally be not hard-coded and instead it would come somewhere from the DB. The custom items add to the menu and save properly, but will probably not be displayed correctly. You might need to hook to the 'wp_setup_nav_menu_item' filter in order to fix the men…
<?php
function my_register_menu_metabox() {
$custom_param = array( 0 => 'This param will be passed to my_render_menu_metabox' );
add_meta_box( 'my-menu-test-metabox', 'Test Menu Metabox', 'my_render_menu_metabox', 'nav-menus', 'side', 'default', $custom_param );
}
add_action( 'admin_head-nav-menus.php', 'my_register_menu_metabox' );
/**