q2a/question2answer — pull request #36 by pupi1985 (2014-02-20 20:50:13+00:00)
Title: Improvements to the update feature

I've created a few commits regarding the update feature (except the first one which is trivial but not less necessary).

48af2fb: This commit basically removes duplicated code
e9b604f: This commit is an upgrade to the previous one. It modifies how `qa_admin_addon_metadata` is extracting data, removes the replacement of spaces with `\s*`, removes the requested fields and absolutely forgets about having to parse things like `Plugin Minimum Question2Answer Version`.

The parsing process first looks for a given tag (eg: `[metadata]`) and fetches all information from it. This has the advantage that if the file contains a few not found keys then instead to having to parse the whole file to find out the keys are not there that would only happen twice. Secondly, returning just the matched `[metadata]` tag reduces the whole matching domain letting future searches run faster.

The matching logic for each value is replaced by using inner tags such as `[php_version]`. Each of those inner tags will be the keys returned. That means that instead of asking the function under what key you want to find a given field you will get all keys at once and the keys will be defined by whatever is between square brackets the file qa-plugin.php or theme file itself. Of course, corresponding values will also be returned making sure whitespace (spaces and tabs) trimmed values are not empty. If they are, they won't be included in the array.