1. Go to this page and download the library: Download moxie-lean/loader 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/ */
// File: partials/single.php
// All loaded files have an $args variable that is used to store all the params
// passed from where the Load function was used.
use Lean\Load;
$set_1 = [
'a' => 1,
'b' => 5,
'c' => 3
];
$set_2 = [
'a' => 10,
'd' => 3
];
$set_3 = [
'd' => 10,
'c' => 2,
'r' => 3,
];
// You can have as many sets as you want.
Load::partials( 'single', $set_1, $set_2, $set_3 )
// File: partials/single.php
// The following lines creates an array with default values. If those values
// are not specified when the file is loaded this values are going to be used instead.
$defaults = [
'url' => '',
'title' => '',
'target' => '_self',
]
// Update $args with the initial $args mixed with the $default values.
$args = wp_parse_args( $args, $defaults );
// File: partials/single.php
// The following lines creates an array with default values. If those values
// are not specified when the file is loaded this values are going to be used instead.
$defaults = [
'url' => '',
'title' => '',
'target' => '_self',
]
// Update $args with the initial $args mixed with the $default values.
$args = wp_parse_args( $args, $defaults );
// Don't render if the title or url are empty.
if ( empty( $args['title'] || empty( $args['url'] ) ) ) {
return;
}