PHP Класс 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...'; } }
С версии: 1.4.21
Автор: =undo= ([email protected])
Наследование: extends WPDKHTMLTag
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$__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)

Свойство Тип Описание
$dismissed array List of permanent dismissed dialog id

Открытые методы

Метод Описание
__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

Приватные методы

Метод Описание
_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.

Описание методов

__construct() публичный Метод

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
Результат WPDKUIModalDialog

addButton() публичный Метод

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() публичный Метод

Устаревший: Sice 1.0.0.b4 - Use addButton() instead
public add_buttons ( $id, $label, $dismiss = true, $class = '' )

add_data() публичный Метод

Устаревший: Sice 1.0.0.b4 - Use addData() instead
public add_data ( $key, $value )

buttonOpenModal() публичный Метод

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
Результат string

button_open_modal() публичный Метод

Устаревший: Since 1.0.0.b4 - Use buttonOpenModal() instead
public button_open_modal ( $label, $class = '' )

buttons() публичный Метод

Return a list of button
public buttons ( ) : array
Результат array

content() публичный Метод

Content
public content ( ) : string
Результат string

hide() публичный Метод

Hide immediately
public hide ( )

html() публичный Метод

Return the HTML markup for modal dialog
public html ( ) : string
Результат string

is_dismissed() публичный Метод

Return TRUE if this modal dialog is dismissed. FALSE otherwise.
public is_dismissed ( ) : boolean
Результат boolean

modal() публичный Метод

Устаревший: Use display() or html() instead
public modal ( $echo = true )

open() публичный Метод

Display and open dialog
С версии: 1.4.9
public open ( )

show() публичный Метод

Display immediately
public show ( )

toggle() публичный Метод

Toggle modal
public toggle ( )

Описание свойств

$__version публичное свойство

Override version
public string $__version
Результат string

$backdrop публичное свойство

Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click.
public bool $backdrop
Результат boolean

$buttons публичное свойство

List of buttons to display in footer
public array $buttons
Результат array

$close_button публичное свойство

True for dismiss button [x] on top right
Устаревший: Since 1.0.0.b4 - Use dismissButton instead
public bool $close_button
Результат boolean

$content публичное свойство

HTML content
public string $content
Результат string

$dismissButton публичное свойство

True for dismiss button [x] on top right
public bool $dismissButton
Результат boolean

$dismiss_button_glyph публичное свойство

Glyph used like dismiss button
С версии: 1.4.22
public string $dismiss_button_glyph
Результат string

$dismissed защищенное свойство

List of permanent dismissed dialog id
protected array $dismissed
Результат array

$height публичное свойство

Height
public int $height
Результат integer

$keyboard публичное свойство

Closes the modal when escape key is pressed
public bool $keyboard
Результат boolean

$permanent_dismiss публичное свойство

If TRUE this modal is permanet dismiss by a logged in user
С версии: 1.5.6
public bool $permanent_dismiss
Результат boolean

$static публичное свойство

Render as static. Default is FALSE
public bool $static
Результат boolean

$title публичное свойство

Title of modal (window)
public string $title
Результат string

$width публичное свойство

Width
public int $width
Результат integer