MyBB Community Forums

Full Version: [plugin] "noparse" tag
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I've just made a plugin for MyBB and want to share it with you all Smile

It's the noparse tag. It adds a tag that allows to post MyCode tags without they being parsed (recognized) so you can teach other how to use MyCode, for example.

Read the readme.txt inside the zip for more details.

choli Wink
Will this work for smiley's as well?

for example [noparse]:wink:[/noparse]
Thank you =) I'm using it now.
There seems to be a problem while using this plugin on MyBB 1.01. When you don't edit functions_post.php, the first four characters of signatures get lost. You should add something in your plugin_activate function so that functions_post gets edited automatically on activation and on deactivation.
I tried this and it works:
function noparse_activate () {
	//EDIT FILES
	$fh = fopen('./inc/functions_post.php', "r") or cperror("Could not open file!"); //OPEN FILE
	$data = fread($fh, filesize('./inc/functions_post.php')) or cperror("Could not read file!"); //MAKE TEMPORARY STRING
	fclose($fh); //CLOSE FILE AGAIN
	$newdata = preg_replace('#if\(\$allowsmilies != "no"\)#','$message = $plugins->run_hooks("pre_parse_message", $message);
if($allowsmilies != "no")',$data); //REPLACE IN STRING
	$fw = fopen('./inc/functions_post.php', "w") or cperror('Could not open file!'); //OPEN FILE AGAIN
	$fb = fwrite($fw, $newdata) or cperror('Could not write to file'); //WRITE STRING TO FILE
	fclose($fw); //CLOSE FILE AGAIN
}

function noparse_deactivate () {
	//EDIT FILES
	$fh = fopen('./inc/functions_post.php', "r") or cperror("Could not open file!"); //OPEN FILE
	$data = fread($fh, filesize('./inc/functions_post.php')) or cperror("Could not read file!"); //MAKE TEMPORARY STRING
	fclose($fh); //CLOSE FILE AGAIN
	$newdata = preg_replace('#\$message = \$plugins->run_hooks\("pre_parse_message", \$message\);
if\(\$allowsmilies != "no"\)#s','if($allowsmilies != "no")',$data); //REPLACE IN STRING
	$fw = fopen('./inc/functions_post.php', "w") or cperror('Could not open file!'); //OPEN FILE AGAIN
	$fb = fwrite($fw, $newdata) or cperror('Could not write to file'); //WRITE STRING TO FILE
	fclose($fw); //CLOSE FILE AGAIN
}
If you use this, don't forget to write in the readme file that users have to chmod their inc/functions_post.php to 755 or 777.