Giter Site home page Giter Site logo

wpgb-extended's Introduction

Gridbuilder ᵂᴾ Extended

Register Gridbuilder ᵂᴾ with object oriented PHP.

Gridbuilder ᵂᴾ Extended provides an object oriented API to register templates and (soon) facets. If you register template or facets in your theme, you can safely rely on version control when working with other developers.

Installation

Require this package, with Composer, in the root directory of your project.

composer require amphibee/wpgb-extended

Download the Gridbuilder ᵂᴾ plugin and put it in either the plugins or mu-plugins directory. Visit the WordPress dashboard and activate the plugin. Please note that this package supports Gridbuilder ᵂᴾ version 1.4 or higher.

Templates

Use the Template::make() function to register a new template. Below you'll find an example of a template registration.

use WpgbExtended\Facades\Template;

Template::make('post-list')
  ->setSourceType('post')
  ->setClasses(['list', 'is-full-width'])
  ->setWrapperTag('ul')
  ->setQueryArgs([
    'post_type'      => 'post',
    'posts_per_page' => 10,
  ])
  ->setRenderCallback('prefix_render_callback')
  ->setNoResultsCallback('prefix_noresults_callback');

Visit the official Gridbuilder ᵂᴾ template documentation to read more about the template settings.

Facets

Get facet by slug

You have now the possibility to get facet by slug

wpgb_render_facet([
  'slug' => 'pagination',
  'grid' => 'post-list'
])

Improved facet rendering

Facets have the slug class make you more powerful styling !

Note : by default, class are only added when wpgb_render_facet is called by slug. If you want to enable it when a facet is called by ID, you need to enable it with this filter :

add_filter('wpgb_extended/enable_facet_class_from_db', '__return_true');

Registering facets

@TODO

Content sync

Gridbuilder ᵂᴾ Extended allows you to synchronize all of your content (grids, cards, facets). This is useful when working with multiple environments (local, staging, production). Like Advanced Custom Fields, the grids, cards, facets are stored in json files. By default, they are stored in your theme folder (wpgb-json folder). You can customize this folder with the wpgb_extended/sync/json_folder filter

It's possible to deactivate the synchronization globally with the filter wp_grid_builder/enable_sync or to deactivate it by entity with the filter wpgb/{$type}/enable_sync (ex. wpgb/card/enable_sync)

Note: For maps and grids, Gridbuilder ᵂᴾ does not offer a single slug. Gridbuilder ᵂᴾ Extended is based on name by default. It is therefore important to be aware that it will not have to change in the meantime in which case, a duplicate will be created. In the same way, it is important that the name is unique otherwise it will generate conflicts on synchronizations (an alert function will be planned on the next versions)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.