id = $id; $this->name = $name; $this->description = $description; } /** * Add a field to the object * * @param string $type * @param string $name * @param string $heading * @param string $description * @param array $values * @return \WP_Doin_Shortcode */ public function add_field($type, $name, $heading = '', $description = '', $values = array()) { $this->fields[$name] = array( 'type' => $type, 'heading' => $heading, 'description' => $description, 'values' => $values ); return $this; } /** * Iterate over the stored fields and generate their corresponding markup */ public function generate_fields() { foreach ( $this->fields as $key => $field ) { switch ( $field['type'] ) { case 'col': $this->generate_col( $field['heading'] ); break; case 'text': $this->generate_text( $key, $field['heading'], $field['description'] ); break; case 'textarea': $this->generate_textarea( $key, $field['heading'], $field['description'] ); break; case 'checkbox': $this->generate_checkbox( $key, $field['heading'], $field['description'], $field['values'] ); break; case 'select': $this->generate_select( $key, $field['heading'], $field['description'], $field['values'] ); break; default: $this->generate_text( $key, $field['heading'], $field['description'] ); break; } } } /** * Generate the 1/3 column markup for the TinyMCE popup * * @param string $type either start or any (usually end :P) */ public function generate_col($type) { if ( $type === 'start' ): ?>

$value ): ?>