Skip to content

Instantly share code, notes, and snippets.

View byjamaljama's full-sized avatar
🎯
Focusing

Jamal Jama byjamaljama

🎯
Focusing
View GitHub Profile
@byjamaljama
byjamaljama / is_custom_page_template.php
Created October 6, 2011 15:27
Conditional WordPress tag to detect page templates when the page is used to display posts, not page content
<?php
/**
* is_custom_page_template()
*
* This is used to test the current page template when the page template in question is used to display
* posts (post archives), not regular page content. The default conditional tag is_page_template() fails
* in this situation, so we're using this in-house function instead.
*
*
* @since 0.1.0
@byjamaljama
byjamaljama / calc_invoice.php
Created October 12, 2011 09:09
Calculates the amount in the invoice and returns a new amount with discount and tax added, the total also will be rounded to 2 decimal places. Discount and tax will only be applied when available.
<?php
/**
* Calculates the amount in the invoice and returns a new amount with discount and tax added,
* the total also will be rounded to 2 decimal places. Discount and tax will only be applied
* when available.
*
* USAGE:
* <code>
* // Example 1: Subtract discount from subtotal, add tax and return the grand-total.
* calc_invoice( 500, 0.5, 5 );
@byjamaljama
byjamaljama / conditional_js.php
Created October 16, 2011 07:25 — forked from peterwilsoncc/functions.php
Conditional commented JavaScript in WordPress
<?php
/* Hook the HTML5 shiv into WP. */
add_action('wp_print_scripts', 'mytheme_ie_specific_js');
/**
* Attaches conditionally commented JS file into wp_print_scripts hook.
*
* A modified version of Peter Wilson's gist https://gist.github.com/1282923
*
@byjamaljama
byjamaljama / responsive-embed-wrapper.php
Last active September 29, 2015 12:17
Respensive embed and iframe for WordPress
<?php
/* Hook responsive_embed_wrapper function to 'the_content' filter. */
add_filter( 'the_content', 'responsive_embed_wrapper', 20 );
/**
* Adds wrapper and container divs to make <object> and <iframe> embeds responsive to
* CSS media queries.
*
*
* @link http://webdesignerwall.com/tutorials/css-elastic-videos
@byjamaljama
byjamaljama / wp_hook_inspector.php
Last active August 9, 2021 21:30
WordPress Hook Inspector: Inspects which functions are attached into what hook.
<?php
/**
* Plugin Name: WordPress Hook Inspector
* Description: Provides a shortcode that displays information table about which function is hooked into what hook. The information displayed is only for debugging and the shortcode will not display anything if the post included is not password protected. <strong>Usage:</strong> add [inspect hook="hook_name"] for single hooks or [inspect] for all hooks. The shortcode requires the post to be password protected.
* Author: JML
* Author URI: http://jml.so
* Version: 1.0
* License: GNU General Public License v2.0
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@byjamaljama
byjamaljama / validate_wildcard_dns.php
Created October 4, 2012 13:36
Wildcard DNS validation regex.
<?php
/**
* Uses a simple regex to validate a wildcard DNS format.
*
* It validates the following entry formats:
* *.example.com.
* *.exa.m.ple.com.
* *.exa-mp.le.com.
* *.ex--ample.com.
*/
@byjamaljama
byjamaljama / select-country.html
Last active December 11, 2015 04:48
240 States Dropdown
<select name="countries-dropdown">
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
<option value="Anguilla">Anguilla</option>
<option value="Antarctica">Antarctica</option>
<option value="Antigua and Barbuda">Antigua and Barbuda</option>
@byjamaljama
byjamaljama / circle.html
Created February 28, 2013 08:14
HTML/CSS circle
<div class="circle circle-100x100"></div>
# Initial setup
git clone -o framework -b develop https://github.com/laravel/laravel.git project-name
cd project-name
git checkout --orphan master
git commit -m "Initial commit"
# Pulling changes
git fetch framework
git merge --squash -m "Upgrade Laravel" framework/develop
# Fix merge conflicts if any and commit

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/