Skip to content

Instantly share code, notes, and snippets.

View ScarletPonytail's full-sized avatar

ScarletPonytail ScarletPonytail

View GitHub Profile
// WPCS: slow query ok.
Reference: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
For security on the other end of the spectrum, we have escaping. To escape is to take the data you may already have and help secure it prior to rendering it for the end user. WordPress thankfully has a few helper functions we can use for most of what we'll commonly need to do:
esc_html() we should use anytime our HTML element encloses a section of data we're outputting.
<h4><?php echo esc_html( $title ); ?></h4>
esc_url() should be used on all URLs, including those in the 'src' and 'href' attributes of an HTML element.
<img src="<?php echo esc_url( $great_user_picture_url ); ?>" />
esc_js() is intended for inline Javascript.
<a href="#" onclick="<?php echo esc_js( $custom_js ); ?>">Click me</a>
=IF(SEARCH("https://www.sc.com/en/about/",B2,1),"Page")
/*
* Add title attribute to file links to indicate that it opens in a new window
*/
var file_type = [ 'a[href$="pdf"]', 'a[href$="doc"]', 'a[href$="docx"]', 'a[href$="xls"]', 'a[href$="xlsx"]' ]; // File type options
var file_type_length = file_type.length; // File type on page?
for( var i = 0; i < file_type_length; i++ ) { // Loop through links on the page
$( file_type[ i ] ).each( function() {
var file_type_names = file_type[ i ]; // Identify file type
$('a[href$=".mp3"]').addClass("mp3");
input[type=text],
input[type=text]:focus,
input[type=password],
select,
input[type=submit],
input[type=reset],
input[type=radio],
input[type=checkbox],
input[type=button],
input[type=color],
@ScarletPonytail
ScarletPonytail / text.txt
Last active December 20, 2018 10:00
Git - Vagrant commands
// Connect to database - wp-2
vagrant sequel
// Start virtual server
vagrant up
// Stop virtual server
vagrant halt
// Some kind of secure connection thingy
@ScarletPonytail
ScarletPonytail / notes.txt
Last active November 29, 2018 17:30
Git - Kaleidoscope diff checker and merge conflicts
git mergetool
@ScarletPonytail
ScarletPonytail / links.txt
Last active November 15, 2018 14:09
Wordpress - Chassis