Читать книгу Professional WordPress Plugin Development - Brad Williams - Страница 101

Adding Only Fields

Оглавление

Of course, it can even make sense to add just one field and no section header to an existing page. Now modify the function in the previous example as shown here:

<?php function pdev_plugin_admin_init(){ $args = array( 'type' => 'string', 'sanitize_callback' => 'pdev_plugin_validate_options', 'default' => NULL ); register_setting( 'reading', 'pdev_plugin_options', $args ); add_settings_field( 'pdev_plugin_text_string', 'Your Name', 'pdev_plugin_setting_name', 'reading', 'default' ); } ?>

Your singular field will be added to the default field set of the reading section, as shown in Figure 3‐7.


FIGURE 3‐7: Singular field

Professional WordPress Plugin Development

Подняться наверх