• Welcome to PHPVIBE Forums. Please log in.
avatar_Marius P.

How to write a plugin

Started by Marius P.,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Marius P.Topic starter

The PHPVibe plugin system is fairly simple to use and code for.
It relies on the hooks and filters present in PHPVibe (very similar to WordPress's system).

The plugin needs to have its own folder name and contain the file plugin.php, it needs to be activated through the 'Plugins' menu in the administration area.

A simple plugin example adding a message at the start of your homepage.

Create /plugins/hello/plugin.php

Top of the file (plugin details, commented):

<?php
/**
 * Plugin Name: Demo source
 * Plugin URI: http://phpvibe.com/
 * Description: Adds something new to PHPVibe
 * Version: 1.0
 * Author: PHPVibe Fan 
 * Author URI: http://www.phpvibe.com
 * License: GPL
 */

Create the function returning the message.
In the simplest form ever you can use the language system to modify and translate the message.

function HelloWorld(){
echo _lang("Welcome to my great website");
}
Now we hook the function to the 'home-start' action present on top of home.php

add_action('home-start', 'HelloWorld');
Sure, you can use very complex logic and code here and on all the other actions, this is just a very simple example.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  
    The following users thanked this post: fox_mulder

Similar topics (2)

Replies: 1
Views: 1482