2017 © Pedro Peláez
 

library wordpress-field

Render form fields in WordPress

image

grottopress/wordpress-field

Render form fields in WordPress

  • Thursday, July 5, 2018
  • by akadusei
  • Repository
  • 2 Watchers
  • 1 Stars
  • 125 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 54 % Grown

The README.md

WordPress Field

Description

WordPress Field is a simple library to render form fields in WordPress., (*1)

Installation

Install via composer: composer require grottopress/wordpress-field, (*2)

Usage

<?php

use GrottoPress\WordPress\Form\Field;

// Text field
$text = new Field([
    'id' => 'field-id',
    'name' => 'field-name',
    'type' => 'text',
    'value' => 'My awesome text field',
    'label' => 'My text field',
]);

// Render text field
echo $text->render();

// Radio buttons
$radio = new Field([
    'id' => 'field-id',
    'name' => 'field-name',
    'type' => 'radio',
    'value' => 'my-choice',
    'choices' => [
        'one' => 'One',
        'my-choice' => 'My Choice',
        'two' => 'Two',
    ],
]);

// Render radio field
echo $radio->render();

// Dropdown
$dropdown = new Field([
    'id' => 'field-id',
    'name' => 'field-name',
    'type' => 'select',
    'value' => 'my-choice',
    'choices' => [
        'one' => 'One',
        'my-choice' => 'My Choice',
        'two' => 'Two',
    ],
]);

// Render dropdown field
echo $dropdown->render();

// Multi-select dropdown
$mdrop = new Field([
    'id' => 'field-id',
    'name' => 'field-name',
    'type' => 'radio',
    'value' => 'my-choice',
    'choices' => [
        'one' => 'One',
        'my-choice' => 'My Choice',
        'two' => 'Two',
    ],
    'meta' => [
        'multiple' => 'multiple',
    ],
]);

// Render multi-select dropdown
echo $mdrop->render();

// Categories dropdown
$catsdrop = new Field([
    'type' => 'wp_dropdown_categories', // callable WP function
    'callbackArgs' => [ // Args to pass to callable function
        [ // @see https://developer.wordpress.org/reference/functions/wp_dropdown_categories/
            'show_option_none'   => '--',
            'echo'               => 0,
            'selected'           => 22,
            'name'               => 'field-name',
            'id'                 => 'field-id',
            'taxonomy'           => 'category',
        ],
    ],
]);

// Render categories dropdown
echo $catsdrop->render();

Development

Run tests with composer run test., (*3)

Contributing

  1. Fork it
  2. Switch to the master branch: git checkout master
  3. Create your feature branch: git checkout -b my-new-feature
  4. Make your changes, updating changelog and documentation as appropriate.
  5. Commit your changes: git commit
  6. Push to the branch: git push origin my-new-feature
  7. Submit a new Pull Request against the GrottoPress:master branch.

The Versions

05/07 2018

dev-master

9999999-dev

Render form fields in WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress forms

05/07 2018

dev-dev

dev-dev

Render form fields in WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress forms

05/07 2018

0.6.0

0.6.0.0

Render form fields in WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress forms

29/06 2018

0.5.1

0.5.1.0

Render form fields in WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress forms

06/03 2018

0.5.0

0.5.0.0

Render form fields in WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress forms

03/03 2018

0.4.0

0.4.0.0

Render form fields in WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress forms

28/09 2017

0.3.0

0.3.0.0

A library to render form fields in WordPress.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

13/09 2017

0.2.0

0.2.0.0

A library to render form fields in WordPress.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress

23/08 2017

0.1.0

0.1.0.0

A library to render form fields in WordPress.

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress