Deprecate anonymous functions on actions and filters

  1. Raul P.



    The purpose of this would be to force developers (especially theme developers) to use better standards and name their functions, instead of using anonymous functions, which are not easy for other authors to remove.

    For example, some theme builders generate inline css code that changes in every page view, and this causes file minification plugins to detect new code and generate a new cache file.

    If it's not desired to block anonymous functions (I think enforcing best practices should be prioritized), then I believe that there should be something that always makes the anonymous function have an internal static name that never changes.

    For example, some md5 hash of the code, recognizing the file and line where the filter was called from, or some unique identifier that would allow people to still use anonymous functions, but make it more performant by not randomly change on every pageview.

    My opinion, is that anonymous functions should be deprecated gradually, and make it best practices to have developers prefix their functions and make them static.

    I realized, this should be both under performance and actions / hooks.
    Please move or leave accordingly.

    Posted: 4 months ago #

RSS feed for this topic


You must log in to post.

  • Rating

    1 Vote
  • Status

    This idea is under consideration