WordPress.org

Ready to get started?Download WordPress

Ideas

Separate the different kinds of WP functions using classes

  1. MS-DOS_1991
    Member

    12345

    Well, actually this would be more a "way-of-coding" guideline than a real implementation in this software, but I think it would be great to separate the "core" functions of WordPress (ex: caching functions) from the ones related to the pages display (that's to say the templates tags) and moreover from the ones created by the plugins.

    The point is that if you open a WordPress template file by now, you won't be able to tell which functions are coming from WordPress (like wp_list_pages) and which are exotic ones, created by a plugin,

    The solution would be to gather all the "display related" functions in an abstract class, called "Blog" for example. Of course there would be no need to instanciate this class, it would just be there to provide a syntax like Blog::list_pages().

    We could even go further and gather the "loop related" functions in an other class, called "Post" for example, which would result in this kind of syntax : Post::title (or Post::display_title, to be debated)

    Here is a small list of the concerned functions :
    get_header, get_sidebar, get_footer
    list_pages, get_archives, list_cats (wp_* presently)
    the_post, the_permalink, the_ID
    the_content, the_category, the_title
    ... and any other function related to the display

    I am fully conscious of the fact that it would break all WordPress themes, but (from my point of view) the earlier it would apply, the best it would be. It should not be so hard to code a "translator", that's to say a php file which would open / search / replace functions in the themes files, as long as the arguments of the functions would not change at all :-)

    P.S: Please forgive my poor english (i'm french)

    Posted: 7 years ago #
  2. h3h
    Member

    12345

    Hooray for robust and organized architectures.

    Posted: 7 years ago #
  3. WebmasterMSB
    Member

    12345

    +1

    I think a solid and logical architecture will encourage people creatins their own plugins/themes.

    Posted: 7 years ago #
  4. m0n5t3r
    Member

    12345

    +1
    ... and don't get me started on the lack of namespaces in PHP and other reasons why PHP sucks :D

    Posted: 7 years ago #
  5. Amaury Balmer
    Member

    12345

    Good idea...

    Posted: 7 years ago #
  6. Samuel Wood (Otto)
    Tech Ninja

    WordPress has already been moving more and more in this direction. Look at all the classes in the core now.

    Most of the functions still exist for backwards compatibility, a surprising lot of them just call classes and such to do the actual work.

    Posted: 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.

  • Rating

    12345
    35 Votes
  • Status

    Good idea! We're working on it