This file contains 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 | |
function nice_search_redirect() { | |
global $wp_rewrite; | |
if ( !isset( $wp_rewrite ) || !is_object( $wp_rewrite ) || !$wp_rewrite->using_permalinks() ) | |
return; | |
$search_base = $wp_rewrite->search_base; | |
if ( is_search() && !is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { | |
wp_redirect( home_url( "/{$search_base}/" . urlencode( get_query_var( 's' ) ) ) ); | |
exit(); |
This file contains 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 isScrolledIntoView(elem) | |
{ | |
var $elem = $(elem); | |
var $window = $(window); | |
var docViewTop = $window.scrollTop(); | |
var docViewBottom = docViewTop + $window.height(); | |
var elemTop = $elem.offset().top; | |
var elemBottom = elemTop + $elem.height(); |
This file contains 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 | |
// place this to mu-plugins folder under wp-content | |
// set WP_DEBUG to true in wp_config.php to see all other errors | |
error_reporting(E_ALL & ~( E_NOTICE | E_USER_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_CORE_WARNING | E_USER_WARNING | E_COMPILE_WARNING | E_PARSE )); |
This file contains 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
var util = require('util'); | |
var _ = require('lodash'); | |
/** | |
* Logs prettyfied and colored objects to console | |
* @param msg - message | |
* @param title - log message title | |
* @param depth - property depth | |
* @param showHidden - show hidden properties | |
*/ |
This file contains 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 isDateString(str) { | |
return !isNaN(Date.parse(str)); | |
} |
This file contains 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
/*https://codepen.io/dimbslmh/full/mKfCc*/ | |
.modal { | |
text-align: center; | |
padding: 0!important; | |
} | |
.modal:before { | |
content: ''; | |
display: inline-block; | |
height: 100%; |
This file contains 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
// http://stackoverflow.com/questions/31683075/how-to-do-a-deep-comparison-between-2-objects-with-lodash | |
function compare(a, b) { | |
var result = { | |
different: [], | |
missing_from_first: [], | |
missing_from_second: [] | |
}; | |
_.reduce(a, function (result, value, key) { |
This file contains 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
/* | |
Thanks David <3 - https://medium.freecodecamp.com/the-100-correct-way-to-do-css-breakpoints-88d6a5ba1862 | |
*/ | |
@for-phone: ~"screen and (max-width: 44.9375rem)"; // < 720 | |
@for-tablet-only: ~"screen and (min-width: 45rem) and (max-width: 74.9375rem)"; // > 720 < 1199 | |
@for-tablet-portrait-only: ~"screen and (min-width: 45rem) and (max-width: 56.1875rem)"; // > 720 < 900 | |
@for-tablet-portrait-up: ~"screen and (min-width: 45rem)"; // > 720 | |
@for-tablet-landscape-up: ~"screen and (min-width: 56.25rem)"; // > 900 | |
@for-desktop-up: ~"screen and (min-width: 75rem)"; // > 1200 | |
@for-big-desktop-up: ~"screen and (min-width: 112.5rem)"; // > 1800 |
This file contains 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 outOfViewport(colorWrapper, colorTag, colorClass) { | |
const bodyWidth = document.body.offsetWidth; | |
const list = document.querySelectorAll('*'); | |
for (let elem of list) { | |
if (elem.offsetWidth > bodyWidth) { | |
console.log( | |
`%c [` + | |
`%c` + elem.tagName + | |
`%c.` + elem.classList + | |
`%c]` + |
This file contains 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
// Implementation in ES6 | |
function pagination(c, m) { | |
var current = c, | |
last = m, | |
delta = 2, | |
left = current - delta, | |
right = current + delta + 1, | |
range = [], | |
rangeWithDots = [], | |
l; |