Skip to content

Instantly share code, notes, and snippets.

@paulund
paulund / Preg_replace_whitespace.php
Created Oct 25, 2012
Remove All Whitespace In A String
View Preg_replace_whitespace.php
$string = preg_replace('/\s+/', '', $string);
@paulund
paulund / remove-firefox-button-padding.css
Last active Oct 12, 2015
Removes inner padding and border in FF3+
View remove-firefox-button-padding.css
/*
* 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 Oct 12, 2015
Removes inner padding and search cancel button in S5, Chrome on OS X
View remove-webkit-button-padding.css
/*
* 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 Oct 13, 2015
Check if card number passes Luhn Check
View check-credit-card-luhn-is-valid.php
/**
* 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-register-taxonomy.php
Last active Dec 14, 2015
A Wordpress snippet to register a new taxonomy.
View wordpress-register-taxonomy.php
<?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 Feb 23, 2013
A template to create any Wordpress plugin.php
View wordpress-plugin-template.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 Feb 23, 2013
Check for different versions of IE.
View code-for-different-ie-versions.js
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 Feb 23, 2013
Make Wordpress Bookmarks no-follow
View wordpress-bookmarks-no-follow.php
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 Feb 23, 2013
Change default Wordpress Author slug to profile
View change-default-author-slug.php
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;
}
@paulund
paulund / wordpress-force-pages-ssl.php
Created Feb 23, 2013
Force certain Wordpress pages to use SSL
View wordpress-force-pages-ssl.php
function wps_force_ssl( $force_ssl, $post_id = 0, $url = '' ) {
if ( $post_id == 25 ) {
return true
}
return $force_ssl;
}
add_filter('force_ssl' , 'wps_force_ssl', 10, 3);