Skip to content

Instantly share code, notes, and snippets.

@slushman
Created April 15, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slushman/2297dcc79dc96171404d to your computer and use it in GitHub Desktop.
Save slushman/2297dcc79dc96171404d to your computer and use it in GitHub Desktop.
Registering WordPress Plugin Options
/**
* $tag The WordPress action you want to hook onto. This is required.
* $function_to_add Your function to hook onto the WordPress action. This is required.
* $priority Determines the importance of your function; 10 is the default. This is optional.
* Higher number equal lower priority
* Lower number equals higher priority
* $accepted_args Sets how many arguments can be passed on to your function. This is optional.
*/
<?php add_action( $tag, $function_to_add, $priority, $accepted_args ); ?>
/**
* $option_group name of the settings group - can be anything you want. This is required.
* $option_name name of the setting you want to save. This is required.
* $sanitize_callback custom function that sanitizes the data. It is optional, but highly recommended.
*>
<?php register_setting( $option_group, $option_name, $sanitize_callback ); ?>
/**
* Example settings registration
*/
function wp_jplayer_register_settings() {
register_setting('wp_jplayer_songs', 'wp_jplayer_songs', 'wp_jplayer_songs_validate');
register_setting('wp_jplayer_options', 'wp_jplayer_options');
}
add_action('admin_init', 'wp_jplayer_register_settings');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment