WordPress.org

Ready to get started?Download WordPress

Forums

using checkboxes in theme options (2 posts)

  1. ext103
    Member
    Posted 4 years ago #

    hello there.

    i am currently getting my theme design up to scratch so i can release it.

    i have built in a "social bookmarking" area in the theme (under posts and pages).

    thing is i want the theme user to be able to decide which icons/bookmarking sites they display out of the selection.

    the best way to do this is to add an options page with checkboxes for the different icons.

    thing is i have prior knowledge of creating and retrieving options, but they have always been text options, so the forms have been pretty easy.

    now i need to figure out checkboxes and countless google searches and codex searches has turned up info, but not anything that runs me through the process from start to finish.

    im hopeing someone here can help me out.

    ill post the code below for the whole options page (unfished obviously)

    <?php
    //customize menu
    add_action('admin_menu', 'my_bookmarks_menu');
    add_action( 'admin_init', 'register_mysettings' );
    function my_bookmarks_menu() {
    add_theme_page(__('theme_bookmarks'), __('Bookmarks'), 'edit_theme_options', 'bookmarks', 'bookmarks_page');
    }
    // register settings
    function register_mysettings() {
    //register our settings
    register_setting('bookmarks' , 'delicious');
    register_setting('bookmarks', 'twit');
    register_setting('bookmarks', 'stumbleupon');
    register_setting('bookmarks', 'face');
    register_setting('bookmarks', 'technorati');
    register_setting('bookmarks', 'google');
    register_setting('bookmarks', 'reddit');
    register_setting('bookmarks', 'blinklist');
    register_setting('bookmarks', 'blogmarks');
    register_setting('bookmarks', 'digg');
    register_setting('bookmarks', 'diigo');
    register_setting('bookmarks', 'misterwong');
    register_setting('bookmarks', 'newsvine');
    }
    //top level menu table page
    function bookmarks_page () {
    ?>
    <div class="wrap">
    <?php screen_icon(); ?>
    <h2>Bookmarks</h2>
    <h3>Please select which bookmarking options you would like to be displayed below posts and pages.</h3>
    <form method="post" action="options.php">
        <?php settings_fields( 'bookmarks' ); ?>
        <table class="form-table">
    
    <tr valign="top">
    <th scope="row">Delicious</th>
    <td><fieldset><legend class="screen-reader-text"><span>Memebership</span></legend><label for="delcious">
    <input name="delcious" type="checkbox" id="delcious" value="true" <?php checked('true', get_option('delicious')); ?> />
    <?php _e('Anyone can register') ?></label>
    </fieldset></td>
    </tr>
    
        </table>
    
        <p class="submit">
        <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
        </p>
    
    </form>
    </div>
    <?php } ?>
  2. Joni
    Member
    Posted 4 years ago #

    Why don't you download a theme that has lots of options, such as Arras, some of Brian Gardner's old themes, I'm trying to think of some nice themes that have lots of options and aren't premium themes that you can download and inspect and see how they do it.

Topic Closed

This topic has been closed to new replies.

About this Topic