## Overview 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'; } } ### draw() VS content 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. ### Observing 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 } }
Author: =undo= (info@wpxtre.me)
Inheritance: extends WPDKObject
Example #1
0
 /**
  * Create an instance of WPDKMetaBoxView class
  *
  * @brief Construct
  *
  * @param string        $id            String for use in the 'id' attribute of tags.
  * @param string        $title         Title of the meta box.
  * @param string|object $screen        Optional. The screen on which to show the box (post, page, link). Defaults to current screen.
  * @param string        $context       Optional. The context within the page where the boxes should show ('normal', 'advanced').
  * @param string        $priority      Optional. The priority within the context where the boxes should show ('high', 'low').   *
  * @param mixed         $callback_args Optional. Callable args.
  *
  * @return WPDKMetaBoxView
  */
 public function __construct($id, $title, $screen = null, $context = WPDKMetaBoxContext::ADVANCED, $priority = WPDKMetaBoxPriority::NORMAL, $callback_args = null)
 {
     // TODO The view id must be different from WordPress postbox id, see HTML generate for detail.
     parent::__construct($id);
     // TODO The view id must be different from WordPress postbox id, see HTML generate for detail.
     add_meta_box($id, $title, array($this, 'display'), $screen, $context, $priority, $callback_args);
 }
Example #2
0
 /**
  * Create an instance of WPDKPreferencesView class
  *
  * @brief Construct
  *
  * @param WPDKPreferences $preferences An instance of WPDKPreferences clas
  * @param string          $property    Preferences branch property name
  *
  * @return WPDKPreferencesView
  */
 public function __construct($preferences, $property)
 {
     parent::__construct('wpdk_preferences_view-' . $property);
     // Strore preferences
     $this->preferences = $preferences;
     // Save the branch if exists
     if (!empty($property) && isset($this->preferences->{$property})) {
         $this->branch_property = $property;
         $this->branch = $this->preferences->{$property};
     }
 }
Example #3
0
 /**
  * Create an instance of WPDKUIPageView class
  *
  * @brief Construct
  *
  * @return WPDKUIPageView
  */
 public function __construct()
 {
     parent::__construct(self::ID, 'wpdk-ui-page-view-main-container');
 }
Example #4
0
    /**
     * Draw the content of this view
     *
     * @brief Draw content
     */
    public function draw()
    {
        ?>
    <div data-type="wpdk-header-view" id="<?php 
        echo $this->id;
        ?>
" class="wpdk-vc-header-icon"></div>

    <h2><?php 
        echo $this->title;
        ?>
      <?php 
        /**
         * Fires into the the title TAG.
         *
         * @since 1.5.16
         *
         * @param WPDKHeaderView $header_view An instance of WPDKHeaderView class.
         */
        do_action('wpdk_header_view_inner_title', $this);
        /**
         * Fires into the the title TAG.
         *
         * The dynamic portion of the hook name, $id, refers to the header view id.
         *
         * @since 1.5.16
         *
         * @param WPDKHeaderView $header_view An instance of WPDKHeaderView class.
         */
        do_action('wpdk_header_view_inner_title-' . $this->id, $this);
        /**
         * Fires into the the title TAG.
         *
         * @deprecated since 1.5.16
         * @param WPDKHeaderView $header_view An instance of WPDKHeaderView class.
         */
        do_action('wpdk_header_view_' . $this->id . '_title_did_appear', $this);
        // @deprecated
        //do_action( 'wpdk_header_view_title_did_appear', $this );
        ?>
</h2>
    <?php 
        /**
         * Fires after the the title.
         *
         * @param WPDKHeaderView $header_view An instance of WPDKHeaderView class.
         */
        do_action('wpdk_header_view_after_title', $this);
        /**
         * Fires after the the title.
         *
         * The dynamic portion of the hook name, $id, refers to the header view id.
         *
         * @since 1.5.16
         *
         * @param WPDKHeaderView $header_view An instance of WPDKHeaderView class.
         */
        do_action('wpdk_header_view_after_title-' . $this->id, $this);
        // @deprecated
        do_action('wpdk_header_view_' . $this->id . '_after_title', $this);
        // @deprecated
        //do_action( 'wpdk_header_view_after_title', $this );
        ?>
    <?php 
        parent::draw();
    }
Example #5
0
 /**
  * Create an instance of WPDKUITableView class
  *
  * @patam string $id The view id.
  *
  * @return WPDKUITableView
  */
 public function __construct($id)
 {
     parent::__construct($id, 'wpdk-ui-table-view');
     // Enqueue component
     WPDKUIComponents::init()->enqueue(WPDKUIComponents::TABLE);
 }
Example #6
0
 /**
  * Create an instance of WPDKjQueryTabsView class
  *
  * @brief Construct
  *
  * @param string $id       The view ID
  * @param array  $tabs     Optional. A tabs list. Instances of WPDKjQueryTab class
  * @param bool   $vertical Optional. Set to TRUE in order to display vertical tab. Default is FALSE.
  *
  * @return WPDKjQueryTabsView
  */
 public function __construct($id, $tabs = array(), $vertical = false)
 {
     parent::__construct($id, 'wpdk-jquery-ui');
     $this->tabs = $tabs;
     $this->vertical = $vertical;
 }
Example #7
0
 /**
  * Create an instance of WPDKDynamicTableView class
  *
  * @brief Construct
  *
  * @param string $id      ID for this dynamic table
  *
  * @return WPDKDynamicTableView
  */
 public function __construct($id)
 {
     parent::__construct($id);
     // Added dynamic
     $this->columns[self::COLUMN_ROW_MANAGE] = '';
     // Enqueue components
     WPDKUIComponents::init()->enqueue(WPDKUIComponents::DYNAMIC_TABLE);
 }