/**
* Get Youtube video ID from URL
*
* @param string $url
* @return mixed Youtube video ID or FALSE if not found
*/
function getYoutubeIdFromUrl($url) {
$parts = parse_url($url);
if(isset($parts['query'])){
This file contains hidden or 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
<? | |
add_action('get_header', function(){ | |
if ( !current_user_can( 'administrator' ) ) { | |
wp_die('<p>This website is under construction. This field accepts HTML markup so you can customize this <i>as</i> you would <b>see fit</b>.</p><'); | |
} | |
}); | |
?> |
This file contains hidden or 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
// Track scrolling percentage from top | |
function getScrollPercentage() { | |
var h = document.documentElement, | |
b = document.body, | |
st = 'scrollTop', | |
sh = 'scrollHeight'; | |
return (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100; | |
} | |
// Track scrolling pixels from top | |
function getScrollPixel() { |
This file contains hidden or 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://www.wpbeginner.com/wp-tutorials/how-to-add-an-admin-user-in-wordpress-using-ftp/ | |
/** | |
* Use this as a last resort to get back in your WordPress installation without using MySQL. | |
*/ | |
add_action('init', function(){ | |
$username = 'Username'; | |
$password = 'Password'; |
This file contains hidden or 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://wordpress.stackexchange.com/questions/4191/allow-editors-to-edit-menus | |
add_action( 'admin_menu', function(){ | |
$role_object = get_role( 'editor' ); | |
$role_object->add_cap( 'edit_theme_options' ); | |
if (current_user_can('editor')): | |
add_menu_page( __('Menu\'s'), 'Menu', 'edit_pages', 'nav-menus.php', '', 'dashicons-menu', 50 ); | |
remove_menu_page( 'themes.php' ); |
This file contains hidden or 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 | |
$api_key = 'YOUR_PLACES_API_KEY'; | |
$place_id = 'PLACE_ID'; | |
$file = file_get_contents( 'https://maps.googleapis.com/maps/api/place/details/json?placeid=' . $place_id . '&key=' . $api_key ); | |
$json = json_decode( $file ); | |
if ( is_object( $json ) ) : | |
foreach ( $json->result->reviews as $review ) : |
This file contains hidden or 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 $locations = get_nav_menu_locations(); ?> | |
<?php $menu = wp_get_nav_menu_object( $locations['theme_location'] ); ?> | |
<?php $menu_items = wp_get_nav_menu_items( $menu->term_id ); ?> | |
<ul class="list-group list-group-flush"> | |
<?php foreach ( (array) $menu_items as $key => $menu_item ): ?> | |
<li class="list-group-item list-group-item-action"> | |
<a href="<?= $menu_item->url; ?>"> | |
<?= $menu_item->title; ?> |
This file contains hidden or 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 $args = array('post_type' => 'posttype', 'post__not_in' => array($post->ID), ); ?> | |
<?php $query = new wp_query( $args ); ?> | |
<?php if($query->have_posts()): ?> | |
<?php while( $query->have_posts() ) : ?> | |
<?php $query->the_post(); ?> | |
// All Post relative stuff here | |
<?php the_title(); ?> | |
<?php echo esc_url( get_post_permalink() ); ?> |
This file contains hidden or 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://stackoverflow.com/a/8028584 | |
function getScrollPercent() { | |
var h = document.documentElement, | |
b = document.body, | |
st = 'scrollTop', | |
sh = 'scrollHeight'; | |
return (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100; | |
} | |
document.addEventListener('scroll', function(){ |
This file contains hidden or 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://www.google.com/maps/dir/Current+Location/Streetname%20housenumber+postalnumbers+postalletters+city |