So now we need to write the PHP file that does all the hard work for this plugin and implements the functionality that we are trying to achieve. In your plg_content_clicktocall
folder, create the file clicktocall.php
with the following code:
<?php defined('_JEXEC') or die; jimport('joomla.plugin.plugin'); class plgContentClicktocall extends JPlugin { function plgContentClicktocall( &$subject, $params ) { parent::__construct( $subject, $params ); } public function onContentPrepare($context, &$row, &$params, $page = 0) { // Do not run this plugin when the content is being indexed if ($context == 'com_finder.indexer') { return true; } if (is_object($row)) { return $this->clickToCall($row->text, $params); } return $this->clickToCall($row, $params); } protected function clickToCall(&$text, &$params) { // matches 4 numbers followed by an optional hyphen or space...