Skip to content

Instantly share code, notes, and snippets.

@kellenmace
kellenmace / add-unfiltered_html-capability-to-admins-or-editors.php
Last active September 20, 2022 18:29
Add unfiltered_html Capability to Admins or Editors in WordPress Multisite
<?php
/**
* Enable unfiltered_html capability for Editors.
*
* @param array $caps The user's capabilities.
* @param string $cap Capability name.
* @param int $user_id The user ID.
* @return array $caps The user's capabilities, with 'unfiltered_html' potentially added.
*/
@mgratch
mgratch / sideload-gf-images.php
Created June 7, 2016 00:24
sideload images from gf multi-upload
<?php
add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
function save_field_value( $value, $lead, $field, $form ) {
$output_ids = array();
global $files_to_sideload;
if(!isset($files_to_sideload) || empty($files_to_sideload)){
$files_to_sideload = array();
}
//if not the form with fields to encode, just return the unaltered value without checking the fields
@zackkatz
zackkatz / fix-checkboxes.php
Created May 17, 2016 04:39
Use UTF-8 checkmark instead of Dashicon .dashicons-yes icon font
<?php
add_filter( 'gravityview_field_tick', 'convert_gravityview_field_tick' );
/**
* Convert <span> to ✓
* @param string $existing_tick HTML span with `dashicons dashicons-yes` class
* @return string HTML entity checkmark character (✓)
*/
function convert_gravityview_field_tick( $existing_tick ) {
/**
* Get single entry pagination links
* to use: call anagram_entry_pagintion();
*
*/
function anagram_entry_pagintion() {
global $gravityview_view;
$criteria['paging'] = array(
'offset' => 0,
@stevenschobert
stevenschobert / load_remote_content_mail_dot_app.scpt
Last active January 12, 2022 11:19
Apple Script to click the "Load Remote Content" button. I like to disable all remote content in Mail.app, and then bind this script to a keyboard shortcut using Keyboard Maestro. https://www.keyboardmaestro.com
tell application "System Events" to tell process "Mail"
set mainWindow to a reference to the first window
set rootSplitter to a reference to the first splitter group of the mainWindow
set firstSplitter to a reference to the last splitter group of the rootSplitter
set scrollArea to a reference to the last scroll area of the firstSplitter
set scrollGroup to a reference to the first group of the scrollArea
if number of groups of the scrollGroup is greater than 1 then
set maybeRemoteContentGroup to a reference to the first group of the scrollGroup
@gmazzap
gmazzap / AutoPaginatedQuery.php
Last active April 8, 2016 21:49
`WP_Query` subclass that takes a non-paginated query and split into different paginated queries offering a transparent interface to "standard loop" usage.
<?php
namespace GM;
/**
* `WP_Query` subclass that takes a non-paginated query and split into different
* paginated queries offering a transparent interface to "standard loop" usage.
*
* The class is not 100% transparent:
* - the var `$posts` and the method `get_posts()`, that are not used directly
* in standard loop usage, here don't return array of all posts, but only posts
@spivurno
spivurno / gform_print_entry_content.php
Created November 2, 2015 14:35
Gravity Forms // Hooks // gform_print_entry_content
<?php
// remove default GF entry content function
remove_action( 'gform_print_entry_content', 'gform_default_entry_content', 10 );
// bind our custom entry content function
add_action( 'gform_print_entry_content', 'my_print_entry_content', 10, 3 );
function my_print_entry_content( $form, $entry, $entry_ids ) {
GFEntryDetail::lead_detail_grid( $form, $entry );
}
@gtallen1187
gtallen1187 / scar_tissue.md
Created November 1, 2015 23:53
talk given by John Ousterhout about sustaining relationships

"Scar Tissues Make Relationships Wear Out"

04/26/2103. From a lecture by Professor John Ousterhout at Stanford, class CS142.

This is my most touchy-feely thought for the weekend. Here’s the basic idea: It’s really hard to build relationships that last for a long time. If you haven’t discovered this, you will discover this sooner or later. And it's hard both for personal relationships and for business relationships. And to me, it's pretty amazing that two people can stay married for 25 years without killing each other.

[Laughter]

> But honestly, most professional relationships don't last anywhere near that long. The best bands always seem to break up after 2 or 3 years. And business partnerships fall apart, and there's all these problems in these relationships that just don't last. So, why is that? Well, in my view, it’s relationships don't fail because there some single catastrophic event to destroy them, although often there is a single catastrophic event around the the end of the relation

@leepettijohn
leepettijohn / functions.php
Last active January 11, 2024 23:16
Add Event to The Events Calendar from a Gravity Form
//The following section is an add-on to this tutorial - https://tri.be/gravity-forms-events-calendar-submissions/
//Shout to CreativeSlice.com for their initial work
/* Before Starting:
- Make sure you have these three plugins installed
- Gravity Forms
- The Events Calendar
- Gravity Forms + Custom Post Types
- Once Gravity Forms is installed, create a form with these fields
- Single Line Text (Event Title)
- Paragraph Text (Event Description)
@jjeaton
jjeaton / .gitignore
Created August 5, 2015 01:54
WordPress root .gitignore. Ignore everything and then opt-in (exclude from the ignore) for your custom code.
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your