Skip to content

Instantly share code, notes, and snippets.

View derpixler's full-sized avatar

DerPixler derpixler

View GitHub Profile
@derpixler
derpixler / mask_mail_adress.php
Last active July 9, 2017 11:05
Mask mailadresses like s*****@************m
<?php
$adress = 'sample@examples.com';
echo get_masked_mailadress( $adress, 10 ) . "\n";
echo get_masked_mailadress( $adress, 95 ) . "\n";
echo get_masked_mailadress( $adress, 30 ) . "\n";
echo get_masked_mailadress( $adress, 5 ) . "\n";
# Return masked eMail adress
# Strip x% from the string length at both parts from a email adress
@derpixler
derpixler / PHPstorm-live-template.php
Last active February 17, 2017 08:12
PHPstorm better DebugSnipped
/**
* 1. Goto Preferences -> Editor -> Live Template -> PHP
* 2. Klick in the right +
* 3. chose Live Template
* 4. Give a abbreviation like "pdebug"
* 5. Copie the Template into Template Text
* 6. in your code Type "pdeb.." use auto compleate ;)
*
* You get a Debug like this.
*
@derpixler
derpixler / wp-hooks-filter.php
Created October 4, 2011 08:37 — forked from bueltge/wp-hooks-filter.php
Instruments Hooks for a Page of WordPress. Outputs during the Shutdown Hook after add get-params: ?instrument=hooks
<?php
/*
Plugin Name: Instrument Hooks for WordPress
Plugin URI: http://bueltge.de/
Description: Instruments Hooks for a Page. Outputs during the Shutdown Hook after add get-params <code>?instrument=hooks</code>.
Version: 0.0.1
Author: Frank B&uuml;ltge
Author URI: http://bueltge.de/
*/
@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/';