Skip to content

Instantly share code, notes, and snippets.

View pbearne's full-sized avatar

Paul Bearne pbearne

View GitHub Profile
@pbearne
pbearne / gist:6250135
Created August 16, 2013 13:49
Timezone array
var timezones = {
'-12': 'GMT -12',
'-11': 'GMT -11',
'-10': 'GMT -10',
'-9': 'GMT -9',
'-8': 'PST',
'-7': 'MST',
'-6': 'CST',
'-5': 'EST',
@pbearne
pbearne / gist:7221162
Created October 29, 2013 19:38
how to add a tax_query to pre_get_posts in wordpress
add_action( 'pre_get_posts', array( $this,'function_pre_get_posts' ) );
function function_pre_get_posts(){
// you can't use the query->set here for tax_query
// as tax query has already been made
// so you need to need add youself to any
// existing tax query
$tax_query = array(
'taxonomy' => 'tax_name',
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@pbearne
pbearne / gist:605d09919ab454062e71
Created October 15, 2014 14:03
loop wp cli to make post per month
for i in {01,02,03,04,05,06,07,08,09,10,11,12}; do curl http://loripsum.net/api/5 | wp post generate --post_content --count=1 --post_date=2013-$i-1 --url=vvv.dev/path ;done;

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@pbearne
pbearne / gist:9b893108ccebe4c4783eefce0ee9f5a9
Created November 23, 2016 19:51
wordpress time offset
$original_timezone = new DateTimeZone( 'UTC' );
// Instantiate the DateTime object, setting it's date, time and time zone.
$datetime = new DateTime( $time_to_change, $original_timezone );
$blog_timezone = get_option( 'timezone_string' );
// timezone not set use offset
if ( ! empty( $blog_timezone ) ) {
// Set the DateTime object's time zone to convert the time appropriately.
function matador_application_default_fields( $methods ){
return array(
'first_and_last_name',
'email',
'phone',
'profile',
'resume',
);
}
add_filter( 'matador_application_fields_defaults', 'matador_application_default_fields' );
function matador_default_required_fields( $fields ) {
return array(
'first_and_last_name',
'email',
'phone',
);
}
add_filter( 'matador_default_required_fields', 'matador_default_required_fields' );
// or
@pbearne
pbearne / gist:87b8f2ca64c7dbb40c39eb07b2b2be81
Created January 12, 2018 15:20
matador_reset_list_filter_text filter example
function matador_reset_list_filter_text( $text, $tax_slug ){
switch ( $tax_slug ) {
case 'matador-locations';
return __( 'Show All Locations', 'text-domain' );
break;
case 'matador-categories';
return __( 'Show All Gategories', 'text-domain' );
if( ! function_exists( 'matador_get_hiring_organization_logo') ) {
// lets add logo to the caompany
add_filter( 'matador_bullhorn_import_save_job_jsonld', 'matador_get_hiring_organization_logo' );
function matador_get_hiring_organization_logo( $ld_data ){
$ld_data['hiringOrganization']['logo'] = 'https://matadorjobs.com/matador-jobs-avatar-transparent-red.png';
return $ld_data;
}