Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Shortcode arguments not parsed

Solved by Brice Boucard View solution

Started by Brice Boucard 4 years ago · 6 replies · 585 views
4 years ago

Hi,

I'm trying to add a shortcode to my GIS plugin but I'm facing the same issue as this one : https://github.com/getgrav/grav-plugin-shortcode-core/issues/24

In my case, it's not because of the Smartypants plugin but because of my Better Typography plugin.

Using the Regex setting in Shortcode Core solves the issue... But instead of using

PHP
$this->grav['config']->set('plugins.shortcode-core.parser', 'regex');

I'd prefer solves the issue within the Better Typography plugin. I suspect it's because I call onPageContentProcessed (https://git.reclic.dev/bricebou/grav-plugin-better-typography/src/branch/main/better-typography.php#L61) and it happens before the Shortcode Core : https://github.com/getgrav/grav-plugin-shortcode-core/blob/develop/shortcode-core.php#L64

So, I just need to change the priority like this ?

PHP
'onPageContentProcessed' => ['onPageContentProcessed', -20],

Thanks !

[EDIT]Changing the priority doesn't seem to work, BetterTypography is applied before ShortcodeCore[/EDIT]

last edited 04/24/22 by Brice Boucard
4 years ago

You need to define it in plugin blueprint
https://learn.getgrav.org/16/advanced/plugin-prioritization

Edit: Hmm.. It looks like it's a separate priorities.yaml 🤔 Actually not sure how to define it from the plugin side, so maybe your approach is the way

Edit2: That page says priorities are defined in onPluginsInitialized(), but can't see it in the docs, so checked shortcode-core and it has priority of 10

TXT
['onPluginsInitialized', 10]

So yours should be < 10

last edited 04/25/22 by Karmalakas
4 years ago Solution

It seems I had a cache issue or something like that... It seems to work now, using

PHP
['onPluginsInitialized', 0]

and then

PHP
'onPageContentProcessed' => ['onPageContentProcessed', -20],

Sorry for the noise ! I'll come back later if the problem reappears.

4 years ago

@bricebou,

  • What behaviour of the shortcode tells you you have a problem?
    What happened and what did you expect to happen?
  • What made you conclude that 'onPageContentProcessed' => ['onPageContentProcessed', -20], solved the issue?
  • The following doesn't make sense to me:

    But instead of using
    $this->grav['config']->set('plugins.shortcode-core.parser', 'regex');
    I’d prefer solves the issue within the Better Typography plugin.

    "Instead of using [code snippet]"
    So you don't want to use the [code snippet]? But that is the proposed solution in the Github issue, isn't it?

    "I’d prefer solves the issue within the Better Typography plugin."
    Doesn't the [code snippet run inside your plugin?
    What other solution would you prefer?

4 years ago

Hi @pamtbaau !

  1. I spotted the issue while adding parameters to the shortcode : [gis /] was well parsed while [gis height=320 /] wasn't and appeared as if, as content.
    If I had quotes in my shortcode arguments ([gis id="test d'id" /]), they were modified into french quotes...
    That's what guided me into considering that the BetterTypography parses markdown content before the Shortcore Core plugin.

  2. Modifying the priority of the onPageContentProcessed appears to solve the issue : quotes are no more modified into french quotes, and shortcodes are well parsed.

  3. i don't see why a plugin should modify the settings of another one ; what if another plugin doesn't need the same setting ? And, deep down, the issue isn't one of the GIS plugin I've been working on but one of the BetterTypography in which content parsing should be applied after every other treatments.

4 years ago

@bricebou, Ah, that added the context and clarity I needed... Yes I know, I'm just bad at mindreading and filling in the blanks.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 60 16 hours ago
Support · by Anna, 3 days ago
2 66 19 hours ago
Support · by Justin Young, 20 hours ago
1 34 20 hours ago
Support · by Duc , 1 week ago
2 70 6 days ago
Support · by Colin Hume, 1 week ago
2 61 6 days ago