WordPress.org

Ready to get started?Download WordPress

Forums

WooP - OOP for wordpress theme development. (1 post)

  1. diasbruno
    Member
    Posted 1 year ago #

    Hi,

    This is a work in progress, but I believe it is good enough for a few tasks.

    I've been working with wordpress for some time, and one thing it's missing in wordpress is a good way to normalize the data we get from get_tags(), get_categories(), get_posts(), and also, a properly way to iterate with this data.

    WooP is a small library (OOP code style, not too complicated to use), that normalizes the data and provide it as a basic iterator.

    Ex.:

    // getTagsUsingArgs uses the get_tags( $args ),
    // but it will return an iterator.
    $tags = $WooPTags->getTagsUsingArgs( $args );

    if ( $tags->isEmpty() ) {
    echo '<p>Iterator is empty</p>';
    } else {
    while ( $tags->hasNext() ) {
    $tag = $tags->get();
    echo '<p>'.$tag->name().'</p>';
    }
    }

    The code is completely independent, so you don't need to use all the classes, and also, it doesn't change the behavior of the build-in wordpress methods.

    Code
    https://github.com/diasbruno/woop

    Hope it make sense. Go to github and contribute.

    Thanks,
    Bruno Dias

Topic Closed

This topic has been closed to new replies.

About this Topic