Created
February 27, 2014 08:14
-
-
Save victorjonsson/9246285 to your computer and use it in GitHub Desktop.
arlima, inline-articles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$current_renderer = false; | |
// Always catch which renderer that is at work | |
add_action('arlima_list_begin', function($renderer) use($current_renderer) { | |
$current_renderer = $renderer; | |
}); | |
// Move "children" into "inline-children" and create their template object | |
add_filter('arlima_template_object', function($tmpl_data, $article, $list, $context) use($current_renderer) { | |
if( $context == 'creating-inline-child' ) | |
return $tmpl_data; | |
if( article-template-support-inline-childs ) { | |
$obj_creator = $current_renderer->getTemplateObjectCreator(); | |
if( !empty($tmpl_data['children']) ) { | |
$tmpl_data['inline_children'] = array(); | |
foreach( $tmpl_data['children'] as $child ) { | |
$tmpl_data['inline_children'][] = $obj_creator->create($child, false, get_post($child['post']), 0, false, 'creating-inline-child'); | |
} | |
unset($tmpl_data['children']); | |
} | |
} | |
return $tmpl_data; | |
}, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment