| @@ -8,47 +8,59 @@ | ||
| 8 | 8 | exit; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | class WINP_SnippetShortcodeText extends WINP_SnippetShortcode { |
| 12 | - | |
| 12 | + | |
| 13 | 13 | public $shortcode_name = 'wbcr_text_snippet'; |
| 14 | - | |
| 14 | + | |
| 15 | 15 | /** |
| 16 | 16 | * Content render |
| 17 | 17 | * |
| 18 | - * @param array $attr | |
| 18 | + * @param array $attr | |
| 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_TEXT ); | |
| 23 | + $id = $this->get_snippet_id( $attr, WINP_SNIPPET_TYPE_TEXT ); | |
| 24 | 24 | |
| 25 | - if( !$id ) { | |
| 26 | - echo '<span style="color:red">' . __('[' . esc_html( $tag ) . ']: Text snippets error (not passed the snippet ID)', 'insert-php') . '</span>'; | |
| 25 | + if ( ! $id ) { | |
| 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]: Text snippets error (not passed the snippet ID)', 'insert-php' ), esc_html( $tag ) ) . '</span>'; | |
| 29 | + } | |
| 27 | 30 | |
| 28 | 31 | return; |
| 29 | 32 | } |
| 30 | - | |
| 33 | + | |
| 31 | 34 | $snippet = get_post( $id ); |
| 32 | 35 | $snippet_meta = get_post_meta( $id, '' ); |
| 33 | - | |
| 36 | + | |
| 34 | 37 | if ( ! $snippet || empty( $snippet_meta ) ) { |
| 35 | 38 | return; |
| 36 | 39 | } |
| 37 | - | |
| 38 | - $is_activate = $this->getSnippetActivate( $snippet_meta ); | |
| 39 | - $snippet_scope = $this->getSnippetScope( $snippet_meta ); | |
| 40 | - $is_condition = WINP_Plugin::app()->getExecuteObject()->checkCondition( $id ); | |
| 41 | - | |
| 40 | + | |
| 41 | + $is_activate = $this->get_snippet_activate( $snippet_meta ); | |
| 42 | + $snippet_scope = $this->get_snippet_scope( $snippet_meta ); | |
| 43 | + $is_condition = WINP_Plugin::app()->get_execute_object()->checkCondition( $id ); | |
| 44 | + | |
| 42 | 45 | if ( ! $is_activate || $snippet_scope != 'shortcode' || ! $is_condition ) { |
| 43 | 46 | return; |
| 44 | 47 | } |
| 45 | 48 | |
| 49 | + // Track shortcode execution. | |
| 50 | + WINP_Plugin::app()->get_execute_object()->track_shortcode_snippet( $id ); | |
| 51 | + | |
| 46 | 52 | $post_content = $snippet->post_content; |
| 47 | - if ( WINP_Plugin::app()->getOption( 'execute_shortcode' ) ) { | |
| 53 | + if ( get_option( 'wbcr_inp_execute_shortcode' ) ) { | |
| 48 | 54 | $post_content = do_shortcode( $post_content ); |
| 49 | 55 | } |
| 50 | 56 | |
| 51 | - echo str_replace( '{{SNIPPET_CONTENT}}', $content, $post_content ); | |
| 57 | + /** | |
| 58 | + * Shortcode content filter | |
| 59 | + * | |
| 60 | + * @since 2.4.4 | |
| 61 | + */ | |
| 62 | + $post_content = apply_filters( 'wbcr/inp/snippet/shortcode_text/post_content', $post_content, $id ); | |
| 63 | + | |
| 64 | + echo wp_kses_post( wpautop( str_replace( '{{SNIPPET_CONTENT}}', $content, $post_content ) ) ); | |
| 52 | 65 | } |
| 53 | - | |
| 54 | -} | |
| 66 | +} | |