protected function generate_part_contents($post_id, $options, $templates, $parts = false, $properties = array()) { //Prepare the parts before rendering if (!$parts) { $parts = array(); foreach (Upfront_ThisPostView::$PARTNAMES as $slug) { array_push($parts, array('slug' => $slug, 'options' => isset($options[$slug]) ? $options[$slug] : array())); } } $post = !empty($post_id) && is_numeric($post_id) ? get_post($post_id) : apply_filters('upfront-this_post-unknown_post', (object) array(), array('post_id' => $post_id)); $tpls = array(); $replacements = array(); $classes = array(); $post_data = Upfront_ThisPostView::prepare_post($post); foreach ($parts as $part) { $slug = $part['slug']; $part_options = !empty($part['options']) ? $part['options'] : array(); // This is for editor $contents = Upfront_ThisPostView::get_post_part($slug, $part_options, isset($templates[$slug]) ? $templates[$slug] : '', $properties); $tpls[$slug] = $contents['tpl']; $classes[$slug] = $contents['classes']; $replacements = array_merge($replacements, $contents['replacements']); if ($slug == 'contents') { $replacements['%raw_content%'] = wpautop($post->post_content); $replacements['%raw_excerpt%'] = wpautop(get_the_excerpt()); } } $output = array('tpls' => $tpls, 'replacements' => $replacements, 'classes' => $classes); return $output; }