Skip to content

Instantly share code, notes, and snippets.

View cobbman's full-sized avatar
🏠
Working Remotely

William cobbman

🏠
Working Remotely
View GitHub Profile
@cobbman
cobbman / Gitignore for WordPress
Last active July 30, 2020 11:58 — forked from redoPop/.gitignore
gitignore template for wordpress sites. Place it in the root directory or where WordPress is installed. Default tracks wp core files. Has option to ignore everything.
###############################################################################
## ##
## GIT IGNORE FOR WORDPRESS SITES ##
## ------------------------------ ##
## By: BigWilliam <hello@bigwilliam.com> ##
## Last Modified: 2016-06-16 ##
## ##
## License: MIT - aka you can use/modify this how you want :) ##
## ##
###############################################################################
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@cobbman
cobbman / login-links.php
Created April 30, 2013 21:52
WordPress: Add login/logout links to WordPress functions.php
@cobbman
cobbman / auto-center-button.js
Last active December 16, 2015 01:59
jQuery: auto-center an element (button) within it's parent div
// Auto center buttons with class of js-center
// example of button HTML this would work for: <div id="sidebar-widget-stuff"><a class="btn js-center">Click Me</a></div>
(function(){
$('.js-center').each(function(){
var elementWidth = $(this).outerWidth(); // measures width including padding
var containerWidth = $(this).parent().width(); // measures width not including padding
var marginLeftValue = containerWidth/2 - elementWidth/2;
$(this).css('margin-left', marginLeftValue);
@cobbman
cobbman / contactForm.js
Created April 8, 2013 22:49
Nifty jQuery for clearing values of forms when focused
var formElements = '.formClass input, .formClass textarea, #anyID';
$(document).ready(function(){
$(formElements).each(function(){ //do this for each element
$.data(this, 'default', this.value); //grab the default value and pair with 'default'
}).focus(function(){
if ( $.data(this, 'default') === $(this).val() ) { // on focus: clear the value if it's the default
$(this).val('');
}
}).blur(function(){
@cobbman
cobbman / home.php
Last active December 15, 2015 21:09
WordPress: Add a featured image to the blog page (more difficult than regular)
<?php
/****** featured image for blog page ******/
$page_for_posts = get_option('page_for_posts'); // gets the ID of the page that displays posts
$default_attr = array( // these are the attributes that can be passed to the image. See WP codex for all options.
'class' => "featured-header-image",
);
global $wp_query;
@cobbman
cobbman / email-submit.html
Created March 19, 2013 00:13
jQuery: Interactive email submit form. Single line email only. Validates email as well. Good for those "announcement" pages when you want users to submit their emails for further notifications. See it in action here: www.sharenpay.com
<div id="email-form">
<p id="form-above"><strong>Enter your email to receive an exclusive first look invitation!</strong></p>
<p id="form-above-error"><strong>Please enter a valid email address. </strong></p>
<p id="form-above-success"><strong>Thank you! We will be sending you an invitation soon.</strong></p>
<form method="" action="" id="subscribe-form">
<fieldset class="cfix">
<input type="text" class="text" name="email" id="subscribe-email" value="Enter your email" />
<input type="submit" class="submit" name="submit" value="Submit" />
</fieldset>
</form>
@cobbman
cobbman / hover-popup.js
Last active December 15, 2015 03:09
jQuery: create hover effects that mimic CSS :hover pseudo elements. This is needed for iOS devices which don't seem to acknowledge :hover.
/*********************************************
rollover effects for iOS devices for multiple
elements on a page.
see this in action here: www.sharenpay.com
*********************************************/
$(document).ready(function() {
$('.spider-popup').hide(); // hide all the popups at first
$('.spider-circle').mouseover(function() {
@cobbman
cobbman / index.html
Last active December 14, 2015 22:19
How to set a div to the size of any browser window with jQuery
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Auto-set div height to window</title>
<meta author="BigWilliam">
<meta description="How to set a div to the size of any browser window with jQuery"
</head>
<body style="margin:0;">
@cobbman
cobbman / index.html
Created March 13, 2013 22:44
How to get your browser to update cache with images and files. Especially helpful for favicons!
Start with this:
<link rel="shortcut icon" href="/ico/favicon.ico">
And add this to the end of the image href: ?v=2 like this...
<link rel="shortcut icon" href="/ico/favicon.ico?v=2">
This will tell your browser that the old version is out of date and to use the new version