Skip to content

Instantly share code, notes, and snippets.

View mohamedhamad's full-sized avatar

Mohamed Hamad mohamedhamad

View GitHub Profile
<?php
// filter the Gravity Forms button type
add_filter("gform_submit_button_1", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
return "<button class='btn btn-primary' id='gform_submit_button_{$form["id"]}'>
".$form['button']['text']." <i class='fa fa-fw fa-angle-right'></i></button>";
}
//Change hook of gform_submit_button_X to the form that you are using
//Change <span><i class='fa fa-share fa-2x'></i> Send </span> to Font awesome and text of your choice
@mohamedhamad
mohamedhamad / cpt_filter_by_taxonomy_admin.php
Created January 7, 2016 18:50 — forked from JiveDig/cpt_filter_by_taxonomy_admin.php
Custom Post Type Filter Admin By Custom Taxonomy
<?php
/**
* Display a custom taxonomy dropdown in admin
* @author Mike Hemberger
* @link http://thestizmedia.com/custom-post-type-filter-admin-custom-taxonomy/
*/
add_action('restrict_manage_posts', 'tsm_filter_post_type_by_taxonomy');
function tsm_filter_post_type_by_taxonomy() {
global $typenow;
$post_type = 'team'; // change to your post type
@mohamedhamad
mohamedhamad / gravityforms-bs-datepicker.less
Last active August 29, 2015 14:25 — forked from corradomatt/gravityforms-bs-datepicker.less
Addon for using gravity forms with a bootstrap based development such as the roots.io theme for WordPress. I specifically wrote this for a roots theme and it's based on this post http://roots.io/style-gravity-forms-with-bootstrap/ by Ben Word.This goes one step further and provides support for some native gravity forms style declarations for for…
/**
* Borrowed from https://github.com/addyosmani/jquery-ui-bootstrap
* Styles the datepicker popup for gravityforms used with bootstrap
*/
/*
* jQuery UI Datepicker
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
@mohamedhamad
mohamedhamad / slugify-text.php
Last active August 29, 2015 14:15
Create a slug form a string of text
<?php
function slugify($text){
$text = preg_replace('~[^\\pL\d]+~u', '-', $text); // replace non letter or digits by -
$text = trim($text, '-'); // trim
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); // transliterate
$text = strtolower($text); // lowercase
$text = preg_replace('~[^-\w]+~', '', $text); // remove unwanted characters
if (empty($text)){
return 'n-a';
}
<?php
if (!function_exists('get_post_id_by_meta_key_and_value')) {
/**
* Get post id from meta key and value
* @param string $key
* @param mixed $value
* @return int|bool
* @author David M&aring;rtensson <david.martensson@gmail.com>
*/
function get_post_id_by_meta_key_and_value($key, $value) {
@mohamedhamad
mohamedhamad / social_media_colours.less
Last active August 29, 2015 14:06
Social Media branding hex colours
@social-twitter: #0099ff;
@social-linkedin: #3399cc;
@social-facebook: #3B5998;
@social-googleplus: #d34836;
@social-flickr: #ff0084;
@social-pinterest: #910101;
@social-instagram: #517fa4;
@social-youtube: #c4302b;
@mohamedhamad
mohamedhamad / format-phone-numbers.php
Last active August 29, 2015 14:06
Strips a phone number of all special characters and spaces for use in callto: link
/***
* Formats a phone number to be used in a callto: link
* Input: Phone number string with special characters
* Output: Phone number without special characters
***/
function mh_format_phone_number($phone){
return preg_replace('~[\W\s]~', "", $phone);
}
@mohamedhamad
mohamedhamad / HEX to RGB
Created September 26, 2014 18:15
Converts a hex color value to it an rgb value array
/***
* Converts a hex color value to it an rgb value array
* Input: Hex value string
* Output: Array of RGB Values
***/
function mh_hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
@mohamedhamad
mohamedhamad / rgb_to_hex.php
Last active August 29, 2015 14:06
Converts an array of RGB values to a HEX colour value
/***
* Formats an array of RGB values to a HEX colour value
* Input: Array of RGB Values
* Output: Hex value string
***/
function mh_rgb2hex($rgb) {
$hex = "#";
$hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT);
$hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT);