About

This plugin is my attempt to simplify the process of adding a setting page for the WordPress themes I was working on. It was originally inspired by the Hybrid theme. I then re-wrote it to utilize the amazing WordPress' Settings API after reading Otto's article.

Features

Currently you can use this plugin for these types of settings:

For plugin/theme setting pages, you have the option to choose between 'plain' and 'metaboxes' display types. For post metaboxes/custom fields and plugin/theme setting pages with display time set to metaboxes, you can freely set the metaboxes positions/contexts and priorities.

Supported input types:

If you think there are other input types that need to be added, don't hesitate to contact me!

Installation

Just install it like any other WordPress plugins :)

The options

You can either create the settings using the Builder by going to Settings » KC Settings, or create them manually.

There are a few sample options files included in the sample directory. Copy (examine and modify) the sample options files included in the sample directory to your plugin/theme directory and then include them from your theme/plugin, eg. require_once TEMPLATEPATH . '/theme_options.php';

Getting the data

Theme/plugin settings

Return values

Custom field / Post metadata

Just use standard WordPress function, but prefix the meta key with an underscore, for example:

$var = get_post_meta( $post_id, '_field_id', true );
or:
$var = get_metadata( 'post', $post_id, '_field_id', true );

Term Metadata

You can use standard WordPress function, for example:

$var = get_metadata( 'term', 'term_id', $field_id, true );

User Metadata

You can use standard WordPress function, for example:

$var = get_user_meta( 'user_id', $field_id, true );
or:
$var = get_metadata( 'user', 'user_id', $field_id, true );

Validation/sanitation

All options are filtered before added to the database. You can add your own filter(s) by using one ore more of these filters:

Theme/plugin settings

Metadata

You can also filter your metadata values using the filters below. Note that there are three arguments passed to these filters, and they're valid for the three metadata types (post, term and user):

  1. $nu_val: The new metadata value from the user
  2. $section: The section array
  3. $field: The field array

Example validation/sanitation function for metadata:

function my_filter_function( $nu_val, $section, $field ) {
	//... do someting with the data
	return $nu_val;
}
			

Custom Fields / Post Meta

Term meta

The filters used for validating term meta values are very similiar with custom fields' filters. The only difference is that you'd use taxonomy name instead of post type name. Also the filters are prefixed with kcv_termmeta_ instead of kcv_postmeta_. Here are the filters used:

And here are the filters:

User meta

Validation/sanitation filters for user meta are very similiar with post and term meta. However, with user meta, you'll get fewer filters:

Helpers

Since version 2.6, KC Settings comes with options helpers to make your life easier ;)

Variables

There are a few variables you can use to pass as field options:

Support

If you think you found a bug, need some features added, have questions or just want to say hi, please feel free to contact me.