Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Check for parent and sub categories
*
* @param int $id
* @return bool
*/
function ja_is_category_deep( $id = '' ) {
if ( !is_category() || empty( $id ) )
return false;
@jaredatch
jaredatch / gist:11234271
Created April 23, 2014 22:12
Default tax name
<?php
/**
* Display default tax name on archives if no headline is provided
*
* @since 1.0.0
* @param string $headline
* @param object $term
* @return string
*/
function ja_tax_default_headline( $headline, $term ) {
<?php
/**
* Creates nested date archive list for a specific category
*
* @since 1.0.0
*/
function ja_category_archive_list() {
global $post;
@jaredatch
jaredatch / gist:d9230215ed8d8beca2c3
Created May 13, 2014 20:06
Mobile detection for NGINX Synthesis accounts
<?php
/**
* Basic mobile detection for Synthesis accounts with NGINX caching.
*
* @since 1.0.0
* @return boolean
*/
function ja_is_mobile() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
jQuery(document).ready(function($){
// Notice bar
// Make sure and enqueue jquery cookie first - https://github.com/carhartl/jquery-cookie
var site_notice = $.cookie('site-notice');
if ( site_notice == null ) {
$('#site-notice').prependTo('body').slideToggle();
}
$('#site-notice .close').on( 'click', function() {
$('#sitenotice').slideToggle();
$.cookie('site-notice', 'hide', { expires: 60 });
@jaredatch
jaredatch / gist:21ffeab7362edd3d7f2f
Created June 4, 2014 17:32
Gravityforms placeholders
(function($){
$.fn.setPlaceholder = function(){
return this.each(function(){
var label = $(this).parent().prev();
label.hide();
var label = $(this).parent().prev().text().replace('*','');
$(this).attr('placeholder',label);
});
};
})(jQuery);
@jaredatch
jaredatch / gist:daaf2071b7e1c5e1dffb
Created July 3, 2014 20:16
jQuery floating header on scroll
jQuery(document).ready(function($){
var showed = false;
function floating_header() {
if ( $(window).width() > 700 ) {
window_scroll = $(this).scrollTop();
if ( window_scroll > 220 ) {
if ( showed == false ) {
$('#floating-header').slideDown('fast');
//alert('show');
@jaredatch
jaredatch / gist:027f611dda00431253ab
Created July 8, 2014 14:34
Dynamically create Pinterest Pin button for content images
<?php
/**
* Inline javascript
*
* @since 1.0.0
*/
function ja_pinterest_button() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
@jaredatch
jaredatch / gist:403ed19a27e24e19b176
Last active August 29, 2015 14:04
Easy share buttons
<?php
$url = urlencode( get_permalink() );
$img = urlencode( genesis_get_image( array( 'format' => 'url' ) ) );
$title = urlencode( get_the_title() );
echo '<a href="http://www.facebook.com/sharer/sharer.php?u=' . $url . '&t=' . $title .'" class="share-button facebook" target="_blank">Share on Facebook</a>';
echo '<a href="http://www.twitter.com/intent/tweet?url=' . $url . '&text=' . $title . '" class="share-button twitter" target="_blank">Tweet Me!</a>';
echo '<a href="http://pinterest.com/pin/create/button/?url=' . $url . '&media=' . $img . ' &description=' . $title . '" class="share-button pinterest" target="_blank">Pinterest</a>';
echo '<a href="http://plus.google.com/share?url=' . $url . '" class="share-button google" target="_blank">Google+</a>';
echo '<a href="http://www.linkedin.com/shareArticle?mini=true&url=' . $url . '" class="share-button linkedin" target="_blank">LinkedIn</a>';
echo '<a href="http://www.reddit.com/submit?url=' . $url . '" class="share-button reddit" target="_blank">LinkedIn</
@jaredatch
jaredatch / gist:8bb719130017f7d9d0ea
Last active August 29, 2015 14:06
Check for page template deep
<?php
/**
* Checks if current or top level pages has a specific page template set.
*
* @param string
* @return mixed false or page id
*/
function ja_is_page_template_deep( $template = '' ) {
if ( !empty( $template ) && is_page() ) {
$parents = get_post_ancestors( get_the_ID() );