Code Monkey home page Code Monkey logo

wpbp-template's Introduction

Template

License Downloads

Templating system in WordPress (woocommerce like) also for email with l10n support.

  • Your plugin as a templates folder that will be loaded by the plugin based on the code
  • If a theme has a folder with the same slug name of the plugin will look if the file exist there

Install

composer require wpbp/language:1.0.1

composer-php52 supported.

Example

// This is like the woocommerce function
function load_content_demo( $original_template ) {
        if ( is_singular( 'demo' ) && in_the_loop() ) {
            return wpbp_get_template_part( 'plugin-name-folder', 'content', 'demo', false, array() ); // The last parameter is for arguments to pass to the template but is not mandatory
        } else {
            return $original_template;
        }
}
add_filter( 'template_include', 'load_content_demo' );

// This is an extended version that search for folder with names based on locales like it_IT
$get_template_email = wpbp_get_template_part( 'plugin-name-folder' , 'header', 'prefix' );

wpbp_get_template_part is the same of https://developer.wordpress.org/reference/hooks/get_template_part/ this filter, the difference is that this one is executed by this library

wpbp_get_email_template is a function that looks for folder like en_US with file's extension .tpl.

The code is very easy and in case of doubts you can check here.

wpbp-template's People

Contributors

mte90 avatar yaroslav-borodii avatar

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.