| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shortcodes Class. |
| 4 |
* |
| 5 |
* This class contains all the Shortcodes. |
| 6 |
* |
| 7 |
* @package RadiusTheme\SB |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace RadiusTheme\SB\Controllers; |
| 11 |
|
| 12 |
use RadiusTheme\SB\Traits\SingletonTrait; |
| 13 |
|
| 14 |
// Do not allow directly accessing this file. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit( 'This script cannot be accessed directly.' ); |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Shortcodes Class. |
| 21 |
*/ |
| 22 |
class Shortcodes { |
| 23 |
/** |
| 24 |
* Singleton Trait |
| 25 |
*/ |
| 26 |
use SingletonTrait; |
| 27 |
|
| 28 |
/** |
| 29 |
* Class Constructor. |
| 30 |
*/ |
| 31 |
private function __construct() { |
| 32 |
add_action( 'init', [ $this, 'register_shortcodes' ] ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Accumulates all the shortcode classes inside an array |
| 37 |
* |
| 38 |
* @return void |
| 39 |
* @since 1.0.0 |
| 40 |
*/ |
| 41 |
public function register_shortcodes() { |
| 42 |
$shortcodes_list = []; |
| 43 |
$shortcodes = apply_filters( 'rtsb/elements/shortcodes', $shortcodes_list ); |
| 44 |
|
| 45 |
if ( ! empty( $shortcodes ) && is_array( $shortcodes ) ) { |
| 46 |
foreach ( $shortcodes as $shortcode ) { |
| 47 |
if ( ! is_object( $shortcode ) && class_exists( $shortcode ) && method_exists( $shortcode, 'instance' ) ) { |
| 48 |
$shortcode::instance(); |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|