i have created this smarty plugin but i'm getting an error message whenever i try to use it.
<?php
function smarty_modifier_prepare_link( $string, $link_type = 'http' ) {
// use SSL
if ( $link_type == 'http' && USE_SSL = 'no' )
$link_type = 'http';
switch( $link_type ) {
case 'http' :
$link = 'http://' . getenv( 'SERVER_NAME' );
// If HTTP_SERVER_PORT is defined and different than default
if ( defined( 'HTTP_SERVER_PORT' ) && HTTP_SERVER_PORT != '80' ) { // Append server port
$link .= ':' . HTTP_SERVER_PORT;
}
$link .= VIRTUAL_LOCATION . $string;
return htmlspecialchars( $link, ENT_QUOTES ); // Escape html
case 'https':
$link = 'https://' . getenv( 'SERVER_NAME' ) . VIRTUAL_LOCATION . $string;
return htmlspecialchars( $link, ENT_QUOTES );
default:
return htmlspecialchars( $string, ENT_QUOTES ); // Escape html
}
}
i'm trying to use it in a smarty template which has this code.
<div id="header">
<a href="{"index.php"|prepare_link:"http"}">
<img src="images/title.png" alt="Site title" />
</a>
</div>
i'm getting an error that the modifier is unknown