PluginProbe
WP Coder – Insert & Manage Code Snippets / 3.0.3
WP Coder – Insert & Manage Code Snippets v3.0.3
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.3, at includes/class-wowp-public.php

70 lines 1.5 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 add_action( 'wp_footer', [ $this, 'print_footer' ], 50 );
21 }
22
23 public function shortcode( $atts ) {
24 $atts = shortcode_atts(
25 [ 'id' => "", 'title' => '', ],
26 $atts,
27 WOW_Plugin::SHORTCODE
28 );
29
30 if ( ! empty( $atts['id'] ) ) {
31 $result = DBManager::get_data_by_id( $atts['id'] );
32 } elseif ( ! empty( $atts['title'] ) ) {
33 $result = DBManager::get_data_by_title( $atts['title'] );
34 } else {
35 return false;
36 }
37
38 if ( empty( $result ) ) {
39 return false;
40 }
41
42 if ( Conditions::init( $result ) === false ) {
43 return false;
44 }
45
46 $html_code = $result->html_code;
47
48 $singleton = Singleton::getInstance();
49 $singleton->setValue( $result->id, $result );
50
51 EnqueueStyle::init( $result );
52 EnqueueScript::init( $result );
53
54 return do_shortcode( $html_code );
55 }
56
57 public function print_footer() {
58 $singleton = Singleton::getInstance();
59 $shortcodes = $singleton->getValue();
60
61 foreach ($shortcodes as $id => $result) {
62 EnqueueStyle::inline( $result );
63 EnqueueScript::inline( $result );
64 }
65
66
67 }
68
69
70 }