PHP Class WPDKUIModalDialog

## Overview You can create in a simple way a standard dialog. ### Create a simple modal dialog For do this just instance this class like: $modal = new WPDKUIModalDialog( 'myDialog', 'Dialog title', 'The content' ); $modal->addButton( 'close', 'Close dialog' ); $modal->modal(); That's all, or since 1.4.9 you can extends this class class MyDialog extends WPDKUIModalDialog { Internal construct public function __construct() { parent::__construct( $id, $title ); } Override buttons public function buttons() { $buttons = array( 'button_id' = array( 'label' => __( 'No, Thanks' ), 'dismiss' => true, ); ); return $buttons; // Filtrable? } Override content public function content() { echo 'Hello...'; } }
Since: 1.4.21
Author: =undo= ([email protected])
Inheritance: extends WPDKHTMLTag
Show file Open project: wpxtreme/wpdk Class Usage Examples

Public Properties

Property Type Description
$__version string Override version
$backdrop boolean Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click.
$buttons array List of buttons to display in footer
$close_button boolean True for dismiss button [x] on top right
$content string HTML content
$dismissButton boolean True for dismiss button [x] on top right
$dismiss_button_glyph string Glyph used like dismiss button
$height integer Height
$keyboard boolean Closes the modal when escape key is pressed
$permanent_dismiss boolean If TRUE this modal is permanet dismiss by a logged in user
$static boolean Render as static. Default is FALSE
$title string Title of modal (window)
$width integer Width

Protected Properties

Property Type Description
$dismissed array List of permanent dismissed dialog id

Public Methods

Method Description
__construct ( string $id, string $title, string $content = '' ) : WPDKUIModalDialog Create an instance of WPDKUIModalDialog class
addButton ( string $id, string $label, boolean $dismiss = true, string $class = '', string $href = '' ) Add a footer button
add_buttons ( $id, $label, $dismiss = true, $class = '' )
add_data ( $key, $value )
buttonOpenModal ( string $label, string $class = '' ) : string Return the HTML markup for button tag to open this modal dialog
button_open_modal ( $label, $class = '' )
buttons ( ) : array Return a list of button
content ( ) : string Content
footer ( ) : string Content of the footer of dialog. You can override this method.
hide ( ) Hide immediately
html ( ) : string Return the HTML markup for modal dialog
is_dismissed ( ) : boolean Return TRUE if this modal dialog is dismissed. FALSE otherwise.
modal ( $echo = true )
open ( ) Display and open dialog
print_footer_scripts ( ) Prints any scripts and data queued for the footer.
show ( ) Display immediately
toggle ( ) Toggle modal

Private Methods

Method Description
_buttons ( ) : string Return the HTML markup for footer buttons
_footer ( ) : string Return the footer content.
aria_title ( ) : string Return the HTML aria title format
dismissButton ( ) : string Return the HTML markup for top right dismiss button [x]
height ( ) : string Return the computate style for height to use in main content div of dialog.
width ( ) : string Return the computate style for width to use in main div of dialog.

Method Details

__construct() public method

Create an instance of WPDKUIModalDialog class
public __construct ( string $id, string $title, string $content = '' ) : WPDKUIModalDialog
$id string ID for this modal
$title string The modal title
$content string Optional. An HTML content for dialog
return WPDKUIModalDialog

addButton() public method

Add a footer button
public addButton ( string $id, string $label, boolean $dismiss = true, string $class = '', string $href = '' )
$id string Unique id for button
$label string Text label
$dismiss boolean Optional. True for data-dismiss
$class string Optional. Addition CSS class
$href string Optional. If set use a TAG A instead BUTTON.

add_buttons() public method

Deprecation: Sice 1.0.0.b4 - Use addButton() instead
public add_buttons ( $id, $label, $dismiss = true, $class = '' )

add_data() public method

Deprecation: Sice 1.0.0.b4 - Use addData() instead
public add_data ( $key, $value )

buttonOpenModal() public method

Return the HTML markup for button tag to open this modal dialog
public buttonOpenModal ( string $label, string $class = '' ) : string
$label string Text button label
$class string Optional. Additional class
return string

button_open_modal() public method

Deprecation: Since 1.0.0.b4 - Use buttonOpenModal() instead
public button_open_modal ( $label, $class = '' )

buttons() public method

Return a list of button
public buttons ( ) : array
return array

content() public method

Content
public content ( ) : string
return string

hide() public method

Hide immediately
public hide ( )

html() public method

Return the HTML markup for modal dialog
public html ( ) : string
return string

is_dismissed() public method

Return TRUE if this modal dialog is dismissed. FALSE otherwise.
public is_dismissed ( ) : boolean
return boolean

modal() public method

Deprecation: Use display() or html() instead
public modal ( $echo = true )

open() public method

Display and open dialog
Since: 1.4.9
public open ( )

show() public method

Display immediately
public show ( )

toggle() public method

Toggle modal
public toggle ( )

Property Details

$__version public property

Override version
public string $__version
return string

$backdrop public property

Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click.
public bool $backdrop
return boolean

$buttons public property

List of buttons to display in footer
public array $buttons
return array

$close_button public property

True for dismiss button [x] on top right
Deprecation: Since 1.0.0.b4 - Use dismissButton instead
public bool $close_button
return boolean

$content public property

HTML content
public string $content
return string

$dismissButton public property

True for dismiss button [x] on top right
public bool $dismissButton
return boolean

$dismiss_button_glyph public property

Glyph used like dismiss button
Since: 1.4.22
public string $dismiss_button_glyph
return string

$dismissed protected property

List of permanent dismissed dialog id
protected array $dismissed
return array

$height public property

Height
public int $height
return integer

$keyboard public property

Closes the modal when escape key is pressed
public bool $keyboard
return boolean

$permanent_dismiss public property

If TRUE this modal is permanet dismiss by a logged in user
Since: 1.5.6
public bool $permanent_dismiss
return boolean

$static public property

Render as static. Default is FALSE
public bool $static
return boolean

$title public property

Title of modal (window)
public string $title
return string

$width public property

Width
public int $width
return integer