register_shortcode_to_function( $shortcode_name, 'handle_shortcode' ); } /** * Register shortcode to function * * @param mixed $shortcode_name either string name of the shortcode * (as it would appear in a post, e.g. [shortcodeName]) * or an array of such names in case you want to have more than one name * for the same shortcode. * @param string $function_name name of public function in this class to call as the * shortcode handler. * @return void */ protected function register_shortcode_to_function( $shortcode_name, $function_name ) { if ( is_array( $shortcode_name ) ) { foreach ( $shortcode_name as $a_name ) { add_shortcode( $a_name, array( $this, $function_name ) ); } } else { add_shortcode( $shortcode_name, array( $this, $function_name ) ); } } /** * Handle Shortcode * * @abstract Override this function and add actual shortcode handling here * @param shortcode $atts inputs. * @return shortcode string content. */ public abstract function handle_shortcode( $atts ); }