Changeset 2984 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
- Timestamp:
- 04/19/2016 08:15:57 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r2966 r2984 1191 1191 1192 1192 /** 1193 * Formats the output of params defined using hash notation.1194 *1195 * This is a temporary measure until the parser parses the hash notation1196 * into component elements that the theme could then handle and style1197 * properly.1198 *1199 * Also, as a stopgap this is going to begin as a barebones hack to simply1200 * keep the text looking like one big jumble.1201 *1202 * @param string $text The content for the param.1203 * @return string1204 */1205 function param_formatting_fixup( $text ) {1206 // Don't do anything if this isn't a hash notation string.1207 if ( '{' != $text[0] ) {1208 return $text;1209 }1210 1211 $new_text = '';1212 $text = trim( substr( $text, 1, -1 ) );1213 $text = str_replace( '@type', "\n@type", $text );1214 1215 $in_list = false;1216 $parts = explode( "\n", $text );1217 foreach ( $parts as $part ) {1218 $part = preg_replace( '/\s+/', ' ', $part );1219 list( $wordtype, $type, $name, $description ) = explode( ' ', $part, 4 );1220 $description = trim( $description );1221 1222 $skip_closing_li = false;1223 1224 // Handle nested hashes.1225 if ( '{' === $description[0] || '{' === $name ) {1226 $description = ltrim( $description, '{' ) . '<ul class="param-hash">';1227 $skip_closing_li = true;1228 } elseif ( '}' === substr( $description, -1 ) ) {1229 $description = substr( $description, 0, -1 ) . "</li></ul>\n";1230 }1231 1232 if ( '@type' != $wordtype ) {1233 if ( $in_list ) {1234 $in_list = false;1235 $new_text .= "</li></ul>\n";1236 }1237 1238 $new_text .= $part;1239 } else {1240 if ( $in_list ) {1241 $new_text .= '<li>';1242 } else {1243 $new_text .= '<ul class="param-hash"><li>';1244 $in_list = true;1245 }1246 1247 // Normalize argument name.1248 if ( $name === '{' ) {1249 // No name is specified, generally indicating an array of arrays.1250 $name = '';1251 } else {1252 // The name is defined as a variable, so remove the leading '$'.1253 $name = ltrim( $name, '$' );1254 }1255 if ( $name ) {1256 $new_text .= "<b>'{$name}'</b><br />";1257 }1258 $new_text .= "<i><span class='type'>({$type})</span></i> {$description}";1259 if ( ! $skip_closing_li ) {1260 $new_text .= '</li>';1261 }1262 $new_text .= "\n";1263 }1264 }1265 1266 if ( $in_list ) {1267 $new_text .= "</li></ul>\n";1268 }1269 1270 return $new_text;1271 }1272 1273 /**1274 1193 * Should the search bar be shown? 1275 1194 *
Note: See TracChangeset
for help on using the changeset viewer.