Skip to content

Instantly share code, notes, and snippets.

View bigdawggi's full-sized avatar

Matthew Richmond bigdawggi

  • Bigdawggi Co
  • Island Park, ID
View GitHub Profile
@bigdawggi
bigdawggi / fast404.sublime-snippet
Created January 8, 2015 19:10
Sublime Text Snippet: fast404
<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>
@bigdawggi
bigdawggi / wpconfig.sublime-snippet
Last active August 29, 2015 14:13
wp-config.php template snippet
<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'] );
@bigdawggi
bigdawggi / gist:c4edae91da16367735f6
Created February 3, 2015 22:30
Code to schedule a cron to run at a certain local time
add_action( 'init', function() {
/* must have this check here, b/c although a new cron event won't be added without it,
*the wp_schedule_event() function triggers the action to run immediately, even if
*set for a different time of day. */
if ( ! wp_next_scheduled( 'social_delete_posts' ) ) {
$local_time_to_run = '1am';
$timestamp = strtotime( $local_time_to_run ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
wp_schedule_event(
$timestamp,
@bigdawggi
bigdawggi / gist:1d58d946bf2f00b34b9d
Created February 3, 2015 22:31
Code to utilize the newly-created wp_cron schedule
// Add the action or social posts deleting
add_action( 'social_delete_posts', function() {
$args = array(
'post_type' => 'social_posts',
'post_status' => 'any',
'posts_per_page' => -1,
'date_query' => array(
array(
'column' => 'post_date_gmt',
'before' => '1 month ago',
@bigdawggi
bigdawggi / gist:896c225e49dd0bc52d55
Last active August 29, 2015 14:15
Database Table Size Query
SELECT
table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "wp_mysitenamegoeshere"
ORDER BY (data_length + index_length) DESC
limit 10;
@bigdawggi
bigdawggi / gist:0189460108f3c2060f5b
Created March 20, 2015 16:24
Search with pretty permalinks
(function($){
$(function(){
$('#search-form').on('submit', function(e){
e.preventDefault();
var searchBox = $(this).find('input[type=search]'),
searchTerm = '';
if(searchBox.length === 0) {
alert('No search term available');
return false;
@bigdawggi
bigdawggi / gist:5360aebfdcad25c995e9
Created April 21, 2015 23:11
WPSEO Stop annoying redirect on update
diff --git a/wp-content/plugins/wordpress-seo/index.php b/wp-content/plugins/wordpress-seo/index.php
index 12c197f..abebf2a 100644
--- a/wp-content/plugins/wordpress-seo/index.php
+++ b/wp-content/plugins/wordpress-seo/index.php
@@ -1,2 +1,9 @@
<?php
-//Nothing to see here
\ No newline at end of file
+//Nothing to see here
+
@bigdawggi
bigdawggi / gist:40d56ee4190e889fde7b
Last active August 29, 2015 14:21
admin-ajax call
<?php
function get_user_snippet(){
$id = intval( $_GET['user_id'] );
global $post;
$post = get_post( $id );
setup_postdata( $post );
get_template_part( 'partials/user-snippet');
exit;
}
@bigdawggi
bigdawggi / addwpremote.sh
Created May 20, 2015 17:45
Clones github repos and fetches WPEngine staging and production repos - then adds wpremote
#!/bin/bash
cd /installs/
echo -e "Please enter the repository name for the Github repo (Example: angelfire): \c "
read GITHUBSLUG
git clone git@github.com:TMBR/${GITHUBSLUG}.git
cd ${GITHUBSLUG}
echo -e "Please enter the WPEngine Install name (Example: angelfireresor): \c "
read WPESLUG
git remote add staging git@git.wpengine.com:staging/${WPESLUG}.git
git remote add production git@git.wpengine.com:production/${WPESLUG}.git
@bigdawggi
bigdawggi / gist:9db55d2e358aaa0259e9
Last active August 29, 2015 14:22
Trigger events on non-DOM objects
foo = {}
jQuery(foo).on('bar', function(){ alert('hey') })
jQuery(foo).trigger('bar')