Pages

Wednesday, December 6, 2017

Using wordpress shortcode system outside wordpress

In one of my projects I need a template variable mechanism something like Wordpress shortcode. The project was in custom build framework.

So I tried to extract the Wordpress shortcoding system out of it and use as a standalone library.


I used two functions for my work:
  • add_shortcode - for the parsing the template variable and
  • do_shortcode - to render the final output

I took my time to strip out the mechanism from workpress chasing the fatal errors and found the below 4 (Four) files are mandatory for the purpose. I included all the four the shortcode worked!

All the files resides in wp-includes/ directory of the Wordpress installation.

List of mandatory files are:
  • shortcodes.php
  • formatting.php
  • plugin.php
  • class-wp-hook.php

The Wordpress version was: 4.8.4

No comments :

Post a Comment