Skip to content

Instantly share code, notes, and snippets.

View sbruner's full-sized avatar

Steve Bruner sbruner

View GitHub Profile
@sbruner
sbruner / RoloPress - Custom logged in menu
Created December 14, 2010 20:48
RoloPress - Custom logged in menu
<?php function rolopress_custom_top_menu() {
if ( is_user_logged_in() ) {
echo "<div id=\"menu\">";
wp_nav_menu( array( 'menu' => 'default-menu') ); // display menu built in Appearance > Menus
rolopress_default_top_menu_right(); // call function to create right side of menu.
echo "</div>";
} else {
SHOW NON-LOGGED IN MENU;
};
@sbruner
sbruner / bp-custom.php
Created August 17, 2011 20:39
WPNYC.ORG / BuddyPress: Redirect to forum on Group home page
<?php
/**
* Redirect to forum on Group home page
*
* http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/changing-group-tab-display-defaults/?topic_page=2&num=15
*/
function sfire_redirect_to_forum() {
global $bp;
$path = clean_url( $_SERVER['REQUEST_URI'] );
@sbruner
sbruner / gist:1845471
Created February 16, 2012 15:03
Custom BuddyPress Activity Stream
<?php
/* = Generate Custom Activity Stream
-----------------------------------------------
* Place this function anywhere you want to show your custom stream.
* Should accept any of these parameters:
* http://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/
*/
@sbruner
sbruner / gist:2577254
Created May 2, 2012 15:03
Fix for NRELATE_RELATED_ADMIN_DIR
<?php
/**
Plugin Name: nrelate Related Content
Plugin URI: http://www.nrelate.com
Description: Easily display related content on your website. Click on <a href="admin.php?page=nrelate-related">nrelate &rarr; Related Content</a> to configure your settings.
Author: <a href="http://www.nrelate.com">nrelate</a> and <a href="http://www.slipfire.com">SlipFire</a>
Version: 0.51.1b
Author URI: http://nrelate.com/
@sbruner
sbruner / gist:2582817
Created May 3, 2012 03:22
Fix for NRELATE_RELATED_SETTINGS_DIR
<?php
/**
* Plugin Admin File
*
* Settings for this plugin
*
* @package nrelate
* @subpackage Functions
*/
@sbruner
sbruner / gist:5199452
Created March 19, 2013 19:43
Piklist temp fix: Media Meta: /includes/class-piklist-media.php
public static function attachment_fields_to_edit($form_fields, $post)
{
global $typenow;
if ($typenow =='attachment')
{
if ($meta_boxes = self::meta_box($post))
{
$form_fields['_final'] = $meta_boxes . '<tr class="final"><td colspan="2">' . (isset($form_fields['_final']) ? $form_fields['_final'] : '');
}
}
@sbruner
sbruner / gist:5502361
Created May 2, 2013 13:56
Piklist: updated get_meta_sql
public function get_meta_sql($meta_query, $queries, $type, $primary_table, $primary_id_column, $context)
{
if (in_array($type, array('user')))
{
return $meta_query;
}
global $wpdb;
$where = array_filter(preg_split('/$\R?^/m', trim(substr($meta_query['where'], 6, strlen($meta_query['where']) - 8))));
<?php
function parse_piklist_array($array) {
if ( empty($array) )
return array();
$keys = array_keys($array);
if ( empty($keys) )
return array();
$results = $values = array();
@sbruner
sbruner / gist:d1f7c5a04533f63d2cf1
Last active September 3, 2015 01:35 — forked from mannieschumpert/gist:8886289
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );