Skip to content

Searches a string for Wordpress shortcodes and calls a mapped function with the attributes as parameters. Return values replace the shortcode in the string.

License

Notifications You must be signed in to change notification settings

websterman/wordpress-shortcode-functions-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

wordpress-shortcode-functions-js

Searches a string for Wordpress shortcodes and calls a mapped function with the attributes as parameters. Return values replace the shortcode in the string.

Usage: WPShortcodes( string, functionMap );

Returns an object with the following structure:

{ markup: The returned markup shortcodes : [ {
code: The shortcode name, raw: The entire shortcode, attributes: [ { name: The name of the attribute. value: The value of the attribute. } ]
} ] }

The functionMap object should be sorted as such:

{ 'exampleShortcode': exampleShortcodeFunction }

Where the value is a valid function. The shortcode attributes will be passed to the function as an object with the following structure:

{ name: Attribute name, value: Attribute value }

About

Searches a string for Wordpress shortcodes and calls a mapped function with the attributes as parameters. Return values replace the shortcode in the string.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published