Skip to content

Instantly share code, notes, and snippets.

View xnau's full-sized avatar

Roland Barker xnau

View GitHub Profile
@xnau
xnau / pdb-single-bootstrap-tabs.php
Created February 28, 2018 18:08
Participants Database responsive single record template with tabs support
<?php
/**
* @name pdb single template bootstrap
* @version 2.1
*
* default template for displaying a single record for the twitter bootstrap framework
*
* http://twitter.github.com/bootstrap/
*
*/
@xnau
xnau / pdb_admin_capabilities.php
Last active March 2, 2018 07:30
Shows how to set up the use of custom admin capabilities for Participants Database
<?php
/*
Plugin Name: PDb Custom Admin Capabilities
Description: Sets up the use of custom admin capabilities for Participants Database
*/
add_filter( 'pdb-access_capability', 'xnau_setup_admin_capabilities', 10, 2 );
/**
* sets the custom capabilities for use with the plugin
*
* @param string $capability the default capability for the role
<?php
/*
*
* template for participants list single record output
*
* use this template with a shortcode like this: [pdb_list template=single]
* if you want to show the search control, use this:
* [pdb_list search=true template=single]
*
*/
@xnau
xnau / set-email-recipient.php
Created March 8, 2018 18:43
Shows how to replace the recipient value in the "to" field of a Participants Database email template.
<?php
add_filter( 'pdbcptet-recipient_tags', 'xnau_filter_recipients' );
/**
* replaces the recipient identifier with the recipient's email address
*
* @param array $tag_list the tag replacement data
* @return array
*/
function xnau_filter_recipients( $tag_list )
{
@xnau
xnau / singlerecordlink_filter_example.php
Last active March 17, 2018 18:05
Shows how to place the single record link on multiple fields in a Participants Database list display
@xnau
xnau / pdb-bypass_text_filter.php
Created March 17, 2018 18:07
Shows how to bypass the HTML tag filters on a Participants Database text field
<?php
/**
* bypass HTML sanitizing on the "home_page" field
*
* @param string $text the sanitized text
* @param object $field the current field object
* @return string the display string
*/
function xnau_bypass_homepage_field_sanitize( $text, $field ) {
if ( $field->name === 'home_page' ) {
@xnau
xnau / pdb-comma-decimal-display.php
Created May 18, 2018 19:04
Demonstrates how to show decimal numbers using comma as the separator
<?php
/**
* Plugin Name: PDB Comma Decimal Separator Display
* Description: alters the display of decimal numbers to use comma as the decimal separator, and point as the thousands separator
*/
add_filter('pdb-before_display_form_element', 'xnau_show_comma_decimals', 10, 2 );
function xnau_show_comma_decimals( $display, $field )
{
// we are only modifying these form element types
if ( $field->form_element === 'decimal' || $field->form_element === 'currency' ) {
@xnau
xnau / pdb-limit-signups.php
Last active May 22, 2018 18:39
Shows how to limit the number of Participants Database signups
<?php
/**
* Plugin Name: PDB Limit Signups
* Description: Adds a count of the number of Participants Database signups, and prevents new signups
* once a number of registrations has been reached
*/
add_filter( 'pdb-signup_shortcode_output', 'xnau_limit_signups' );
/**
* adds a display of the number of signups and prevents signups once a limit is reached
*
@xnau
xnau / pdb-custom-link-recovery.php
Created May 28, 2018 21:32
Shows how to send a Participants Database private link by matching 2 or more fields
@xnau
xnau / pdb-prevent-php-clock-sync.php
Last active June 3, 2018 20:29
shows how to disable Participants Database synchronizing the php timezone with the WordPress timezone
<?php
/**
* Plugin Name: PDB Defeat Timezone Sync
* Description: disables Participants Database synchronizing the php timezone with the WordPress timezone
*/
add_filter( 'pdb-php_timezone_sync', function () { return false; } );