Specifications", $rm); $rm = preg_replace ("/(\=\=)( )(Installation)( )(\=\=)/", "
tags for WP-Syntax.
if (function_exists ("wp_syntax_before_filter") && function_exists ("wp_syntax_before_filter"))
{
$rm = preg_replace ("/\\/i", '', $rm);
$rm = preg_replace ("/\<\/code\>\<\/pre\>/i", '', $rm);
$rm = wp_syntax_after_filter (wp_syntax_before_filter ($rm));
}
}
@ini_set ("pcre.backtrack_limit", $o_pcre);
$readme = '' . "\n";
$readme .= $rm . "\n"; // Content.
$readme .= '' . "\n";
return apply_filters("ws_plugin__s2member_parse_readme", $readme, get_defined_vars ());
}
else // Otherwise, we're going for the entire readme file. Here we have lots of work to do.
{
$rm = preg_replace ("/(\=\=\=)( )(.+?)( )(\=\=\=)/", "Specifications
", $rm);
$rm = preg_replace ("/(\=\=)( )(Installation)( )(\=\=)/", "$3
", $rm);
$rm = preg_replace ("/(\=\=)( )(Description)( )(\=\=)/", "$3
", $rm);
$rm = preg_replace ("/(\=\=)( )(Screenshots)( )(\=\=)/", "$3
", $rm);
$rm = preg_replace ("/(\=\=)( )(Frequently Asked Questions)( )(\=\=)/", "$3
", $rm);
$rm = preg_replace ("/(\=\=)( )(Changelog)( )(\=\=)/", "$3
", $rm);
$rm = preg_replace ("/(\=\=)( )(.+?)( )(\=\=)/", "$3
", $rm);
$rm = preg_replace ("/(\=)( )(.+?)( )(\=)/", "$3
", $rm);
$y1 = "/\[youtube http\:\/\/www\.youtube\.com\/view_play_list\?p\=(.+?)[\s\/]*?\]/i";
$y2 = "/\[youtube http\:\/\/www\.youtube\.com\/watch\?v\=(.+?)[\s\/]*?\]/i";
$rm = preg_replace ($y1, '', $rm);
$rm = preg_replace ($y2, '', $rm);
$rm = NC_Markdown ($rm); // Parse out the Markdown syntax.
$r1 = "/(\)(.+?)(\<\/h2\>)(.+?)(\|$)/si";
$r2 = "/(\<\/div\>)(\)(.+?)(\<\/h2\>)(.+?)(\\|$)/si";
$r3 = "/(\)(\)(Specifications)(\<\/h2\>)(\)(.+?)(\<\/div\>\<\/div\>)/sei";
$r4 = "/(\)(\)(Screenshots)(\<\/h2\>)(\)(.+?)(\<\/div\>\<\/div\>)/sei";
$r5 = "/(\' . "$1$3$4" . '' . "$5" . '' . "$6", $rm);
$rm = preg_replace ($r2, "$1" . '' . "$2$4$5" . '' . "$6" . '' . "$7", $rm);
$rm = stripslashes (preg_replace ($r3, "'$1$2$3$4$5'.c_ws_plugin__s2member_readmes::_parse_readme_specs('$6').'$7'", $rm, 1));
$rm = preg_replace ($r4, "", $rm, 1); // Here we just remove the screenshots completely.
if ($_blank_targets) // Modify all links. Always nofollow. ( with _blank targets ? ).
$rm = preg_replace ($r5, "$1" . ' target="_blank" rel="nofollow external"' . "$2", $rm);
else // Otherwise, we don't need to set _blank targets. So external is removed also.
$rm = preg_replace ($r5, "$1" . ' rel="nofollow"' . "$2", $rm);
if ($process_wp_syntax) // If we're processing tags for WP-Syntax.
if (function_exists ("wp_syntax_before_filter") && function_exists ("wp_syntax_before_filter"))
{
$rm = preg_replace ("/\\/i", '', $rm);
$rm = preg_replace ("/\<\/code\>\<\/pre\>/i", '', $rm);
$rm = wp_syntax_after_filter (wp_syntax_before_filter ($rm));
}
@ini_set ("pcre.backtrack_limit", $o_pcre);
$readme = '' . "\n";
$readme .= $rm . "\n"; // Content.
$readme .= '' . "\n";
return apply_filters("ws_plugin__s2member_parse_readme", $readme, get_defined_vars ());
}
}
else // Just in case readme.txt was deleted by the site owner.
{
return "Unable to parse /readme.txt.";
}
}
/**
* Callback parses specs in a readme file.
*
* @package s2Member\Readmes
* @since 3.5
*
* @param string $str A string *(i.e., the specs section)*.
* @return string Parsed specs. With HTML markup for list item display.
*/
public static function _parse_readme_specs ($str = FALSE)
{
do_action("_ws_plugin__s2member_before_parse_readme_specs", get_defined_vars ());
$str = preg_replace ("/(\|^)(.+?)(\:)( )(.+?)($|\<\/p\>)/mi", "$1" . '
' . "$2" . '' . "$3" . ' ' . "$5" . ' ' . "$6", $str);
$str = preg_replace ("/\\
/i", '- ', $str); // Open the list items.
$str = preg_replace ("/\<\/li\>\<\/p\>/i", '
', $str);
return apply_filters("_ws_plugin__s2member_parse_readme_specs", $str, get_defined_vars ());
}
/**
* Parses readme specification keys.
*
* @package s2Member\Readmes
* @since 3.5
*
* @param string $key A key *(within the specs section)*.
* @param string $specific_path Optional. Path to a specific readme file to parse. Defaults to that of the software itself.
* When/if a readme-dev.txt file is available, that will be used instead of the default readme.txt.
* @return string|bool The value of the key, else false if not found.
*/
public static function parse_readme_value ($key = '', $specific_path = '')
{
static $readme = array(); // For repeated lookups.
if (!($path = $specific_path)) // Was a specific path passed in?
{
$path = dirname (dirname (dirname (dirname (__FILE__)))) . "/readme.txt";
$dev_path = dirname (dirname (dirname (dirname (__FILE__)))) . "/readme-dev.txt";
$path = (file_exists ($dev_path)) ? $dev_path : $path;
}
foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
do_action("ws_plugin__s2member_before_parse_readme_value", get_defined_vars ());
unset($__refs, $__v);
if (!empty($readme[$path]) || file_exists ($path))
{
if (empty($readme[$path])) // If not already opened.
{
$readme[$path] = file_get_contents ($path); // Get readme.txt file contents.
$mb = function_exists ("mb_convert_encoding") ? @mb_convert_encoding ($readme[$path], "UTF-8", $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["mb_detection_order"]) : $readme[$path];
$readme[$path] = ($mb) ? $mb : $readme[$path]; // Double check this, just in case conversion fails on an unpredicted charset.
}
preg_match ("/(^)(" . preg_quote ($key, "/") . ")(\:)( )(.+?)($)/m", $readme[$path], $m);
return apply_filters("ws_plugin__s2member_parse_readme_value", ((isset ($m[5]) && strlen ($m[5] = trim ($m[5]))) ? $m[5] : false), get_defined_vars ());
}
return false;
}
}
}