PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.0.1
WP Coder – Insert & Manage Code Snippets v3.0.1
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
wp-coder / includes / class-wowp-public.php

class-wowp-public.php in WP Coder – Insert & Manage Code Snippets 3.0.1, at includes/class-wowp-public.php

56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }