No sure if you know about this, but I was thinking (and actually got to beta stage) about
forking your plugin. There are many things I don't like about it TBH, even when it does is the BEST plugin for which it does currently freely available (ignoring Tomm's Post Reputation, which requires MyNetworks, a big downward for me since I'm an optimize freaky, you can say).
My fork is now SO different, that I don't consider it a fork anymore, really, I can not see to find a piece of code that remains from yours. Anyways, there are some things that you need to improve here quite seriously, the main problem with your plugin for me was two things.
- Too many queries.
- It uses jQuery.
Glad you "fixed" the jQuery one. But currently I can see some performance issues regarding your plugin.
function ratemf_postbit(&$post)
{
global $db,$settings,$mybb;
$query = $db->simple_select("posts", "*", "pid='".$post['pid']."'");
$ratemf_yes = $db->fetch_field($query, "ratemf");
$post['ratemf'] = '';
You don't need to query the DB to get each post's "ratemf" column, it is already there for you to use it.
function ratemf_postbit(&$post)
{
global $db,$settings,$mybb;
$ratemf_yes = $post['ratemf'];
$post['ratemf'] = '';
You are even doing queries inside queries, which is next to unbelievable.
function ratemf_postbit_rate_it($post)
{
global $db,$settings,$mybb;
$rate_name = '';
$rate_img = '';
$querys = $db->simple_select("ratemf", "*", "", array('order_by' => 'disporder'));
while($result=$db->fetch_array($querys))
{
$stop = 0;
$query = $db->simple_select("posts", "*", "pid='".$post['pid']."'");
$fid = $db->fetch_field($query, "fid");
$query = $db->simple_select("ratemf", "*", "id='".$result['id']."'");
while($inception=$db->fetch_array($query))
Even through you are passing the post information by reference, you are querying it once again (two times by now!). For the rates, why not trying to use the MyBB cache system? Only difference is the change from
while loop to a
foreach loop, and I'm sure performance will significantly increase.
$query = $db->simple_select("users", "*", "uid='".$whom."'");
$username = $db->fetch_field($query, "username");
Try to use the core get_user() function, at least probably save queries.
$user = get_user($whom);
$username = $user['username'];
Don't trying to say I'm an expert when it comes to optimization, because it is not true at all. Just pouting out what I noticed.
I really wish you the best of the lucks with your plugin and I just approved it.