- httsp://bigdawggi.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! wp_next_scheduled( 'tmbr_daily_at_midnight_actions' ) ) { | |
$local_time_to_run = 'midnight'; | |
$timestamp = strtotime( $local_time_to_run ) - ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); | |
wp_schedule_event( | |
$timestamp, | |
'daily', | |
'tmbr_daily_at_midnight_actions' | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
<?php | |
// Should only need to modify this line | |
define( 'DB_NAME', 'tmbr_${1:install_name}' ); | |
// Rest of these can likely stay the same | |
define( 'WP_DEBUG', true ); | |
define( 'WP_HOME', 'http://' . \$_SERVER['HTTP_HOST'] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
# Return Fast 404 for assets that don't exist | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule .(jpe?g|gif|png|css|js)\$ - [L,R=404] | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be sure to change or omit the --network parameter; it defaults to 1. | |
wp site list --network=4 --field=url | while read line; do wp theme list --status=active --field=name --url=$line >> /tmp/wpcli-themes.txt; done && sort /tmp/wpcli-themes.txt | uniq -c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Routes all email from WP installation to specific Mailtrap | |
* account inbox. | |
* | |
* All you need to do is change the "Username" and "Password" | |
* settings to the appropriate box in Mailtrap. Then all | |
* mail **should** be routed to that box. Exceptions would | |
* be other functionality that overwrite the wp_mail() functions | |
* and may not use this filter, or other filters that change | |
* this behavior after we set it, or millions of other things. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (isset($_GET['matt'])) { | |
$cur_time = time(); | |
$cache = wp_cache_get('matt-time', 'matt'); | |
if ($cache !== false) { | |
echo '<pre>Found'.print_r($cache, 1).'</pre>'; | |
} | |
else { | |
wp_cache_set('matt-time', $cur_time, 'matt', 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this to your functions.php file | |
function mgr_og_image_fallback() { | |
if (!has_post_thumbnail()) { | |
// Replace the image URL unless you want my mug as your image for Open Graph Image ;) | |
?> | |
<meta property="og:image" content="http://i1.wp.com/matthewgrichmond.com/files/2012/03/matt.jpg?resize=310%2C180" /> | |
<?php | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( | |
'get_post_metadata', | |
array($this, 'maybe_grab_simpleview_photo_for_featured_image'), | |
10, | |
4 | |
); | |
/** | |
* On the request for a post's featured image, it goes and retrieves it from the 3rd party site, | |
* attaches it to the current post, then sets it as a featured image. This only happens once per post. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo '<pre>'; | |
class string_array_parser { | |
function parse_string($key, $value) { | |
// no limit, no empty values in returned array | |
$splits = preg_split('[\[|\]]', $key, -1, PREG_SPLIT_NO_EMPTY); | |
// Get the first element, that will be the name of the actual meta key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Friendly_Exception extends Exception { | |
public function __construct($friendly_message, $technical_message = '', $code = 0) { | |
$this->friendly_message = $friendly_message; | |
$this->technical_message = $technical_message; | |
parent::__construct($friendly_message, $code); | |
} | |