Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
// Add inline styles to WP admin
add_action('admin_head', 'colorpicker_styles');
function colorpicker_styles() {
echo '<style>
.wp-picker-container .iris-picker {
height: 50px !important;
padding-top: 15px;
}
function clearParams() {
var uri = window.location.toString();
if (uri.indexOf("?") > 0) {
var clean_uri = uri.substring(0, uri.indexOf("?"));
window.history.replaceState({}, document.title, clean_uri);
}
}
/**
* A simple drop-in snippet to ajaxify a site.
* If the user's browser doesn't support HTML5 History API,
* the site will navigate regularly.
*
* Change content and menu link selectors according to your need.
*
* Dependencies: jQuery 2+, jQuery.history
*/
(function(window, jQuery){
jQuery.extend(jQuery.easing, {
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
easeOutQuad: function (t) { return t*(2-t) },
// acceleration until halfway, then deceleration
easeInOutQuad: function (t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t },
// accelerating from zero velocity
easeInCubic: function (t) { return t*t*t },
/**
* Regular Expression IndexOf for Arrays
*/
if (typeof Array.prototype.reIndexOf === 'undefined') {
Array.prototype.reIndexOf = function (rx) {
for (var i in this) {
if (this[i].toString().match(rx)) {
return i;
}
}
function timeStamp() {
var now = new Date(),
date = [ now.getMonth() + 1, now.getDate(), now.getFullYear() ],
time = [ now.getHours(), now.getMinutes(), now.getSeconds() ];
// Leftpad seconds with 0
for ( var i = 1; i < 3; i++ ) {
if ( time[i] < 10 ) {
time[i] = "0" + time[i];
}
/**
* Get user's IPs using WebRTC (if supported)
* if WebRTC is not supported, ping FreeGeoIP.net
*
* partly from: https://github.com/diafygi/webrtc-ips
*
* @param onNewIP listener function for new IPs
*/
function findIP(onNewIP) {
var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome