Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
bf4007d6
Commit
bf4007d6
authored
Mar 20, 2014
by
Scott Vivian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small optimization for qa_addon_metadata
parent
4aef3f2c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
qa-base.php
qa-include/qa-base.php
+11
-6
No files found.
qa-include/qa-base.php
View file @
bf4007d6
...
@@ -272,13 +272,19 @@
...
@@ -272,13 +272,19 @@
}
}
function
qa_addon_metadata
(
$contents
,
$type
)
function
qa_addon_metadata
(
$contents
,
$type
,
$versiononly
=
false
)
/*
/*
Retrieve metadata information from the $contents of a qa-theme.php or qa-plugin.php file, specified by $type ('Plugin' or 'Theme').
Retrieve metadata information from the $contents of a qa-theme.php or qa-plugin.php file, specified by $type ('Plugin' or 'Theme').
If $versiononly is true, only version metadata is parsed.
Name, Description, Min Q2A & Min PHP are not currently used by themes.
Name, Description, Min Q2A & Min PHP are not currently used by themes.
*/
*/
{
{
$fields
=
array
(
$fields
=
array
(
'min_q2a'
=>
'Minimum Question2Answer Version'
,
'min_php'
=>
'Minimum PHP Version'
,
);
if
(
!
$versiononly
)
{
$fields
=
array_merge
(
$fields
,
$fields
=
array
(
'name'
=>
'Name'
,
'name'
=>
'Name'
,
'uri'
=>
'URI'
,
'uri'
=>
'URI'
,
'description'
=>
'Description'
,
'description'
=>
'Description'
,
...
@@ -287,12 +293,11 @@
...
@@ -287,12 +293,11 @@
'author'
=>
'Author'
,
'author'
=>
'Author'
,
'author_uri'
=>
'Author URI'
,
'author_uri'
=>
'Author URI'
,
'license'
=>
'License'
,
'license'
=>
'License'
,
'min_q2a'
=>
'Minimum Question2Answer Version'
,
'min_php'
=>
'Minimum PHP Version'
,
'update'
=>
'Update Check URI'
,
'update'
=>
'Update Check URI'
,
);
)
);
$metadata
=
array
();
}
$metadata
=
array
();
foreach
(
$fields
as
$key
=>
$field
)
{
foreach
(
$fields
as
$key
=>
$field
)
{
// prepend 'Theme'/'Plugin' and search for key data
// prepend 'Theme'/'Plugin' and search for key data
$fieldregex
=
str_replace
(
' '
,
'[ \t]*'
,
preg_quote
(
"
$type
$field
"
,
'/'
));
$fieldregex
=
str_replace
(
' '
,
'[ \t]*'
,
preg_quote
(
"
$type
$field
"
,
'/'
));
...
@@ -316,7 +321,7 @@
...
@@ -316,7 +321,7 @@
foreach
(
$pluginfiles
as
$pluginfile
)
{
foreach
(
$pluginfiles
as
$pluginfile
)
{
// limit plugin parsing to first 8kB
// limit plugin parsing to first 8kB
$contents
=
file_get_contents
(
$pluginfile
,
false
,
NULL
,
-
1
,
8192
);
$contents
=
file_get_contents
(
$pluginfile
,
false
,
NULL
,
-
1
,
8192
);
$metadata
=
qa_addon_metadata
(
$contents
,
'Plugin'
);
$metadata
=
qa_addon_metadata
(
$contents
,
'Plugin'
,
true
);
// skip plugin which requires a later version of Q2A
// skip plugin which requires a later version of Q2A
if
(
isset
(
$metadata
[
'min_q2a'
])
&&
qa_qa_version_below
(
$metadata
[
'min_q2a'
]))
if
(
isset
(
$metadata
[
'min_q2a'
])
&&
qa_qa_version_below
(
$metadata
[
'min_q2a'
]))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment