Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / gist:93c2a278a04216e3539df7378744c041
Last active September 20, 2016 15:19
Change Name of BP Activity Stream
function change_buddypress_activity_title( $title ) {
if ( __( 'Site-Wide Activity', 'text-domain' ) === $title ) {
$title = __( 'Latest and Greatest News', 'text-domain' );
}
return $title;
}
@pbrocks
pbrocks / image-url-filter.php
Created December 1, 2016 03:34
Add to local wp-config.php to grab images when overriding urls
function filter_image_url( $url ) {
global $wpdb;
$siteurl = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %d LIMIT 1", "siteurl" ) );
// $siteurl = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = siteurl LIMIT 1" ) );
$siteurl = $siteurl->option_value . '/';
$url = str_replace( WP_SITEURL, $siteurl, $url );
return $url;
}
add_filter( 'wp_get_attachment_url', 'filter_image_url' );
add_filter( 'bp_get_directory_title', 'change_activity_title' );
function change_activity_title( $data ) {
if ( 'Sitewide Activity' === $data ) {
$data = 'Name';
}
return $data;
}
@pbrocks
pbrocks / pmpro-pbrx-custom-email-templates.php
Last active February 7, 2017 18:58
Attempt to remove and replace custom email templates for PMPro
/**
* Drop into PMPro Customizations file /pmpro-customizations/pmpro-customizations.php
* Copy emailtemplates.php from /pmpro-email-templates/adminpages/ to /pmpro-customizations/
*/
add_action( 'admin_init', 'remove_original_admin_menu', 0 );
function remove_original_admin_menu() {
remove_submenu_page( 'pmpro-membershiplevels', 'pmpro-email-templates' );
}
@pbrocks
pbrocks / pmpro-pbrx-register-helper-sample-fields.php
Last active March 1, 2017 15:51
Sample code to add to PMPro Customizations plugin designed to illustrate fields added with Register Helper plugin
<?php
/**
* Sample code to add to PMPro Customizations plugin designed to illustrate fields added with Register Helper plugin
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
function pbrx_pmprorh_init() {
//don't break if Register Helper is not loaded
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
@pbrocks
pbrocks / pmpro-pbrx-diagnostic.php
Last active March 2, 2017 18:10
PMPro Diagnostic
add_action( 'wp_head', 'pbrx_temp_css' );
function pbrx_temp_css() {
?>
<style>
.head-diagnostic {
text-align: center;
}
.positive {
color: green;
@pbrocks
pbrocks / a.md
Created August 21, 2017 19:46 — forked from ericandrewlewis/a.md
The WordPress Customizer

The WordPress Customizer

The WordPress Customizer is an interface for drafting changes to content while previewing the changes before they are saved. This is an alternative to the "save and suprise" model of changing settings without knowing what exactly will happen.

The customizer can be accessed in the admin interface under Appearance > Customize.

A screenshot of the customizer

#19909 is the trac ticket that introduced the Customizer during the 3.4 release cycle.

@pbrocks
pbrocks / wp-print-hooks.php
Created August 23, 2017 14:04 — forked from arioch1984/wp-print-hooks.php
Wordpress: Print hooks
<?php
/*
Plugin Name: Instrument Hooks for WordPress
Description: Instruments Hooks for a Page. Outputs during the Shutdown Hook.
Version: 0.1
Author: Mike Schinkel
Author URI: http://mikeschinkel.com
*/
if ($_GET['instrument']=='hooks') {
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@pbrocks
pbrocks / hide-toolbar-non-manager.php
Created August 30, 2017 23:18
Hide the WordPress Toolbar for non-admins and non-Membership Managers
<?php
/**
* Plugin Name: PMPro Customizations
*/
add_action( 'init', 'disable_toolbar_on_frontend', 9 );
function disable_toolbar_on_frontend() {
if ( ! current_user_can( 'pmpro_membership_manager' )
&& ! current_user_can( 'administrator' ) ) {
add_action( 'admin_enqueue_scripts', 'hide_toolbar_in_edit_user_settings' );