Not much has changed from vBulletin 3.8 with respect to writing plugins. In order to write a plugin, we would ideally create a variable within the template and then create a new plugin from the AdminCP to set that variable using PHP. However, starting with vBulletin 4, all of the variables are referenced differently. For example, a custom variable that once would be called $HelloWorld would now be called {vb:raw HelloWorld} within the templates.

At the end of the plugin code, we also need to declare the template that this variable is being pushed to.
Code:
vB_Template::preRegister('Template_name',array('HelloWorld' => $HelloWorld));
Let's walk through the creation of a simple example plugin for vBulletin 4. We will be adding the text "Hello World" to the top of our forum.

Step 1
Add the variable {vb:raw HelloWorld} to the first line within the header template.

Step 2
Create a new plugin from admincp->Plugin & Products->Plugin Manager and scroll all the way down and click Add new Plugin.

Step 3
The following would be the information that you would place into the input fields for this new plugin.

Product: vBulletin
(or whatever product you want to assign this plugin to)

Hook Location: global_start
(To simplify things for this example, we use global_start rather than parse_templates)

Title: Hello

Execution Order: 5

Plugin PHP Code:
Code:
$HelloWorld = "Hello World";
vB_Template::preRegister('header',array('HelloWorld' => $HelloWorld));
Plugin is active: yes

Step 4
Save your plugin.

Now with all of the steps complete, you should be able to visit your forum and see the words "Hello World" printed at the top.