Plugin Use the good codename
#1
MyBB uses the plugin info "codename" to check plugins updates. This codename is set when creating a project on MyBB community.
   

The codename must match the plugin's filename without the .php extension, like abp_autodownpics if the plugin file is abp_autodownpics.php.

The simplest way to have the good and generic info, even if you change your filename, is to do:
PHP Code:
function yourplugin_info()
{
   return array(
      
/* ... */
      
'codename' => str_replace('.php'''basename(__FILE__))
   );


I like having the codename accessible for any function, so I create a constant to store the codename value. The constant must be unique it is a good idea to define some kind of rules, see below mine as an example.
  • CN_ (for CodeName)
  • ABP (for Another Bugged Plugin)
  • XXX are the plugin "human name" first letters

Examples : CN_ABPFP for Force Portal, CN_ABPLIC for [i]lightIRC Chat[/b], ...

To sumarize, given all the explanation detailed above, the plugin template would start as follow:
PHP Code:
<?php
/**
 * Description of the plugin
 * This one is "My Example Plugin"
 * Its file is myexample.php
 * By CrazyCat <http://ab-plugin.cc>
 */
if(!defined("IN_MYBB")) die("Direct initialization of this file is not allowed.<br />Please make sure IN_MYBB is defined.");

// Unique constant used as codename
define('CN_ABPMEP'str_replace('.php'''basename(__FILE__)));

function 
myexample_info()
{
   global 
$lang;
   
$lang->load(CN_ABPMEP);
   return array(
      
"name" => $lang->myexample_name,
      
"description" => $lang->myexample_desc,
      
"website" => "http://ab-plugin.cc/ABP-My-Example-Plugin-t-99.html",
      
"author"    => "CrazyCat",
      
"authorsite"    => "http://ab-plugin.cc",
      
"version"    => "1.0",
      
"compatibility" => "18*",
      
"codename"    => CN_ABPMEP
   
);
}

/* ... */ 

Please note that the constant is also used to load language files, so they have to be named myexample.lang.php. This rule is a precept of MyBB developper guide.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)