Skip to content

A helper class for outputting common HTML elements, used within WordPress when building plugins.

Notifications You must be signed in to change notification settings

itowhid06/html-elements

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This class was built for my own need. Decided to share in case someone else needs something like this.

Example usage:

This is meant to be used within a WordPress plugin so make sure you've uploaded this class and all the other files within your plugin's folder.

Then:

require_once( 'class-html-elements.php' );

Next, instantiate the class:

use \AT\HTML_Elements;
$elements = new HTML_Elements;

Now you've got access to the "render" method:

$elements->render( 'checkbox', array(
  'id'    => 'test',
  'name'  => 'test',
  'value' => true,
  'label' => 'Checkbox label',
));

The render method accepts 2 parameters, the field type and an array containing the settings of the field. Here you can find a list of supported parameters.

Additional attributes can be passed to each field type by using the "attributes" parameter. Example:

$elements->render( 'text', array(
  'id'         => 'test',
  'name'       => 'test',
  'value'      => 'something',
  'label'      => 'My text field',
  'attributes' => array( 'attr' => 'value' )
) );

About

A helper class for outputting common HTML elements, used within WordPress when building plugins.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages