Skip to content

Commit bf6368c

Browse files
committed
Merge branch 'release/5.1.3'
2 parents 6c6a8d9 + 02083ef commit bf6368c

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v5.1.3
2+
## 06/01/2022
3+
4+
1. [](#improved)
5+
* Added a new `display` CLI command to show all registered shortcodes
6+
17
# v5.1.2
28
## 05/10/2022
39

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,11 @@ $this->shortcode->getRawHandlers()->add('prism', function(ProcessedShortcode $sc
565565
```
566566

567567
The difference here is it uses `getRawHandlers()` to ensure the handler is processed to the content in the _raw_ state.
568+
569+
## Display All Shortcodes
570+
571+
You can now display all available shortcodes by using the CLI command:
572+
573+
```shell
574+
bin/plugin shortcode-core display
575+
```

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Shortcode Core
22
slug: shortcode-core
33
type: plugin
4-
version: 5.1.2
4+
version: 5.1.3
55
description: "This plugin provides the core functionality for shortcode plugins"
66
icon: code
77
author:

cli/ShortcodesCommand.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
namespace Grav\Plugin\Console;
3+
4+
use Grav\Common\Grav;
5+
use Grav\Common\Twig\Twig;
6+
use Grav\Console\ConsoleCommand;
7+
use Grav\Plugin\CloudflarePlugin;
8+
use Symfony\Component\Console\Helper\ProgressBar;
9+
use Symfony\Component\Console\Helper\Table;
10+
use Symfony\Component\Console\Input\InputOption;
11+
use Symfony\Component\Console\Style\SymfonyStyle;
12+
13+
/**
14+
* Class CloudflareIPsCommand
15+
*
16+
* @package Grav\Plugin\Console
17+
*/
18+
class ShortcodesCommand extends ConsoleCommand
19+
{
20+
21+
/**
22+
*
23+
*/
24+
protected function configure()
25+
{
26+
$this
27+
->setName('display')
28+
->setDescription('Display a list the available shortcodes that are registered');
29+
}
30+
31+
/**
32+
* @return int|null|void
33+
*/
34+
protected function serve()
35+
{
36+
$io = new SymfonyStyle($this->input, $this->output);
37+
$this->initializePlugins();
38+
$this->initializeThemes();
39+
40+
$shortcodes = Grav::instance()['shortcode'];
41+
42+
$io->title('Available Shortcodes');
43+
$io->section('Regular Handlers:');
44+
foreach ($shortcodes->getHandlers()->getNames() as $name) {
45+
$io->writeln($name);
46+
}
47+
$io->section('Raw Handlers:');
48+
foreach ($shortcodes->getRawHandlers()->getNames() as $name) {
49+
$io->writeln($name);
50+
}
51+
52+
$io->newLine();
53+
54+
}
55+
}

0 commit comments

Comments
 (0)