/includes/skip/elements/element.php

  1. <?php 
  2. /** 
  3. * Skip Element 
  4. * @package Skip 
  5. * @since 1.0 
  6. * @ignore 
  7. */ 
  8.  
  9. namespace skip\v1_0_0; 
  10.  
  11. class Element{ 
  12.  
  13. var $before_element; 
  14. var $after_element; 
  15.  
  16. var $elements = array(); 
  17.  
  18. public function __construct( $args = array() ) { 
  19. $defaults = array( 
  20. 'before_element' => '',  
  21. 'after_element' => '',  
  22. ); 
  23.  
  24. $args = wp_parse_args( $args, $defaults ); 
  25. extract( $args , EXTR_SKIP ); 
  26.  
  27. $this->before_element = $before_element; 
  28. $this->after_element = $after_element; 
  29.  
  30. public function before( $content ) { 
  31. $this->before_element.= $content; 
  32.  
  33. public function after( $content ) { 
  34. $this->after_element.= $content; 
  35.  
  36. public function add_element( $element ) { 
  37. $this->elements[] = $element; 
  38.  
  39. public function render() { 
  40. foreach( $this->elements AS $element ) 
  41. $content.= $element; 
  42.  
  43. $content = $this->before_content . $content . $this->after_element; 
  44. return $content; 
  45.  
  46. /** 
  47. * Helping function for handling element objects 
  48. * 
  49. * @param object $object The object to handle 
  50. * @param string $return How to return 'echo', 'object' or 'html' 
  51. * @package Skip 
  52. * @since 1.0 
  53. * @ignore 
  54. */ 
  55. function element_return( $object, $return = 'html' ) { 
  56. return $object->render(); 
.