Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ConditionalTagCheck and usage docs #1365

Merged
merged 1 commit into from
Mar 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/conditional-tag-check.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ public function __construct($conditionals = []) {
}
}

private function checkConditionalTag($conditional_tag) {
$conditional_arg = is_array($conditional_tag) ? $conditional_tag[1] : false;
$conditional_tag = $conditional_arg ? $conditional_tag[0] : $conditional_tag;
private function checkConditionalTag($conditional) {
if (is_array($conditional)) {
list($tag, $args) = $conditional;
} else {
$tag = $conditional;
$args = false;
}

if (function_exists($conditional_tag)) {
return $conditional_arg ? $conditional_tag($conditional_arg) : $conditional_tag();
if (function_exists($tag)) {
return $args ? $tag($args) : $tag();
} else {
return false;
}
Expand Down
14 changes: 5 additions & 9 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,22 @@ function display_sidebar() {
* Any of these conditional tags that return true won't show the sidebar.
* You can also specify your own custom function as long as it returns a boolean.
*
* To use a function that accepts arguments, use the following format:
*
* ['function_name', ['arg1', 'arg2']]
*
* Note: The second element must be an array even if there's only 1 argument.
* To use a function that accepts arguments, use an array instead of just the function name as a string.
*
* Examples:
*
* 'is_single'
* 'is_archive'
* ['is_page', ['about-me']]
* ['is_page', 'about-me']
* ['is_tax', ['flavor', 'mild']]
* ['is_page_template', ['about.php']]
* ['is_post_type_archive', [['foo', 'bar', 'baz']]]
* ['is_page_template', 'about.php']
* ['is_post_type_archive', ['foo', 'bar', 'baz']]
*
*/
[
'is_404',
'is_front_page',
['is_page_template', ['template-custom.php']]
['is_page_template', 'template-custom.php']
]
);

Expand Down