I've written a custom plugin, ta-intentclicks
which is used as a shortcode:
[ta-intentclicks count="3" category="SEC-EDR"...]
Within this shortcode I'd like to use another shortcode that I can use as a helper. For example; in one of the PHP templates within my plugin.
[ta-intentclicks-link url="$list_item['link']"]Visit website[/ta-intentclicks-link]
[ta-intentclicks-link url="$list_item['link']"]<img src="foo" />[/ta-intentclicks-link]
Which would output this:
<a href="<the URL>" rel="sponsored" target="_blank" class="icp-list-link">Visit website</a>
<a href="<the URL>" rel="sponsored" target="_blank" class="icp-list-link"><img src="foo" /></a>
Here's a quick directory snapshot to help illustrate my question.
The plugin entry point is includes/class-ta-intentclicks.php
which defines the shortcode and runs it, calling the Layout class along the way.
class TaIntentClicks {
function __construct() {
add_shortcode('ta-intentclicks', array($this, 'run'));
}
function run($attributes = []) {
... do some stuff
return $this->layout->render($response, $layoutAttributes, $dataAttributes);
}
}
class TAIntentClicksLayout {
function parse($stuff, $template) {
ob_start();
$output = '';
include $template;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
function render($response, $layoutAttributes, $dataAttributes) {
return $this->parse(
$response,
$layoutAttributes,
$this->getTemplate($layoutAttributes),
$dataAttributes
);
}
}
I've seen examples of people calling "do_shortcode" to execute a shortcode, but I'm unclear where the shortcode function goes in my case, OR where to place the "do_shortcode" call.
Can anyone offer guidance here? This is my first plugin and I'm a bit lost as to how and implement this functionality. Thanks in advance.