Skip to content

Instantly share code, notes, and snippets.

@hiphopsmurf
hiphopsmurf / Redirect WordPress Logout to Home Page
Last active December 3, 2016 06:38 — forked from bwhli/Redirect WordPress Logout to Home Page
Redirect WordPress Logout to Home Page
//* Redirect WordPress Logout to Home Page - Anonymous Function
add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));
// Redirect WordPress Logout to Home Page - Full Function
function logout_redirect_home(){
wp_safe_redirect(home_url());
exit;
}
add_action('wp_logout', 'logout_redirect_home');
@hiphopsmurf
hiphopsmurf / gist:c1f18408eb1b4557bb0344cb909cef7a
Last active December 1, 2016 16:38 — forked from fastmover/gist:7771483
Wordpress is lacking an is_subscriber method.
if( !function_exists( "is_subscriber" ) ){
function is_subscriber() {
// Test if role is subscriber
$cu = wp_get_current_user();
if (!empty($cu->roles) && is_array($cu->roles)) {
if(in_array('subscriber', $cu->roles)) {
return true;
}
}
return false;
@hiphopsmurf
hiphopsmurf / secure-auth-cookies.php
Created November 28, 2016 17:03 — forked from tott/secure-auth-cookies.php
Encrypt WordPress auth cookies
<?php
function sav_encrypt_cookie( $decrypted ) {
$encrypted = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, substr( AUTH_SALT, 0, 32 ), $decrypted, MCRYPT_MODE_ECB, mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ), MCRYPT_RAND ) );
return trim( base64_encode( $encrypted ) );
}
function sav_decrypt_cookie( $encrypted ) {
$decrypted = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, substr( AUTH_SALT, 0, 32 ), base64_decode( $encrypted ), MCRYPT_MODE_ECB, mcrypt_create_iv( mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ), MCRYPT_RAND ) );
return trim( $decrypted );
@hiphopsmurf
hiphopsmurf / collection-filter.js
Created October 31, 2016 23:27 — forked from danielbachhuber/collection-filter.js
Add a custom taxonomy dropdown filter to the WordPress Media Library
(function(){
/**
* Create a new MediaLibraryTaxonomyFilter we later will instantiate
*/
var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({
id: 'media-attachment-taxonomy-filter',
createFilters: function() {
var filters = {};
// Formats the 'terms' we've included via wp_localize_script()
@hiphopsmurf
hiphopsmurf / wordpress-disable-distraction-free.php
Created October 27, 2016 15:38 — forked from jwondrusch/wordpress-disable-distraction-free.php
Disable Distraction Free Writing Mode and Full Height Editor editor based on a list of post types.
<?php
/**
* Disable Distraction Free Writing Mode and the "Auto Expanding"
* height of the editor based on a list of post types.
*
* @return void
*/
function my_deregister_editor_expand($val, $post_type)
{
@hiphopsmurf
hiphopsmurf / server.conf
Last active October 10, 2016 20:36 — forked from laurenorsini/server.conf
OpenVPN configuration for /etc/openvpn/server.conf
#local prevents openvpn from starting automagically
#local 192.168.2.0 # SWAP THIS NUMBER WITH YOUR RASPBERRY PI IP ADDRESS
dev tun
proto udp #Some people prefer to use tcp. Don't change it if you don't know.
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/Server.crt # SWAP WITH YOUR CRT NAME
key /etc/openvpn/easy-rsa/keys/Server.key # SWAP WITH YOUR KEY NAME
dh /etc/openvpn/easy-rsa/keys/dh1024.pem # If you changed to 2048, change that here!
server 10.8.0.0 255.255.255.0
@hiphopsmurf
hiphopsmurf / MakeOpenVPN.sh
Last active October 10, 2016 21:04 — forked from laurenorsini/MakeOpenVPN.sh
MakeOpenVPN.sh by Eric Jodoin
#!/bin/bash
# Default Variable Declarations
DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
@hiphopsmurf
hiphopsmurf / .readme.md
Created September 10, 2016 01:25 — forked from morganestes/.readme.md
Create multiple sites with wp-cli in WordPress multisite for testing.

These commands will install multiple dummy sites in a WordPress Multisite environment.

I wrote this to easily create an environment to work on https://core.trac.wordpress.org/ticket/15317.

Usage

Shell

In the terminal, inside your WordPress directory: simply copy, paste, and run the one-line command.

You can also add it to a location available in your $PATH and invoke the script from the shell.

@hiphopsmurf
hiphopsmurf / starting_library_project_AS.md
Created May 19, 2016 17:32 — forked from daniellevass/starting_library_project_AS.md
Getting Started with a library project in Android Studio

Getting Started with a library project in Android Studio

So we're working on creating Android Material Awesome, a library which will hopefully incorperate the benefits of Material Design, Twitter's Bootstrap, and FontAwesome. What we really wanted is a project other people can easily include into their projects using gradle dependencies. To do this we needed to create a standalone library project so we could make it as lightweight as possible for including as a dependency, and a sample app that would use it for testing. These are the steps we took to get started in Android Studio (version 1.1).

Create Projects

The first thing we needed to do was to create two new projects, with all the default settings (Blank Activity etc). One for our sample app, and one for our library. We added both of ours into the same GitHub repo, however you can save them wherever you like.

Fix Up Library Project

@hiphopsmurf
hiphopsmurf / mysqldump-backup.sh
Created April 8, 2016 15:44 — forked from tony4d/mysqldump-backup.sh
Backup all databases on a mysql server, excluding information_schema and performance_schema. Most useful scheduling this on a slave db.
#!/bin/bash
# No username or passwords in this script, you should use mysql_config_editor
# to store it securely. The login-path in this script is set to "local-backup" so when you create
# your .mylogin.cnf with the mysql-config-editor make sure it is set the same
# See http://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html
# An example to create your config for a mysql user "backup":
# shell> sudo mysql_config_editor set --login-path=local-backup --host=localhost --user=backup --password
# The backup user in the mysql server needs these privileges: SELECT, RELOAD, SHOW DATABASES, REPLICATION CLIENT