Skip to content

Instantly share code, notes, and snippets.

View paulund's full-sized avatar

Paulund paulund

View GitHub Profile
@paulund
paulund / Preg_replace_whitespace.php
Created October 25, 2012 09:29
Remove All Whitespace In A String
$string = preg_replace('/\s+/', '', $string);
@paulund
paulund / remove-firefox-button-padding.css
Last active October 12, 2015 07:07
Removes inner padding and border in FF3+
/*
* Removes inner padding and border in FF3+
* www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
@paulund
paulund / remove-webkit-button-padding.css
Last active October 12, 2015 07:07
Removes inner padding and search cancel button in S5, Chrome on OS X
/*
* Removes inner padding and search cancel button in S5, Chrome on OS X
*/
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none;
}
@paulund
paulund / check-credit-card-luhn-is-valid.php
Last active October 13, 2015 03:57
Check if card number passes Luhn Check
/**
* Determines whether the supplied PAN is valid. Will also check to see whether the PAN is numeric.
* @private
* @param pan
* The PAN to validate.
* @return If the PAN failed the Luhn Check of if the PAN is not numeric.
*/
public function isValidLuhn($pan) {
if (!ctype_digit((string)$pan)) {
@paulund
paulund / wordpress-custom-post-type.php
Created February 23, 2013 14:27
A Wordpress snippet to create custom post types.
add_action( 'init', 'register_cpt_cp_name' );
function register_cpt_cp_name() {
$labels = array(
'name' => __( 'plural post type name', 'text_domain' ),
'singular_name' => __( 'single post type name', 'text_domain' ),
'add_new' => _x( 'Add New single post type name', '${4:Name}', 'text_domain' ),
'add_new_item' => __( 'Add New single post type name', 'text_domain}' ),
'edit_item' => __( 'Edit single post type name', 'text_domain' ),
@paulund
paulund / wordpress-register-taxonomy.php
Last active December 14, 2015 03:19
A Wordpress snippet to register a new taxonomy.
<?php
add_action( 'init', 'register_new_taxonomy' );
function register_new_taxonomy() {
$labels = array(
'name' => _x( 'plural taxonomy', 'Taxonomy general name', 'text_domain' ),
'singular_name' => _x( 'single taxonomy', 'Taxonomy singular name', 'text_domain' ),
'search_items' => __( 'Search plural taxonomy', 'text_domain' ),
@paulund
paulund / wordpress-plugin-template.php
Created February 23, 2013 14:35
A template to create any Wordpress plugin.php
<?php
/*
Plugin Name:
Description:
Plugin URI: http://
Author:
Author URI: http://
Version:
License: GPL2
Text Domain: Text Domain
@paulund
paulund / code-for-different-ie-versions.js
Created February 23, 2013 14:57
Check for different versions of IE.
if(navigator.appVersion.indexOf("MSIE 6.")!=-1)
{
// IE 6 code
}
if(navigator.appVersion.indexOf("MSIE 7.")!=-1)
{
// IE 7 code
}
@paulund
paulund / wordpress-bookmarks-no-follow.php
Created February 23, 2013 15:13
Make Wordpress Bookmarks no-follow
function no_follow( $links ) {
foreach($links as $link) {
$link->link_rel .= ' nofollow';
$link->link_rel = trim($link->link_rel);
}
return $links;
}
add_filter('get_bookmarks', 'no_follow');
@paulund
paulund / change-default-author-slug.php
Created February 23, 2013 15:50
Change default Wordpress Author slug to profile
add_action('init', 'cng_author_base');
function cng_author_base() {
global $wp_rewrite;
$author_slug = 'profile'; // change slug name
$wp_rewrite->author_base = $author_slug;
}