All Projects → johnbillion → Extended Template Parts

johnbillion / Extended Template Parts

Licence: gpl-2.0
A library which provides extended functionality to WordPress template parts, including template variables and caching.

Labels

Projects that are alternatives of or similar to Extended Template Parts

Wp Ulike
WP ULike enables you to add Ajax Like button into your WordPress and allowing your visitors to like and unlike posts,comments, BuddyPress activities & bbPress Topics
Stars: ✭ 84 (-8.7%)
Mutual labels:  wordpress
Tj
Create local WordPress dev sites, manage existing sites, and deploy them, all from the command line.
Stars: ✭ 88 (-4.35%)
Mutual labels:  wordpress
Teepay
Typecho 个人支付宝、微信收款插件
Stars: ✭ 90 (-2.17%)
Mutual labels:  wordpress
I hate wordpress
I used to hate Wordpress until I had created this repo. This is me documenting how to make WordPress not suck like everyone thinks it does.
Stars: ✭ 85 (-7.61%)
Mutual labels:  wordpress
Jetpack
Security, performance, marketing, and design tools — Jetpack is made by the WordPress experts to make WP sites safer and faster, and help you grow your traffic.
Stars: ✭ 1,283 (+1294.57%)
Mutual labels:  wordpress
Wp Less
WordPress plugin which seemlessly compiles, caches and rebuilds your LESS stylesheets.
Stars: ✭ 88 (-4.35%)
Mutual labels:  wordpress
Shadow Shop
Building highly customizable e-commerce websites selling shadowsocks services, using Wordpress and WooCommerce
Stars: ✭ 84 (-8.7%)
Mutual labels:  wordpress
Searchwp Live Ajax Search
[WordPress Plugin] Enhance your search forms with live search (utilizes SearchWP if installed)
Stars: ✭ 91 (-1.09%)
Mutual labels:  wordpress
Wp Functions List
This is a list of all WordPress functions from version 0 to version 4.8.1 along with the data of when they were first introduced and if they are deprecated or not
Stars: ✭ 88 (-4.35%)
Mutual labels:  wordpress
Wordpress Multisite Enhancements
Enhance WordPress Multisite for Network Admins with different topics
Stars: ✭ 89 (-3.26%)
Mutual labels:  wordpress
Remove Comments Absolutely
WordPress Plugin to deactivate comments functions and remove areas absolute form the WordPress install
Stars: ✭ 86 (-6.52%)
Mutual labels:  wordpress
Popup Maker
Popup Maker plugin for WordPress
Stars: ✭ 87 (-5.43%)
Mutual labels:  wordpress
Imposter Plugin
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.
Stars: ✭ 90 (-2.17%)
Mutual labels:  wordpress
Zoninator
Curation made easy! Create "zones" then add and order your content straight from the WordPress Dashboard.
Stars: ✭ 84 (-8.7%)
Mutual labels:  wordpress
Cmseek
CMS Detection and Exploitation suite - Scan WordPress, Joomla, Drupal and over 180 other CMSs
Stars: ✭ 1,296 (+1308.7%)
Mutual labels:  wordpress
Wp User Profiles
⭐️ Better Profiles for WordPress
Stars: ✭ 84 (-8.7%)
Mutual labels:  wordpress
Kubernetes Course
Kubernetes Course Files
Stars: ✭ 1,291 (+1303.26%)
Mutual labels:  wordpress
Wooshop
A Wocommerce Based React Native App for IOS and Android over GraphQL
Stars: ✭ 92 (+0%)
Mutual labels:  wordpress
Wordpress Seo
Yoast SEO for WordPress
Stars: ✭ 1,301 (+1314.13%)
Mutual labels:  wordpress
Headless Wp
A demo repo for Headless WordPress
Stars: ✭ 89 (-3.26%)
Mutual labels:  wordpress

Build Status Stable Release License PHP 7

Extended Template Parts

Extended Template Parts is a library which provides extended functionality to WordPress template parts, including template variables and caching.

Features

  • Pass variables into your template parts and access them via the $this->vars array. No polluting of globals!
  • Easy optional caching of template parts using transients.

Minimum Requirements

PHP: 7.0
WordPress: 4.4

Installation

Extended Template Parts is a developer library, not a plugin, which means you need to include it somewhere in your own project. You can use Composer:

composer require johnbillion/extended-template-parts

Or you can download the library and include it manually:

require_once 'extended-template-parts/extended-template-parts.php';

Basic Usage

The get_extended_template_part() function behaves exactly like WordPress' get_template_part() function, except it loads the template part from the template-parts subdirectory of the theme for better file organisation. The usual parent/child theme hierarchy is respected.

get_extended_template_part( 'foo', 'bar' );

Use the $vars parameter to pass in an associative array of variables to the template part:

get_extended_template_part( 'foo', 'bar', [
	'my_variable' => 'Hello, world!',
] );

In your template-parts/foo-bar.php template part file, you can access the variables that you passed in by using $this->vars:

echo esc_html( $this->vars['my_variable'] );

Advanced Usage

The get_extended_template_part() function also accepts a second optional parameter that controls the directory name and caching.

The following code will load foo-bar.php from the my-directory subdirectory and automatically cache its output in a transient for one hour:

get_extended_template_part( 'foo', 'bar', [
	'my_variable' => 'Hello, world!',
], [
	'dir'   => 'my-directory',
	'cache' => 1 * HOUR_IN_SECONDS,
] );

License: GPLv2 or later

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].