beans_register_options

Register options.

This function should only be invoked through the ‘admin_init’ action.

beans_register_options( $fields, $menu_slug, $section, $args = array() )

Source

function beans_register_options( array $fields, $menu_slug, $section, $args = array() ) {

	/**
	 * Filter the options fields.
	 *
	 * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields.
	 *
	 * @since 1.0.0
	 *
	 * @param array $fields An array of options fields.
	 */
	$fields = apply_filters( "beans_options_fields_{$section}", _beans_pre_standardize_fields( $fields ) );

	/**
	 * Filter the options fields menu slug.
	 *
	 * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields.
	 *
	 * @since 1.0.0
	 *
	 * @param array $menu_slug The menu slug.
	 */
	$menu_slug = apply_filters( "beans_options_menu_slug_{$section}", $menu_slug );

	// Stop here if the page isn't concerned.
	if ( ( beans_get( 'page' ) !== $menu_slug ) || ! is_admin() ) {
		return;
	}

	// Stop here if the field can't be registered.
	if ( ! beans_register_fields( $fields, 'option', $section ) ) {
		return false;
	}

	// Load the class only if this function is called to prevent unnecessary memory usage.
	require_once( BEANS_API_PATH . 'options/class.php' );

	$class = new _Beans_Options();
	$class->register( $section, $args );

	return true;

}