| Server IP : 198.38.94.67 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64 User : azfilmst ( 1070) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/azfilmst/sunsetbarbers.ae/wp-content/plugins/edge-cpt/lib/ |
Upload File : |
<?php
namespace EdgeCore\Lib;
use EdgeCore\PostTypes\Portfolio;
use EdgeCore\PostTypes\Carousels;
use EdgeCore\PostTypes\Slider;
use EdgeCore\PostTypes\Testimonials;
/**
* Class ShortcodeLoader
* @package EdgeCore\Lib
*/
class ShortcodeLoader {
/**
* @var private instance of current class
*/
private static $instance;
/**
* @var array
*/
private $loadedShortcodes = array();
/**
* Private constuct because of Singletone
*/
private function __construct() {}
/**
* Returns current instance of class
* @return ShortcodeLoader
*/
public static function getInstance() {
if(self::$instance == null) {
return new self;
}
return self::$instance;
}
/**
* Adds new shortcode. Object that it takes must implement ShortcodeInterface
* @param ShortcodeInterface $shortcode
*/
private function addShortcode(ShortcodeInterface $shortcode) {
if(!array_key_exists($shortcode->getBase(), $this->loadedShortcodes)) {
$this->loadedShortcodes[$shortcode->getBase()] = $shortcode;
}
}
/**
* Adds all shortcodes.
*
* @see ShortcodeLoader::addShortcode()
*/
private function addShortcodes() {
$this->addShortcode(new Portfolio\Shortcodes\PortfolioList());
$this->addShortcode(new Portfolio\Shortcodes\PortfolioSlider());
$this->addShortcode(new Carousels\Shortcodes\Carousel());
$this->addShortcode(new Slider\Shortcodes\Slider());
$this->addShortcode(new Testimonials\Shortcodes\Testimonials());
}
/**
* Calls ShortcodeLoader::addShortcodes and than loops through added shortcodes and calls render method
* of each shortcode object
*/
public function load() {
$this->addShortcodes();
foreach ($this->loadedShortcodes as $shortcode) {
add_shortcode($shortcode->getBase(), array($shortcode, 'render'));
}
}
}