Last active
February 7, 2018 03:55
-
-
Save lukeburford/11c6fa82ac4018f3852a22a03b7bb830 to your computer and use it in GitHub Desktop.
Add Jribbble to WordPress
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
// Load Jribbble | |
function lunamedia_theme_load_scripts() { | |
if (!is_admin()) { | |
if(is_page_template('page-about.php')){ | |
// Register our Javascript | |
wp_register_script('jribbble', get_template_directory_uri() . '/js/jribbble.min.js', array('jquery'), false, false); | |
// Load our Javascript | |
wp_enqueue_script('jribbble'); | |
} | |
} | |
} | |
add_action('wp_enqueue_scripts', 'lunamedia_theme_load_scripts'); |
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
// Somewhere in your page template | |
<div id="dribbble-shots" class="row"> | |
// Get yr shots from the Dribbble | |
<script> | |
(function($) { | |
$.jribbble.setToken('super-secret-token-string'); | |
$.jribbble.users('lukeburford').shots({per_page: 9}).then(function(shots) { | |
var html = []; | |
shots.forEach(function(shot) { | |
html.push('<div class="dribbble-shot col-sm-8">'); | |
html.push('<a href="' + shot.html_url + '" target="_blank">'); | |
html.push('<img src="' + shot.images.normal + '">'); | |
html.push('</a></div>'); | |
}); | |
$('#dribbble-shots').html(html.join('')); | |
}); | |
})( jQuery ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment