Changeset 8855
- Timestamp:
- 09/09/2008 10:31:22 PM (16 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r8845 r8855 1508 1508 } 1509 1509 1510 // crazyhorse - this can be made simpler1511 1510 function do_meta_boxes($page, $context, $object) { 1512 1511 global $wp_meta_boxes; … … 1603 1602 } 1604 1603 } 1604 1605 /** 1606 * Add a new section to a settings page 1607 * 1608 * @since 2.7 1609 * 1610 * @param string $id String for use in the 'id' attribute of tags. 1611 * @param string $title Title of the section 1612 * @param string $callback Function that fills the section with the desired content. The function should echo its output. 1613 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...) 1614 */ 1615 function add_settings_section($id, $title, $callback, $page) { 1616 global $wp_settings_sections; 1617 1618 if ( !isset($wp_settings_sections) ) 1619 $wp_settings_sections = array(); 1620 if ( !isset($wp_settings_sections[$page]) ) 1621 $wp_settings_sections[$page] = array(); 1622 if ( !isset($wp_settings_sections[$page][$id]) ) 1623 $wp_settings_sections[$page][$id] = array(); 1624 1625 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); 1626 } 1627 1628 /** 1629 * Add a new field to a settings page 1630 * 1631 * @since 2.7 1632 * 1633 * @param string $id String for use in the 'id' attribute of tags. 1634 * @param string $title Title of the field 1635 * @param string $callback Function that fills the field with the desired content. The function should echo its output. 1636 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...) 1637 * @param string $section The section of the settingss page in which to show the box (default, ...) 1638 * @param array $args Additional arguments 1639 */ 1640 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { 1641 global $wp_settings_fields; 1642 1643 if ( !isset($wp_settings_fields) ) 1644 $wp_settings_fields = array(); 1645 if ( !isset($wp_settings_fields[$page]) ) 1646 $wp_settings_fields[$page] = array(); 1647 if ( !isset($wp_settings_fields[$page][$section]) ) 1648 $wp_settings_fields[$page][$section] = array(); 1649 1650 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); 1651 } 1652 1653 function do_settings_sections($page) { 1654 global $wp_settings_sections, $wp_settings_fields; 1655 1656 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) 1657 return; 1658 1659 foreach ( (array) $wp_settings_sections[$page] as $section ) { 1660 echo "<h3>{$section['title']}</h3>\n"; 1661 call_user_func($section['callback'], $section); 1662 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) 1663 continue; 1664 echo '<table class="form-table">'; 1665 do_settings_fields($page, $section['id']); 1666 echo '</table>'; 1667 } 1668 } 1669 1670 function do_settings_fields($page, $section) { 1671 global $wp_settings_fields; 1672 1673 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) 1674 return; 1675 1676 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { 1677 echo '<tr valign="top">'; 1678 if ( !empty($field['args']['label_for']) ) 1679 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>'; 1680 else 1681 echo '<th scope="row">' . $field['title'] . '</th>'; 1682 echo '<td>'; 1683 call_user_func($field['callback']); 1684 echo '</td>'; 1685 echo '</tr>'; 1686 } 1687 } 1688 1605 1689 ?> -
trunk/wp-admin/options-discussion.php
r8802 r8855 84 84 </fieldset></td> 85 85 </tr> 86 <?php do_settings_fields('discussion', 'default'); ?> 86 87 </table> 87 88 … … 155 156 </fieldset></td> 156 157 </tr> 157 158 <?php do_settings_fields('discussion', 'avatars'); ?> 158 159 </table> 159 160 161 <?php do_settings_sections('discussion'); ?> 160 162 161 163 <p class="submit"> -
trunk/wp-admin/options-general.php
r8802 r8855 118 118 </select></td> 119 119 </tr> 120 <?php do_settings_fields('general', 'default'); ?> 120 121 </table> 122 123 <?php do_settings_sections('general'); ?> 121 124 122 125 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> -
trunk/wp-admin/options-misc.php
r8831 r8855 46 46 </th> 47 47 </tr> 48 <?php do_settings_fields('misc', 'default'); ?> 48 49 </table> 49 50 … … 131 132 </fieldset></td> 132 133 </tr> 133 134 <?php do_settings_fields('misc', 'images'); ?> 134 135 </table> 135 136 … … 158 159 </table> 159 160 161 <?php do_settings_sections('misc'); ?> 162 160 163 <p class="submit"> 161 164 <input type="hidden" name="action" value="update" /> -
trunk/wp-admin/options-permalink.php
r8705 r8855 192 192 <td><input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" /></td> 193 193 </tr> 194 <?php do_settings_fields('permalink', 'optional'); ?> 194 195 </table> 196 197 <?php do_settings_sections('permalink'); ?> 198 195 199 <p class="submit"><input type="submit" name="submit" class="button" value="<?php _e('Save Changes') ?>" /></p> 196 200 </form> -
trunk/wp-admin/options-privacy.php
r8802 r8855 32 32 </fieldset></td> 33 33 </tr> 34 <?php do_settings_fields('privacy', 'default'); ?> 34 35 </table> 36 37 <?php do_settings_sections('privacy'); ?> 35 38 36 39 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> -
trunk/wp-admin/options-reading.php
r8802 r8855 73 73 <?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td> 74 74 </tr> 75 <?php do_settings_fields('reading', 'default'); ?> 75 76 </table> 76 77 <p class="submit"> -
trunk/wp-admin/options-writing.php
r8802 r8855 64 64 </select></td> 65 65 </tr> 66 <?php do_settings_fields('writing', 'default'); ?> 66 67 </table> 67 68 … … 84 85 <?php _e('Enable the WordPress, Movable Type, MetaWeblog and Blogger XML-RPC publishing protocols.') ?></label><br /> 85 86 </fieldset></td> 86 </tr></table> 87 </tr> 88 <?php do_settings_fields('writing', 'remote_publishing'); ?> 89 </table> 87 90 88 91 <h3><?php _e('Post via e-mail') ?></h3> … … 121 124 </select></td> 122 125 </tr> 126 <?php do_settings_fields('writing', 'post_via_email'); ?> 123 127 </table> 124 128 … … 137 141 <?php endif; ?> 138 142 143 <?php do_settings_sections('writing'); ?> 144 139 145 <p class="submit"> 140 146 <input type="hidden" name="action" value="update" />
Note: See TracChangeset
for help on using the changeset viewer.