Skip to content

Instantly share code, notes, and snippets.

@blobaugh
blobaugh / mysql_backup.sh
Created August 30, 2016 20:29
Quick and dirty db backup. Stores backups for 30 days
#!/bin/bash
# Database credentials
user="USERNAME"
password="PASSWORD"
host="HOST"
db_name="DATABASE"
# General config
backup_path="/WHERE/TO/PUT/BACKUP/FILE"
@blobaugh
blobaugh / sep_logs_by_date.sh
Last active May 25, 2016 17:15
Seperate a PHP log file by date
#!/bin/bash
# Location of log file is passed in as the first parameter
# Get a list of all the dates in the file
DATES="$(grep "2016" $1 | cut -d ' ' -f 1 | sort | uniq)"
for i in ${DATES}; do
# $i contains the string of the date we are looking at
# Remove the leading [ to prevent grep regex errors
@blobaugh
blobaugh / mysql_who.pl
Created February 29, 2016 16:57
Who is connected to a mysql server
#!/usr/bin/perl
use DBI;
use 5.010;
use Getopt::Long;
# Set defaults
my $host = 'localhost';
my $db = 'information_schema';
my $user = '';
@blobaugh
blobaugh / wp-seo-no.php
Created December 17, 2015 19:41
Prevents WP SEO from requesting updates
add_filter( 'site_transient_update_plugins', 'wds_wp_seo_no_update' );
function wds_wp_seo_no_update( $value ) {
if ( empty( $value ) || empty( $value->response['wordpress-seo/wp-seo.php'] ) ) {
return $value;
}
unset( $value->response['wordpress-seo/wp-seo.php'] );
return $value;
}
@blobaugh
blobaugh / auto_activate_users.php
Created December 11, 2015 15:36
Auto activate users on WordPress Multisite
<?php
add_filter('wpmu_signup_user_notification', 'auto_activate_users', 10, 4);
function auto_activate_users($user, $user_email, $key, $meta){
wpmu_activate_signup($key);
return false;
}
@blobaugh
blobaugh / remove-emoji.php
Created November 30, 2015 18:08
mu-plugin to remove WordPress emoji auto-support
<?php
/*
* Disable emojis.
*
* There have been security issues, plus it simply provides better
* performance not to load unecessary core crap all the time.
*/
function grd_remove_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
@blobaugh
blobaugh / wds_vc_cta.php
Last active November 4, 2015 20:32
Example Visual Composer CTA addon
<?php
WDS_VC_CTA::get_instance();
class WDS_VC_CTA {
private static $instance = null;
private $block_name = 'wds_cta';
private function __construct() {
@blobaugh
blobaugh / linkedin_share_count.php
Created October 9, 2015 14:21
LinkedIn Share Count
<?php
function linkedin_share_count( $post_id ) {
$api = 'http://www.linkedin.com/countserv/count/share?format=json&url=';
$api .= urlencode( get_permalink( $post_id ) );
if ( ! ( $count = get_transient( 'linkedin_count' . $post_id ) ) ) {
$response = wp_remote_get( $api );
if( is_wp_error( $response ) ) {
// eat it
return 0;
@blobaugh
blobaugh / facebook_share_count.php
Created October 9, 2015 14:17
Facebook share count
<?php
function wds_post_facebook_count( $post_id ) {
$api = "https://graph.facebook.com/";
$url = $api . urlencode( get_permalink( $post_id ) );
$response = wp_remote_get( $url );
if( is_wp_error( $response ) ) {
return 0;
}
@blobaugh
blobaugh / unregisterposttype.php
Created October 2, 2015 20:48
Unregister post type
if ( ! function_exists( 'unregister_post_type' ) ) :
function unregister_post_type( $post_type ) {
global $wp_post_types;
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
return true;
}
return false;
}
endif;