Shortcode within Plugins

Ive been working on this for a few hours and I cant seem to get any shortcodes to work in an admin panel plugin I have made.

  • yes, I have made sure “run in admin” is enabled in the shortcode plugin panel
  • I have checked their ‘extension php code’ to show how to use it in shortcode extenstion plugins (but mine is not an extension plugin, I just need shortcodes to work).
  • Ive tried a few manual things in php to execute shortcodes with no luck.
    My current guess is that I need to register shortcode with the pages I am using in my plugin (I thought this might be done when running twig).

Any ideas/help would be greatly appreciated.

Screenshot of what happens:

Ok. I have shortcodes and SQLite shortcode extension now running. But the output is injected directly into the page. This seems like it would be easy to fix, but again, Im a little puzzled.

I’ll put up a description of what I had to do to get this working soon.

Finally sorted it all out. Not sure if there are better ways to do this but, here goes.

Im using Shorcode-core + SQLite and deps to display a table of my project information into the admin so I can apply admin changes from the admin panel. This will make changing sqlitedb records easier and safer.

I had to remove the admin restrictions in the SQLite.php file:

if ($this->isAdmin()) {
$this->active = false;
return;
}
There are two instances of this. I may add a flag so only my plugin is allowed in the admin to do this.

Then I added my plugin and a simple SQLite shortcode to the admin.html.twig file for my tables:

{% block content %}
  <h1>{{ page.title }}</h1>
  <h1>Scenes</h1>
  <div id='scenetableoutput'>
  {% set modelq = "[sql-table]select name, sceneid, projectid, environment, models from scenes[/sql-table]" %}
  {% set modelres = (modelq|shortcodes) %}
  {{ modelres }}
  </div>
<script>
$(window).load(function() {
  var text = $('#scenetableoutput').text();
  $('#scenetableoutput').html(text.slice(1, -1));
});
</script>
{% endblock %}

The reason I had to do this was because when using the {{ modelres }} call, the admin renderer wraps it in " ".

And now its looking quite good. Still some edit forms and buttons to add, but its getting there.