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
const getPositionAtCenter = function (element) { | |
let data = element.getBoundingClientRect(); | |
return { | |
x: data.left + data.width / 2, | |
y: data.top + data.height / 2 | |
}; | |
}; | |
const getDistanceBetweenElements = function(a, b) { | |
let aPosition = getPositionAtCenter(a); |
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 | |
$dir = dirname(__FILE__); | |
echo "<p>Full path to this dir: " . $dir . "</p>"; | |
echo "<p>Full path to a .htpasswd file in this dir: " . $dir . "/.htpasswd" . "</p>"; | |
?> |
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 wpse_128636_redirect_post() { | |
$queried_post_type = get_query_var('post_type'); | |
if ( is_single() && 'post_type' == $queried_post_type ) { | |
wp_redirect( home_url(), 301 ); | |
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 lazy_load_videos($atts) { | |
$a = shortcode_atts( array( | |
'id' => 'something else', | |
'width' => '', | |
'height' => '' | |
), $atts ); | |
$stringbean = '<div class="js-lazyYT '; | |
if( !empty($a['height']) ){ | |
$stringbean .= '" data-height="'.$a['height'].'" style="height:'.$a['height'].'; width:'.$a['width'].';" data-width="'.$a['width'].'"'; | |
}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() { | |
$('a[href*=#]:not([href=#])').click(function() { | |
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); | |
if (target.length) { | |
$('html,body').animate({ | |
scrollTop: target.offset().top | |
}, 1000); | |
return false; |
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
$('[placeholder]').focus(function() { | |
var input = $(this); | |
if (input.val() == input.attr('placeholder')) { | |
input.val(''); | |
input.removeClass('placeholder'); | |
} | |
}).blur(function() { | |
var input = $(this); | |
if (input.val() == '' || input.val() == input.attr('placeholder')) { | |
input.addClass('placeholder'); |
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
$( "object" ).wrap( "<div class='flex-video widescreen vimeo'></div>" ); |