PHP code example of underpin / shortcode-loader

1. Go to this page and download the library: Download underpin/shortcode-loader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

underpin / shortcode-loader example snippets


// Register shortcode
underpin()->shortcodes()->add( 'shortcode-key', [
	'shortcode'                  => 'custom-shortcode',              // Required. Shortcode name.
	'defaults'                   => [ 'foo' => 'bar' ],              // Default atts. See shortcode_atts
	'shortcode_actions_callback' => function ( $parsed_atts ) {      // Required. Shortcode action.
		return $parsed_atts['key']; // 'value'
	},

] );

// Shortcode output examples
do_shortcode( '[custom-shortcode foo="baz"]' ); // baz
do_shortcode( '[custom-shortcode]' ); // bar

underpin()->shortcodes()->add('shortcode-key','Namespace\To\Class');