- 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
# Switch to Post README | |
## Overview | |
switch_to_post() stack implementation (similar to switch_to_blog()) for WordPress | |
## Questions | |
1. Do we want to still switch to post if the get_post fails? | |
2. Have a (bool) return value based on get_post? | |
## Test Steps |
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
/** | |
* Outbound link tracking | |
* | |
* This code largely based on examples from | |
* [Google Analytics Help](http://www.google.com/support/googleanalytics/bin/answer.py?answer=55527). | |
*/ | |
jQuery(function($){ | |
$('a:not([href*="' + document.domain + '"])').click(function(event){ | |
// Just in case, be safe and don't do anything | |
if (typeof _gat == 'undefined') { |
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); | |
} | |
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
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 | |
// 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
<?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
/** | |
* 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
# 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
<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> |
OlderNewer