Skip to content

Instantly share code, notes, and snippets.

@ramiabraham
ramiabraham / user-meta-starter.php
Last active July 15, 2016 02:47
A simple, fairly un-opinionated starter abstract class and subclass example, for generating user meta in WordPress.
<?php
/**
* Plugin Name: User meta starter class.
* Plugin URI: https://dennys.com
* Description: User meta
* Author: ramiabraham
* Version: 1.0
* Text Domain: user-meta-starter
* Domain Path: languages
*/
@ramiabraham
ramiabraham / gethooks
Last active April 21, 2023 13:38
Copy all actions and filters in a plugin and save to a file.
#!/bin/bash
#
# Prints all hooks in a dir to a .log file.
#
# Permissions issues:
# run: chmod +x gethooks
#
# gist: https://gist.github.com/ramiabraham/e8356e00130351ddcbe2c62125e6c52a
#
# Easy usage:
@sadortun
sadortun / magnific-popup-deep-linking.js
Created October 28, 2015 04:19
Deep Linking with Magnificent popup
<script type="text/javascript">
function loadGalleryDeepLink()
{
var prefix = "#gallery-";
var h = location.hash;
if (document.g_magnific_hash_loaded === undefined && h.indexOf(prefix) === 0)
@zackkatz
zackkatz / edd-create-coupon-slack.php
Last active July 6, 2016 12:05
EDD Create Coupon from Slack - Allow creating a coupon `/coupon $20` or `/coupon 20%` in Slack
<?php
/*
Plugin Name: EDD Create Coupon from Slack
Plugin URL: http://gravityview.co
Description: Allow creating a coupon `/coupon [%]` in Slack
Version: 1.0
Author: Katz Web Services, Inc.
Author URI: http://katz.co
Contributors: katzwebservices
*/
@chriscct7
chriscct7 / gist:d7d077afb01011b1839d
Last active January 24, 2024 04:20
Plugins that need to be updated to be ready for the move to PHP 5 constructors

Important Notice for WordPress Plugins Using PHP 4 Style Constructors

The ability to use PHP 4 style constructors is getting removed from PHP. Without an update, many plugins will eventually no longer work (this is PHP breaking this backwards compatibility, not WordPress)

One of the more common uses of the PHP 4 style constructor (as opposed to PHP 5 style __construct() ) are plugins with widgets calling WP_Widget::WP_Widget() and/or parent::WP_Widget() and/or {object}->WP_Widget()

Note: Starting in WordPress 4.3, regardless of the PHP version in use on a server, WordPress will throw a deprecated notice when one of the PHP 4 style constructors is called specifically for widgets.

Basically instead of doing these:

@wpn
wpn / hs-nav-js
Created December 9, 2014 04:52
Helpscout Navigation JS
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
var html = '<li id="nf_docs"><a href="/">Docs</a></li><li id="nf_features"><a href="https://ninjaforms.com/features/">Features</a></li><li id="nf_addons"><a href="https://ninjaforms.com/extensions/">Add-Ons</a></li><li id="nf_help"><a href="https://ninjaforms.com/contact/">Ask a Question?</a></li>';
$( '.nav-collapse ul.nav' ).empty().append( html );
} );
</script>
@jasesmith
jasesmith / AtomVerticalTabs.md
Last active November 23, 2019 09:40
Vertical file tab list in Atom

Vertical File Tabs in Atom

Add the styles to the .atom/styles.less stylesheet in Atom.

Atom Vertical File Tabs

@amdrew
amdrew / gist:ae2cf4bad5ac31d8e17b
Last active August 29, 2015 14:07
AffiliateWP - Per-affiliate, per-product rate
<?php
function affwp_custom_per_product_per_affiliate_referral_amount( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
$special_affiliate_id = 145;
$special_product_id = 3133;
$special_referral_amount = $amount * .8; // 80%
if ( $special_affiliate_id == $affiliate_id && $special_product_id == $product_id ) {
$referral_amount = $special_referral_amount;
<?php
/*
* Plugin Name: EDD Redirect to Next Product on Add to Cart
* Description: Automatically redirects the customer to the next product after they have added an item to the cart
* Author: Pippin Williamson
* Version: 0.1
*/
function pw_edd_redirect_to_next_scripts( $download_id = 0 ) {
@cobyism
cobyism / osx-install-media.md
Last active March 11, 2023 00:42
Command to create installable OS X USB drive.

Creating a bootable macOS USB installer

  • First, plug in an 8GB (or bigger) USB drive, and use Disk Utility to erase it
  • If you use the default settings, you should wind up with a blank drive at /Volumes/Untitled.

With that volume in place, and with the macOS installer sitting in /Applications/Install\ macOS\ [VERSION].app, run the following command in your terminal to create a bootable install media (for Sierra):

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction