Skip to content

Commit

Permalink
Element Base: Added get_render_attributes method. Closes elementor#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kobizz committed Oct 9, 2018
1 parent f426716 commit 35df5c8
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions includes/base/element-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,43 @@ public function add_render_attribute( $element, $key = null, $value = null, $ove
return $this;
}

/**
* Get Render Attributes
*
* Used to retrieve render attribute.
*
* The returned array is either all elements and their attributes if no `$element` is specified, an array of all
* attributes of a specific element or a specific attribute properties if `$key` is specified.
*
* Returns null if one of the requested parameters isn't set.
*
* @param string $element
* @param string $key
*
* @return array
*/
public function get_render_attributes( $element = '', $key = '' ) {
$attributes = $this->render_attributes;

if ( $element ) {
if ( ! isset( $attributes[ $element ] ) ) {
return null;
}

$attributes = $attributes[ $element ];

if ( $key ) {
if ( ! isset( $attributes[ $key ] ) ) {
return null;
}

$attributes = $attributes[ $key ];
}
}

return $attributes;
}

/**
* Set render attribute.
*
Expand Down

0 comments on commit 35df5c8

Please sign in to comment.