Skip to content

Instantly share code, notes, and snippets.

View designbuildtest's full-sized avatar

designbuildtest

View GitHub Profile
@designbuildtest
designbuildtest / gist:aea3d135eb5294d66647
Created September 29, 2015 21:15
Testimonials with ratings
/**
* Create a Rating metabox for Accolades.
*/
function dbt_accolade_rating_metabox() {
add_meta_box( 'dbt_accolade_rating_metabox', __( 'Testimonial Rating' ), 'dbt_accolade_rating_callback', 'accolade', 'normal', 'default' );
}
add_action( 'add_meta_boxes', 'dbt_accolade_rating_metabox' );
function dbt_accolade_rating_callback( $post ) {
wp_nonce_field( 'accolade_rating_check', 'accolade_rating_nonce' );
@designbuildtest
designbuildtest / gist:5a2e962fed23dde5d414
Created September 22, 2015 11:11
Google Maps example - with marker and custom controls
<div id="map" style="height:600px"></div>
<script>
function initMap() {
var myLatLng = { lat: <?php esc_attr_e( sing_post_latitude() ); ?>, lng: <?php esc_attr_e( sing_post_longitude() ); ?> };
var map = new google.maps.Map(document.getElementById('map'), {
center: myLatLng,
scrollwheel: false,
disableDoubleClickZoom: true,
streetViewControl: false,
mapTypeControl: false,
@designbuildtest
designbuildtest / gist:06c248c249e72fc4e8f6
Created September 18, 2015 04:56
Remove the "Protected" prefix that WordPress adds to password protected entries.
function dbt_remove_protected_private_in_title( $title ) {
return '%s';
}
add_filter( 'protected_title_format', 'dbt_remove_protected_private_in_title' );
@designbuildtest
designbuildtest / gist:9c044f3ca4e79b45bc2f
Created September 16, 2015 02:43
Customize the_archive() title output.
function dbt_custom_archive_title() {
if ( is_category() ) {
$title = single_cat_title( '', false );
}
elseif ( is_tag() ) {
$title = single_tag_title( '', false );
}
else {
$title = post_type_archive_title( '', true );
}
@designbuildtest
designbuildtest / gist:fd74d80a5ee9c651f131
Created August 11, 2015 20:31
Gist oembed support.
function bhww_embed_handler_gist( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<script src="https://gist.github.com/%1$s.js%2$s"></script>',
esc_attr($matches[1]),
esc_attr($matches[2])
);
return apply_filters( 'embed_gist', $embed, $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'gist', '/https?:\/\/gist\.github\.com\/([a-z0-9]+)(\?file=.*)?/i', 'bhww_embed_handler_gist' );
@designbuildtest
designbuildtest / gist:b243e74bf6049e7d0f13
Last active August 29, 2015 14:26
WordPress remove POST and PAGE type (feature) support
function dbt_remove_post_type_support() {
remove_post_type_support( 'post', 'custom-fields' ); // 'page' also a valid value
remove_post_type_support( 'post', 'comments' ); // 'page' and 'attachment' also valid values
remove_post_type_support( 'post', 'trackbacks' );
}
add_action( 'init', 'dbt_remove_post_type_support' );
@designbuildtest
designbuildtest / gist:52db8064fd1cf54f6a79
Created August 7, 2015 03:29
WordPress add support for page excerpts and show the excerpt metabox by default
function dbt_add_page_excerpt_support() {
add_post_type_support( 'page', 'excerpt' );
}
add_action( 'init', 'dbt_add_page_excerpt_support' );
function dbt_show_page_excerpt_metabox_by_default( $hidden, $screen ) {
if ( 'page' == $screen->id ) {
$hidden = array_flip( $hidden );
unset( $hidden['postexcerpt'] );
$hidden = array_flip( $hidden );
@designbuildtest
designbuildtest / gist:24412c6b04f2b616cbac
Last active August 29, 2015 14:26
WordPress custom manage PAGES & CUSTOM POST TYPE views
function dbt_custom_manage_columns( $columns ) {
unset( $columns['author'] );
unset( $columns['date'] );
unset( $columns['comments'] );
return $columns;
}
add_filter( 'manage_edit-page_columns', 'dbt_custom_manage_columns' ); // Pages
add_filter( 'manage_edit-cpt_columns', 'dbt_custom_manage_columns' ); // Custom Post Type - replace 'cpt' with your named CPT
@designbuildtest
designbuildtest / gist:02db20a0758795e963a6
Last active August 29, 2015 14:26
WordPress custom manage POSTS view
function dbt_custom_manage_posts_columns( $columns ) {
unset( $columns['author'] );
unset( $columns['date'] );
unset( $columns['comments'] );
unset( $columns['categories'] );
unset( $columns['tags'] );
return $columns;
}
add_filter( 'manage_posts_columns', 'dbt_custom_manage_posts_columns' );
@designbuildtest
designbuildtest / gist:b97cb9c6c66abcc157f1
Created August 7, 2015 02:59
WordPress remove 'Mine' tab
function dbt_remove_mine_view( $views ) {
unset( $views['mine'] );
return $views;
}
add_action( 'views_edit-page', 'dbt_remove_mine_view' );