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
$("#glossary > .term").each(function() { | |
$(this).addClass("glossary-" + $(this).children("h3").text().charAt(0)); | |
}); | |
$('#glossary > #no-results').hide(); | |
var resetDirectory = function () { | |
$("#glossary > .term").show(); | |
}; |
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 to head tag in template | |
<script> | |
var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; | |
</script> | |
// Ajax Function for Returning Custom Post Type of Glossary | |
function test_ajax() { | |
header( "Content-Type: application/json"); |
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
function build_category_navigation( $cat = null ){ | |
$args = array( | |
'hierarchical' => 1, | |
'pad_counts' => 1, | |
'taxonomy' => 'categories', | |
'order_by' => 'id', | |
'order' => 'asc' | |
); |
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
// Example | |
function shortcode_name( $atts, $content = null ){ | |
$a = shortcode_atts( array( | |
'example' => '' | |
), $atts ); | |
return '<a id="example" data-example="' . $a['example'] . '">' . $content . '</a>'; | |
} | |
add_shortcode( 'name', 'shortcode_name' ); |
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 if this.property exists, if so use it, if not create it and add value to the array | |
var object = { | |
method: function (value) { | |
this.property = this.property || []; | |
this.property.push(value); | |
} | |
}; |
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
// Credit: Montague Monro | |
// https://www.youtube.com/watch?v=3WiyGmdOjbc | |
app.factory('Posts', ['$http', function ($http) { | |
return { | |
getPosts: function () { | |
var response = $http({ | |
url: ajaxurl, | |
method: "GET", | |
params: {action: 'test_ajax'} |
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 | |
// Put JavaScript into Template | |
function enable_ajax_functionality() { | |
wp_localize_script( 'ajaxify', 'ajaxify_function', array('ajaxurl' => admin_url('admin-ajax.php')) ); | |
} | |
add_action('template_redirect', 'enable_ajax_functionality'); | |
// Add two actions to wp_ajax, where we get posts array back as json | |
function test_ajax() { |
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
function init_scroll(event, delta) { | |
var deltaOfInterest = delta, | |
timeNow = new Date().getTime(), | |
quietPeriod = 500; | |
// Cancel scroll if currently animating or within quiet period | |
if(timeNow - lastAnimation < quietPeriod + settings.animationTime) { | |
event.preventDefault(); | |
return; | |
} |
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
!function($) { | |
var defaults = { | |
sectionContainer: "section", | |
}; | |
$.fn.onepage_scroll = function(options) { | |
var settings = $.extend({}, defaults, options); | |
} |
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
$(".btn").bind("click", function () { | |
$(this).attr('data-state', 'pressed'); | |
}); |