• it is quite often: a plugin is created as a single huge file with an singleton object (only one instance created). that object has constructor that attaches it’s methods to some actions, filters.
    but in many cases object is loaded, created and does nothing ‘couse it’s not required.
    I see a way to solve that.

    you need to create another add_action and add_filter
    (add_action2, add_filter2 or add_action_unloaded, add_filter_unloaded) that will take not Object and method name, but class name and method name. or add ‘path’ parameter to add_action, add_filter functions.
    in apply_filter it will get a singleton object with that class name (simple class to implement singleton) and use it to call method.

    a Singleton class will include (require_once) classes that it needs when it creates a new object.

    a Singleton class should also have RegisterClass method, that will register ‘className’ => ‘path’ pairs.

    so, many plugins might be separated into at least two parts.
    1. declaration, that attaches actions and filters
    2. implementation, that is loaded only when it’s needed.

    the same can be done with functions.
    that will greately increase perfomance (for not-including and not-parsing many files) especially with plugins.

    I can write a code that’s needed for that.

  • The topic ‘increasing perfpmance – feature for actions’ is closed to new replies.