Skip to content

Instantly share code, notes, and snippets.

@hiphopsmurf
hiphopsmurf / README.md
Created January 18, 2017 17:50 — forked from foosel/README.md
OctoPrint Filetab plugin & configuration instructions

Moving the "Files" component from the sidebar to the tab section

  1. Create .octoprint/plugins/filetab and .octoprint/plugins/filetab/templates
  2. Copy __init__.py to .octoprint/plugins/filetab
  3. Copy filetab_tab.jinja2 to .octoprint/plugins/filetab/templates
  4. Modify .octoprint/plugins/config.yaml to include files in the disabled values for sidebar (see example)
  5. Optional: Adjust the order for tab if you want the "Files" tab to be placed somewhere else than after the regular tab components (see example)
  6. Restart OctoPrint, verify in the log that it discovered the plugin
@hiphopsmurf
hiphopsmurf / replace-wp-dashboard.php
Created January 17, 2017 18:56 — forked from wpscholar/replace-wp-dashboard.php
Replace the default WordPress dashboard with a custom one
<?php
/**
* Plugin Name: Replace WordPress Dashboard
* Description: Replaces the default WordPress dashboard with a custom one.
* Author: Micah Wood
* Author URI: http://micahwood.me
* Version: 0.1
* License: GPL3
*/
@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.