PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.0.4
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.0.4
2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 2.7.1 All 27 releases
insert-php / includes / shortcodes.php

shortcodes.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.0.4, at includes/shortcodes.php

55 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * A base shortcode for all lockers
5 *
6 * @since 1.0.0
7 */
8 class WINP_SnippetShortcode extends Wbcr_FactoryShortcodes321_Shortcode {
9
10 public $shortcode_name = 'wbcr_php_snippet';
11 // -------------------------------------------------------------------------------------
12 // Includes assets
13 // -------------------------------------------------------------------------------------
14
15 public $assets_in_header = true;
16
17 // -------------------------------------------------------------------------------------
18 // Content render
19 // -------------------------------------------------------------------------------------
20
21 public function html($attr, $content)
22 {
23 $id = isset($attr['id'])
24 ? (int)$attr['id']
25 : null;
26
27 if( !$id ) {
28 echo '<span style="color:red">' . __('[wbcr_php_snippet]: PHP snippets error (not passed the snippet ID)', 'insert-php') . '</span>';
29
30 return;
31 }
32
33 $snippet_meta = get_post_meta($id, '');
34
35 if( empty($snippet_meta) ) {
36 return;
37 }
38
39 $is_activate = isset($snippet_meta[$this->plugin->getPrefix() . 'snippet_activate']) && $snippet_meta[$this->plugin->getPrefix() . 'snippet_activate'][0];
40
41 $snippet_code = isset($snippet_meta[$this->plugin->getPrefix() . 'snippet_code'])
42 ? $snippet_meta[$this->plugin->getPrefix() . 'snippet_code']
43 : null;
44
45 $snippet_scope = isset($snippet_meta[$this->plugin->getPrefix() . 'snippet_scope'])
46 ? $snippet_meta[$this->plugin->getPrefix() . 'snippet_scope'][0]
47 : null;
48
49 if( !$is_activate || empty($snippet_code) || $snippet_scope != 'shortcode' ) {
50 return;
51 }
52
53 eval($snippet_code[0]);
54 }
55 }