Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
Like Tree3Likes
  • 2 Post By TheGAME1264
  • 1 Post By Ronald Roe

Thread: Wordpress Conference Presentation

  1. #1
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times

    Wordpress Conference Presentation

    One thing I've been big on lately is web APIs. In other words, a server you can hit with a request and it returns the requested data in a consumable format like JSON. These are particularly useful for AJAX-based web apps or a simple site that needs some dynamic data but doesn't need the overhead of a full-on CMS behind it.

    It appeals to me so much that I have been working to build my own blog-ready "headless" CMS, or a simple, drop-in CMS that simply returns data about posts or pages, but doesn't come with the front-end (or at this point, even a back-end) infrastructure. It isn't designed for large enterprise applications.

    During the recent Wordcamp OKC, it dawned on me that Wordpress' theming could be used for something very similar, but more robust. Here would be the concept: using WP_Query, one could request a page or list of posts using the WP_Query object, JSON encode it and echo or return it as necessary. That would create a simple API that most WP devs would already be familiar with.

    So, let's say you sent an AJAX request out to http://mysite.com?p=234

    That would echo the output for what would be a page or post with the ID 234. Now, there are much more useful ways to get specific posts than passing an ID, but that's just an example, and one could easily grab anything WP_Query is capable of returning.

    I was thinking of putting together and shopping around a presentation on this. I've searched a bit for it, and it doesn't seem like anyone's done this, at least that I can find. The only thing I've run into has been the REST API plugin, which does similar, but it doesn't have the customization capability that my idea has. With mine, you could easily loop through results and build a custom output, which it doesn't appear you can do with the REST API.

    Now, on to my question: thoughts? Is this an idea devs would grab onto?
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    I'm going to answer this from the standpoint of me personally and from devs in general.

    Me, personally? No, I wouldn't grab onto it. You can probably guess why!

    Devs in general? Probably not, but for a different reason. The one thing about WP is that, for all of the talk about how you can add plugins and how easy it is to customize, very few people actually go out and do that from what I've seen. I've done a bit of it myself for clients, and I suspect that I've done more to get relatively simple customizations done than about 99.999% of the "WordPress Community". It has gotten to the point where there is more focus on the design aspects than the development ones, which isn't overly surprising given that it's an "off the shelf CMS".

    A lot of the more accomplished devs might already have something such as your idea, but in scraper form. Since WP is a templating system, it would be relatively easy for a dev with strong skills to harvest information from posts, categories, archives, etc. The one advantage that I can see in your idea is in the potential filtering of "irrelevant" posts, categories, etc. by keyword or whatever other criteria; mind you, that would only potentially impact bandwidth and CPU resource, and the former is like Kool-Aid these days. Bandwidth for pennies a GB, OH YEAHHHHHHHHHHHH!

    I think it's an interesting idea, and certainly one that has more thought put into it already than most of what we see on here. It just strikes me as the juxtaposition of a potentially good idea for mainstream use without much mainstream appeal.
    Ronald Roe and bleau canon like this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    I think you're on the right track with the design vs dev, though I have seen quite a bit more work done in terms of development lately. This comes from the perspective of trying to pick up work after my deployment. Things were moving that direction before I left, which I think is awesome, but I feel a bit sorry for the theme modifier types who aren't going to be able to find work.

    That said, the REST API plugin does some of what I'm proposing, though in order to truly customize results, you'd have to do exactly what I'm proposing while using the plugin instead of WP_Query. Post-filtering results or building a custom output is where my method would come in, and it uses the native object with all of its methods available. This could easily be used to output a fully custom JSON encoded from a custom array you build. The best part of it is that the code looks very similar to what theme devs are already doing. It's just that rather than echoing out, say the title, you would store it in an associative array. It also becomes lighter since you don't end up sending everything over the connection, and you wouldn't need as much client-side code to process through the results.

    Is it better than the official REST API plugin? Not really, but it does have some use cases that make it something to consider.

    And if nothing else, I'd like to help with the push toward development with and without Wordpress. In that, I think I can help make it a tool in the toolbox rather than a de facto standard by corrupting the minds of the theme tweakers and plugin installers with my devilish development ideas.
    TheGAME1264 likes this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Hey, I'm all about doing things non-standard. You know that.

    But I'm just not sure on this one. I think you're going to have to allow an XML output, if for no other reason than certain languages and frameworks don't have a native JSON parser (e.g. .NET...it's becoming a bit of a headache: On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API - Scott Hanselman). Now, some of us who are more enterprising (read: F**KING INSANE) wrote our own JSON parsers, but that's because we're enterprising (read: F**KING INSANE). I believe there's a library out there for it somewhere, but I've never been able to find it. So yeah, you'll want XML support as well.

    I'm not going to say anything about the theme modifier types except that "some of them probably have really nice hair", since that's about the only thing that won't set off a firestorm.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Quote Originally Posted by TheGAME1264 View Post
    I'm not going to say anything about the theme modifier types except that "some of them probably have really nice hair", since that's about the only thing that won't set off a firestorm.
    Also, some of the respected members of this very forum are exactly that.

    If there's not a JSON parser in ASP.net (there must be), this might not be something you can use. There are ways to output to XML in PHP. The built-in way is marked "experimental", and was added in PHP 4, which released in May of 2000. My guess there is that with JSON having better support and frankly being a better format, that functionality was started and summarily forgotten.

    At any rate, you can create an API in 3 lines of code:

    PHP Code:
    $args = ['post_type' => 'post'];

    $output = new WP_Query($post);

    echo 
    json_encode($output->posts); 
    Now, that doesn't allow input or custom output of any kind, but you get the idea.
    Last edited by Ronald Roe; Aug 04th, 2016 at 01:23 PM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:12 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com