PHP code example of starring-jane / wordpress-blade
1. Go to this page and download the library: Download starring-jane/wordpress-blade library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
starring-jane / wordpress-blade example snippets
use StarringJane\WordpressBlade\WordpressBlade;
WordpressBlade::create(
base_path('resources/views'), // Path to all blade files
base_path('storage/views/cache'), // Path to blade cache
base_path('public/themes/janes/components') // Path to component classes (optional, but recommended)
);
use StarringJane\WordpressBlade\WordpressBlade;
WordpressBlade::create(
get_theme_file_path('views'), // Path to all blade files
get_theme_file_path('cache/views'), // Path to blade cache
get_theme_file_path('components') // Path to component classes (optional, but recommended)
);
namespace ThemeName;
use StarringJane\WordpressBlade\Component;
class Page extends Component
{
public function render()
{
return $this->view('pages.default', [
'post' => get_post(),
]);
}
}
namespace ThemeName\Components;
use StarringJane\WordpressBlade\Component;
class Button extends Component
{
public $type;
public function __construct($type)
{
$this->type = $type;
}
public function render()
{
return $this->view('components.button', [
'color' => $this->color(),
]);
}
protected function color()
{
return 'red';
}
}
use StarringJane\WordpressBlade\WordpressBlade;
add_action('after_setup_theme', function () {
WordpressBlade::directive('datetime', function ($expression) {
return " echo ($expression)->format('m/d/Y H:i');
add_filter('wordpress-blade/template-directories', function ($directories) {
$directories[] = 'controllers';
return $directories;
});