Skip to content

Instantly share code, notes, and snippets.

@xnau
Last active September 3, 2020 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xnau/d93c36ceb9efd36ddfece57504641a62 to your computer and use it in GitHub Desktop.
Save xnau/d93c36ceb9efd36ddfece57504641a62 to your computer and use it in GitHub Desktop.
Shows how to set up a custom "shortcode present" notification for Participants Database
<?php
/*
* Plugin Name: PDb Shortcode Placement Notification
* Description: Tells the Participants Database plugin that a shortcode is present on the page.
*/
add_filter( 'pdb-shortcode_in_content', 'xnau_notify_shortcode_present', 10, 2 );
/**
* tells the plugin that a shortcode is present
*
* @param bool $present
* @param WP_Post $post
*/
function xnau_notify_shortcode_present( $present, $post )
{
// this is a list of all the pages that have PDB shortcodes
// you must edit this in order for it to work for you
// this must be the page's "slug name"
$pages = array( 'test-page' );
if ( in_array( $post->post_name, $pages ) ) {
$present = true;
}
return $present;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment