Skip to content

Instantly share code, notes, and snippets.

Eric (shamai) Greenfield saltnpixels

Block or report user

Report or block saltnpixels

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
@saltnpixels
saltnpixels / wp_menu_auto_post_type.php
Created Jul 25, 2018
WP hierarichal menu of any post type. posts are auto added, like pages can be
View wp_menu_auto_post_type.php
//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;
@bob-lee
bob-lee / polyfill-ie11-nodelist-foreach.js
Created Nov 24, 2017
Polyfill for IE11 missing NodeList.forEach
View polyfill-ie11-nodelist-foreach.js
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);
}
};
}
@Jany-M
Jany-M / wp_ics.php
Last active Oct 24, 2019 — forked from jakebellacera/ICS.php
[WP] Generate a downloadable .ics file from any WordPress post or custom post type
View wp_ics.php
<?php
// Add a custom endpoint "calendar"
function add_calendar_feed(){
add_feed('calendar', 'export_ics');
// Only uncomment these 2 lines the first time you load this script, to update WP rewrite rules
/*global $wp_rewrite;
$wp_rewrite->flush_rules( false );*/
}
add_action('init', 'add_calendar_feed');
@nicdford
nicdford / filters
Last active Feb 24, 2016
filters setup
View filters
<?php
$things_to_do = pods( 'things_to_do' );
$limit = 9;
$params = array(
'fields' => array(
'region',
'activity',
'legend_items'
),
@silenzium
silenzium / objectfit-fallback.js
Last active Nov 4, 2019
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.
View objectfit-fallback.js
$(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) {
@sc0ttkclark
sc0ttkclark / pods-examples.php
Created Mar 3, 2015
Example from PodsCast 1
View pods-examples.php
<?php
////////////////
// User Example
////////////////
$user = pods( 'user' ); // User
$params = array(
'orderby' => 't.user_login',
'limit' => 10,
@luizventurote
luizventurote / google-maps-converting.php
Created Apr 13, 2014
Converting address to latitude and longitude - Google Maps - PHP.
View google-maps-converting.php
<?php
/**
* Converting address to latitude and longitude
*/
function setLatitudeAndLongitude($address) {
$address = urlencode($address);
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$address."&sensor=true";
$xml = simplexml_load_file($request_url) or die("url not loading");
$status = $xml->status;
@letanure
letanure / article.html
Created Apr 8, 2014
Social Media Tag Template
View article.html
<!-- Place this data between the <head> tags of your website -->
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. No longer than 155 characters." />
<!-- Twitter Card data -->
<meta name="twitter:card" value="summary">
<!-- Open Graph data -->
<meta property="og:title" content="Title Here" />
<meta property="og:type" content="article" />
@richardW8k
richardW8k / RW_Delete_Entry.php
Last active Nov 10, 2016
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.
View RW_Delete_Entry.php
<?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 );
@mannieschumpert
mannieschumpert / gist:8334811
Last active Sep 18, 2019
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.
View gist:8334811
<?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
You can’t perform that action at this time.