Three ideas:
1. The way you’re referencing the method to handle the shortcode it needs to be “static”
public static function rsconf_schedule_shortcode( $attrs ) {
error_log( __CLASS__ . '::' . __FUNCTION__ );
return '<h2>Here</h2>';
}
2. Or if the add_shortcode part and the function rsconf_schedule_shortcode are defined within the same class you could make an internal reference.
add_shortcode( 'rsconf_schedule', array( $this, 'rsconf_schedule_shortcode' ) );
Then the method wouldn’t have to be static.
3. Are you sure the first code block even runs? If not, why not add the “add_shortcode(…)” to the constructor?
A 4th idea would be to pass the object instead of the class (name) like
add_shortcode( 'rsconf_schedule', array( $rsconf, 'rsconf_schedule_shortcode' ) );
Thanks for the input Chris. Alas, these sugggestions seem not to have the desired effect.
I have discovered that there seems to be an issue using shortcodes with multisite with subdirectoriies(?) I am able to get a shortcode to render if it is in a plugin activated on the base blog (blog 1). It seems that shortcodes will not work from subdirectory-activated plugins. This is really puzzling. I can’t imagine this is true for everyone. There would be a mass developer outcry against such restrictions.
Here is a restatement of my code in case something jumps out at someone.
if( ! class_exists('RSConferenceDisplay')) :
include_once( ABSPATH.'wp-includes/pluggable.php');
include_once( ABSPATH.'wp-includes/shortcodes.php');
class RSConferenceDisplay {
function __construct() {
add_action( 'init', array( &$this, '_init' ) );
add_shortcode('rsconf_regform',array( &$this, 'rsconf_registration_form' ));
}
function _init() {
error_log( __CLASS__.'::'.__FUNCTION__ );
}
public function rsconf_registration_form() {
error_log( __CLASS__.'::'.__FUNCTION__ );
$out = array( '<div class="rsc_registration">');
$out[] = '<h1>Shortcode</h1>';
$out[] = '</div><!-- .rsc_registration -->';
return implode("\n",$out);
}
}
if( ! isset( $rsdisplay )) {
global $rsdisplay;
$rsdisplay = new RSConferenceDisplay();
}
endif;
I see the _init method firing when the plugin loads, but the shortcode does not get replaced in the page which calls it.
Solved it. The theme file was calling get_the_content() instead of using the_content().
See also this WordPress Answers article: http://wordpress.stackexchange.com/questions/22482/loop-on-page-makes-shortcode-fail