Skip to content

Instantly share code, notes, and snippets.

@miziomon
miziomon / admin-redirect
Created May 15, 2015 12:55
WordPress user admin redirect
/**
*
* redirect to homepage if has non "edit_posts" capabilities
*/
add_filter("admin_init", function () {
if (!current_user_can('edit_posts')) {
wp_redirect(WP_HOME);
exit;
@miziomon
miziomon / .htaccess | custom admin installation
Created June 27, 2012 10:54
WordPress secure .htaccess
Options All -Indexes
<files .htaccess>
Order allow,deny
Deny from all
</files>
<files wp-config.php>
Order allow,deny
Deny from all
@miziomon
miziomon / wp-cloudflare-url-replacement.php
Created April 21, 2012 13:08
WordPress CloudFlare Url Replacement
<?php
/*
Plugin Name: CloudFlare URL Replacement
Plugin URI: http://maurizio.mavida.com/wordpress-cloudflare-url-replacement/
Description: Super simle replacer for CloudFlare user.
License: GPL
Version: 0.6
Author: Maurizio Pelizzone
Author URI: http://maurizio.mavida.com
@miziomon
miziomon / composer.json
Created July 31, 2012 15:26
WordPress MonoLog integration
{
"require": {
"monolog/monolog": "1.1.*"
}
}
@miziomon
miziomon / the_filters
Created January 29, 2014 08:13
Get WordPress filters attach to specific hook
/**
* get filters attach to specific hook
* eg. the_filters("the_title");
*/
function the_filters($hook = '') {
global $wp_filter;
if (empty($hook) || !isset($wp_filter[$hook]))
return;
echo '<pre>';
@miziomon
miziomon / gist:4467983
Created January 6, 2013 15:41
My WordPress robot.txt
User-agent: *
Disallow:
Disallow: /blackhole/*
Disallow: /cgi-bin/
Disallow: /bin/
Disallow: /wp-includes/
Disallow: /wp-content/
Disallow: /wp-admin/
Disallow: /app/
@miziomon
miziomon / shortcode-navmenu.php
Created September 14, 2012 12:12
Hook to implement shortcode logic inside WordPress nav menu items
<?php
/**
* Hook to implement shortcode logic inside WordPress nav menu items
* Shortcode code can be added using WordPress menu admin menu in description field
*/
function shortcode_menu( $item_output, $item ) {
if ( !empty($item->description)) {
$output = do_shortcode($item->description);
@miziomon
miziomon / mysql2mail
Created September 13, 2012 08:54
MySql dump + zip + mail
mysqldump -u[user] -p[password] [dbname]| gzip --best -c > [dbname].sql.gz && (date && echo "[mail subjext]" && uuencode [dbname].sql.gz ) | mail [mail] -s "[mail subjext]"
@miziomon
miziomon / parent_metabox.php
Created July 24, 2012 12:58
WordPress custom metabox implementation
<?php
/**
* parent metabox implementation
*/
// hook
add_action( 'add_meta_boxes', 'CustomMetabox_setup' );
/**
@miziomon
miziomon / gist:2906618
Created June 10, 2012 17:00
pear common command
pear config-set auto_discover 1
pear clear-cache
pear update-channels
pear remote-list
pear upgrade pear
pear -V