Classy is a framework for building WordPress themes, based on Blade template engine

Overview

alt tag

Scrutinizer Code Quality Build Status

Classy is a framework for building WordPress themes, based on Blade template engine. It's fast with beautiful architecture that allows you to write less code and focus more on project itself. It doesn't provide frontend boilerplate, since every project needs its own, instead it handles all architecture, providing an elegant way to separate logic from view.

Why Blade?

Blade is the simple, yet powerful templating engine provided with Laravel. Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. All Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application.

Code example:
{{ $post->content() }} @endif @stop ">
@extends('layout.default')

@section('content')
	@if ($post)
		<article>
			<h1>{{ $post->title() }}h1>
			
			<section class="body">
				{{ $post->content() }}
			section>
		article>
	@endif
@stop

What’s about structure?

The biggest problem with WordPress theme development is that you always need to repeat same code. New approach, that assumes that template data will be collected and prepared separately from actual render allows you to have the project structured more accurate.

alt tag

How it works?

ClassyView and ClassyScope repeat the WordPress template hierarchy, however they do it independently. This allows to use the same scope with different templates and different scopes with the same template.

Example of project structure

alt tag

Getting started

  1. Navigate to your WordPress themes directory cd ~/Sites/mysite/wp-content/themes
  2. Clone repository git clone [email protected]:anrw/classy.git
  3. Navigate to it cd classy
  4. Install composer dependencies composer install

Config file

Check our GitHub Wiki

Page Templates

To register a template you need simply to put {{-- Template Name: Example --}} at the top of your blade file. We recommend you to structure your templates in one of this ways:

  1. views/page/templatename.blade.php
  2. views/template/templatename.blade.php
  3. views/template-name/templatename.blade.php

Useful links

  1. Blade documentation
  2. WordPress Code Style
  3. PHP Mess Detector

Requirements:

  • WordPress: 4.5+
  • PHP: 5.6+

How to check php code style

Check WP Code Style composer cs

How to run static code analyzer

Check PHPMD composer md

Contribute

You can report a bug, implement a feature or simply give an idea on how to make the project better. Every input from your side will be highly appreciated!

Big thanks to:

anrw LehaMotovilov konstantp
anrw LehaMotovilov konstantp

License

Classy is under GNU General Public Licence (GPL). You can use it in your personal and commercial work.

Comments
  • App structure refactoring

    App structure refactoring

    Появилась идея сделать небольшой рефакторинг. Идея частично обсуждалась с @konstantp.

    В текущей реализации папка models находится внутри app/classes, что на мой взгляд не очень удобно. Я предлагаю перенести модели сразу в app. При этом, в папке classes реализовать дефолтную модель WordPress Post Type, которую будут расширять все модели из app/models. Саму же папку classes переименовать в core. На выходе мы получаем изолированный core от кастомной функциональности, что дает также возможность его обновлять внутри проекта.

    Что думаешь @LehaMotovilov ?

    enhancement question 
    opened by anrw 18
  • Namespaces Classy

    Namespaces Classy

    Есть смысл добавить namespace Classy; Тогда можно будет убрать методы:

    $this->define_constants();
    $this->include_core_files();
    $this->include_models();
    

    Ну и шаг вперед к best practices. Что думаете?

    enhancement question 
    opened by LehaMotovilov 5
  • Question: Dynamic define constants.

    Question: Dynamic define constants.

    При динамическом определении констант в методе Classy->define_constants(), моя IDE PhpStorm не понимает что вообще происходит и при каждом обращении к именовоной константе, например к THEME_PATH выдает warning "Undefined constant" и соответственно не работает goto definition.

    Может быть есть смысл оставить более прямой вариант без враппера Classy->define()? Что думаешь по этому поводу?

    question 
    opened by LehaMotovilov 3
  • @php, @continue(), $loop

    @php, @continue(), $loop

    Очень не хватает возможностей @php, @continue(), $loop... Полагаю, связано с тем, что поддержка разработки Classy закончилась до появления этих директив в Blade))) Можно ли лелеять надежду на обновление?) Или если совсем нет времени, укажите в каком направлении двигаться, чтобы обновить его самостоятельно.

    opened by PrOpOvEdNiK 2
  • Classy/Menu class doesn't support menu locations.

    Classy/Menu class doesn't support menu locations.

    classy/app/classes/appearance.php registers theme locations:

    register_nav_menus(array(
    'header-menu' => __( 'Header Menu', Classy::textdomain() ),
    'footer-menu' => __( 'Footer Menu', Classy::textdomain() ),
    ));
    

    However classy/app/classes/menu.php doesn't support wp_nav_menu function and theme locations and to add a menu into scope you have to pass its ID.

    opened by konstantp 2
  • Fixes post get_content method and applies the_content filter

    Fixes post get_content method and applies the_content filter

    Initially get_content method returned content with applied the_content filter only if $post_content property is empty. Now it applies the_content filter in any case. It fixes shortcodes execution.

    opened by konstantp 1
  • Composer updates

    Composer updates

    I added scripts to composer.json so it is easier to run phpcs and phpmd.

    Now you don't need to know the details of the command, you just run composer cs and composer md.

    I also added type so that Composer installer will recognize the package as a theme.

    opened by webdeveric 1
  • Updates get_request_hierarchy_list method

    Updates get_request_hierarchy_list method

    Fixes issue with a page that has classy template and is set as FrontPage in General->Reading settings. Initially it was ignored and custom template couldn't be found.

    opened by konstantp 0
  • Update classyUser wrapper. Fix some phpMD and phpCS errors.

    Update classyUser wrapper. Fix some phpMD and phpCS errors.

    Обновил инициализацию ClassyUser. Там была ошибка в методе импорта. Добавил в PHP CS правила для комментариев в коде. Так же пофиксил все ошибки которые нашли phpMD phpCS в классе ClassyUser.

    Так же я не совсем понял суть метода verify_id() добавил туда todo. Как я понял пользоваться нужно вот так?

    $some_user = new ClassyUser( 1 );
    

    Тогда veryfy_id толжен вернуть WP_Error? Если все так, могу написать валидацию юзера по id.

    opened by LehaMotovilov 0
  • class Comment

    class Comment

    Сегодня решил посмотреть класс Comment. Если не смотреть на get/set методы то его функционал в основном заключается в формировании структуры комментариев parent->child. Так же в текущей реализации класс Comment не поддерживает вложеность больше одного уровня.

    Я предлагаю в данном случае использовать родной WordPress API для отображения комментов. Убрать логику формирования структуры parent->child из Comment и добавить метод classy_comments для обработки вывода. В общем сделать Comment больше как Helper а не как wrapper для WP_Comment.

    Вариант вывода комментариев: views/layouts/comments.blade.php

    <h4>{{ get_comments_number_text(); }}</h4>
    {{ wp_list_comments( [ 'callback' => [ '\Classy\Comment', 'render_comments' ] ] ); }}
    

    Что думаешь?

    enhancement question 
    opened by LehaMotovilov 3
  • ClassyUser

    ClassyUser

    У нас небольшая проблема. Вот все варианты как можно использовать класс ClassyUser.

    $user = new ClassyUser( 1 ); // User by ID - Ok.
    $user_2 = new ClassyUser(); // Must be current user?
    $user_3 = new ClassyUser( 234 ); // User not exist.
    

    Первый вариант в принципе понятен. Но с вторым и третим вариантами есть проблема. Во втором случае если пользователь не залогинен мы получаем пустой обьект ClassyUser так же как и в третьем варианте если юзера с таким ID не существует.

    object(ClassyUser)[469]
      public 'ID' => int 234
      public 'link' => null
      public 'user_login' => null
      public 'name' => string 'Anonymous' (length=9)
      public 'user_nicename' => null
      public 'user_email' => null
      public 'display_name' => null
      private 'object' => boolean false
    

    Получается что конструктор класа ClassyUser должен кидать Exception что юзер не найден. Что не сильно удобно так как все варианты использования класа нужно будет оборачивать в try catch.

    enhancement 
    opened by LehaMotovilov 2
Owner
DigitalKwarts
We write high-quality code that prioritizes reliability, scalability and performance.
DigitalKwarts
Brings Laravel's great template engine, Blade, to WordPress

###This plugin is deprecated in favor of ekandreas/bladerunner WordPress Blade Brings Laravel's great template engine, Blade, to WordPress. Just insta

Mikael Mattsson 150 Nov 29, 2022
A WordPress package for updating custom plugins and themes based on an API response from a custom update server.

WordPress Update Handler A WordPress package for updating custom plugins and themes based on an JSON REST API response from a custom update server. Ch

WP Forge 7 Oct 5, 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
A WordPress plugin to create Blockbase child themes

Create Blockbase Theme A WordPress plugin to create Blockbase child themes Find out more about Blockbase at blockbasetheme.com Step 1 – Setup Install

Automattic 171 Jan 3, 2023
A custom update API for WordPress plugins and themes

A custom update API for WordPress plugins and themes. Intended to be used in conjunction with my plugin-update-checker library.

Yahnis Elsts 717 Dec 31, 2022
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
Hozokit - Theme Building Framework for WordPress

Hozokit - Theme Building Framework for WordPress Hozokit gives you the power to create unique WordPress themes without the WordPress hassle.

cristiano 16 Nov 15, 2022
Rabbit Framework - A modern way of building WordPress plugins

Rabbit Framework - A modern way of building WordPress plugins. About Rabbit Framework is a modern framework designed to be a solid foundation for your

VeronaLabs 8 Nov 20, 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 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
A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.

WordPress Plugin Boilerplate A standardized, organized, object-oriented foundation for building high-quality WordPress Plugins. Contents The WordPress

Devin 7.2k Jan 4, 2023
This WP plugin will update GitHub, Bitbucket, GitLab, and Gitea hosted plugins and themes

Transition from GitHub Updater 9.x to Git Updater 10.x Due to the renaming of the plugin folders and files, after the initial update, the plugin will

Andy Fragen 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
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
: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
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
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