Skip to content

Instantly share code, notes, and snippets.

@ellm
ellm / gist:1325000
Last active October 25, 2022 05:09 — forked from NateJacobs/gist:1321741
WordPress - List all authors of a blog grouped by first name with a single letter as a header character.
<?php
/**
* List Users Alphabetically
*
* Create a list of all authors of a WordPress blog.
* Names are grouped by first name with a single letter
* as a header character.
*
* Call the function with <?php ngtj_list_users_alphabetically(); ?>
@ellm
ellm / cool-module.js
Created January 25, 2016 19:31
JavaScript - Module Pattern Example
function CoolModule() {
var something = "cool";
var another = [1, 2, 3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join( " ! " ) );
@ellm
ellm / cool-module-2.js
Created January 28, 2016 18:36
JavaScript - Module Example using Init
var ModuleExample = {
init: function() {
var _self = this;
var varExample = $('form.variations_form');
function exampleFunction() {
console.log(this);
}
}
};
@ellm
ellm / viewport-test.js
Created February 2, 2016 20:54
JavaScript - Test for Element in Viewport
// Check to see if an element is in the viewport
function elementInViewport(el) {
var top = el.offsetTop;
var left = el.offsetLeft;
var width = el.offsetWidth;
var height = el.offsetHeight;
while (el.offsetParent) {
el = el.offsetParent;
top += el.offsetTop;
@ellm
ellm / wp-wysiwyg-test.html
Created March 2, 2016 16:20
WordPress - WYSIWYG Unit Test for CSS Styles
<h1>Heading 1</h1>
Nulla eu erat dolor. <strong>Vestibulum</strong> vel eleifend libero. Donec molestie urna posuere egestas suscipit. Nunc id porttitor nulla. Nulla facilisi. In hac habitasse platea dictumst. <a href="http://www.google.com" target="_blank">Maecenas</a> quis condimentum ipsum. Suspendisse potenti. Cras eget <em>tristique</em> nulla, nec tempus arcu. Donec pulvinar sapien a sapien lobortis, eget egestas augue interdum. Curabitur imperdiet urna et pellentesque convallis. Morbi id risus ex. Morbi condimentum gravida odio. <del>Vestibulum</del> fermentum molestie vestibulum. Phasellus pretium nulla arcu, at pellentesque diam efficitur vitae.
<h2>Heading 2</h2>
Nulla eu erat dolor. Vestibulum vel eleifend libero. Donec molestie urna posuere egestas suscipit. Nunc id porttitor nulla. Nulla facilisi. In hac habitasse platea dictumst. Maecenas quis condimentum ipsum. Suspendisse potenti. Cras eget tristique nulla, nec tempus arcu. Donec pulvinar sapien a sapien lobortis, eget egestas augue interdum.
@ellm
ellm / php-note-snippets.md
Last active November 29, 2018 14:28
Php Snippets and Notes

Php Snippets and Notes

printf

I need to escape/translate text that also requires HTML within in the copy. Use printf()

    <h3><?php printf( esc_html__( 'Get our exclusive newsletter—the best of %1$s The Dude %2$s every day!', 'localdude' ), '<span>', '</span>' ); ?></h3>
@ellm
ellm / webpack-notes.md
Last active January 17, 2019 10:20
Webpack Notes and Snippets

Webpack 3.0

Code spliting in webpack to help decrease loaded dependencies on load.

  • UI that gets displayed as a callback from an event can benefit.
  • We can async. load a ES6 import() and code after it is returned using a promise.
// At top of file, assign an `import()` that is returned from a function.
const getBloodhound = () => import('bloodhound-js');

// Add an event that will trigger loading the module.
@ellm
ellm / javascript-notes-snippets.md
Last active April 21, 2024 20:02
JavaScript Notes and Snippets

JavaScript Notes and Snippets

Promises

  • promise.all() can be used to queue up a few asynchronous calls to load before a subsquent script is called.
  • This can be useful for preloading libraries before some scripts that depend on the library are called.
this.searchTrigger.addEventListener('click', () => {
 // Lazyload Typeahead and Bloodhound libraries.
@ellm
ellm / css-notes-and-snippets.md
Last active March 15, 2017 18:34
CSS Notes and Snippets

CSS notes and snippets

Push elements off screen

  • for UX where navigation flies in from the side of the screen or a rollup that swoops in from the bottom of the screen, use translate3d().
  • the advantage is that you do not need to know the height or width. Whereas using negative margin or top, bottom, etc requires that an exact measurement to push off screen
  • add transition: transform 0.5s to have it smoothly move in and out.
transform: translate3d(0, 100%, 0); // push off screen