', $pee); $last_pee = array_pop($pee_parts); $pee = ''; $i = 0; foreach ($pee_parts as $pee_part) { $start = strpos($pee_part, ''; $pee .= substr($pee_part, 0, $start) . $name; $i++; } $pee .= $last_pee; } /* * Shortcodes shouldn't be touched by autop. * Replace pre tags with placeholders and bring them back after autop. */ foreach ($chiedolabs_wpautop_shortcodes_to_ignore as $shortcode) { if (strpos($pee, "[$shortcode") !== false) { $pee_parts = explode("[/$shortcode]", $pee); $last_pee = array_pop($pee_parts); $pee = ''; $i = 0; foreach ($pee_parts as $pee_part) { $start = strpos($pee_part, "[$shortcode"); // Malformed html? if ($start === false) { $pee .= $pee_part; continue; } $name = "[$shortcode wp-$shortcode-tag-$i][/$shortcode]"; $shortcode_tags[$name] = substr($pee_part, $start) . "[/$shortcode]"; $pee .= substr($pee_part, 0, $start) . $name; $i++; } $pee .= $last_pee; } } // Change multiple
s into two line breaks, which will turn into paragraphs. $pee = preg_replace('|\s*|', "\n\n", $pee); $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; // Add a single line break above block-level opening tags. $pee = preg_replace('!(<' . $allblocks . '[\s/>])!', "\n$1", $pee); // Add a double line break below block-level closing tags. $pee = preg_replace('!()!', "$1\n\n", $pee); // Standardize newline characters to "\n". $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // Find newlines in all elements and add placeholders. $pee = wp_replace_in_html_tags($pee, array("\n" => " ")); // Collapse line breaks before and after ', $pee); } /* * Collapse line breaks inside elements, before and elements * so they don't get autop'd. */ if (strpos($pee, '') !== false) { $pee = preg_replace('|(]*>)\s*|', '$1', $pee); $pee = preg_replace('|\s*|', '', $pee); $pee = preg_replace('%\s*(]*>)\s*%', '$1', $pee); } /* * Collapse line breaks inside