Skip to content

Commit 095c2a2

Browse files
committed
Merge branch 'release/4.1.5'
2 parents d0ae495 + 0c05a1d commit 095c2a2

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v4.1.5
2+
## 09/05/2019
3+
4+
1. [](#improved)
5+
* Run `onContentProcessed()` event after all other plugins [#75](https://github.com/getgrav/grav-plugin-shortcode-core/issues/75)
6+
17
# v4.1.4
28
## 08/11/2019
39

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,17 @@ You can now use shortcodes in Twig templates and process them with the `|shortco
422422
{{ twig_text|shortcodes }}
423423
```
424424

425-
## Developing Shortcode Plugins
425+
## Custom Shortcodes
426426

427-
The **Shortcode Core** plugin is developed on the back of the [Thunderer Advanced Shortcode Engine](https://github.com/thunderer/Shortcode) and as such loads the libraries and classes required to build third party shortcode plugins.
427+
### Simple Way
428+
429+
First, configure a directory from which custom shortcodes are loaded. Edit `user/config/plugins/shortcode-core.yaml` like follows (create it if it does not exist):
430+
431+
```yaml
432+
custom_shortcodes: '/user/custom/shortcodes'
433+
```
428434

429-
The simplest way to add your own custom shortcodes, it to simply create a new shortcode in a directory (e.g. `user/custom/shortcodes`) such as this simple one to allow for strike-through text:
435+
To add a custom shortcode, create a PHP file that defines a new shortcode class. For example, to create a shortcode for ~~strikethrough~~ text, save the following code as `user/custom/shortcodes/StrikeShortcode.php`:
430436

431437
```php
432438
<?php
@@ -445,13 +451,15 @@ class StrikeShortcode extends Shortcode
445451
}
446452
```
447453

448-
Then simply set the plugin to look in this directory for custom shortcodes by editing the `user/config/plugins/shortcode-core.yaml` file (create it if missing):
454+
Note that the class name (`StrikeShortcode`) must match the file name for the shortcode to work.
449455

450-
```yaml
451-
custom_shortcodes: '/user/custom/shortcodes'
452-
```
456+
`[strike]text[/strike]` should now produce strikethrough text.
453457

454-
The more flexible approach is to create a custom plugin to do provide a tidy package for your shotdcodes.
458+
### As a Custom Plugin
459+
460+
The more flexible approach is to create a custom plugin.
461+
462+
The **Shortcode Core** plugin is developed on the back of the [Thunderer Advanced Shortcode Engine](https://github.com/thunderer/Shortcode) and as such loads the libraries and classes required to build third party shortcode plugins.
455463

456464
We introduced a new event called `onShortcodeHandlers()` that allows a 3rd party plugin to create and add their own custom handlers. These are then all processed by the core plugin in one shot.
457465

@@ -524,4 +532,4 @@ However, there are situations when you need to process the shortcode **before**
524532
$this->shortcode->getRawHandlers()->add('prism', function(ProcessedShortcode $sc) { ... }
525533
```
526534

527-
The difference here is it uses `getRawHandlers()` to ensure the handler is processed to the content in the _raw_ state.
535+
The difference here is it uses `getRawHandlers()` to ensure the handler is processed to the content in the _raw_ state.

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Shortcode Core
2-
version: 4.1.4
2+
version: 4.1.5
33
description: "This plugin provides the core functionality for shortcode plugins"
44
icon: code
55
author:

shortcode-core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function onPluginsInitialized()
4646
'onMarkdownInitialized' => ['onMarkdownInitialized', 0],
4747
'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
4848
'onPageContentRaw' => ['onPageContentRaw', 0],
49-
'onPageContentProcessed' => ['onPageContentProcessed', 0],
49+
'onPageContentProcessed' => ['onPageContentProcessed', -10],
5050
'onPageContent' => ['onPageContent', 0],
5151
'onTwigInitialized' => ['onTwigInitialized', 0]
5252
]);

0 commit comments

Comments
 (0)