Example Plugin

From CashCrusaderWiki

(Difference between revisions)
Jump to: navigation, search
m (Optimization tips)
m (tweaking)
Line 43: Line 43:
}
}
-
function yourownpublicfunction()
+
function yourownpublicfunction()
{
{
//another public page function <?php plugin('yourpluginclass', 'yourownpublicfunction'); //this would be in /pages/somefile.php ?>
//another public page function <?php plugin('yourpluginclass', 'yourownpublicfunction'); //this would be in /pages/somefile.php ?>
Line 50: Line 50:
}
}
-
function yourownadminfunction()
+
function yourownadminfunction()
{
{
//another admin page function
//another admin page function

Revision as of 19:50, 30 January 2012

The most simple plugin example:

/public_html/scripts/plugins/yourpluginfolder/plugin.php

<?php
$plugins[]=array("name"=>"YourPlugin name", "classname"=>"yourpluginclass");

class yourpluginclass extends plugin_base
{
	var $class_name = 'yourpluginclass';
	var $file_name = 'yourpluginfolder/plugin.php';
	var $author = 'You';
	var $web = 'http://yourwebsite.com';
	var $name = 'YourPlugin name';
	var $date = 'Apr-17-2009 (v0.6.1)';

        // If your plugin does not use cronjobs, do not include cron_job function to your plugin.php
	function cron_job()//<-- scheduled tasks etc
	{
              //Hint: put script in external file and include() it like below
              //include('mycron.php'); //would include file /public_html/scripts/plugins/yourpluginfolder/mycron.php
		return 1; 
	}

	function admin_page()//<-- default admin area page of your plugin
	{
              //This function is loaded after clicking 'YourPlugin name' link on plugins list
              //Direct link: http://domain/scripts/admin/pload.php?p_load=yourpluginclass
		return 1;
	}
	
	function public_page()//<-- default public page
	{
              //like <?php plugin('yourpluginclass'); //this would be in /pages/somefile.php ?>
		return 1;
	}

        // If your plugin does not use runner, do not include runner function to your plugin.php
        function runner()//<-- called at start up time of runner.php, like when user clicks a link or banner
	{
		return 1;
 	}

        function yourownpublicfunction()
	{
              //another public page function <?php plugin('yourpluginclass', 'yourownpublicfunction'); //this would be in /pages/somefile.php ?>
              //you can have many own functions
		return 1;
 	}

        function yourownadminfunction()
	{
              //another admin page function
              //Link to this function: http://domain/scripts/admin/pload.php?p_load=yourpluginclass&function=yourownadminfunction
              // p_load and function can be POSTed or via GET like above
		return 1;
 	}


}
?>
Personal tools
Administration manual