Changeset 3825 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php
- Timestamp:
- 08/18/2016 01:17:38 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php
r3795 r3825 198 198 199 199 /** 200 * Temporary FAQ parser until we have all readmes re-imported. 201 * 202 * @param $content 203 * @param $section_slug 204 * 205 * @return string 206 */ 207 function temporary_faq_parser( $content, $section_slug ) { 208 if ( 'faq' !== $section_slug ) { 209 return $content; 210 } 211 212 if ( strpos( $content, '</dl>' ) ) { 213 return $content; 214 } 215 216 $lines = explode( "\n", $content ); 217 $definition = false; 218 219 $content = "<dl>\n"; 220 while ( ( $line = array_shift( $lines ) ) !== null ) { 221 $trimmed = trim( $line ); 222 if ( empty( $trimmed ) ) { 223 continue; 224 } 225 226 if ( 0 === strpos( $trimmed, '<h4>' ) ) { 227 if ( $definition ) { 228 $content .= "</dd>\n"; 229 $definition = false; 230 } 231 232 $content .= '<dt aria-expanded="false">' . strip_tags( $line ) . "</dt>\n"; 233 continue; 234 } 235 236 if ( ! $definition ) { 237 $content .= '<dd>' . $line; 238 $definition = true; 239 continue; 240 } 241 242 $content .= "\n" . $line; 243 } 244 245 $content .= "</dd>\n</dl>"; 246 247 if ( ! strpos( $content, '</dt>' ) ) { 248 $content = wp_kses( $content, array( 249 'a' => array( 250 'href' => true, 251 'title' => true, 252 'rel' => true, 253 ), 254 'blockquote' => array( 255 'cite' => true 256 ), 257 'br' => true, 258 'p' => true, 259 'code' => true, 260 'pre' => true, 261 'em' => true, 262 'strong' => true, 263 'ul' => true, 264 'ol' => true, 265 'li' => true, 266 'h3' => true, 267 'h4' => true, 268 ) ); 269 } 270 271 return $content; 272 } 273 add_filter( 'the_content', __NAMESPACE__ . '\temporary_faq_parser', 10, 2 ); 274 275 /** 200 276 * Bold archive terms are made here. 201 277 *
Note: See TracChangeset
for help on using the changeset viewer.