/** * Return HTML markup for a input type * * @brief Simple button * * @param string $label Optional. Button label. If empty default is 'Update' * @param array $args Optional. A keys value array for additional settings * * 'type' => 'submit', * 'name' => 'button-update', * 'classes' => ' button-primary', * 'additional_classes' => '', * 'data' => '' * * @return string HTML input type submit */ public static function button($label = '', $args = array()) { $default_args = array('type' => 'submit', 'name' => 'button-update', 'classes' => ' button button-primary alignright', 'additional_classes' => '', 'data' => array()); $args = wp_parse_args($args, $default_args); // Label if (empty($label)) { $label = __('Update', WPDK_TEXTDOMAIN); } // Name attribute if (empty($args['name'])) { $name = ''; } else { $name = sprintf('name="%s"', $args['name']); } // Build data $data = WPDKHTMLTag::dataInline($args['data']); // Build classes $classes = WPDKHTMLTag::classInline($args['classes'], $args['additional_classes']); WPDKHTML::startCompress(); ?> <input type="<?php echo $args['type']; ?> " <?php echo $name; ?> <?php echo $data; ?> class="<?php echo $classes; ?> " value="<?php echo $label; ?> " /> <?php return WPDKHTML::endHTMLCompress(); }
/** * Return a string with complete list of data attributes as `data-name = "value"`. For example: * * <div data-my_attribute="my_value"></div> * * The data asttributes are readable and writeable from jQuery with: * * $( 'div' ).data( 'my_attribute' ); * * @brief Data attributes * * @return string */ protected function data() { $result = ''; if (isset($this->item['data']) && !empty($this->item['data'])) { $result = WPDKHTMLTag::dataInline($this->item['data']); } return $result; }
/** * Display the HTML markup content for this view. * * @brief Display view content * * @return string */ public function display() { $classes = WPDKHTMLTag::classInline($this->class); $style = WPDKHTMLTag::styleInline($this->style); $data = WPDKHTMLTag::dataInline($this->data); ?> <div data-type="wpdk-view" style="<?php echo $style; ?> " id="<?php echo $this->id; ?> " <?php echo $data; ?> class="<?php echo $classes; ?> "> <?php /** * Fires before start drawing content for this {id} view. * * @param WPDKView $view This view */ do_action('wpdk_view_will_draw_content-' . $this->id, $this); ?> <?php /** * Fires before start drawing content for this view. * * @param WPDKView $view This view */ do_action('wpdk_view_will_draw_content', $this); ?> <?php $this->draw(); ?> <?php if (is_array($this->subviews)) { ?> <?php /** * @var WPDKView $view */ foreach ($this->subviews as $view) { ?> <?php $view->display(); ?> <?php } ?> <?php } ?> <?php /** * Fires after drawing content for this view. * * @param WPDKView $view This view */ do_action('wpdk_view_did_draw_content', $this); ?> <?php /** * Fires after drawing content for this {id} view. * * @param WPDKView $view This view */ do_action('wpdk_view_did_draw_content-' . $this->id, $this); ?> </div> <?php }