protected function preProcessBookContents($book_contents) { // We need to change global $id for shortcodes, the_content, ... global $id; $old_id = $id; // Do root level structures first. foreach ($book_contents as $type => $struct) { if (preg_match('/^__/', $type)) { continue; // Skip __magic keys } foreach ($struct as $i => $val) { if (isset($val['post_content'])) { // @codingStandardsIgnoreLine $id = $val['ID']; $book_contents[$type][$i]['post_content'] = $this->preProcessPostContent($val['post_content']); } if (isset($val['post_title'])) { $book_contents[$type][$i]['post_title'] = Sanitize\sanitize_xml_attribute($val['post_title']); } if (isset($val['post_name'])) { $book_contents[$type][$i]['post_name'] = $this->preProcessPostName($val['post_name']); } if ('part' == $type) { // Do chapters, which are embedded in part structure foreach ($book_contents[$type][$i]['chapters'] as $j => $val2) { if (isset($val2['post_content'])) { // @codingStandardsIgnoreLine $id = $val2['ID']; $book_contents[$type][$i]['chapters'][$j]['post_content'] = $this->preProcessPostContent($val2['post_content']); } if (isset($val2['post_title'])) { $book_contents[$type][$i]['chapters'][$j]['post_title'] = Sanitize\sanitize_xml_attribute($val2['post_title']); } if (isset($val2['post_name'])) { $book_contents[$type][$i]['chapters'][$j]['post_name'] = $this->preProcessPostName($val2['post_name']); } } } } } // @codingStandardsIgnoreLine $id = $old_id; return $book_contents; }