31/03/2015 - Shortcode system.

Posts

I've integrated WordPress's shortcode system with MyBB.

While this might not mean much to you, it means I can rapidly create bbcodes with far advanced functionality than the default system alone offers.

Here are some of the new "shortcodes" that are available to you:

[spoiler]
This is a basic spoiler without any options.
[/spoiler]

Which returns a basic spoiler (I'll be making it stay open on click tomorrow, just put this together quickly before bed).
This is a basic spoiler without any options.

You can also add a title to your spoiler, like this:

[spoiler title="My Spoiler"]
This is a spoiler with a title.
[/spoiler]

My Spoiler
This is a spoiler with a title.

There's even an option for a nsfw spoiler.

[spoiler mode="nsfw"]
mis's nudes go here
[/spoiler]

mis's nudes go here

And of course, you can give it a title:

[spoiler title="mis's nudes" mode="nsfw"]
mis's nudes go here
[/spoiler]

mis's nudes
mis's nudes go here

There's the username shortcode.

[username]

Which returns the logged in user's username: ([username])

The hide shortcode.

[hide]hidden content[/hide]

That hides text from guests.

And more to come!

ok
okay

can we make the spoilers onclick instead of onmouseover?

mumu wrote

ok
okay

can we make the spoilers onclick instead of onmouseover?

Senpai wrote

(I'll be making it stay open on click tomorrow, just put this together quickly before bed).

Senka wrote

my noods

I know, old joke. but i never got to participate ;_;



your noods are hot

[username] spooky magic

hahaha guest plebs cant see this

how exactly does [ username ] work

mumu wrote

[username] spooky magic

[hide]hahaha guest plebs cant see this[/hide]

[spoiler]how exactly does [ username ] work[/spoiler]

This is the code for it. :^)
[php]
function shortcode_username($params, $content) {
global $mybb;

if ($content) { // this does not require any content.
	return false;
}

if($mybb->user['uid']) {
	return $mybb->user['username'];
} else {
	return "future member";
}

}

Shortcodes::add("username", "shortcode_username");
[/php]

I'll likely release the shortcodes plugin for free.

EDIT, btw, you can escape the shortcodes by wrapping them in brackets: [[username]]

[[username]]

senpai a bulli, never gib permission to share those

What if we want to give nsfw spoilers a title?

mis wrote

senpai a bulli, never gib permission to share those

What if we want to give nsfw spoilers a title?

You can.

mis ily
pls marry me mis :heart:

@"Senpai" @"mumu" today i learned that the whole forum doesn't talk about me 🙁(

Do you love me [username] ?

jokatk wrote

@"Senpai" @"mumu" today i learned that the whole forum doesn't talk about me 🙁(

Do you love me [username] ?

Maybe you should join the Slack :^)