Forums

Making Plugins - Database (4 posts)

  1. snareklutz
    Member
    Posted 3 years ago #

    Hi,
    I was reading the codex when I came up to reading about how to Save Plugin Data: http://codex.wordpress.org/Writing_a_Plugin#Saving_Plugin_Data_to_the_Database.

    For the add_option function, there are 4 variables but no real description for each...what are they?

    Also, if I were to make a admin panel, will all user types be able to see it? If yes, how do I make only the global admin able to see it?

    Thanks!

  2. jaredquinn
    Member
    Posted 3 years ago #

    The add_, update_ and get_ option functions are used for "configuration" values for plugins.

    The options for add_option are:

    add_option($name, $value, $description, $autoload);

    $name = name of the option
    $value = the value you want set
    $description = a description of this optioin
    $autoload = autoload this setting

    If autoload is set (default yes) then the setting is automatically retrieved by the get_alloptions function.

    You will want to add a page to either the 'options' or 'manage' section of the admin interface for your admin panel.

    For these you would use add_options_page or add_management_page respectively.

    Syntax:

    add_options_page(page_title, menu_title, access_level, file, [function]);

    or

    add_management_page(page_title, menu_title, access_level, file, [function]);

    e.g.

    add_options_page('Test Options', 'Test Options', 8, __FILE__, 'functiontocall');

    (note: __FILE__ can be used to mean "this current plugin file" handles the display of options. The 'functiontocall' is called to display/save/set etc the options.)

    There is more good info, as usual, in the codex.. http://codex.wordpress.org/Adding_Administration_Menus

  3. snareklutz
    Member
    Posted 3 years ago #

    About Adding Administration Menus, does the code need to be run every single time the plugin runs, or just the first time?

  4. snareklutz
    Member
    Posted 3 years ago #

    Never mind, I've found out -- you can run it every time and it'll be fine. One question though, what does get_alloptions do?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.