Skip to content

Instantly share code, notes, and snippets.

@dboutote
dboutote / category-taxonomy-all-post-types.php
Last active December 20, 2015 17:02
Adding Category Taxonomy Support for all WordPress Post-types
<?php
function add_category_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
register_taxonomy_for_object_type('category', $post_type);
}
}
add_action( 'init', 'add_category_support', 99 );
function findMiddleDiv(){
var scrollTop = $(window).scrollTop();
var winHeight = $(window).height();
var middleHeight = winHeight / 2;
var visibleElements = $('.platform-section');
var $midElement = visibleElements.eq(0);
var targetId,
@dboutote
dboutote / default-post-thumb.php
Created July 26, 2015 15:39
Create/Load a default post thumbnail (WordPress theme)
<?php
/**
* Default Img for post thumbnails
*
* @param $file_name_new (string) Name of the newly-created file
* @param $file_name_orig (string) Filename of the original default image
* @param $post_id (int) ID of the associated Post
* @param $size (array) Width/height of cropped thumbnail
* @param $class (string) Optional class attribute for output image
@dboutote
dboutote / remove-post-row-actions.php
Created July 26, 2015 15:34
Hide Links in page and post row actions (WordPress edit.php)
<?php
/**
* Hide certain links from edit.php
*
* @param array $actions Array of action links
* @return array $actions Filtered array of links
*/
function remove_row_actions( $actions ) {
@dboutote
dboutote / google-map-link.php
Last active August 29, 2015 14:25
Build a link to Google Maps
@dboutote
dboutote / bing-map-link.php
Last active August 29, 2015 14:25
Build a link to Bing Map (for WordPress Theme)
@dboutote
dboutote / hideemail.php
Created July 26, 2015 15:26
Hide email from Spam Bots using a shortcode. (WordPress theme)
<?php
/**
* Hide email from Spam Bots using a shortcode.
*
* @param array $atts Shortcode attributes. Not used.
* @param string $content The shortcode content. Should be an email address.
*
* @return string The obfuscated email address.
*/
function _ss_hide_email_shortcode( $atts , $content = null ) {
@dboutote
dboutote / google-img-map-link.php
Last active August 29, 2015 14:25
Builds A Link to Google Maps (for WordPress theme)
@dboutote
dboutote / body_id.php
Last active August 29, 2015 14:23
Add an ID Attribute to WordPress Body Element
<?php
// Create a dynamic id on body elements
function get_body_id( $id = '' ) {
global $wp_query;
// Fallbacks
if ( is_front_page() ) $id = 'front-page';
if ( is_home() ) $id = 'blog';
if ( is_search() ) $id = 'search';
if ( is_404() ) $id = 'error404';
@dboutote
dboutote / gist:62e4fac0600895d5b879
Last active August 29, 2015 14:10
This checks if a parent page should load its first child page.
add_action( 'parse_request', 'check_for_redirect' );
function check_for_redirect( $query ) {
if( is_admin() ){
return;
}
if( isset($query->query_vars[ 'pagename' ]) ){
$pagename = $query->query_vars[ 'pagename' ];