|
1 |
| -Object-Oriented approach to the [WordPress Settings API](http://codex.wordpress.org/Settings_API) |
| 1 | +Object-Oriented approach to the [WordPress Settings API](http://codex.wordpress.org/Settings_API) |
| 2 | + |
| 3 | +Usage |
| 4 | +===== |
| 5 | +<pre> |
| 6 | +$options = new WordPress_Settings(array( |
| 7 | + 'option_group' => 'sample_options', |
| 8 | + 'option_name' => 'sample_options', |
| 9 | + 'page_title' => 'vBulletin Connect Options', |
| 10 | + 'menu_title' => 'vBulletin Connect', |
| 11 | + 'capability' => 'administrator' |
| 12 | +)); |
| 13 | + |
| 14 | +$options |
| 15 | + ->addSection(array('id' => 'general', 'title' => 'General Settings', 'callback' => '')) |
| 16 | + ->addField(array('key' => 'forum_path', 'title' => 'Forum Path (Relative)')) |
| 17 | + ->addSection(array('id' => 'authentication', 'title' => 'Authentication Settings', 'callback' => '<p>Authentication integration settings.</p>')) |
| 18 | + ->addField(array('key' => 'authentication', 'title' => 'Enable vBulletin Login', 'type' => 'checkbox')) |
| 19 | + ->addSection(array('id' => 'publishing', 'title' => 'Content Publish Settings', 'callback' => '<p>Posts are published to desired forum with the user of your choice.</p>')) |
| 20 | + ->addField(array('key' => 'publishing', 'title' => 'Enable Content Publishing', 'type' => 'checkbox')) |
| 21 | + ->addField(array('key' => 'publishing_forum_id', 'title' => 'Forum ID')) |
| 22 | + ->addField(array('key' => 'publishing_user_id', 'title' => 'User ID')) |
| 23 | + ->addField(array('key' => 'publishing_content_tpl', 'title' => 'Content Template', 'type' => 'textarea')) |
| 24 | +; |
| 25 | + |
| 26 | +add_action('admin_init', array($options, 'init')); |
| 27 | +add_action('admin_menu', array($options, 'addPage')); |
| 28 | +</pre> |
0 commit comments