Skip to content

Instantly share code, notes, and snippets.

@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 / functions-theme.php
Created May 3, 2012 12:17
Little collection of WordPress utility
/*
* Apply transient cache and return posts (like get_posts)
*
* @param array $args query params WP_Query
* @param string $transient_name
* @param string $transient_expiration Optional defaul 7200
*/
function cache_posts( $args , $transient_name , $transient_expiration = 7200 ){
if ( false === ( $posts = get_transient( $transient_name ) ) ) {
@miziomon
miziomon / class-formfields.php
Created May 11, 2012 16:30
Helper Class to render html form element width WordPress data
<?php
/*
* Mvd_FormFields
* Helper Class to render html form element width WordPress data
* NOTE: Designed for use with WordPress
* @author Maurizio Pelizzone
* @link http://maurizio.mavida.com
* @license: GPLv2 or later
* @License URI: http://www.gnu.org/licenses/gpl-2.0.html
@miziomon
miziomon / RequirePlugins.php
Created June 6, 2012 12:14
Developers Helper to check WordPress required plugins. If a required plugin not exist will be displayed an admin notice with plugin install link
if ( !class_exists( 'RequirePlugins' ) ):
class RequirePlugins {
private $require_plugins = array();
private $miss_plugins = array();
private $found_plugins = array();
function __construct( $require_plugins = null ) {
if (is_array( $require_plugins )) {
@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
@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 / 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 / composer.json
Created July 31, 2012 15:26
WordPress MonoLog integration
{
"require": {
"monolog/monolog": "1.1.*"
}
}
@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 / 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);