Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Schutzsmith schutzsmith

View GitHub Profile
@schutzsmith
schutzsmith / gist:4652354
Created Jan 28, 2013
Include custom post types in “Right Now” admin dashboard widget
View gist:4652354
// 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 Feb 12, 2013
Buddypress Functions for profile url logged in user lots off globals
View gist:4758909
$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 Feb 12, 2013
Get Buddypress avatar
View gist:4758917
<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 Feb 12, 2013
Buddypress Get user profile data function
View gist:4758938
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 Apr 14, 2013
Random text in PHP
View gist:5383348
<?
$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 Aug 31, 2013
Execute admin only code in Wordpress
View gist:6400038
if(!is_admin())
return;
@schutzsmith
schutzsmith / gist:6400047
Created Aug 31, 2013
Change default Post Type labels in Wordpress
View gist:6400047
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 Aug 31, 2013
Custom set of default quick tags in Wordpress
View gist:6400056
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;
}
View pagelines-dms-customize-image-sizes.php
<?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