My First Plugin - ShowNewPoints
#1
Hello Friends,

i studied 4-5 days continuously on MyBB Plugins, how they works, how they can activated, deactivated, install, uninstall and all of things.

After Learning a basic of making plugin i successfully created a Plugin Called "ShowNewPoints".
It is a simple but powerful plugin as i think about that.. hehe  Big Grin

Requirements:- NewPoints Plugin installed

Working of This Plugin:- It will be displayed users newpoints on every page under the header bar.
In case of deactivating or uninstalling NewPoints plugin it will be Disabled automatically and it will be automatically Enabled as NewPoints Installed/Activated.

Features:- You can Change text before and after newpoints value. Currently this plugin has only this feature.

I am very happy i create a plugin.. File and screen shots is attached below...
Please take a look and tell me any bugs and errors.

Any reply,comment and feedback will be appreciate. Smile Rolleyes


Attached Files Thumbnail(s)
       

.php   ShowNewPoints.php (Size: 6.01 KB / Downloads: 101)
Reply
#2
  • $is_activated = $db->fetch_array($db->query("select `title` from ".TABLE_PREFIX."templates where `title`='newpoints_home'"));

    You should read the plugins cache instead, as a template may be deleted yet the plugin be active.
  • 'gid'		=> 'NULL',

    Unnecessary and may throw SQL errors on some environments.
  • 	$db->insert_query('settinggroups',$ShowNewPoints_group);
    	$gid = $db->insert_id();

    Equals to:
    $gid = $db->insert_query('settinggroups',$ShowNewPoints_group);

    Toungue
  • $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('ShowNewPoints_Enable')");

    Use the delete_query() method instead.
  • require MYBB_ROOT.'/inc/adminfunctions_templates.php';
    require vs require_once?
  • Ideally you should use the _install/_uninstall routines to modify the DB (settings, templates, etc) and avoid the use of settings such as ShowNewPoints_Enable. But I suppose that is a matter of preferences.
  • Avoid hard-coded HTML.
  • There is no need to duplicate what newpoints_format_points() already does, unless it was intentional.
  • Latest Newpoints version already offers this BTW http://forums.mybb-plugins.com/Thread-Ne...-Guide-FAQ

    Luck and keep going!  Big Grin
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#3
Quote:
$is_activated = $db->fetch_array($db->query("select `title` from ".TABLE_PREFIX."templates where `title`='newpoints_home'"));

You should read the plugins cache instead, as a template may be deleted yet the plugin be active.

i am also thinking so but i was not find any chache of templates, i used
$templates['title']
and
$mybb->templates['title']

but this is not working.. after some search i found there is no cache of this type in MyBB.
i don't know where is the template cache stored, if yo tell me then it will be very helpful for me.


Quote:
'gid'		=> 'NULL',

Unnecessary and may throw SQL errors on some environments.
[*]
	$db->insert_query('settinggroups',$ShowNewPoints_group);
	$gid = $db->insert_id();


Equals to:
$gid = $db->insert_query('settinggroups',$ShowNewPoints_group);


$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('ShowNewPoints_Enable')");

Thanks For this Information. Smile




Quote:
require MYBB_ROOT.'/inc/adminfunctions_templates.php';

i also prefer to use require_once in my other coding, i don't know how i didn't see this.... may be i am still copy-pasting because i am just learning pulgins so i didn't notice that..


Happy to see your reply and thanks telling my mistakes.. Smile
Reply
#4
Quote:i don't know where is the template cache stored, if yo tell me then it will be very helpful for me.

I meant the plugin list cache.

$plugins = (array)$cache->read('plugins');

$is_activated = false;
if(isset($plugins['active']) && isset($plugins['active']['newpoints']))
{
	$is_activated = true;
}

Didn't test it.
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#5
(2014-08-27, 06:51 AM)Omar G. Wrote:
Quote:i don't know where is the template cache stored, if yo tell me then it will be very helpful for me.

I meant the plugin list cache.

$plugins = (array)$cache->read('plugins');

$is_activated = false;
if(isset($plugins['active']) && isset($plugins['active']['newpoints']))
{
	$is_activated = true;
}


Wow... its osome, Its very helpful in my next plugin...
Thanks Alot...!! Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)