1. Home
  2. Docs
  3. WordPress Studio Framework
  4. How-To…
  5. Add New Fields

Add New Fields

There are three steps to creating a new and custom field to use within the WordPress Studio Framework (WPSF). One note: if this is a useful field that other developers could take advantage of, send it to me and I’ll look at rolling it into the official release.

Step One : Create a field class php file

/*
 * Field: password
 *
 * Created by Bob
*/
if ( ! class_exists( 'WPSF_Field_password' ) ){
  class WPSF_Field_password extends WPSF_Fields {

  public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
    parent::__construct( $field, $value, $unique, $where, $parent );
  }

  public function render() {
    echo $this->field_before();
    echo '<input type="password" name="'. $this->field_name() .'" value="'. $this->value() .'"'. $this->field_attributes() . ' />';
    echo $this->field_after();
  }
 }
}

Step Two: Include this created file in your site

Step Three: Use your new field in the configuration

array(
  'id' => 'example-password',
  'type' => 'password',
  'title' => 'Password Field',
),
Was this article helpful to you? Yes No

How can we help?