| Current Path : /home/jeromecohp/www/plugins/emailbeautifier/tagreplacements/ |
| Current File : /home/jeromecohp/www/plugins/emailbeautifier/tagreplacements/tagreplacements.php |
<?php
/**
* @package EmailBeautifier
* @subpackage Emailbeautifier.tagreplacements
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// No direct access.
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
/**
* Plugin eb tags class
*
* @package EmailBeautifer
* @subpackage com_emailbeautifier
* @since 2.1.0
*/
class PlgEmailbeautifierTagreplacements extends CMSPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 2.1.0
*/
protected $autoloadLanguage = true;
/**
* Function to add more tags in tempelate
*
* @return array
*/
public function onDisplayReplacementTags()
{
$name = array (
array("NAME", Text::_('PLG_EMAILBEAUTIFIER_TAGREPLACEMENTS_NAME')),
array("USERNAME", Text::_('PLG_EMAILBEAUTIFIER_TAGREPLACEMENTS_USERNAME')),
array("EMAIL", Text::_('PLG_EMAILBEAUTIFIER_TAGREPLACEMENTS_EMAIL'))
);
return $name;
}
/**
* Function to add tags value in email subject
*
* @param array &$subject Array of emails
* @param string $email email
* @param integer $userid integer
*
* @return null
*/
public function onPrepareEmailSubject(&$subject, $email, $userid)
{
$user = Factory::getUser($userid);
$name = array('[NAME]', '[USERNAME]', '[EMAIL]');
$replace = array($user->name, $user->username, $user->email);
$subject = str_replace($name, $replace, $subject);
}
/**
* Function to add tags value in email body
*
* @param array &$body Array of emails
* @param string $email email
* @param integer $userid integer
*
* @return null
*/
public function onPrepareEmailBody(&$body, $email, $userid)
{
$user = Factory::getUser($userid);
$name = array('[NAME]', '[USERNAME]', '[EMAIL]');
$replace = array($user->name, $user->username, $user->email);
$body = str_replace($name, $replace, $body);
}
}