Brings Laravel's great template engine, Blade, to WordPress

Overview

###This plugin is deprecated in favor of ekandreas/bladerunner

WordPress Blade

Brings Laravel's great template engine, Blade, to WordPress. Just install and start using blade in your theme.

Blade is the template engine for Laravel, a very popular php framework, developed by Taylor Otwell. This plugin brings the same template engine to WordPress. Using a template engine will result in much cleaner template files and quicker development. Normal php can still be used in the template files. The plugin also adds a WordPress specific snippet to blade. Check out the examples for more info.

WordPress Repository: Blade

Blade Tutorial on YouTube: Video Tutorial

Echo/Print

// Normal
 echo $foo; ?>

// Blade
{{ $foo }}

Post Data

// Normal
 the_title(); ?>

// Blade
{{ the_title() }}

If Statements

Normal

/images/thumbnail-default.jpg" /> ">
 if( has_post_thumbnail() ) : ?>
     the_post_thumbnail() ?>
 else: ?>
    <img src=" bloginfo( 'stylesheet_directory' ) ?>/images/thumbnail-default.jpg" />
 endif; ?>

Blade

@endif ">
@if( has_post_thumbnail() )
    {{ the_post_thumbnail() }}
@else
    "{{ bloginfo( 'stylesheet_directory' ) }}/images/thumbnail-default.jpg" />
@endif

WordPress Loop

Normal

">
  • ">
      
      $query = new WP_Query( array( 'post_type' => 'post' ) ); ?> if ( $query->have_posts() ) : ?> while ( $query->have_posts() ) : $query->the_post(); ?> <li><a href=" the_permalink() ?>"> the_title() ?> a>li> endwhile; ?> else : ?> <li> _e( 'Sorry, no posts matched your criteria.' ) ?>li> endif; wp_reset_postdata(); ?> ul>

    Blade

    {{ the_title() }} @wpempty
  • {{ __( 'Sorry, no posts matched your criteria.' ) }}
  • @wpend ">
      

    Advanced Custom Fields

    Normal

    " /> ">
      
      if( get_field( 'images' ) ): ?> while( has_sub_field( 'images' ) ): ?> <li><img src=" the_sub_field( 'image' ) ?>" />li> endwhile; ?> endif; ?> ul>

    Blade

      
      @acfrepeater('images')
    • {{ get_sub_field( 'image' ) }}
    • @acfend

    Including Files

    Files included with functions, e.g. the_header(), will not be compiled by Blade, however the php code in the file is still executed. To include a file with blade use:

    @include( 'header' )

    Note that you should not type “.php”.

    Layouts

    master.php

    @yield( 'content' )
    ">
        
     
    class="content"> @yield( 'content' )

    page.php

    @layout( 'master' )
    
    @section( 'content' )
        

    Lorem ipsum

    @endsection

    Documentation

    Check out the complete Blade Documentation for more examples.

    Contributing

    Pull requests are highly appreciated. Feel free to report a bug, typo, enhancement or a feature you want to add to the plugin.

    Comments
    • Issue with Wordpress Template Names

      Issue with Wordpress Template Names

      The beginning of my template file is like this: @layout('layouts.master') {{-- Template Name: MySuperTemplate --}}

      In the wp-admin page template dropdown menu the template will read as: MySuperTemplate --}}

      A way to bypass this would be to place the comment in the template file like this {{-- Template Name: MySuperTemplate -- }}

      But this is not optimal. {{-- Template Name: MySuperTemplate --}} would be preferred.

      Would this be possible to fix / implement in the plugin?

      opened by ghost 8
    • Added Advanced Custom Fields support

      Added Advanced Custom Fields support

      Hey, I've been looking for Blade templates on Wordpress for quite a while and I want to know if you will still continue to develop this plugin or if I should just go on this on my own.

      Thanks. :)

      opened by jaggy 6
    • @layout and @endsection ???

      @layout and @endsection ???

      Well not sure, but as far as i know blade uses @extends('nameoflayout') and @stop instead of @endsection, is that available or is this an out-dated plugin ?

      opened by byordereurope 3
    • Warning: file_put_contents

      Warning: file_put_contents

      Hi,

      Love the idea of this, but after installing the plugin, I just get a series of errors:

      Warning: file_put_contents(/Users/XXX/Desktop/XXX/wp-content/plugins/blade/storage/views/b53abbc6886c9f3bc6e767c1fc5198d6): failed to open stream: Permission denied in /Users/XXX/Desktop/XXX/wp-content/plugins/blade/application/models/main-model.php on line 47

      This is then repeated on:

      Warning: include(/Users/XXX/Desktop/XXX/wp-content/plugins/blade/storage/views/b53abbc6886c9f3bc6e767c1fc5198d6): failed to open stream: No such file or directory in /Users/XXX/Desktop/XXX/wp-includes/template-loader.php on line 74

      opened by tmyie 2
    • Help to adapt Blade plugin

      Help to adapt Blade plugin

      Hi @mikaelmattsson I'm working in a repo combining Laravel with Wordpress. Your plugin is just what I want, but I would like to implement using the already View facade provided by the Laravel, but I tried without success. :-( Using your plugin works fine, but you did bring the Blade to WP. On my case I already have access to Laravel stuff. Could you help me? Any advice would be nice.

      My repo: https://github.com/bruno-barros/w.eloquent

      opened by bruno-barros 2
    • Blade in WordPress

      Blade in WordPress

      How to implement in wordpress? i have created a plugin Cities in which we will have the details about any city we add to it. it was generated with WP MVC and its working properly. Now i need to implement blade in wordpress.

      i have installed blade plugin in wordpress and have activated it. i have renamed some files to .blade.php say for ex. add.blade.php. when i happen to execute this particular file, it gives a warning message followed by an error message and the action is not done.

      [MVC] Warning: View "admin/add" not found. Thrown on line 204 of /var/www/html/wordpress/wp-content/plugins/wp-mvc/core/controllers/mvc_controller.php

      ( ! ) Warning: require(): Filename cannot be empty in /var/www/html/wordpress/wp-content/plugins/wp-mvc/core/controllers/mvc_controller.php on line 265

      ( ! ) Fatal error: require(): Failed opening required '' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/wordpress/wp-content/plugins/wp-mvc/core/controllers/mvc_controller.php on line 265

      Could you please help me in this regard?

      opened by prabhuchelladurai 2
    • Blade not working

      Blade not working

      Hi,

      FIrst of all, I'm pretty sure this is a stupid question. Nevertheless I had no idea where else I could find any help.

      I've followed the install instructions and installed + activated the blade plugin: http://prntscr.com/2u0x1u

      Next thing I did was making sure the views folder is writable by setting the chmod to 777.

      According to http://wordpress.org/plugins/blade/installation/ I should now be able to use blade syntax.

      Next thing I did was add the following lines to a working wp template file: http://prntscr.com/2u0xwu

      The output is: http://prntscr.com/2u0y9x

      As you can see, it's not parsing the template engine. The page renders {{$helloWorld}}

      Do you have any idea what I am missing? Since I realy appreciate bringing a template engine into wordpress, especially when it's based on Razor, ofwhich I have years of experience.

      Thanks

      opened by frederikprijck 2
    • added wpposts helper for generic query loop

      added wpposts helper for generic query loop

      I love the wpquery helper but thought it might be nice to quickly be able to run the generic loop without any params for simple needs. I added in a simple wpposts helper.. thoughts?

      opened by mykebates 2
    • How to use it in a Widget

      How to use it in a Widget

      Hi,

      First of all: Hallelujah! Blade is such a great engine and we love to work with it!

      Being able to use Blade in Wordpress is the best!

      I do have a about using it in a widget. Is there someway to include the engine in a widget?

      My {{ }} are not being replaced right now!

      opened by prodes 1
    • Latest Blade Version?

      Latest Blade Version?

      Is this plugin compatible with the latest version of Blade or are there any plans to update?

      I've been looking to learn Laravel for more complex projects and it seems like this could be a step in the right direction.

      Thanks,

      opened by christianmagill 1
    • Version of Blade?

      Version of Blade?

      Hey I was just wondering what version of blade this plugin uses?! Looks like @layout() was replaced with @extends() in version 4, so i'm wondering which to use.

      I assume 3, but it'd be nice to see which version somewhere in the readme and on the plugin description page on Wordpress.org.

      Thanks, nice plugin!

      opened by plankguy 1
    • Bound data / view variables

      Bound data / view variables

      Hi,

      I'm trying to include data with my templates. Both of these render nothing for {{ $title }}:

      @include('partials/sighting-top', array('title' => 'My Title'))       // usual way
      @include('partials/sighting-top')->with('title','My Title')            // should work to?
      

      So I look at this: blade.php#L332-L337

      and wonder about ->with(get_defined_vars()).

      Doesn't this just rewrite my $title to null, since no value is supplied?

      view.php#L452-L463

      opened by AppSynergy 0
    • ->render() not evaluating Blade syntax

      ->render() not evaluating Blade syntax

      I could not find an existing issue, and I could not find that I'm using incorrect syntax. When I want to have a template rendered manually to output, in this case for an Ajax-request, I would assume the following would work:

      $content = view('name-of-template')->render();
      

      It does however not evaluate Blade-syntax like {{ 'Foo' }}. The $content contains the literal string {{ 'Foo' }}.

      I did use a hacky way to get it rendered properly:

      $model = \WP_Blade_Main_Model::make();
      $absolute_path = get_template_directory().'/name-of-template.php';
      $rendered_path = $model->template_include_blade($absolute_path);
      include($rendered_path);
      

      This seems however not exactly the best approach. Am I right in assuming ->render() should work in this situation?

      opened by qrazi 0
    Releases(0.3.7)
    • v0.3.2(Oct 14, 2013)

      Remove unused file and add prefixes:

      • Remove include-the-real-path.php
      • Prefix constants with WP_BLADE_
      • Prefix Main_Controller with WP_Blade_
      • Prefix Main_Model with WP_Blade_
      Source code(tar.gz)
      Source code(zip)
    • v0.3.0(Oct 13, 2013)

      Plugin functionality continues the same as in v0.2.2 but some changes in the folders structure and the source code have been made:

      • Add storage/views folder by default
      • Add Main_Controller class
      • Add Main_Model class
      • Move plugin files toapplication folder
      Source code(tar.gz)
      Source code(zip)
    Owner
    Mikael Mattsson
    Mikael Mattsson
    Create WordPress themes with beautiful OOP code and the Twig Template Engine

    By Jared Novack (@jarednova), Lukas Gächter (@lgaechter), Pascal Knecht (@pascalknecht), Maciej Palmowski (@palmiak_fp), Coby Tamayo (@cobytamayo), Up

    Timber 5.2k Jan 5, 2023
    WordPress plugin that lets you use Discourse as the community engine for a WordPress blog

    WP Discourse Note: the wp-discourse plugin requires >= PHP-5.4.0. The WP Discourse plugin acts as an interface between your WordPress site and your Di

    Discourse 497 Dec 10, 2022
    WordPress & TypeScript. Simple starter template for WordPress projects

    WordPress & TypeScript. Simple starter template for WordPress projects that want to use TypeScript in combination with @wordpress/scripts

    Make it WorkPress 11 Sep 27, 2022
    A custom WordPress nav walker class to fully implement the Twitter Bootstrap 4.0+ navigation style (v3-branch available for Bootstrap 3) in a custom theme using the WordPress built in menu manager.

    WP Bootstrap Navwalker This code in the main repo branch is undergoing a big shakeup to bring it in line with recent standards and to merge and test t

    WP Bootstrap 3.3k Jan 5, 2023
    A curated list of Awesome WordPress Theme, Plugins and Framework development Resources and WordPress Communities.

    Awesome WordPress A curated list of Awesome WordPress Theme, Plugins and Framework development Resources and WordPress Communities. Inspired by bayand

    Dropndot Limited 91 Dec 26, 2022
    The Pronamic WordPress Basecone plugin allows you to connect your WordPress installation to Basecone.

    Pronamic WordPress Basecone The Pronamic WordPress Basecone plugin allows you to connect your WordPress installation to Basecone. Table of contents Au

    Pronamic 1 Oct 19, 2021
    A WordPress plugin to suspend WordPress sites automagically. Simple and lightweight, no annoying ads and fancy settings.

    Suspend WP A WordPress plugin to suspend WordPress sites automagically. Simple and lightweight, no annoying ads and fancy settings. ?? Demo (coming so

    Waren Gonzaga 3 Nov 15, 2021
    Twenty Twenty-Two, the default WordPress theme that will launch with WordPress 5.9.

    Twenty Twenty-Two Welcome to the development repository for the default theme that will launch with WordPress 5.9. About Twenty Twenty-Two is designed

    null 414 Nov 28, 2022
    Easy handle APlayer on WordPress. A shortcode for WordPress to using APlayer.

    Description Easy handle APlayer on WordPress. A shortcode for WordPress to using APlayer. Support [audio] tag, compatible with AMP. Requirement WordPr

    Karl Chen 24 Nov 3, 2022
    Simple WordPress plugin to learn how to understand WordPress Crons and the Action Scheduler library.

    Simple WordPress plugin to learn how to understand WordPress Crons and the Action Scheduler library. Import Jamendo playlists with tracks in WordPress posts.

    Pierre Saikali 3 Dec 7, 2022
    A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API

    Wordpress XML-RPC PHP Client A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API Created by Hieu Le MIT licensed. Cur

    Hieu Le 112 Nov 10, 2022
    :rocket: Next Generation Template / Theme Framework

    Gantry Framework Ready to get started with Gantry 5? That's great! We are here to help. On this page, you will get some quick tips to help you hit the

    Gantry Framework 979 Dec 31, 2022
    Automattic 10.7k Jan 2, 2023
    WordPress Framework based on parent theme

    Cherry Framework The most delicious WordPress framework Fully responsive design, easy install, steady updates, great number of shortcodes and widgets,

    Cherry Framework 158 Nov 23, 2022
    A better way to create WordPress themes.

    Runway Framework for WordPress Visit the Runway website: RunwayWP.com A better way to create WordPress themes. Runway was built for creating WordPress

    Parallelus 214 Nov 18, 2022
    The easiest to use WordPress option framework.

    Titan Framework The easiest to use WordPress options framework. Titan Framework allows theme and plugin developers to create admin pages, options, met

    Gambit Technologies 374 Nov 14, 2022
    🚀WordPress Plugin Boilerplate using modern web techs like TypeScript, SASS, and so on... on top of a local development environment with Docker and predefined GitLab CI for continous integration and deployment!

    WP React Starter: WordPress React Boilerplate DEPRECATED: WP React Starter was a "research project" of devowl.io for the development of our WordPress

    devowl.io GmbH 344 Jan 1, 2023
    📦 A zero-configuration #0CJS developer toolkit for building WordPress Gutenberg block plugins.

    create-guten-block is zero configuration dev-toolkit (#0CJS) to develop WordPress Gutenberg blocks in a matter of minutes without configuring React, w

    Ahmad Awais ⚡️ 3.1k Dec 23, 2022
    Examples for extending WordPress/Gutenberg with blocks.

    Gutenberg Examples Examples for extending Gutenberg with plugins which create blocks. See also: Gutenberg developer documentation Installation Gutenbe

    null 1.1k Dec 29, 2022