| @@ -19,12 +19,15 @@ | ||
| 19 | 19 | * @param string $content |
| 20 | 20 | * @param string $tag |
| 21 | 21 | */ |
| 22 | 22 | public function html( $attr, $content, $tag ) { |
| 23 | - $id = $this->getSnippetId( $attr, WINP_SNIPPET_TYPE_JS ); | |
| 23 | + $id = $this->get_snippet_id( $attr, WINP_SNIPPET_TYPE_JS ); | |
| 24 | 24 | |
| 25 | 25 | if ( ! $id ) { |
| 26 | - echo '<span style="color:red">' . __( '[' . esc_html( $tag ) . ']: PHP snippets error (not passed the snippet ID)', 'insert-php' ) . '</span>'; | |
| 26 | + if ( current_user_can( 'manage_options' ) || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) { | |
| 27 | + /* translators: %s: Shortcode tag name */ | |
| 28 | + echo '<span style="color:red">' . sprintf( esc_html__( '[%s]: PHP snippets error (not passed the snippet ID)', 'insert-php' ), esc_html( $tag ) ) . '</span>'; | |
| 29 | + } | |
| 27 | 30 | |
| 28 | 31 | return; |
| 29 | 32 | } |
| 30 | 33 | |
| @@ -34,28 +37,30 @@ | ||
| 34 | 37 | if ( ! $snippet || empty( $snippet_meta ) ) { |
| 35 | 38 | return; |
| 36 | 39 | } |
| 37 | 40 | |
| 38 | - $attrs = $this->filterAttributes( $attr, $id ); | |
| 41 | + $attrs = $this->filter_attributes( $attr, $id ); | |
| 39 | 42 | |
| 40 | 43 | // Let users pass arbitrary variables, through shortcode attributes. |
| 41 | 44 | // @since 2.4.0 |
| 42 | - $vars = ""; | |
| 45 | + $vars = ''; | |
| 43 | 46 | foreach ( $attrs as $var => $value ) { |
| 44 | - $vars .= PHP_EOL."var {$var} = \"{$value}\";"; | |
| 47 | + $vars .= PHP_EOL . "var {$var} = \"{$value}\";"; | |
| 45 | 48 | } |
| 46 | 49 | |
| 47 | 50 | |
| 48 | - $is_activate = $this->getSnippetActivate( $snippet_meta ); | |
| 49 | - $snippet_content = $this->getSnippetContent( $snippet, $snippet_meta, $id ); | |
| 50 | - $snippet_scope = $this->getSnippetScope( $snippet_meta ); | |
| 51 | - $is_condition = WINP_Plugin::app()->getExecuteObject()->checkCondition( $id ); | |
| 51 | + $is_activate = $this->get_snippet_activate( $snippet_meta ); | |
| 52 | + $snippet_content = $this->get_snippet_content( $snippet, $snippet_meta, $id ); | |
| 53 | + $snippet_scope = $this->get_snippet_scope( $snippet_meta ); | |
| 54 | + $is_condition = WINP_Plugin::app()->get_execute_object()->checkCondition( $id ); | |
| 52 | 55 | |
| 53 | 56 | if ( ! $is_activate || empty( $snippet_content ) || $snippet_scope != 'shortcode' || ! $is_condition ) { |
| 54 | 57 | return; |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | - echo "<script type='text/javascript'>{$vars}</script>"; //print attributes | |
| 60 | + // Track shortcode execution. | |
| 61 | + WINP_Plugin::app()->get_execute_object()->track_shortcode_snippet( $id ); | |
| 62 | + | |
| 63 | + echo "<script type='text/javascript'>{$vars}</script>"; // print attributes | |
| 58 | 64 | echo WINP_Execute_Snippet::getJsCssSnippetData( $id ); |
| 59 | 65 | } |
| 60 | - | |
| 61 | -} | |
| 66 | +} | |