PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.2.7
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.2.7
2.7.7 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 All 28 releases
← All changes | includes/shortcodes/shortcode-universal.php +26 -18 2.1.912.2.7 View file →
@@ -1,48 +1,56 @@
1 1 <?php
2 -
3 2 /**
4 3 * Universal Shortcode
5 4 */
5 +
6 +// Exit if accessed directly
7 +if ( ! defined( 'ABSPATH' ) ) {
8 + exit;
9 +}
10 +
6 11 class WINP_SnippetShortcodeUniversal extends WINP_SnippetShortcode {
7 -
12 +
8 13 public $shortcode_name = 'wbcr_snippet';
9 -
14 +
10 15 /**
11 16 * Content render
12 17 *
13 - * @param array $attr
18 + * @param array $attr
14 19 * @param string $content
20 + * @param string $tag
15 21 */
16 - public function html( $attr, $content ) {
22 + public function html( $attr, $content, $tag ) {
17 23 $id = $this->getSnippetId( $attr, WINP_SNIPPET_TYPE_UNIVERSAL );
18 -
24 +
19 25 if ( ! $id ) {
20 - echo '<span style="color:red">' . __( '[wbcr_snippet]: PHP snippets error (not passed the snippet ID)', 'insert-php' ) . '</span>';
21 -
26 + echo '<span style="color:red">' . __( '[' . esc_html( $tag ) . ']: PHP snippets error (not passed the snippet ID)', 'insert-php' ) . '</span>';
27 +
22 28 return;
23 29 }
24 -
30 +
31 + $snippet = get_post( $id );
25 32 $snippet_meta = get_post_meta( $id, '' );
26 - if ( empty( $snippet_meta ) ) {
33 +
34 + if ( ! $snippet || empty( $snippet_meta ) ) {
27 35 return;
28 36 }
29 -
37 +
30 38 $attr = $this->filterAttributes( $attr, $id );
31 -
39 +
32 40 // Let users pass arbitrary variables, through shortcode attributes.
33 41 // @since 2.0.5
34 42 extract( $attr, EXTR_SKIP );
35 -
43 +
36 44 $is_activate = $this->getSnippetActivate( $snippet_meta );
37 - $snippet_content = $this->getSnippetContent( $snippet_meta, $id );
45 + $snippet_content = $this->getSnippetContent( $snippet, $snippet_meta, $id );
38 46 $snippet_scope = $this->getSnippetScope( $snippet_meta );
39 47 $is_condition = WINP_Plugin::app()->getExecuteObject()->checkCondition( $id );
40 -
48 +
41 49 if ( ! $is_activate || empty( $snippet_content ) || $snippet_scope != 'shortcode' || ! $is_condition || WINP_Helper::is_safe_mode() ) {
42 50 return;
43 51 }
44 -
45 - eval( "?> " . $snippet_content . " <?php " );
52 +
53 + eval( "?>" . $snippet_content . "<?php " );
46 54 }
47 -
55 +
48 56 }