Add the below function in /includes/class-plugin-loader.php
:
public function add_shortcode( $tag, $component, $callback, $priority = 10, $accepted_args = 2 ) {
$this->shortcodes = $this->add( $this->shortcodes, $tag, $component, $callback, $priority, $accepted_args );
}
You can then define your shortcode in /includes/class-plugin.php
within this function:
/**
* Register all of the hooks related to the public-facing functionality
* of the plugin.
*
* @since 1.0.0
* @access private
*/
private function define_public_hooks() {
$plugin_public = new Plugin_Public( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
$this->loader->add_shortcode( 'YOUR-SHORTCODE-NAME', $plugin_public, 'YOUR_CALLBACK_FUNCTION' );
}
Finally add your callback function in the /public/class-plugin-public.php
like this:
public function YOUR_CALLBACK_FUNCTION( $atts ){
// do your shortcode stuff
}
Change plugin
in the filenames above with your own plugin name.