PHP Class WPDKHTMLTag

Thanks to http://www.w3schools.com/tags/default.asp for definitions
Author: =undo= ([email protected])
Inheritance: extends WPDKObject
Mostra file Open project: wpxtreme/wpdk Class Usage Examples

Public Properties

Property Type Description
$__version string Override version
$accesskey Global attributes
$class
$content string HTML inner content of tag.
$contenteditable
$contextmenu
$data array Key value pairs array Attribute data: data-attribute = value
$dir
$draggable
$dropzone
$hidden
$id
$lang
$onclick
$spellcheck
$style
$tabindex
$tagName WPDKHTMLTagName The TAG name
$title string Title

Protected Properties

Property Type Description
$attributes array Override. List of tag attributes that can be used on any HTML element.
$close string Override. Close format Eg. '' or '/>'
$open string Override. Open format Eg. '

Public Methods

Method Description
__construct ( string $tag_name ) : WPDKHTMLTag Create an instance of WPDKHTMLTag class
addClass ( string $class ) Utility to add a class. You can access directly to class array property instead
addData ( string $name, string $value ) Utility to add a data attribute. You can access directly to data array property instead
attributeInline ( array $attributes, array | boolean $additional_attributes = false ) : string Return a inline generic attribute
classInline ( array | string $classes, array | boolean $additional_classes = false ) : string Return a sanitize and inline list of css classes
dataInline ( array $data, array | boolean $additional_data = false ) : string Return a inline data attribute
display ( ) Display HTML markup for this tag
draw ( ) Draw the content of tag
html ( ) : string Return the HTML markup for this tag
mergeClasses ( array | string $class, array | string $class2 = null, array | string $_ = null ) : array Merge one or more class
sanitizeAttributes ( string $attributes ) : array Return a key value pairs array with generic attribute list
sanitizeClasses ( string | array $classes ) : array Return key value pairs array unique with css class list. In this way you can unset a secified class.
sanitizeData ( string $attributes ) : array Return a key value pairs array with data attribute list
sanitizeStyles ( string | array $styles ) : array Return key value pairs array unique with css styke list. In this way you can unset a secified class.
setPropertiesByArray ( array $properties = [] ) Set one or more WPDKHTMLTag properties by an array.
styleInline ( array | string $styles, array | boolean $additional_styles = false ) : string Return a sanitize and inline list of css styles

Protected Methods

Method Description
afterContent ( ) Override this method to display anything after the content output
beforeContent ( ) Override this method to display anything before the content output

Method Details

__construct() public method

Create an instance of WPDKHTMLTag class
public __construct ( string $tag_name ) : WPDKHTMLTag
$tag_name string
return WPDKHTMLTag

addClass() public method

Utility to add a class. You can access directly to class array property instead
Since: 1.3.1
public addClass ( string $class )
$class string

addData() public method

Utility to add a data attribute. You can access directly to data array property instead
public addData ( string $name, string $value )
$name string Data attribute name
$value string Data attribute value

afterContent() protected method

Override this method to display anything after the content output
protected afterContent ( )

attributeInline() public static method

$data = array( 'color' => 'red', 'size' => 12 ); echo self::attributeInline( $data, array( 'modal' => "true" ) ); 'color="red" size="12" modal="true"'
public static attributeInline ( array $attributes, array | boolean $additional_attributes = false ) : string
$attributes array Key value pairs array with data attribute list
$additional_attributes array | boolean Optional. Additional data
return string

beforeContent() protected method

Override this method to display anything before the content output
protected beforeContent ( )

classInline() public static method

$classes = array( 'color', 'modal', ); echo self::classInline( $classes, array( 'modal', 'hide' ) ); 'color modal hide' echo self::classInline( $classes, 'delta modal' ); 'color delta modal'
public static classInline ( array | string $classes, array | boolean $additional_classes = false ) : string
$classes array | string List of css classes
$additional_classes array | boolean Optional. Additional classes
return string

dataInline() public static method

$data = array( 'color' => 'red', 'size' => 12 ); echo self::dataInline( $data, array( 'modal' => "true" ) ); 'data-color="red" data-size="12" data-modal="true"'
public static dataInline ( array $data, array | boolean $additional_data = false ) : string
$data array Key value pairs array with data attribute list
$additional_data array | boolean Optional. Additional data
return string

display() public method

Display HTML markup for this tag
public display ( )

draw() public method

Draw the content of tag
public draw ( )

html() public method

Return the HTML markup for this tag
public html ( ) : string
return string

mergeClasses() public static method

Merge one or more class
Since: 1.4.0
public static mergeClasses ( array | string $class, array | string $class2 = null, array | string $_ = null ) : array
$class array | string Initial string or array class to merge
$class2 array | string Optional.
$_ array | string Optional.
return array

sanitizeAttributes() public static method

self::sanitizeAttributes( 'modal="false" modal="true" color=red' ); array(2) { ["modal"]=> string(5) "true" ["color"]=> string(3) "red" }
public static sanitizeAttributes ( string $attributes ) : array
$attributes string Attribute inline
return array

sanitizeClasses() public static method

If the input is a string (space separate strings) will return an array with css classes. $class = 'a b c c'; echo self::sanitizeClasses( $class ); array( 'a' => 'a', 'b' => 'b', 'c' => 'c', )
public static sanitizeClasses ( string | array $classes ) : array
$classes string | array Any string or array with classes
return array

sanitizeData() public static method

self::sanitizeAttributes( 'data-modal="false" modal="true" data-color=red' ); array(2) { ["modal"]=> string(5) "true" ["color"]=> string(3) "red" }
public static sanitizeData ( string $attributes ) : array
$attributes string Data attribute inline
return array

sanitizeStyles() public static method

If the input is a string (space separate strings) will return an array with css classes. $style = 'display:block;position:absolute'; echo self::sanitizeStyles( $style ); array( 'display' => 'block', 'position' => 'absolute', )
Since: 1.4.7
public static sanitizeStyles ( string | array $styles ) : array
$styles string | array Any string or array with styles
return array

setPropertiesByArray() public method

Set one or more WPDKHTMLTag properties by an array.
public setPropertiesByArray ( array $properties = [] )
$properties array A key value pairs array with the property (key) and its value

styleInline() public static method

$styles = array( 'position' => 'absolute', 'top' => 0, ); echo self::styleInline( $styles, array( 'left' => 0, 'display' => 'block' ) ); 'position:absolute;top:0;left:0;display:block' echo self::styleInline( $styles, 'display:block' ); 'position:absolute;top:0;display:block'
Since: 1.4.7
public static styleInline ( array | string $styles, array | boolean $additional_styles = false ) : string
$styles array | string List of css styles
$additional_styles array | boolean Optional. Additional styles
return string

Property Details

$__version public_oe property

Override version
public string $__version
return string

$accesskey public_oe property

Global attributes
public $accesskey

$attributes protected_oe property

Override. List of tag attributes that can be used on any HTML element.
protected array $attributes
return array

$class public_oe property

public $class

$close protected_oe property

Override. Close format Eg. '' or '/>'
protected string $close
return string

$content public_oe property

HTML inner content of tag.
public string $content
return string

$contenteditable public_oe property

public $contenteditable

$contextmenu public_oe property

public $contextmenu

$data public_oe property

Key value pairs array Attribute data: data-attribute = value
public array $data
return array

$dir public_oe property

public $dir

$draggable public_oe property

public $draggable

$dropzone public_oe property

public $dropzone

$hidden public_oe property

public $hidden

$id public_oe property

public $id

$lang public_oe property

public $lang

$onclick public_oe property

public $onclick

$open protected_oe property

Override. Open format Eg. '
protected string $open
return string

$spellcheck public_oe property

public $spellcheck

$style public_oe property

public $style

$tabindex public_oe property

public $tabindex

$tagName public_oe property

The TAG name
public WPDKHTMLTagName $tagName
return WPDKHTMLTagName

$title public_oe property

Title
public string $title
return string