Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliot-akira/local-shortcodes
https://github.com/eliot-akira/local-shortcodes
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/eliot-akira/local-shortcodes
- Owner: eliot-akira
- Created: 2014-12-22T18:39:15.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-05T10:50:52.000Z (over 9 years ago)
- Last Synced: 2023-02-26T05:09:07.670Z (over 1 year ago)
- Language: PHP
- Size: 123 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Local shortcodes
Register and run shortcodes within a local namespace.
This avoids competing with shortcode names used by other themes and plugins.
## Usage
###### Register
Declare your chosen namespace, local shortcode name and function.
```
add_local_shortcode('context', 'local', 'local_shortcode');
```###### Run
Run local shortcodes registered under the namespace.
```
do_local_shortcode('context', $content);
```###### Run global shortcodes also
```
do_local_shortcode('context', $content, true);
```###### Unregister
Unregister a local shortcode within the given namespace.
```
remove_local_shortcode('context', 'local');
```###### Unregister all within context
Unregister all local shortcodes within the given namespace.
```
remove_all_local_shortcodes('context');
```
## Example
###### Inside post```
[parent][child]
[/parent]
```###### Inside parent shortcode
```
// Register parent shortcode in global namespace
add_shortcode('parent', 'parent_shortcode');// Register child shortcode in local namespace
add_local_shortcode('parent', 'child', 'child_shortcode');function parent_shortcode( $atts, $content ) {
...Do stuff here..
return do_local_shortcode('parent', $content);
}function child_shortcode( $atts, $content ) {
...Do stuff here..
}
```