Skip to content

Instantly share code, notes, and snippets.

View mohsinr's full-sized avatar

Mohsin Rasool mohsinr

View GitHub Profile
@mohsinr
mohsinr / .htaccess
Last active September 11, 2015 06:55 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@mohsinr
mohsinr / functions.php
Created October 29, 2015 10:24
Add Excerpts Support for WordPress Pages
<?php
// Add Post Excerpt Support to WordPress Pages
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
@mohsinr
mohsinr / functions.php
Created October 29, 2015 10:41
Convert Hex Color to RGBa to create Color Shades on the fly
<?php
/* Convert hexdec color string to rgb(a) string */
function hex2rgba($color, $opacity = false) {
$default = 'rgb(0,0,0)';
//Return default if no color provided
if(empty($color))
return $default;
@mohsinr
mohsinr / wp-functions.php
Last active December 19, 2018 12:34
WordPress Common Custom Codes for Functions.php
<?php
//* Add new image sizes
add_image_size( 'logo-thumb', 270, 180, TRUE );
//* Change the number of portfolio items to be displayed (props Bill Erickson)
add_action( 'pre_get_posts', 'minimum_portfolio_items' );
function minimum_portfolio_items( $query ) {
if ( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
$query->set( 'posts_per_page', '6' );
@mohsinr
mohsinr / functions-genesis.php
Created October 29, 2015 10:41
Genesis Framework WordPress custom tweaks
<?php
// Remove Genesis Default Stylesheet
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
//* Unregister layout settings
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
//* Unregister secondary sidebar
@mohsinr
mohsinr / 00.howto_install_phantomjs.md
Created April 12, 2016 19:24 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@mohsinr
mohsinr / header.php
Created July 1, 2016 10:50 — forked from retlehs/header.php
Sage header template for Bootstrap top navbar component
<?php
// This file assumes that you have included the nav walker from https://github.com/twittem/wp-bootstrap-navwalker
// somewhere in your theme.
?>
<header class="banner navbar navbar-default navbar-static-top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?= __('Toggle navigation', 'sage'); ?></span>
@mohsinr
mohsinr / functions.php
Last active January 27, 2017 12:49
WordPress Taxonomies , Remove Trailing And Leading Spaces from Terms' Names
<?php
/**
Need to run this code just ONCE,
so remove it after one pageload once spaces are removed
**/
# List of Taxonomies with terms which have leading spaces
$taxos = array('rooms', 'settings', 'views', 'features');
@mohsinr
mohsinr / execute_on_router.sh
Created February 28, 2017 15:09 — forked from javikalsan/execute_on_router.sh
Simple Bash Script to execute a command on the router through telnet command
#!/bin/sh
# replace cmd1 for the command to execute
host=192.168.1.1
port=23
user=admin
pass=02B08
cmd1='adsl info'
current_date_time="`date +%Y-%m-%d\ %H:%M:%S`";
( echo open ${host}
@mohsinr
mohsinr / functions.php
Last active March 31, 2017 11:47
WordPress Move Meta data from OLD custom field Key to New key
<?php
# Inlcude in functions file for one time
# Remove after calling this function on some page one time
function warmarks_update_new_meta_from_old(){
# Provide your custom values here:
$post_type = 'pdf'; //change it with your post type
$old_metaKey = 'ecpt_pdflink';
$new_metaKey = '_jb_pdf';