Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / paulund-wp-list-table.php
Last active August 24, 2016 12:43 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class.With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area created by Paul Underwood and edited by @palibaacsi according to WP VIP Standards
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood and @palibaacsi
* Author URI: http://www.paulund.co.uk
* Version: 1.2
* License: GPL2
*/
@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' );
@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 / Sublime-stuffs.txt
Created April 1, 2017 19:53 — forked from vishalbasnet23/Sublime-stuffs.txt
Install PHPCS with WordPress Coding Standard with Sublime Text 3
1. cmd+shift+p
2. Type phpcs and install it
3. Preferences > Package Settings > Php Code Sniffer > User settings
@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