2015-12-22, 05:41 AM
Making a plugin for a site and when I try to do the search and replace for activate/deactivate it completely screws over and doesn't work as it should.
The code is:
Outcome:
http://i.imgur.com/mFJoaeo.png
and on de-activate:
http://i.imgur.com/TdIzX4X.png
The code is:
function gradient_activate()
{
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("usercp_nav_misc", '#'.preg_quote('<tr><td class="trow1 smalltext"><a href="{$profile_link}" class="usercp_nav_item usercp_nav_viewprofile">{$lang->ucp_nav_view_profile}</a></td></tr>').'#', '<tr><td class="trow1 smalltext"><a href="{$profile_link}" class="usercp_nav_item usercp_nav_viewprofile">{$lang->ucp_nav_view_profile}</a></td></tr><tr><td class="trow1 smalltext"><a href="page.php" class="usercp_nav_item usercp_nav_usergroups">The link</a></td></tr>');
}
function gradient_deactivate()
{
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("usercp_nav_misc", '#'.preg_replace('<tr><td class="trow1 smalltext"><a href="{$profile_link}" class="usercp_nav_item usercp_nav_viewprofile">{$lang->ucp_nav_view_profile}</a></td></tr><tr><td class="trow1 smalltext"><a href="page.php" class="usercp_nav_item usercp_nav_usergroups">The link</a></td></tr>').'#','<tr><td class="trow1 smalltext"><a href="{$profile_link}" class="usercp_nav_item usercp_nav_viewprofile">{$lang->ucp_nav_view_profile}</a></td></tr>');
}
Outcome:
http://i.imgur.com/mFJoaeo.png
and on de-activate:
http://i.imgur.com/TdIzX4X.png