Skip to content

Instantly share code, notes, and snippets.

@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 / 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
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 / 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 );
@dboutote
dboutote / posttag-taxonomy-all-post-types.php
Created December 20, 2015 16:24
Adding post_tag Taxonomy Support for all WordPress Post-types
<?php
function add_post_tag_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
register_taxonomy_for_object_type('post_tag', $post_type);
}
}
add_action( 'init', 'add_post_tag_support', 99 );
@dboutote
dboutote / template-include.php
Last active December 30, 2015 23:39
WordPress: Load a template file on singe-post-type page (if applicable)
<?php
/**
* Load a template file on single-post-type page (if applicable)
*
* Works for all post-types
*/
function dbdb_include_post_template($template) {
if( !is_archive() ) {
$id = get_queried_object_id();
$template_name = get_post_meta($id, '_wp_page_template', true);
@dboutote
dboutote / body_id.php
Last active January 9, 2019 09:02
Add an ID Attribute to the WordPress Body Element: http://darrinb.com/adding-a-custom-id-to-the-body-element-in-wordpress/
<?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';
@dboutote
dboutote / post_class_filter.php
Last active January 11, 2016 04:45
Customizing the WordPress post_class Filter
<?php
function my_post_classes( $classes ) {
global $multipage, $page, $post, $wp_taxonomies;
if($wp_taxonomies) {
foreach($wp_taxonomies as $taxonomy) {
$tax_array[] = $taxonomy->name;
}
<?php
/**
* Add dynamic classes to the WP body_class() function
*
* updated: 01/06/16
*/
function _dbdb_body_classes( $classes ) {
global $wp_query, $post;
// if it's the front page of the site
@dboutote
dboutote / external_links.js
Created January 9, 2016 20:34
jQuery script to add target=“_blank” for outgoing links