MyBB Community Forums

Full Version: Disable/Edit MyCodes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to disable/edit the default MyCodes?
e.g [img], [b], [list], [code]
You can create your own MyCodes, overwriting the default ones. The replacement will be the mycode it self:

Regular Expression:
\[img\](.*?)\[\/img\]

Replacement:
[img]$1[/img]

That should do it.
Yes I thought that, but I wanted to know if there was a file or something that had all the default ones in it...
Right, maybe a core edit suits it better, open ./inc/class_parser.php, find:
		$standard_mycode['b']['regex'] = "#\[b\](.*?)\[/b\]#si";
        $standard_mycode['b']['replacement'] = "<span style=\"font-weight: bold;\">$1</span>";

        $standard_mycode['u']['regex'] = "#\[u\](.*?)\[/u\]#si";
        $standard_mycode['u']['replacement'] = "<span style=\"text-decoration: underline;\">$1</span>";

        $standard_mycode['i']['regex'] = "#\[i\](.*?)\[/i\]#si";
        $standard_mycode['i']['replacement'] = "<span style=\"font-style: italic;\">$1</span>";

		$standard_mycode['s']['regex'] = "#\[s\](.*?)\[/s\]#si";
		$standard_mycode['s']['replacement'] = "<del>$1</del>";

		$standard_mycode['copy']['regex'] = "#\(c\)#i";
		$standard_mycode['copy']['replacement'] = "&copy;";

		$standard_mycode['tm']['regex'] = "#\(tm\)#i";
		$standard_mycode['tm']['replacement'] = "™";

		$standard_mycode['reg']['regex'] = "#\(r\)#i";
		$standard_mycode['reg']['replacement'] = "&reg;";

		$standard_mycode['url_simple']['regex'] = "#\[url\]([a-z]+?://)([^\r\n\"<]+?)\[/url\]#sei";
		$standard_mycode['url_simple']['replacement'] = "\$this->mycode_parse_url(\"$1$2\")";

		$standard_mycode['url_simple2']['regex'] = "#\[url\]([^\r\n\"<]+?)\[/url\]#ei";
		$standard_mycode['url_simple2']['replacement'] = "\$this->mycode_parse_url(\"$1\")";

		$standard_mycode['url_complex']['regex'] = "#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#esi";
		$standard_mycode['url_complex']['replacement'] = "\$this->mycode_parse_url(\"$1$2\", \"$3\")";

		$standard_mycode['url_complex2']['regex'] = "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#esi";
		$standard_mycode['url_complex2']['replacement'] = "\$this->mycode_parse_url(\"$1\", \"$2\")";

		$standard_mycode['email_simple']['regex'] = "#\[email\](.*?)\[/email\]#ei";
		$standard_mycode['email_simple']['replacement'] = "\$this->mycode_parse_email(\"$1\")";

		$standard_mycode['email_complex']['regex'] = "#\[email=(.*?)\](.*?)\[/email\]#ei";
		$standard_mycode['email_complex']['replacement'] = "\$this->mycode_parse_email(\"$1\", \"$2\")";
		
		$standard_mycode['hr']['regex'] = "#\[hr\]#si";
		$standard_mycode['hr']['replacement'] = "<hr />";

		$nestable_mycode['color']['regex'] = "#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#si";
		$nestable_mycode['color']['replacement'] = "<span style=\"color: $1;\">$2</span>";

		$nestable_mycode['size']['regex'] = "#\[size=(xx-small|x-small|small|medium|large|x-large|xx-large)\](.*?)\[/size\]#si";
        $nestable_mycode['size']['replacement'] = "<span style=\"font-size: $1;\">$2</span>";

        $nestable_mycode['size_int']['regex'] = "#\[size=([0-9\+\-]+?)\](.*?)\[/size\]#esi";
        $nestable_mycode['size_int']['replacement'] = "\$this->mycode_handle_size(\"$1\", \"$2\")";

        $nestable_mycode['font']['regex'] = "#\[font=([a-z ]+?)\](.+?)\[/font\]#si";
        $nestable_mycode['font']['replacement'] = "<span style=\"font-family: $1;\">$2</span>";

        $nestable_mycode['align']['regex'] = "#\[align=(left|center|right|justify)\](.*?)\[/align\]#si";
        $nestable_mycode['align']['replacement'] = "<div style=\"text-align: $1;\">$2</div>";

Remove the ones you don't want or create new mycodes for them. There may be some issues if you choose to remove them all.
Thank you very much