Skip to content

Instantly share code, notes, and snippets.

View ewistrand's full-sized avatar
🦸‍♂️

Eric Wistrand ewistrand

🦸‍♂️
  • Truly Free
  • Traverse City Michigan
View GitHub Profile
@ewistrand
ewistrand / bs3-480-grid.css
Created November 19, 2015 14:40
Bootstrap 3 480px grid
.col-ms-1,
.col-ms-2,
.col-ms-3,
.col-ms-4,
.col-ms-5,
.col-ms-6,
.col-ms-7,
.col-ms-8,
.col-ms-9,
.col-ms-10,
@ewistrand
ewistrand / wp-extract-shortcode.php
Created November 19, 2015 14:08
WP Extract Shortcode from the_content
<?php
/**
* Use in loop or single, has to access post_content
*/
$pattern = get_shortcode_regex();
preg_match('/'.$pattern.'/s', $post->post_content, $matches);
if (is_array($matches) && $matches[2] == 'smart_track_player') {
$shortcode = $matches[0];
echo do_shortcode($shortcode);
}
@ewistrand
ewistrand / wp-widget-shortcodes.php
Created November 19, 2015 13:58
WP allow shortcodes in sidebar text widgets
<?php
/**
* Allow shortcodes in WP text widgets
*/
add_filter('widget_text', 'do_shortcode');
?>
@ewistrand
ewistrand / wp-post-id-column.php
Last active November 19, 2015 13:55
Create admin post and page id column in Wordpress admin
<?php
// Show Page Id In Admin panel
add_filter('manage_posts_columns', 'posts_columns_id', 5);
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
add_filter('manage_pages_columns', 'posts_columns_id', 5);
add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_columns_id($defaults){
$defaults['wps_post_id'] = __('ID');
return $defaults;
@ewistrand
ewistrand / wp-add-browser-classes.php
Created November 19, 2015 13:50
WP Add Browser Classes to body tag
<?php
// Add Browser To Body Class
add_filter('body_class','browser_body_class');
function browser_body_class($classes) {
global $is_lynx, $is_gecko, $is_IE, $is_opera,$is_NS4, $is_safari, $is_chrome, $is_iphone;
if($is_lynx) $classes[] = 'lynx';
elseif($is_gecko) $classes[] = 'gecko';
elseif($is_opera) $classes[] = 'opera';
@ewistrand
ewistrand / wp-rss-thumbnails.php
Created November 19, 2015 13:45
WP RSS Thumbnails
<?php
// Add Thumbnail To RSS
function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) . '</p>' . get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
@ewistrand
ewistrand / wp-remove-jquery-migrate.php
Created November 19, 2015 13:41
WP Remove jQuery Migrate
<?php
// Remove jQuery Migrate From End
add_filter( 'wp_default_scripts', 'remove_jquery_migrate' );
function remove_jquery_migrate( &$scripts)
{
if(!is_admin())
{
$scripts->remove( 'jquery');
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' );
@ewistrand
ewistrand / wp-new-user-role.php
Last active January 17, 2017 00:20
WP Add New User Role Example
<?php
/**
* WP Add New User Role
*/
function wps_add_role() {
add_role( 'manager', 'Manager',
array(
'read' => true,
'edit_posts' => true,
'delete_posts' => true,
@ewistrand
ewistrand / wp-remove-emoji-support.php
Created November 19, 2015 13:36
WP Remove Emoji Support
<?php
//Remove Emoji Support
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
?>
@ewistrand
ewistrand / wp-post-metabox.php
Last active November 19, 2015 13:34
WP Post Meta Box
<?php
/**
* Adds a box to the main column on the Post and Page edit screens.
*/
function myplugin_add_meta_box() {
$screens = array( 'post', 'page' );
foreach ( $screens as $screen ) {