Skip to content

Instantly share code, notes, and snippets.

View derpixler's full-sized avatar

DerPixler derpixler

View GitHub Profile
@derpixler
derpixler / .bashrc
Created January 30, 2017 08:43
beautiful promt
[ -r /etc/bashrc ] && source /etc/bashrc
[ -r /etc/bash_completion ] && source /etc/bash_completion
[ -r ~/.git-completion.bash ] && source ~/.git-completion.bash
[ -r ~/.git-prompt.sh ] && source ~/.git-prompt.sh
[ -r /usr/local/rvm/scripts/rvm ] && source /usr/local/rvm/scripts/rvm
__has_parent_dir () {
# Utility function so we can test for things like .git/.hg without firing up a
# separate process
test -d "$1" && return 0;
@derpixler
derpixler / functions.php
Last active January 9, 2017 08:09
Refactored WordPress theme uku nav menu loader by @elmastudio
<?php
/**
* Uku functions and definitions
*
* Change note:
* @see line 31 - 40 remove register nav_menu, this is merge into inc/nav-menu.php
* @see line 987 - 990 require nav-menu.php
*
* @package Uku
* @since Uku 1.0
@derpixler
derpixler / load_plugin_assets.php
Last active December 12, 2016 07:44
Load custom WordPress templates or assets like js, css
<?php
/**
* Load template or assets
*
* @param $tpl
* @param $type
*/
function load_plugin_assets( $tpl, $type = 'php' ){
$default_tpl = $tpl . '.’ . $type;
@derpixler
derpixler / AdminMenu.php
Created October 17, 2016 14:23
abstract wordpress AdminMenu class
<?php # -*- coding: utf-8 -*-
namespace my_plugin\admin_menu;
use my_plugin\functions as Functions;
/**
* Abstract AdminMenu class
*
* Provides methods to create admin menues
@derpixler
derpixler / .htaccess
Last active September 22, 2016 08:22
Multiblemultisite in subfolder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^(?:([_0-9a-zA-Z-]+)/?){0,2}wp-admin$ $1/wp-admin/ [R=302,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
<?php # -*- coding: utf-8 -*-
namespace [PLUGIN]\Addons;
class Loader {
/**
* @var array
*/
const ADDONSPATH = '/../Addons/';
@derpixler
derpixler / wp-flush-rules.php
Last active May 16, 2016 08:21
Flush WordPress Rewrite Rule if you have changes on a document
<?php
/**
* validate the last modification of this file
* on modification flush rewrite rules
*
* @return void
*/
function _flush_rules() {
$o = __CLASS__;
@derpixler
derpixler / wp-logger.php
Last active April 11, 2016 04:40
Simple WordPress Logger
<?php
add_filter( 'logfile_path', function(){ return __DIR__ . '/log/'; } );
add_filter( 'logfile_name', function(){ return 'app.log'; } );
wp_logger( __LINE__, 'Log msg' );
/**
* log easy a msg
*
* @param int $line the linenumer
@derpixler
derpixler / show-colors.sh
Created March 26, 2016 14:14
The code below is a sample of echo in colour, it will run through all the sequences and ouput some nice looking tables. This can be use to test what different colours will look like as well as show the hidious combinations.
#/bin/sh
# Show all the colours of the rainbow, should be run under bash
for STYLE in 0 1 2 3 4 5 6 7; do
for FG in 30 31 32 33 34 35 36 37; do
for BG in 40 41 42 43 44 45 46 47; do
CTRL="\033[${STYLE};${FG};${BG}m"
echo -en "${CTRL}"
echo -n "${STYLE};${FG};${BG}"
echo -en "\033[0m"
done
@derpixler
derpixler / wpcli-composer-update.sh
Last active March 21, 2016 07:39
Create a DB backup and a working development DB-Dump before installing a WordPress Projekt via Composer and WPCLI.
#!/bin/bash
# Create a DB backup and a working development DB-Dump before
# installing a WordPress Projekt with Composer and WPCLI.
#
# Author: René Reimann <info@rene-reimann.de>
project="renreim"
tdl="$project.de"
local_tdl="$project.dev"
prefix="wp_"