HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to overwrite class.pluginname.plugin.php ???

Hello Forum,
If I want small html changes (for example add class or add elements) in class.pluginname.plugin.php of a plugins , what do I do ? changing directly to the pluigins is very bad idea i guess.

Note: I dont want to do any changes on codes.
as an example:
echo WrapIf($AuthorRank->Name, 'span', array('class' => 'MItem Rank Rank-' . Gdn_Format::Url($AuthorRank->Name)));

in abobe code, I would like some thing like this :

echo WrapIf($AuthorRank->Name, 'span', array('class' => 'MItem Rank exampleClass Rank-' . Gdn_Format::Url($AuthorRank->Name)));

here I have added class name 'exampleClass'.

I alredy tried with js (it works fine) but I had problem at some point.

So if you have any idea please help me.



  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    You are not the first to ask such question, however it's a bad question because we don't know anything about your setup , what theme, what plugins.

    Your question is too vague to understand what you want. I can guess that the reason you want to add a class or change a class is to be able to style some element as you like.

    This sort of thing is unnecessary if you know what you are doing, in fact it is a bit ludicrous. So please make a mock up in a picture to help us understand why on earth you would need to do what you ask. Why the need to change a class. Adding a class is not a problem. It can be done in a variety of ways. But we need to know what you expect to do with this. There are tons of tutorials about adding class or id to elements.

    Because in order to truly help you, we first need to understand what exactly you want to achieve …

    echo WrapIf($AuthorRank->Name, 'span', array('class' => 'MItem Rank exampleClass Rank-' . Gdn_Format::Url($AuthorRank->Name)));

    This would technically work except sometimes adding the class here will make the link unavailable to non logged in people.

    to make it work try this, it was one of the first things I learned here because my adding classes to php links was not working and I found out it's because you need to add empty arrays. Hope this works for you.

    echo WrapIf($AuthorRank->Name, 'span', array(),array(), array('class' => 'MItem Rank exampleClass Rank-' . Gdn_Format::Url($AuthorRank->Name)));

  • @vrijvlinder
    my question was just to know whether we can overwrite class.pluginname.plugin.php file of any plugins or not.
    As far as i know (recently knew) that we cannot, so I just edited the original plugins and rename it on my own.

  • R_JR_J Ex-Fanboy Munich Admin

    Overwriting parts of functions is never possible.
    Overwriting some functions might be possible.

    If a function is encapsuled between if (!function_exists... you can replace it.

    Sometimes you have the opportunity to change a css class with a plugin before it is rendered.

    But anyway: adding a class is a change you almost never need. I cannot think of one single reason for that. If you give information what exactly you try to achieve, we most certainly will be able to help you with a hint to the appropriate solution

Sign In or Register to comment.