WPDK
1.5.0
WordPress Development Kit
|
Public Member Functions | |
__construct ($id, $class= '') | |
Construct. More... | |
html () | |
Get HTML markup content. More... | |
draw () | |
Draw. More... | |
addSubview ($view) | |
Add a subview. More... | |
removeFromSuperview () | |
Remove this view. More... | |
Public Member Functions inherited from WPDKObject | |
__className () | |
Returns the class object. More... | |
__parentClass () | |
Returns the class object for the receiver’s superclass. More... | |
__isClass ($class) | |
Brief. More... | |
__isSubclassOfClass ($class) | |
Return TRUE if the receiving class is a subclass of —or identical to— $class, otherwise FALSE. More... | |
Static Public Member Functions | |
static | initWithContent ($id, $class= '', $content= '') |
Init a WPDKView. More... | |
static | initWithFrame ($id, $rect) |
Static Public Member Functions inherited from WPDKObject | |
static | __delta ($last_version, $old_version) |
Object delta compare for combine. More... | |
static | delta ($last_version, $old_version) |
static | __dump ($var, $monitor=false) |
Dump a variable. More... | |
Data Fields | |
$__version = '1.1.2' | |
Version. More... | |
$class | |
Class. More... | |
$style | |
Inline style. More... | |
$content | |
The content. More... | |
$data | |
$id | |
ID. More... | |
$subviews | |
List of sub views. More... | |
$superview | |
The superview. More... | |
Data Fields inherited from WPDKObject | |
$__version = '1.0.0' | |
The version number assigned to the class. More... | |
Protected Attributes | |
$views | |
List of views. More... | |
The base view class
To create a view use
$view = new WPDKView( 'my-view' ); $view->content = 'Hello World"; $view->display();
Or
$view = WPDKView::initWithContent( 'my-view', '', 'Hello World' ); $view->display();
Or, suggested method
class MyView extends WPDKView { public function __construct() { parent::__construct( 'my-id', 'additional class' ); } // Override public function draw() { echo 'Hello World'; } }
If you like use a WPDKView
directly, you will use the content
property. Otherwise, you can sub class the WPDKView
and then use the method draw()
to diplay the content of the view.
You can observe some event via filters and actions. For example you can catch when a content has been drawed. For fo this you can use the filter wpdk_view_did_draw_content
:
add_action( 'wpdk_view_did_draw_content', array( $this, 'wpdk_view_did_draw_content') ); public function wpdk_view_did_draw_content( $view ) { if ( is_a( $view, 'WPDKHeaderView' ) ) { // Do something } }
In this case we had used the "is_a" function to understand which type of view was passed. Alternatively you can check the view id, for example.
public function wpdk_view_did_draw_content( $view ) { if ( 'my_id' == $view->id ) { // Do something } }
Definition at line 63 of file wpdk-view.php.
__construct | ( | $id, | |
$class = '' |
|||
) |
Construct.
Create an instance of WPDKView class
string | $id | The unique id for this view |
array | string | $class | Optional. The CSS classes for this view |
Definition at line 155 of file wpdk-view.php.
addSubview | ( | $view | ) |
Add a subview.
Add a view in queue views
WPDKView | $view |
Definition at line 273 of file wpdk-view.php.
draw | ( | ) |
Draw.
Draw the view content
Definition at line 257 of file wpdk-view.php.
html | ( | ) |
Get HTML markup content.
Return the HTML markup content of this view
Definition at line 197 of file wpdk-view.php.
|
static |
Init a WPDKView.
Create an instance of WPDKView class with a content
string | $id | The unique id for this view |
array | string | $class | Optional. The CSS classes for this view |
string | $content | Optional. An HTML markup content |
Definition at line 175 of file wpdk-view.php.
|
static |
Definition at line 186 of file wpdk-view.php.
removeFromSuperview | ( | ) |
string $__version = '1.1.2' |
array $class |
string $content |
array $data |
Key value pairs array Attribute data: data-attribute = value
Definition at line 106 of file wpdk-view.php.
string $id |
array $style |
array $subviews |
List of sub views.
An array list with the subviews of this view
Definition at line 124 of file wpdk-view.php.
WPDKView $superview |
|
protected |
List of views.
An array list with views of this view controller
Definition at line 143 of file wpdk-view.php.