| 1 |
<?php |
| 2 |
namespace EverCompare\Frontend; |
| 3 |
|
| 4 |
/** |
| 5 |
* Shortcode handler class |
| 6 |
*/ |
| 7 |
class Shortcode { |
| 8 |
|
| 9 |
/** |
| 10 |
* [$_instance] |
| 11 |
* @var null |
| 12 |
*/ |
| 13 |
private static $_instance = null; |
| 14 |
|
| 15 |
/** |
| 16 |
* [instance] Initializes a singleton instance |
| 17 |
* @return [Base] |
| 18 |
*/ |
| 19 |
public static function instance() { |
| 20 |
if ( is_null( self::$_instance ) ) { |
| 21 |
self::$_instance = new self(); |
| 22 |
} |
| 23 |
return self::$_instance; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Initializes the class |
| 28 |
*/ |
| 29 |
function __construct() { |
| 30 |
add_shortcode( 'evercompare_button', [ $this, 'button_shortcode' ] ); |
| 31 |
add_shortcode( 'evercompare_table', [ $this, 'table_shortcode' ] ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* [button_shortcode] Compare Button Shortcode callable function |
| 36 |
* @param [type] $atts |
| 37 |
* @param string $content |
| 38 |
* @return [HTML] |
| 39 |
*/ |
| 40 |
public function button_shortcode( $atts, $content = '' ){ |
| 41 |
wp_enqueue_style( 'evercompare-frontend' ); |
| 42 |
wp_enqueue_script( 'evercompare-frontend' ); |
| 43 |
return Manage_Compare::instance()->add_to_compare_btn(); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* [table_shortcode] Compare table shortcode callable function |
| 48 |
* @param [type] $atts |
| 49 |
* @param string $content |
| 50 |
* @return [HTML] |
| 51 |
*/ |
| 52 |
public function table_shortcode( $atts, $content = '' ){ |
| 53 |
wp_enqueue_style( 'evercompare-frontend' ); |
| 54 |
wp_enqueue_script( 'evercompare-frontend' ); |
| 55 |
return Manage_Compare::instance()->compare_table_shortcode(); |
| 56 |
} |
| 57 |
|
| 58 |
} |
| 59 |
|