PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.0.6
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.0.6
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.6, at includes/shortcodes.php

68 lines 1.6 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_FactoryShortcodes324_Shortcode {
9
10 public $shortcode_name = 'wbcr_php_snippet';
11
12 /**
13 * Includes assets
14 * @var bool
15 */
16 public $assets_in_header = true;
17
18 /**
19 * Content render
20 *
21 * @param array $attr
22 * @param string $content
23 */
24 public function html($attr, $content)
25 {
26 if( isset($attr['title']) ) {
27 unset($attr['title']);
28 }
29
30 $attr = array_map('sanitize_title', $attr);
31
32 // Let users pass arbitrary variables, through shortcode attributes.
33 // @since 2.0.5
34 extract($attr, EXTR_SKIP);
35
36 $id = isset($attr['id'])
37 ? (int)$attr['id']
38 : null;
39
40 if( !$id ) {
41 echo '<span style="color:red">' . __('[wbcr_php_snippet]: PHP snippets error (not passed the snippet ID)', 'insert-php') . '</span>';
42
43 return;
44 }
45
46 $snippet_meta = get_post_meta($id, '');
47
48 if( empty($snippet_meta) ) {
49 return;
50 }
51
52 $is_activate = isset($snippet_meta[$this->plugin->getPrefix() . 'snippet_activate']) && $snippet_meta[$this->plugin->getPrefix() . 'snippet_activate'][0];
53
54 $snippet_code = isset($snippet_meta[$this->plugin->getPrefix() . 'snippet_code'])
55 ? $snippet_meta[$this->plugin->getPrefix() . 'snippet_code']
56 : null;
57
58 $snippet_scope = isset($snippet_meta[$this->plugin->getPrefix() . 'snippet_scope'])
59 ? $snippet_meta[$this->plugin->getPrefix() . 'snippet_scope'][0]
60 : null;
61
62 if( !$is_activate || empty($snippet_code) || $snippet_scope != 'shortcode' ) {
63 return;
64 }
65
66 eval($snippet_code[0]);
67 }
68 }