I tried everything I could (yes, searching with google for a long time too) but I can't find what I am doing wrong here. I am trying to write Joomla plugin to change shortcode into list od adverts on OtoMoto.pl. But I am stuck on changing shortcode to any text. For some reason joomla don't even trigger my code in function. Could anyone help me with that? I am using Joomla 3.9.23 Stable, PHP 7.4.10 and below is my code:
otomoto.php:
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
class plgContentOtoMotoShortcode extends JPlugin
{
protected $autoloadLanguage = true;
function onContentPrepare($context, &$article, &$params, $limitstart = 0)
{
var_dump($article);
$list_of_adverts = "Temporary";
$text = str_replace('[otomoto]', $list_of_adverts, $article->text);
$article->text = $text;
return true;
}
}
otomoto.xml
<?xml version="1.0" encoding="utf-8" ?>
<extension version="3.2" type="plugin" group="content" method="upgrade">
<name>otomoto</name>
<author>Futuristic Tomasz Burzyński</author>
<creationDate>November 2020</creationDate>
<copyright>Copyright (C) 2020</copyright>
<license>Private, if you get this code for free you probably have it illegaly</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://futuristic.com.pl</authorUrl>
<version>0.0.2</version>
<description>Shortcode for OtoMoto adverts list</description>
<files>
<filename plugin="otomoto">otomoto.php</filename>
<filename>index.html</filename>
</files>
<config>
</config>
</extension>
Instalation of plugin went without problems so I really have no idea what is going wrong. I will add one more thing: I checked, plugin code is loaded on site, but its event just doesn`t work. I will be gratefull for any tip what's wrong with that code.