parism5
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [WP-Syntax] [Plugin: WP-Syntax] [PATCH] Add "include" parameterConstantin Bosneaga!!
Your patch work just great!! Thanks a lot. I add a warning message if file not found:
--- wp-syntax.php.orig 2013-01-17 13:16:59.739527313 -0600 +++ wp-syntax.php 2013-01-18 11:00:33.664527445 -0600 @@ -59,7 +59,7 @@ if (!defined("WP_PLUGIN_URL")) define("WP_PLUGIN_URL", WP_CONTENT_URL . "/plugins"); function wp_syntax_change_mce_options($init) { - $ext = 'pre[id|name|class|style|lang|line|escaped|hightlight|src]'; + $ext = 'pre[id|name|class|style|lang|line|escaped|hightlight|src|include]'; if ( isset($init["extended_valid_elements"]) ) { @@ -166,7 +166,17 @@ $line = trim($match[2]); $escaped = trim($match[3]); $caption = wp_syntax_caption($match[5]); - $code = wp_syntax_code_trim($match[6]); + $include_file = wp_syntax_code_trim($match[6]); + $code = wp_syntax_code_trim($match[7]); + + if (!empty($include_file)) { + if (substr($include_file,0,4) == 'http') + $code = file_get_contents($include_file); + elseif (file_exists(ABSPATH.$include_file)) + $code = file_get_contents(ABSPATH.$include_file); + if(!$code) + $code="WARNING! file :".$include_file."\nNot found."; + } if ($escaped == 'true') $code = htmlspecialchars_decode($code); @@ -214,7 +224,7 @@ function wp_syntax_before_filter($content) { return preg_replace_callback( - "/\s*<pre(?:lang=[\"']([\w-]+)[\"']|line=[\"'](\d*)[\"']|escaped=[\"'](true|false)?[\"']|highlight=[\"']((?:\d+[,-])*\d+)[\"']|src=[\"']([^\"']+)[\"']|\s)+>(.*)<\/pre>\s*/siU", + "/\s*<pre(?:lang=[\"']([\w-]+)[\"']|line=[\"'](\d*)[\"']|escaped=[\"'](true|false)?[\"']|highlight=[\"']((?:\d+[,-])*\d+)[\"']|src=[\"']([^\"']+)[\"']|include=[\"']([^\"']+)[\"']|\s)+>(.*)<\/pre>\s*/siU", "wp_syntax_substitute", $content );
Forum: Plugins
In reply to: [WP-Syntax] Load fileThanks for add it to the feature request list, and thanks for the post of https://www.ads-software.com/support/topic/plugin-wp-syntax-patch-add-include-parameter.
I feel a little ashamed that I didn’t find it by my self, because it works just fine. My patch file for version 0.9.13 is at wp-syntax.patch. I just add a warning if file not found.
Viewing 2 replies - 1 through 2 (of 2 total)