Skip to content

Instantly share code, notes, and snippets.

@bacoords
bacoords / wp.jquery.default.js
Created July 2, 2019 20:45
Just a default wrapper
(function($) {
// Any generic functions can go here...
$(document).ready(function($){
// Anything that needs to wait for the document to be ready goes here
});
@mathiasbynens
mathiasbynens / escape.js
Created June 26, 2019 07:29
Escaping JSON-stringified data for use as a JavaScript string literal
// This object contains a string value that in contains a single quote,
// a double quote, a backtick, and a backslash.
const data = { foo: `a'b"c\`d\\e` };
// Turn the data into its JSON-stringified form.
const json = JSON.stringify(data);
// Now, we want to insert the data into a script body as a JavaScript
// string literal per https://v8.dev/blog/cost-of-javascript-2019#json,
// escaping special characters like `"` in the data.
@matthewjberger
matthewjberger / GroupCommands.ps1
Last active June 19, 2020 23:18
Creating windows users and groups with powershell
$fakeUserName = "Some Engineer"
$fakeUserDescription = "A fake engineer used for testing purposes"
$groups = @(
[System.Tuple]::Create('My Group', 'Users who have two thumbs'),
[System.Tuple]::Create('My Other Group', 'Users who have no thumbs')
)
function GetADSI()
{
<?php
/*
* Plugin Name: WP REST API Demo
* Plugin URI: https://gist.github.com/wpscholar/693517420ca6c9e29e7719ef24e7e00f
* Description: A developer plugin designed for playing around with the WordPress REST API.
* Version: 1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
<?php
/*
* Plugin Name: WP REST API - Allow All CORS Requests
* Description: Adds headers to allow cross-origin requests to the WordPress REST API.
* Version: 1.0
* Plugin URI: https://gist.github.com/wpscholar/59f5708cba291a314375b2dedd104e1e
* Author: Micah Wood
* Author URI: https://wpscholar.com
*/
<?php
/**
* Gravity Perks // GP Limit Submissions // Apply Limit Collectively to Group of Forms
* http://gravitywiz.com/documentation/gravity-forms-limit-submissions/
*/
add_filter( 'gpls_rule_groups', function( $rule_groups, $form_id ) {
// Update "123" to the ID of the form that will share its feeds with the other forms.
$primary_form_id = 123;
add_filter( 'gform_form_post_get_meta_7', 'add_form_fields' );
function add_form_fields( $form ) {
// Don't make the parent form messy
if ( ! GFCommon::is_form_editor() ) {
// form we are adding fields to
$parent_id = $form['id'];
// template form ID
$childId = 5;
<?php
/**
* Gravity Perks // Populate Anything // Use Standard Merge Tags in Choice/Value Templates
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/
*/
add_filter( 'gppa_process_template', function( $template_value, $field, $template, $populate, $object, $object_type, $objects ) {
return GFCommon::replace_variables( $template_value, GFAPI::get_form( $object->form_id ), (array) $object );
}, 10, 7 );
@rafaehlers
rafaehlers / gv-remove-all-styles-and-scripts.php
Last active May 11, 2021 18:42
Dequeue/Deregister/Remove all scripts of GravityView from the front-end of your website
<?php // don't copy this line
add_action( 'wp_enqueue_scripts', 'gv_dequeue_main_css', 30 );
add_action( 'wp_print_scripts', 'gv_dequeue_main_css', 2 );
function gv_dequeue_main_css() {
wp_dequeue_style( 'gravityview_default_style' );
wp_dequeue_style( 'gravityview_style_default_table' );
wp_dequeue_style( 'gravityview_style_default_list' );