Skip to content

Instantly share code, notes, and snippets.

@ziadoz
ziadoz / awesome-php.md
Last active April 17, 2024 21:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@johnbillion
johnbillion / wp_mail.md
Last active January 27, 2024 14:06
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@vxnick
vxnick / gist:380904
Created April 27, 2010 15:52
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@GaryJones
GaryJones / gist:8430080
Created January 15, 2014 03:08
References for Why Not to Use Singleton Design Pattern
http://www.youtube.com/watch?v=-FRm3VPhseI Google's Clean Code Talks
http://blog.gordon-oheim.biz/2011-01-17-Why-Singletons-have-no-use-in-PHP/
http://sebastian-bergmann.de/archives/882-Testing-Code-That-Uses-Singletons.html
http://eamann.com/tech/making-singletons-safe-in-php/
http://hakre.wordpress.com/2012/06/10/the-missing-patterns-of-the-php-manual/#p2
http://blogs.msdn.com/b/scottdensmore/archive/2004/05/25/140827.aspx
http://www.phptherightway.com/pages/Design-Patterns.html ("You should be wary when using the singleton pattern, as by its very nature it introduces global state into your application, reducing testability.")
http://www.practicaldesignpatternsinphp.com/ ("The Singleton Pattern is perhaps the most well known - and most often misused - pattern in all of PHP design pattern development. Its simplicity, combined with its seeming benefits makes it a widely-used (and overused) pattern. The Singleton is not so much a recommended pattern, as a pattern I recommend you shy away from.")
http://www.sli
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@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:
@polevaultweb
polevaultweb / edd_perpetual_discounts.php
Last active June 28, 2022 08:31
EDD - Allow discounts to be set to apply to all renewals
<?php
// Add new Discount setting the to discount add and edit forms
add_action( 'edd_add_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_add_form' ) );
add_action( 'edd_edit_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_edit_form' ) );
// Handle saving the settings on form submission
add_filter( 'edd_update_discount', 'edd_perpetual_discounts_add_meta' );
add_filter( 'edd_insert_discount', 'edd_perpetual_discounts_add_meta' );
@danielbachhuber
danielbachhuber / gist:8af274e2b7f21c8c3bb6
Created July 3, 2014 14:40
Post-style permalinks for your custom post types
<?php
/**
* Post-style permalinks for your custom post types
* e.g. %year%/%monthnum%/%day%/%postname%
*/
function dbx_get_post_types() {
return array(
// replace with your custom post types
'my-custom-post-type'
);
@mattbanks
mattbanks / wp-setup.sh
Created March 14, 2014 18:01
Scaffold a new WordPress development site in Alfred, utilizing WP-CLI. Use this script to run as a Terminal Script. Customize for your theme needs, plugin needs, etc.
# Create directory for new site
cd ~/Sites
mkdir {query}
cd {query}
# Download latest version of WordPress
wp core download
# Setup wp-config file with WP_DEBUG enabled
wp core config --dbname={query} --dbuser=root --dbpass=root --dbprefix={query}wp_ --extra-php <<PHP
@davekiss
davekiss / gist:2639184ac066c53416b23c5a66f42d1e
Created February 2, 2019 17:44
EDD Weekly Domain Report via Email
/**
* Add a weekly email report that summarizes which domains that
* your products are being used on.
*/
add_filter( 'cron_schedules', function( $schedules ) {
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __('Once Weekly')
);