Skip to content

Instantly share code, notes, and snippets.

Gabe Shackle hereswhatidid

Block or report user

Report or block hereswhatidid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hereswhatidid
hereswhatidid / acf-block-preview-action.js
Last active Sep 4, 2019
Example ACF block preview action
View acf-block-preview-action.js
if( window.acf ) {
window.acf.addAction( 'render_block_preview/type=accordion', function( $elem, blockDetails ) {
initializeElement( $elem );
} );
}
@hereswhatidid
hereswhatidid / custom-package-name.php
Created Oct 18, 2016
Create custom shipping packages and manually set their display names in WooCommerce
View custom-package-name.php
<?php
add_filter( 'woocommerce_shipping_package_name', 'rmg_package_names', 10, 3 );
function rmg_package_names( $package_name, $i, $package ) {
if ( ! empty( $package['name'] ) ) {
$package_name = $package['name'];
}
@hereswhatidid
hereswhatidid / acf-gf-dropdown.php
Last active Jul 22, 2019
Populate ACF drop down with Gravity Forms forms
View acf-gf-dropdown.php
<?php
namespace HWID\ACFGravity;
class ACF_GF_DropDown {
public static function init() {
add_filter( 'acf/load_field/key=FIELDKEY', [ 'HWID\ACFGravity\ACF_GF_DropDown', 'populate_gform_dropdown' ] );
@hereswhatidid
hereswhatidid / create-file-archive.sh
Last active Jul 18, 2019
Puts the modified files in an archive using git
View create-file-archive.sh
git archive -o update.zip HEAD $(git diff --name-only 8de5622^)
@hereswhatidid
hereswhatidid / grouped-viewmodel.js
Last active Jun 24, 2019
Knockout extender to group the results of an observable array.
View grouped-viewmodel.js
var ViewModel = function( data ) {
this.observableArrayObject = ko.observableArray( data.items ).extend( { 'grouped': 4 } );
};
@hereswhatidid
hereswhatidid / archive-commit.bat
Last active May 14, 2019
Create a zip archive of a specific commit. The archive will be named deploy/deploy-COMMITID.zip.
View archive-commit.bat
setlocal enabledelayedexpansion
set var=%1
set output=
for /f "delims=" %%a in ('git diff-tree --no-commit-id --name-only -r %1^^') do ( set output=!output! "%%a" )
git archive -o update-%var:~0,7%.zip HEAD %output%
endlocal
@hereswhatidid
hereswhatidid / range.knockout.js
Created Jan 1, 2014
Knockout extender to force a field to be an integer value within a specified range.
View range.knockout.js
ko.extenders.range = function( target, intRange ) {
//create a writeable computed observable to intercept writes to our observable
var result = ko.computed({
read: target, //always return the original observables value
write: function( newValue ) {
var current = target(),
newValueAsNum = isNaN( newValue ) ? 0 : parseInt( +newValue, 10 ),
valueToWrite = newValueAsNum;
if ( newValueAsNum < intRange.min ) {
@hereswhatidid
hereswhatidid / acf-sample-options.php
Last active Apr 22, 2019
Set correct language for ACF options pages with custom post_id
View acf-sample-options.php
<?php
class ACF_SampleOptions_Page {
static $slug = 'sample_options_slug';
static $post_id = 'sample_options_id';
public static function init() {
@hereswhatidid
hereswhatidid / Settings.php
Created Mar 21, 2019
WooCommerce custom settings page
View Settings.php
<?php
namespace RMG\QuoteBuilder;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'RMG\QuoteBuilder\Settings_Quotes', false ) ) {
return new Settings_Quotes();
@hereswhatidid
hereswhatidid / custom-gut-category.php
Last active Mar 8, 2019
Register custom Gutenberg block category
View custom-gut-category.php
<?php
function new_category( $categories, $post ) {
return array_merge(
$categories,
array(
array(
'slug' => 'custom-category',
'title' => __( 'Custom Category', 'language' ),
),
)
You can’t perform that action at this time.