Commit 499810bc authored by Penny Leach's avatar Penny Leach
Browse files

make the template parser a little less strict

parent abb54f7e
......@@ -91,26 +91,19 @@ function template_parse_block($blockstr) {
}
function template_validate_block($data, $name='') {
function template_validate_block(&$data, $name='') {
$type = isset($data[$name . 'type']) ? $data[$name . 'type'] : '';
$format = isset($data[$name . 'format']) ? $data[$name . 'format'] : '';
$type &= (isset($data[$name . 'type']) ? $data[$name . 'type'] : '');
$format &= (isset($data[$name . 'format']) ? $data[$name . 'format'] : '');
if (!empty($type)) {
if (empty($format)) {
throw new InvalidArgumentException("Cannot specify {$name}type without ($name}format");
}
}
if (!empty($format) && $format != 'label') {
if (empty($type)) {
throw new InvalidArgumentException("Cannot specify {$name}format without {$name}type");
}
}
if ((empty($format) && empty($type)) || $format == 'label') { // labels are special cases
return true;
}
// if we've got type but no format and we're looking at defaults, use main format.
if (!empty($type) && empty($format) && $name == 'default' && !empty($data['format'])) {
$format = $data['format'];
}
// figure out what plugin handles this type and validate the class exists.
if (!$plugin = get_field('artefact_installed_type', 'plugin', 'name', $type)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment