Wordpress soon in JavaScript

With the WP API, Wordpress is no longer written in PHP, but goes JavaScript, allowing the use of modern frameworks for application interface...

Wordpress en JavaScript

Because Wordpress wants to become an application framework (it's the team who says), it must give up PHP in favor of a language that provides a better interface with the content to the user.

This does not affect the existing PHP code in the short term at least, but offers another way to do the same thing in a different way. Instead of downloading the PHP application (that we can always do in the years to come, no doubt), we install the JavaScript framework that display the blog or site according to similar principles but with different methods.
With the JavaScript code, all exchanges with the database, in read or write mode, are through HTTP GET and POST requests!

Inspired by the Backbone.js model which is the basis of many frameworks, the new platform also allows to create plugins and themes using a JavaScript framework.

WP API is divided into several sections: post API, users, API, revisions API, etc ... All use the WP Query interface that performs queries to the database through JSON descriptions. These queries are built and performed automatically by the HTML and JavaScript interface in response to user actions.

The end of the loop

Any page of the current software it built over a loop in PHP, like for example:

<?php while ( have_posts() ) : the_post() ?>
<h1 class="postitle"><?php the_title(); ?></h1>
<div class="content"><?php the_content(); ?></div>
<div class="postinfo">
Author: <?php the_author(); ?> on <?php the_date(); ?> </div> ?>

This will display an article, or a list of items or titles and summaries.

This is replaced in WP API by a GET request to a URL like this:

/posts?filter[s]="Title of the post" 

or:

/posts/<id> 

The system responds with a JSON file containing all the elements of a page, which is then converted to HTML by the API ...

When editing a post, form data are also converted into JSON file as below, which will be transformed into SQL queries to be stored in the database...

{
 "title": "Title of the post",
 "content_raw": "The text",
 "date":"2015-03-0212:00:00+01:00"
}

Bye PHP...

The Wordpress team has a plan to integrate progressively the WP API in the core of the project, which will over time replace the current PHP code with the new JavaScript model. This will begin with the admin panel that already uses JavaScript and eventually will use only thus language. The display of the contents will become an option, to allow authors of themes and plugins to adapt them, for a day to become the default process: Wordpress will then become a framework like Drupal, but without the complexity and taking advantage of all the new technologies to build dynamic and intuitive interfaces.

Update 25/11/2015

On November 23, the team announced Calypso, the new interface for Wordpress written in JavaScript. Calypso replaces the client part of the CMS and support themes and plugins. Node.js is required on the server. Replacing the old code by this new one is optional.

Resources