• Stars
    star
    137
  • Rank 265,437 (Top 6 %)
  • Language
    PHP
  • Created over 10 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A stripped down example of a WordPress theme that utilizes Backbone.js

Welcome

This repository holds a WordPress theme that uses Backbone.js to deliver a single page application experience. This remarkably simple theme was created for demonstration purposes during a WP Sessions talk. The theme is very incomplete and is intended for use as an example of how to start and structure a WordPress theme with Backbone.js integration. Additionally, some notes from the session are below.

As part of this WP Session, I did a live demonstration that builds a basic theme into a functioning Backbone.js theme. I am including the steps that I followed for this code demonstration. If you add app-live-demo as a WordPress theme and follow the steps provided in live-demo.md, you will understand my logic in building this theme.

Backbone.js WordPress Themes (as of 26/Jan/2014)

  • Tareq Hasan's Backbone.js Proof of Concept Theme (blog | github | demo)
    • Uses the JSON REST API plugin
    • Works for most views (e.g., pages, widget links, etc)
    • Requires a specific permalink structure
    • Uses hashbang based URLs
    • Plugin support? Don't know couldn't get it to work
  • Emanuel Kluge's Backboned (v2) Theme (github | demo)
    • Works with normal WP URLs
    • Supports pages, posts, taxonomies
    • Uses require.js and supports it's own versions of the deps
    • Uses Mustache templates in the PHP; WordPress templating system is largely ignored
    • Works as a server side app and a client side app
    • Does not use the JSON REST API plugin
    • Does not support default permalink structure
    • Plugin compatibility issues
  • O2 (site | WP API Team Demo)
    • Launching in the spring (maybe)
    • Not much info available, presently
  • Collections (demo)
    • Custom JSON API implementation
    • Supports all of the default permalink structures
    • Attempts to support a lot of plugins
    • Works with different MS setups
    • Every URL is a potential starting point for the app
    • Uses the regular WordPress templating system

Challenges of a Backbone.js WordPress Theme

Adding a client side application on top of the WordPress server side application changes the assumptions of the software. Developers build WordPress and plugins with the assumption that every page view will be generated by the server. Loading pages via the client changes these assumptions and can present some issues.

Routing

  • WordPress allows for any URL structure to be implemented
  • Backbone.js asks you to define this structure and works best with a RESTful API, which WordPress does not support
  • Using a "catchall" router helps to avoid this issue:
routes: {
	'*notFound' : 'go',
	''          : 'go'
},

Plugin support

  • For proper plugin support, enqueues need to work, environments need to be set, and the front end needs to support this
  • JSON API needs to mimic a full page load and front needs to alter this environment
<?php
ob_start();
wp_head();
ob_end_clean();

if ( have_posts() ) {
    while( have_posts() ) {
        the_post();
        
        // Get the data
    }
}

ob_start();
wp_footer();
ob_end_clean();

A Backbone.js WordPress Theme Bill of Rights

  1. The theme shall be held to the same standards as all other, non-Backbone.js themes.
  2. The install process shall be the same as a standard WordPress theme.
  3. The theme shall support permalink structures.
  4. The theme shall make a strong effort to support common plugin scenarios.

More Repositories

1

wordpress-pecl-memcached-object-cache

A WordPress object cache that uses the memcached (not memcache) PECL extension.
PHP
228
star
2

ostrichcize

A WordPress plugin to hide PHP errors for specified plugins or themes
PHP
26
star
3

wordpress-https-mixed-content-detector

Monitor a WordPress site served over TLS for mixed content warnings
PHP
23
star
4

a-fresher-cache

Get a fresher cache with a dash of "A Fresher Cache" for absolutely no cash.
PHP
14
star
5

debug-bar-cron

Debug Bar Cron adds a new panel to Debug Bar that displays information about WP scheduled events.
PHP
14
star
6

wordpress-development-course

JavaScript
14
star
7

report-only-capture

Useful scripts for testing the wide array of CSP reports
JavaScript
11
star
8

custom-taxonomy-sort

Custom Taxonomy Sort allows you to explicitly control the sort order of all taxonomy terms.
PHP
10
star
9

csp-report-norm

Normalize Content Security Policy report payloads
JavaScript
8
star
10

diffie-hellman-key-exchange-demo

Materials for presenting a live demo of Diffie Hellman key exchange principles
7
star
11

kses-cases

A test of WordPress kses performance
PHP
6
star
12

ssl-nginx-starter

A sample configuration for SSL and Nginx
JavaScript
6
star
13

caching-for-coders

JavaScript
6
star
14

wcchi-2014

Slide for WCCHI talk on Page Load Time
4
star
15

wp-page-cache

PHP
4
star
16

wphttp

PHP
4
star
17

wordpress-plugin-repository-search-alfred-extension

Searches the WordPress plugin repository for information about plugins
PHP
3
star
18

cookbook-wordpress

A Chef Cookbook for WordPress
Ruby
2
star
19

Quick-Edit-for-Taxonomy-Terms

A primer for adding quick edit for use on the taxonomy term pages
PHP
2
star
20

hither-and-thither

My vivaciously viable Vagrantfile (and related accouterments).
1
star
21

theres-a-function-for-that

JavaScript
1
star
22

wcyvr-2013

Slides from "Towards a Partial Page Templating System in WordPress" talk given at WCYVR 2013
JavaScript
1
star
23

alexa-traffic

An Amazon Echo command built for AWS Lambda that gives you traffic information.
JavaScript
1
star
24

bracket

Keep score of NHL playoff picks
JavaScript
1
star
25

report-only

An application to handle Content Security Policy reports
Shell
1
star
26

screts-lated-posts

A stupid plugin to demonstrate common WordPress development errors.
PHP
1
star
27

report-only-api

JavaScript
1
star