Skip to content

Instantly share code, notes, and snippets.

View mahfuzul's full-sized avatar

Mahfuzul Hasan mahfuzul

View GitHub Profile
@mahfuzul
mahfuzul / setwp.sh
Last active August 29, 2015 14:13
setwp function download and extract wordpress from https://wordpress.org
#!/bin/zsh
# @author: Mahfuzul Hasan <mha.cse@gmail.com>
# setwp function download and extract wordpress from https://wordpress.org
# To execute this function run this commands:
# chmod +x setwp.sh
# ./setwp.sh
# or add this file as a source in your .zshrc / .bashrc file " source ~/bin/zsh/setwp.sh "
#
setwp(){
echo "Downloading....."
@mahfuzul
mahfuzul / setdrupal.sh
Last active August 29, 2015 14:13
setdrupal function download and extract Drupal from https://www.drupal.org
#!/bin/zsh
# @author: Mahfuzul Hasan <mha.cse@gmail.com>
# setdrupal function download and extract Drupal from https://www.drupal.org
# To execute this function run this commands:
# chmod +x setwp.sh
# ./setwp.sh
# or add this file as a source in your .zshrc / .bashrc file " source ~/bin/zsh/setdrupal.sh "
#
setdrupal(){
echo -n "Which version you want to download (ex. 7.34) ? "
@mahfuzul
mahfuzul / virtualhost
Last active August 29, 2015 14:22 — forked from saniyat/virtualhost
# Make a file named virtualhost and place it in /usr/local/bin folder.
# Give +x permission to the file.
# use as
# virtualhost sitename.tld relative_path_to/var/www/
# i.e virtualhost d7.san d7
#!/bin/bash
### Set default parameters
action='create'
domain=$1
<!-- Save this snippet in Packages/User/wpbaseurl.sublime-snippet -->
<snippet>
<content><![CDATA[
define('WP_HOME', 'http://${1}.mh/');
define('WP_SITEURL', 'http://${1}.mh/');
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>wpbaseurl</tabTrigger>
<description>WordPress Base URL</description>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@mahfuzul
mahfuzul / print-wp-tags.php
Last active January 4, 2016 10:52
print-wp-tags
<?php
// Print WordPress Post Tags Comma Seperated
$post_tags = get_the_tags();
if ($post_tags) {
$last = end($post_tags);
foreach($post_tags as $tag) {
echo '<a href="'. get_tag_link($tag->term_id).'" class="">' . $tag->name . '</a>';
if($tag != $last) { echo ", "; }
}
}
@mahfuzul
mahfuzul / wp-get-unique-year-from-post-type.php
Last active January 26, 2016 07:33
Get Unique years from post type
<?php
/**
* Get posts year
* @return [type] [description]
*/
function get_post_years() {
global $wpdb;
$sql = "SELECT YEAR(STR_TO_DATE(p.post_date, '%Y')) as year
FROM $wpdb->posts as p
WHERE p.post_type = 'post' AND p.post_status = 'publish'
@mahfuzul
mahfuzul / print_terms.php
Created January 21, 2016 08:26
Print WordPress Taxonomy Terms as list
<?php
/**
* Print WordPress Taxonomy Terms as list
* @param [type] $terms_array [description]
* @param [type] $first_item [description]
* @return [type] [description]
*/
function print_terms($terms_array, &$first_item) {
if(!$terms_array || count($terms_array) < 1) return;
foreach($terms_array as $term) {
@mahfuzul
mahfuzul / us_states_list.php
Last active April 6, 2017 07:27
US States List As Array
$us_states = array(
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
'DC' => 'District of Columbia',
@mahfuzul
mahfuzul / us_states_lat_lng.js
Created April 6, 2017 13:05
Us States Latitudes and Longitudes list
var us_states_lat_lng = [
{lat: 32.806671, lng: -86.791130},
{lat: 61.370716, lng: -152.404419},
{lat: 33.729759, lng: -111.431221},
{lat: 34.969704, lng: -92.373123},
{lat: 36.116203, lng: -119.681564},
{lat: 39.059811, lng: -105.311104},
{lat: 41.597782, lng: -72.755371},
{lat: 39.318523, lng: -75.507141},
{lat: 38.897438, lng: -77.026817},
@mahfuzul
mahfuzul / mime_types.php
Created May 31, 2017 09:22
The Complete List of MIME Types as php array
<?php
// Source URL: https://www.sitepoint.com/web-foundations/mime-types-complete-list/
$mime_types = array (
'3dm' => 'x-world/x-3dmf',
'3dmf' => 'x-world/x-3dmf',
'a' => 'application/octet-stream',
'aab' => 'application/x-authorware-bin',
'aam' => 'application/x-authorware-map',
'aas' => 'application/x-authorware-seg',
'abc' => 'text/vnd.abc',