Skip to content

Instantly share code, notes, and snippets.

View schutzsmith's full-sized avatar

Daniel Schutzsmith schutzsmith

View GitHub Profile
@schutzsmith
schutzsmith / gist:4652354
Created January 28, 2013 02:11
Include custom post types in “Right Now” admin dashboard widget
// originally from http://wpsnipp.com/index.php/functions-php/include-custom-post-types-in-right-now-admin-dashboard-widget/
function wph_right_now_content_table_end() {
$args = array(
'public' => true ,
'_builtin' => false
);
$output = 'object';
$operator = 'and';
$post_types = get_post_types( $args , $output , $operator );
@schutzsmith
schutzsmith / gist:4758909
Created February 12, 2013 00:20
Buddypress Functions for profile url logged in user lots off globals
$bp->loggedin_user->id The user ID of the user.
$bp->loggedin_user->domain The profile page URL of the user
$bp->loggedin_user->fullname The display name of the user
$bp->displayed_user->id The user ID of the user.
$bp->displayed_user->domain The profile page URL of the user
@schutzsmith
schutzsmith / gist:4758917
Created February 12, 2013 00:21
Get Buddypress avatar
<a href="<?php bloginfo('url'); ?>/category/<? echo $post->post_author;?>"><?php echo get_avatar( get_the_author_meta('ID'), '65' ); ?></a>
@schutzsmith
schutzsmith / gist:4758938
Created February 12, 2013 00:24
Buddypress Get user profile data function
Drop in functions.php
function getProfileData($fieldName){
global $bp;
return xprofile_get_field_data($fieldName,$bp->loggedin_user->id);
}
We couldn’t find that file to show.
@schutzsmith
schutzsmith / gist:5383348
Created April 14, 2013 16:40
Random text in PHP
<?
$random_text = array("Random Text 1",
"Random Text 2",
"Random Text 3",
"Random Text 4",
"Random Text 5");
srand(time());
$sizeof = count($random_text);
$random = (rand()%$sizeof);
print("$random_text[$random]");
@schutzsmith
schutzsmith / gist:6400038
Created August 31, 2013 19:12
Execute admin only code in Wordpress
if(!is_admin())
return;
@schutzsmith
schutzsmith / gist:6400047
Created August 31, 2013 19:14
Change default Post Type labels in Wordpress
function frl_change_post_labels($post_type, $args){ /* change assigned labels */
global $wp_post_types;
if($post_type != 'post')
return;
$labels = new stdClass();
$labels->name = __('Articles', 'frl');
$labels->singular_name = __('Article', 'frl');
@schutzsmith
schutzsmith / gist:6400056
Created August 31, 2013 19:16
Custom set of default quick tags in Wordpress
function frl_quicktags_settings($qt_init, $editor_id){
if($editor_id != 'content')
return $qt_init; //not a default case
/* default set of values - "strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close,fullscreen" */;
$qt_init['buttons'] = "strong,em,link,block,img,ul,ol,li,code,fullscreen"; ;
return $qt_init;
}
<?php
// PageLines references
// https://github.com/pagelines/DMS/blob/Dev/includes/library.wordpress.php#L54
// 'aspect-thumb' not in use -- https://github.com/pagelines/DMS/search?q=aspect-thumb&type=Code
// 'basic-thumb' might be used by PopThumbs -- https://github.com/pagelines/DMS/blob/Dev/sections/popthumbs/section.php#L143
// 'landscape-thumb' used when PL settings have featured image on top of posts -- https://github.com/pagelines/DMS/blob/Dev/includes/class.posts.php#L396
// WordPress references
// http://codex.wordpress.org/Function_Reference/add_image_size
// http://codex.wordpress.org/Plugin_API/Filter_Reference/image_size_names_choose