Skip to content

Instantly share code, notes, and snippets.

View saltnpixels's full-sized avatar

Eric Greenfield saltnpixels

View GitHub Profile
@jakebellacera
jakebellacera / ICS.php
Last active April 19, 2024 09:06
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@ganapativs
ganapativs / iTerm2 + oh-my-zsh + Pure theme + zsh plugins setup.md
Last active April 8, 2024 22:56
iTerm2 + oh-my-zsh + Pure theme + zsh plugins setup
@hissy
hissy / gist:7352933
Created November 7, 2013 11:07
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@Jany-M
Jany-M / wp_ics.php
Last active September 19, 2023 03:15 — forked from jakebellacera/ICS.php
[WP] Generate a downloadable .ics file from any WordPress post or custom post type
<?php
/*
For a better understanding of ics requirements and time formats
please check https://gist.github.com/jakebellacera/635416
*/
// UTILS
// Check if string is a timestamp
@mannieschumpert
mannieschumpert / gist:8334811
Last active August 20, 2023 14:58
Filter the submit button in Gravity Forms to change the <input type="submit> element to a <button> element. There's an example in the Gravity Forms documentation, but it lacks the proper code to show your custom button text, AND removes important attributes like the onclick that prevents multiple clicks. I was trying to solve that.
<?php
// filter the Gravity Forms button type
add_filter("gform_submit_button", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
// The following line is from the Gravity Forms documentation - it doesn't include your custom button text
// return "<button class='button' id='gform_submit_button_{$form["id"]}'>'Submit'</button>";
// This includes your custom button text:
return "<button class='button' id='gform_submit_button_{$form["id"]}'>{$form['button']['text']}</button>";
}
// Oops this strips important stuff
@bob-lee
bob-lee / polyfill-ie11-nodelist-foreach.js
Created November 24, 2017 18:41
Polyfill for IE11 missing NodeList.forEach
if ('NodeList' in window && !NodeList.prototype.forEach) {
console.info('polyfill for IE11');
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
@richardW8k
richardW8k / RW_Delete_Entry.php
Last active January 20, 2022 07:21
When placed in the theme functions.php file this will add a checkbox to the 'Form Options' part of the Form Settings page which when checked will cause entries to be automatically deleted at the end of the submission process.
<?php
class RW_Delete_Entry {
function __construct() {
if( ! property_exists( 'GFCommon', 'version' ) || ! version_compare( GFCommon::$version, '1.8.5.8', '>=' ) )
return;
add_filter( 'gform_tooltips', array( $this, 'add_delete_tooltip') );
add_filter( 'gform_form_settings', array( $this, 'add_delete_setting' ), 10, 2 );
add_action( 'gform_pre_form_settings_save', array( $this, 'save_delete_setting' ), 10 );
add_action( 'gform_after_submission', array( $this, 'maybe_delete_form_entry' ), 15, 2 );
@silenzium
silenzium / objectfit-fallback.js
Last active November 4, 2019 04:36
This is a simple fallback for the object-fit property on responsive images inside picture elements (with srcset and media-query sources). It hides the img on browsers that don't support object-fit and sets the current used image as a background-image with background-size:cover.
$(function() {
'use strict';
// the css selector for the container that the image should be attached to as a background-image
var imgContainer = '.cover-img picture';
function getCurrentSrc(element, cb)
{
var getSrc;
if (!window.HTMLPictureElement) {
@saltnpixels
saltnpixels / wp_menu_auto_post_type.php
Created July 25, 2018 18:55
WP hierarichal menu of any post type. posts are auto added, like pages can be
//hijack menu and output a whole post type in hierarchical order.
//post type must have hierarchical order capability and menu name must match post type
//add post types for this inside $post_types below
add_filter( 'wp_get_nav_menu_items', 'cpt_auto_add_menu', 10, 3 );
function cpt_auto_add_menu( $items, $menu, $args ) {
$post_types = array( 'add_post_types', 'that_you_want' );
$menu_slug = $menu->slug;
@sc0ttkclark
sc0ttkclark / pods-examples.php
Created March 3, 2015 20:58
Example from PodsCast 1
<?php
////////////////
// User Example
////////////////
$user = pods( 'user' ); // User
$params = array(
'orderby' => 't.user_login',
'limit' => 10,