Skip to content

Instantly share code, notes, and snippets.

@psdtohtml5
psdtohtml5 / gist:5130223
Created March 10, 2013 20:14
HTML : Base Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
@psdtohtml5
psdtohtml5 / gist:5137793
Created March 11, 2013 21:11
PHP : Enable Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', 'On');
ini_set('html_errors', 'On');
@psdtohtml5
psdtohtml5 / gist:5160807
Created March 14, 2013 11:55
jQuery : Ajax Request
$("#contact-form").submit(function(e) {
e.preventDefault();
var name = $("#name").val(),
email = $("#email").val(),
subject = $("#subject").val(),
message = $("#message").val();
$.ajax({
type: "POST",
url: "contact.php",
data: {
@psdtohtml5
psdtohtml5 / gist:5160963
Created March 14, 2013 12:31
jQuery : Scroll Top
$(window).scroll(function() {
if($(window).scrollTop() > 300){
$("#top").fadeIn();
} else{
$("#top").fadeOut();
}
});
$("#top").click(function() {
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
@psdtohtml5
psdtohtml5 / gist:5192243
Created March 19, 2013 00:04
jQuery Current Navigation Item
var curPage = ["index", "features", "blog", "gallery", "contact"],
selected;
curPage.forEach(function(page) {
if(window.location.href.indexOf(page) != -1) {
$("#"+page+"-nav").addClass("current");
}
});
@psdtohtml5
psdtohtml5 / gist:5192250
Created March 19, 2013 00:05
jQuery : Validate Email
function isValidEmail(email) {
return ( /(.+)@(.+){2,}\.(.+){2,}/.test(email) );
}
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@psdtohtml5
psdtohtml5 / gist:5284396
Created April 1, 2013 11:19
WordPress : Register Sidebar
register_sidebar( array(
'name' => __( 'Homepage 2 Facebook Widget', 'twentyeleven' ),
'id' => 'sidebar-212',
'description' => __( 'Facebook Widget For Homepage 2 Template', 'twentyeleven' ),
'before_widget' => '<div id="homepage2-facebook" class="widget %2$s">',
@psdtohtml5
psdtohtml5 / gist:5286312
Created April 1, 2013 17:21
SQL : Search and Replace
UPDATE tableName SET columnName = REPLACE (
columnName,
'TEXT TO REPLACE',
'TEXT TO REPLACE WITH')
@psdtohtml5
psdtohtml5 / gist:5309252
Created April 4, 2013 10:07
WordPress : Register Custom Post Type
if ( ! function_exists('product_post_type') ) {
// Register Custom Post Type
function product_post_type() {
$labels = array(
'name' => _x( 'Products', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Product', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Product', 'text_domain' ),
'parent_item_colon' => __( 'Parent Product:', 'text_domain' ),
'all_items' => __( 'All Products', 'text_domain' ),