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 | |
/** | |
* Add custom attributes to WP nav menu links | |
*/ | |
add_filter( 'nav_menu_link_attributes', 'nav_menu_link_attributes_override', 10, 3 ); | |
function nav_menu_link_attributes_override( $atts, $item, $args ) { | |
// Use an identifier like a hashtag to grab the ones you want to override | |
if ( 'custom' === $item->type && ( preg_match( '/^#/', $item->url ) ) ) { |
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
/** | |
* Distance between two coordinates | |
* | |
* @author Salvador Dali | |
* | |
* @param { number } lat_1 - Latitude of first point | |
* @param { number } lon_1 - Longitude of first point | |
* @param { number } lat_2 - Latitude of second point | |
* @param { number } lon_2 - Longitude of second point | |
* |
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
/** | |
* Obtain a user's location | |
* | |
* @see https://developers.google.com/web/fundamentals/native-hardware/user-location/obtain-location | |
* @return { object } Location data | |
*/ | |
window.onload = function() { | |
var startPos; | |
var geoOptions = { enableHighAccuracy : true }; |
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 | |
/** | |
* Localize strings for JavaScripts | |
* | |
* @link https://codex.wordpress.org/Function_Reference/wp_localize_script | |
*/ | |
// Enqueue the script which will use the localized strings | |
wp_enqueue_script( 'name-of-your-script', '/js/yourscript.js' ); | |
// Define an array of data to be passed on to your JavaScript file |
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
<!DOCTYPE html> | |
<html <?php language_attributes(); ?>> | |
<head> | |
<meta charset="<?php bloginfo('charset'); ?>" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
</head> | |
<body> | |
... |
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
#!/bin/bash | |
bold=`tput bold` | |
normal=`tput sgr0` | |
clear | |
printf "Updating ${bold}Debian packages${normal}...\n"; | |
sudo aptitude update && sudo aptitude full-upgrade |
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 | |
/** | |
* Adds support for `admin.css` (with child-theme support) | |
* | |
* You can use this to style anything from edit buttons on the frontend | |
* to customizing your admin screen for logged in users | |
* | |
* @link http://codex.wordpress.org/Function_Reference/wp_enqueue_script | |
*/ | |
add_action( 'admin_enqueue_scripts', 'theme_admin_styles' ); |
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
/** | |
* Check for SVG support (modified to support data-src attribute) | |
* Source: http://www.prosoxi.com/2013/04/24/svg-replace-using-modernizr/ | |
* | |
* Usage (CSS): | |
* .svg .element { background-image: url('image.svg'); } | |
* .no-svg .element { background-image: url('image.png'); } | |
* | |
* Usage (HTML): | |
* <img src="image.svg" data-src="image.png" alt="" /> |
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
// Convert RGB(A) values to #hexdecimal using jQuery.css() | |
// Original: http://jsfiddle.net/DCaQb/ | |
// Note: This will not work on browsers which return 'color names' instead of rgb(a) values (i.e. IE8) | |
function rgba2hex( color_value ) { | |
if ( ! color_value ) return false; | |
var parts = color_value.toLowerCase().match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/), | |
length = color_value.indexOf('rgba') ? 3 : 2; // Fix for alpha values | |
delete(parts[0]); | |
for ( var i = 1; i <= length; i++ ) { | |
parts[i] = parseInt( parts[i] ).toString(16); |
NewerOlder