PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.7.9
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.7.9
2.7.9 2.7.8 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 All 30 releases
← All changes | includes/shortcodes/shortcodes.php +35 -3 2.7.6 → 2.7.9 View file →
@@ -80,11 +80,20 @@
80 80 *
81 81 * @return string
82 82 */
83 83 public function render( $attr, $content, $tag ) {
84 + if ( WINP_Helper::is_safe_mode() ) {
85 + return '';
86 + }
87 +
84 88 ob_start();
85 - $this->html( $attr, $content ?? '', $tag );
86 - $html = ob_get_clean();
89 + $result = $this->html( $attr, $content ?? '', $tag );
90 + $html = ob_get_clean();
91 +
92 + if ( is_string( $result ) ) {
93 + $html = ( false !== $html ? $html : '' ) . $result;
94 + }
95 +
87 96 return false !== $html ? $html : '';
88 97 }
89 98
90 99 /**
@@ -220,8 +229,31 @@
220 229 return WINP_Plugin::app()->get_execute_object()->prepareCode( $snippet_code, $id );
221 230 }
222 231
223 232 /**
233 + * Report a top-level declaration the snippet would redeclare instead of evaluating it.
234 + *
235 + * Repeated placements of one snippet re-evaluate it, and a redeclaration inside
236 + * eval() ends the request. Clears the current snippet context when reporting.
237 + *
238 + * @param string $snippet_content Snippet code.
239 + * @param string $snippet_type Snippet type.
240 + *
241 + * @return string|null Error output, or null when the snippet can be evaluated.
242 + */
243 + protected function render_redeclaration_error( string $snippet_content, string $snippet_type ): ?string {
244 + $redeclaration_error = WINP_Code_Validator::get_redeclaration_error( $snippet_content, $snippet_type );
245 + if ( null === $redeclaration_error ) {
246 + return null;
247 + }
248 +
249 + $error_output = WINP_Error_Handler::handle_exception( $redeclaration_error );
250 + WINP_Error_Handler::clear_current_snippet();
251 +
252 + return $error_output;
253 + }
254 +
255 + /**
224 256 * Content render
225 257 *
226 258 * @param array<string, mixed> $attr Shortcode attributes.
227 259 * @param string $content Shortcode content.
@@ -226,9 +258,9 @@
226 258 * @param array<string, mixed> $attr Shortcode attributes.
227 259 * @param string $content Shortcode content.
228 260 * @param string $tag Shortcode tag.
229 261 *
230 - * @return void
262 + * @return mixed Rendered content when returned directly, if any.
231 263 */
232 264 public function html( $attr, $content, $tag ) {
233 265 }
234 266 }