| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPCoder; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || exit; |
| 6 |
|
| 7 |
use WPCoder\Dashboard\DBManager; |
| 8 |
use WPCoder\Publisher\Conditions; |
| 9 |
use WPCoder\Publisher\Display; |
| 10 |
use WPCoder\Publisher\EnqueueScript; |
| 11 |
use WPCoder\Publisher\EnqueueStyle; |
| 12 |
use WPCoder\Publisher\PageTemplate; |
| 13 |
use WPCoder\Publisher\Shortcodes; |
| 14 |
use WPCoder\Publisher\Singleton; |
| 15 |
|
| 16 |
class WOWP_Public { |
| 17 |
|
| 18 |
public function __construct() { |
| 19 |
add_shortcode( WOW_Plugin::SHORTCODE, [ $this, 'shortcode' ] ); |
| 20 |
} |
| 21 |
|
| 22 |
public function shortcode( $atts ) { |
| 23 |
$atts = shortcode_atts( |
| 24 |
[ 'id' => "", 'title' => '', ], |
| 25 |
$atts, |
| 26 |
WOW_Plugin::SHORTCODE |
| 27 |
); |
| 28 |
|
| 29 |
if ( ! empty( $atts['id'] ) ) { |
| 30 |
$result = DBManager::get_data_by_id( $atts['id'] ); |
| 31 |
} elseif ( ! empty( $atts['title'] ) ) { |
| 32 |
$result = DBManager::get_data_by_title( $atts['title'] ); |
| 33 |
} else { |
| 34 |
return false; |
| 35 |
} |
| 36 |
|
| 37 |
if ( empty( $result ) ) { |
| 38 |
return false; |
| 39 |
} |
| 40 |
|
| 41 |
if ( Conditions::init( $result ) === false ) { |
| 42 |
return false; |
| 43 |
} |
| 44 |
|
| 45 |
$html_code = $result->html_code; |
| 46 |
|
| 47 |
$singleton = Singleton::getInstance(); |
| 48 |
$singleton->setValue( $result->id, $result ); |
| 49 |
|
| 50 |
EnqueueStyle::init( $result ); |
| 51 |
EnqueueScript::init( $result ); |
| 52 |
|
| 53 |
return do_shortcode( $html_code ); |
| 54 |
} |
| 55 |
|
| 56 |
} |