Skip to content

Instantly share code, notes, and snippets.

View alispx's full-sized avatar

ALI MAHFUD alispx

View GitHub Profile
@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
@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 / 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) {
UPDATE your_table_name SET meta_key = REPLACE( meta_key, 'your_old_meta_key', 'your_new_meta_key' )
@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'
add_action('add_meta_boxes', 'alispx_meta_boxes');
function alispx_meta_boxes() {
add_meta_box(
'alispx-meta-box',
__( 'Phone Model', THEMO_TEXT_DOMAIN ),
'alispx_meta_box_callback',
'page'
);
}
<?php
/**
* Escape all translations with
*/
__( ‘Some String’, ‘text-domain’ ); _e( ‘Some string’, ‘text-domain’ );.
/**
* When there is no HTML use:
*/
esc_html__( ‘Some String’, ‘text-domain’ ); esc_html_e( ‘Some String’, ‘text-domain’ );
/**
@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.
<?php
/**
* Constructor
*/
add_action( 'init', 'tax_image_init' );
function tax_image_init() {
$tk_taxonomies = array( 'authors', 'publisher' );
foreach ( $tk_taxonomies as $tk_taxonomy ) {
jQuery(document).ready(function($) {
$('ul').find('li').each(function () {
if ($.trim($(this).text()) == "") {
$(this).remove();
}
})
});