This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Perl and PHP Regular Expressions | |
| PHP regexes are based on the PCRE (Perl-Compatible Regular Expressions), so any regexp that works for one should be compatible with the other or any other language that makes use of the PCRE format. Here are some commonly needed regular expressions for both PHP and Perl. Each regex will be in string format and will include delimiters. | |
| All Major Credit Cards | |
| This regular expression will validate all major credit cards: American Express (Amex), Discover, Mastercard, and Visa. | |
| //All major credit cards regex | |
| '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Digits | |
| /^[0-9]+$/ | |
| // Alphabetic Characters | |
| /^[a-zA-Z]+$/ | |
| // Alpha-Numeric Characters | |
| /^[a-zA-Z0-9]+$/ | |
| // Date (MM/DD/YYYY)/(MM-DD-YYYY)/(MM.DD.YYYY)/(MM DD YYYY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [rel="external"] ---------------- Attribute EXACTLY matches a certain value | |
| [rel*="external"] --------------- Attribute CONTAINS certain value somewhere | |
| [rel^="external"] --------------- Attribute BEGINS WITH certain value | |
| [rel$="external"] --------------- Attribute ENDS WITH certain value | |
| [rel~="external"] --------------- Attribute is WITHIN Space Separated List (e.x.-compound classes) | |
| [rel|="external"] --------------- Attribute is WITHIN Dash Separated List (e.x.-compound classes) | |
| [title="one"][rel^="external"] -- Multiple Attribute Matches |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getPosition(element) { | |
| var xPosition = 0; | |
| var yPosition = 0; | |
| while(element) { | |
| xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft); | |
| yPosition += (element.offsetTop - element.scrollTop + element.clientTop); | |
| element = element.offsetParent; | |
| } | |
| return { x: xPosition, y: yPosition }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($, window, undefined) { | |
| var InfiniteScroll = function() { | |
| this.initialize = function() { | |
| this.setupEvents(); | |
| }; | |
| this.setupEvents = function() { | |
| $(window).on( | |
| 'scroll', | |
| this.handleScroll.bind(this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function doSomething (condition) { | |
| var stuff = { | |
| 'one': function () { | |
| return 'one'; | |
| }, | |
| 'two': function () { | |
| return 'two'; | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function supportsSVG() { | |
| return !! document.createElementNS && !! document.createElementNS('http://www.w3.org/2000/svg','svg').createSVGRect; | |
| } | |
| if ( supportsSVG() ) { | |
| document.documentElement.className += ' svg'; | |
| } else { | |
| document.documentElement.className += ' no-svg'; | |
| var imgs = document.getElementsByTagName('img'), | |
| dotSVG = /.*\.svg$/; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('#someInput').keyup(function( e ) { | |
| var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g"); | |
| var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); | |
| var enoughRegex = new RegExp("(?=.{6,}).*", "g"); | |
| if ( false == enoughRegex.test( $(this).val() ) ) { | |
| $('#validationMessage').html('Need More Characters'); | |
| } | |
| if ( strongRegex.test( $(this).val() ) ) { | |
| $('#validationMessage').className = 'ok'; | |
| $('#validationMessage').html('Strong Like Bull!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Adding Admin Favicon | |
| function add_admin_favicon() { | |
| $favicon_url = get_stylesheet_directory_uri() . '/assets/admin/images/admin-favicon.ico'; | |
| echo '<link rel="shortcut icon" href="' . $favicon_url . '" />'; | |
| } | |
| // Calling Favicon Function in the <head> on Login and Admin pages | |
| add_action('login_head', 'add_admin_favicon'); | |
| add_action('admin_head', 'add_admin_favicon'); |