| @@ -1,59 +1,49 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Text Shortcode | |
| 4 | - */ | |
| 5 | - | |
| 6 | -// Exit if accessed directly | |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 8 | - exit; | |
| 9 | -} | |
| 10 | - | |
| 11 | -class WINP_SnippetShortcodeText extends WINP_SnippetShortcode { | |
| 12 | - | |
| 13 | - public $shortcode_name = 'wbcr_text_snippet'; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * Content render | |
| 17 | - * | |
| 18 | - * @param array $attr | |
| 19 | - * @param string $content | |
| 20 | - * @param string $tag | |
| 21 | - */ | |
| 22 | - public function html( $attr, $content, $tag ) { | |
| 23 | - $id = $this->getSnippetId( $attr, WINP_SNIPPET_TYPE_TEXT ); | |
| 24 | - | |
| 25 | - if ( ! $id ) { | |
| 26 | - echo '<span style="color:red">' . __( '[' . esc_html( $tag ) . ']: Text snippets error (not passed the snippet ID)', 'insert-php' ) . '</span>'; | |
| 27 | - | |
| 28 | - return; | |
| 29 | - } | |
| 30 | - | |
| 31 | - $snippet = get_post( $id ); | |
| 32 | - $snippet_meta = get_post_meta( $id, '' ); | |
| 33 | - | |
| 34 | - if ( ! $snippet || empty( $snippet_meta ) ) { | |
| 35 | - return; | |
| 36 | - } | |
| 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 | - | |
| 42 | - if ( ! $is_activate || $snippet_scope != 'shortcode' || ! $is_condition ) { | |
| 43 | - return; | |
| 44 | - } | |
| 45 | - | |
| 46 | - $post_content = $snippet->post_content; | |
| 47 | - if ( WINP_Plugin::app()->getOption( 'execute_shortcode' ) ) { | |
| 48 | - $post_content = do_shortcode( $post_content ); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * Shortcode content filter | |
| 53 | - * @since 2.4.4 | |
| 54 | - */ | |
| 55 | - $post_content = apply_filters('wbcr/inp/snippet/shortcode_text/post_content', $post_content, $id); | |
| 56 | - | |
| 57 | - echo str_replace( '{{SNIPPET_CONTENT}}', $content, $post_content ); | |
| 58 | - } | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Text Shortcode | |
| 4 | + */ | |
| 5 | + | |
| 6 | +// Exit if accessed directly | |
| 7 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 8 | + exit; | |
| 9 | +} | |
| 10 | + | |
| 11 | +class WINP_SnippetShortcodeText extends WINP_SnippetShortcode { | |
| 12 | + | |
| 13 | + public $shortcode_name = 'wbcr_text_snippet'; | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * Content render | |
| 17 | + * | |
| 18 | + * @param array $attr | |
| 19 | + * @param string $content | |
| 20 | + * @param string $tag | |
| 21 | + */ | |
| 22 | + public function html( $attr, $content, $tag ) { | |
| 23 | + $id = $this->getSnippetId( $attr, WINP_SNIPPET_TYPE_TEXT ); | |
| 24 | + | |
| 25 | + if( !$id ) { | |
| 26 | + echo '<span style="color:red">' . __('[' . esc_html( $tag ) . ']: Text snippets error (not passed the snippet ID)', 'insert-php') . '</span>'; | |
| 27 | + | |
| 28 | + return; | |
| 29 | + } | |
| 30 | + | |
| 31 | + $snippet = get_post( $id ); | |
| 32 | + $snippet_meta = get_post_meta( $id, '' ); | |
| 33 | + | |
| 34 | + if ( ! $snippet || empty( $snippet_meta ) ) { | |
| 35 | + return; | |
| 36 | + } | |
| 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 | + | |
| 42 | + if ( ! $is_activate || $snippet_scope != 'shortcode' || ! $is_condition ) { | |
| 43 | + return; | |
| 44 | + } | |
| 45 | + | |
| 46 | + echo str_replace( '{{SNIPPET_CONTENT}}', $content, do_shortcode( $snippet->post_content ) ); | |
| 47 | + } | |
| 48 | + | |
| 59 | 49 | } |