Skip to content

Instantly share code, notes, and snippets.

@Sanabria
Last active March 18, 2022 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sanabria/24ea53654b1d91f1bcea0771a6feef6c to your computer and use it in GitHub Desktop.
Save Sanabria/24ea53654b1d91f1bcea0771a6feef6c to your computer and use it in GitHub Desktop.
/**
* Sage required files
*
* The mapped array determines the code library included in your theme.
* Add or remove files to the array as needed. Supports child theme overrides.
*/
array_map(function ($file) use ($sage_error) {
$file = "../app/{$file}.php";
if (!locate_template($file, true, true)) {
$sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file), 'File not found');
}
}, ['helpers', 'setup', 'filters', 'admin', 'shortcodes']); //add shortcodes to the required files array
<?php
// app/shortocodes.php
namespace App;
use App\Controllers\App;
/**
* Return if Shortcodes already exists.
*/
if (class_exists('Shortcodes')) {
return;
}
/**
* Shortcodes
*/
class Shortcodes
{
/**
* Constructor
*/
public function __construct()
{
$shortcodes = [
'calendario'
];
return collect($shortcodes)
->map(function ($shortcode) {
return add_shortcode($shortcode, [$this, strtr($shortcode, ['-' => '_'])]);
});
}
/**
* Calendar
* Loads the calendar event partial
*
* @param array $atts
* @param string $content
* @return string
*/
public function calendario($atts, $content = null)
{
return \App\template('partials.eventos', array('shortcode' => 'true'));
}
}
new Shortcodes();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment