The PHP Bridge (plugin or theme?)

I’ve been thinking about this and I think maybe a PHP theme is not a good idea for these reasons:

  • We won’t be able to upload the theme to the WordPress Theme Repository because, well… it’s a theme that needs an external server and it will confuse people.
  • People would need to download it from us, then upload it manually adding friction
  • They need the Frontity WP Plugin anyway.
  • We can add all the theme bridge functionality to the Frontity WP Plugin hooking into template_redirect.

This is how the AMP plugin does it and they don’t need a theme (some code removed):

/**
 * Add action to do post template rendering at template_redirect action.
 */
function amp_prepare_render() {
	add_action( 'template_redirect', 'amp_render', 11 );
}

/**
 * Render AMP for queried post.
 */
function amp_render() {
	$post = get_queried_object();
	if ( $post instanceof WP_Post ) {
		amp_render_post( $post );
		exit;
	}
}

/**
 * Render AMP post template.
 */
function amp_render_post( $post ) {
	amp_add_post_template_actions();
	$template = new AMP_Post_Template( $post );
	$template->load();
}

So I think an option in our Frontity WP Plugin is a better idea.