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() | |
{ | |
if( window.localStorage ) | |
{ | |
if( !localStorage.getItem('firstLoad') ) | |
{ | |
localStorage['firstLoad'] = true; | |
window.location.reload(); | |
} | |
else |
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 getUrlParameter(name) { | |
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); | |
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); | |
var results = regex.exec(location.search); | |
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | |
}; | |
// from url like sales/?search=roadmap+mcp+test | |
// using getUrlParameter('search') it return "roadmap mcp test" |
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 ts; | |
$(document).bind('touchstart', function(e) { | |
ts = e.originalEvent.touches[0].clientY; | |
}); | |
$(document).bind('touchmove', function(e) { | |
var te = e.originalEvent.changedTouches[0].clientY; | |
if (ts > te) { | |
console.log('down'); | |
} else { |
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
$(window).bind('mousewheel', function(event) { | |
if (event.originalEvent.wheelDelta >= 0) { | |
console.log('Scroll up'); | |
} | |
else { | |
console.log('Scroll down'); | |
} | |
}); |
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
$default_opengraph = 'https://www.rafaeldejongh.com/wp-content/uploads/2017/08/RafaelDeJongh-Web-Developer-3D-Artist.jpg'; | |
function add_default_opengraph($object){global $default_opengraph; $object->add_image($default_opengraph);} | |
add_action('wpseo_add_opengraph_images','add_default_opengraph'); | |
function default_opengraph(){global $default_opengraph; return $default_opengraph;} | |
add_filter('wpseo_twitter_image','default_opengraph'); |
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 $query = new WP_Query( array( 'category_name' => 'blog' ) ); ?> | |
<?php while ($query->have_posts()) : $query->the_post(); ?> | |
<?php get_template_part('partials/content-category-blog'); ?> | |
<?php | |
endwhile; | |
wp_reset_query(); | |
?> |
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 GetIP(){ | |
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) | |
{ | |
if (array_key_exists($key, $_SERVER) === true) | |
{ | |
foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) | |
{ | |
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) | |
{ | |
return $ip; |
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
$api_response_sorted; // initial array | |
$sortArray = array(); | |
foreach($api_response_sorted as $person){ | |
foreach($person as $key=>$value){ | |
if(!isset($sortArray[$key])){ | |
$sortArray[$key] = array(); | |
} | |
$sortArray[$key][] = $value; |
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
// source: https://stackoverflow.com/questions/9162933/make-iframe-height-dynamic-based-on-content-inside-jquery-javascript | |
//parent: | |
window.addEventListener('message', function(e) { | |
var $iframe = jQuery("#myIframe"); | |
var eventName = e.data[0]; | |
var data = e.data[1]; | |
switch(eventName) { | |
case 'setHeight': | |
$iframe.height(data); |
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
$(document).ready(function(){ | |
var uri = window.location.toString(); | |
if (uri.indexOf("?") > 0) { | |
var clean_uri = uri.substring(0, uri.indexOf("?")); | |
window.history.replaceState({}, document.title, clean_uri); | |
} | |
}); |