Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
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
<?php | |
$countries = array | |
( | |
'AF' => 'Afghanistan', | |
'AX' => 'Aland Islands', | |
'AL' => 'Albania', | |
'DZ' => 'Algeria', | |
'AS' => 'American Samoa', | |
'AD' => 'Andorra', |
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 |
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" |
#!/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: |
<?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' ); |
<?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' | |
); |
# 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 |
/** | |
* 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') | |
); |