| @@ -14,17 +14,18 @@ | ||
| 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_AD ); | |
| 23 | + $id = $this->get_snippet_id( $attr, WINP_SNIPPET_TYPE_AD ); | |
| 24 | 24 | |
| 25 | - if( !$id ) { | |
| 26 | - echo '<span style="color:red">' . __('[' . esc_html( $tag ) . ']: Advertisement snippets error (not passed the snippet ID)', 'insert-php') . '</span>'; | |
| 25 | + if ( ! $id ) { | |
| 26 | + /* translators: %s: Shortcode tag name */ | |
| 27 | + echo '<span style="color:red">' . sprintf( esc_html__( '[%s]: Advertisement snippets error (not passed the snippet ID)', 'insert-php' ), esc_html( $tag ) ) . '</span>'; | |
| 27 | 28 | |
| 28 | 29 | return; |
| 29 | 30 | } |
| 30 | 31 | |
| @@ -34,21 +35,30 @@ | ||
| 34 | 35 | if ( ! $snippet || empty( $snippet_meta ) ) { |
| 35 | 36 | return; |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | - $is_activate = $this->getSnippetActivate( $snippet_meta ); | |
| 39 | - $snippet_scope = $this->getSnippetScope( $snippet_meta ); | |
| 40 | - $is_condition = WINP_Plugin::app()->getExecuteObject()->checkCondition( $id ); | |
| 39 | + $is_activate = $this->get_snippet_activate( $snippet_meta ); | |
| 40 | + $snippet_scope = $this->get_snippet_scope( $snippet_meta ); | |
| 41 | + $is_condition = WINP_Plugin::app()->get_execute_object()->checkCondition( $id ); | |
| 41 | 42 | |
| 42 | 43 | if ( ! $is_activate || $snippet_scope != 'shortcode' || ! $is_condition ) { |
| 43 | 44 | return; |
| 44 | 45 | } |
| 45 | 46 | |
| 47 | + // Track shortcode execution. | |
| 48 | + WINP_Plugin::app()->get_execute_object()->track_shortcode_snippet( $id ); | |
| 49 | + | |
| 46 | 50 | $post_content = $snippet->post_content; |
| 47 | - if ( WINP_Plugin::app()->getOption( 'execute_shortcode' ) ) { | |
| 51 | + if ( get_option( 'wbcr_inp_execute_shortcode' ) ) { | |
| 48 | 52 | $post_content = do_shortcode( $post_content ); |
| 49 | 53 | } |
| 50 | 54 | |
| 55 | + /** | |
| 56 | + * Shortcode content filter | |
| 57 | + * | |
| 58 | + * @since 2.4.4 | |
| 59 | + */ | |
| 60 | + $post_content = apply_filters( 'wbcr/inp/snippet/shortcode_ad/post_content', $post_content, $id ); | |
| 61 | + | |
| 51 | 62 | echo str_replace( '{{SNIPPET_CONTENT}}', $content, $post_content ); |
| 52 | 63 | } |
| 53 | - | |
| 54 | -} | |
| 64 | +} | |