Skip to content

Instantly share code, notes, and snippets.

View alispx's full-sized avatar

ALI MAHFUD alispx

View GitHub Profile
@alispx
alispx / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@alispx
alispx / convert-post-meta.php
Created December 27, 2015 09:50 — forked from ChaseWiseman/convert-post-meta.php
A function for converting existing WordPress meta keys to new values.
/**
* Convert existing meta keys to new meta keys.
*
* @since x.x.x
*
* @global object $wpdb The current database.
*
* @param string $existing_key The existing meta key.
* @param string $new_key The new meta key.
* @param bool $remove_existing Optional. Whether to remove the old meta entries after conversion.
@alispx
alispx / wp-reset-roles.php
Created January 25, 2016 10:43 — forked from AKTed/wp-reset-roles.php
The following code will reset a WordPress default role to it's default capabilities. Note: these defaults are for WordPress 3.5, any other versions might have different defaults. To be safe, only use this code on WordPress 3.5. Warning: This cannot be undone! The role, in it's current state, is removed and recreated with the WordPress default ro…
<?php
/*
* example usage: $results = reset_role_WPSE_82378( 'subscriber' );
* per add_role() (WordPress Codex), $results "Returns a WP_Role object
* on success, null if that role already exists."
*
* possible $role values:
* 'administrator'
* 'editor'
* 'author'
@alispx
alispx / php-html-css-js-minifier.php
Created June 29, 2016 05:35 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/engine/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@alispx
alispx / .htaccess
Created July 15, 2016 08:47 — forked from bhubbard/.htaccess
This is my template .htaccess file for WordPress on Cloud Sites.
# Apache Server Config | MIT License
# https://gist.github.com/bhubbard/6082577
# Modified from https://github.com/h5bp/server-configs-apaches
# ##############################################################################
# # Default WordPress #
# ##############################################################################
# http://randomtype.ca/blog/the-wordpress-htaccess-file-explained/
# BEGIN WordPress
@alispx
alispx / .htaccess
Created January 4, 2017 03:39 — forked from agusmu/.htaccess
PageSpeed Optimization with Htaccess
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
<IfModule mod_mime.c>
AddType text/css .css
AddType text/x-component .htc
AddType application/x-javascript .js
AddType application/javascript .js2
AddType text/javascript .js3
AddType text/x-js .js4