Skip to content

Commit

Permalink
added setPosition method
Browse files Browse the repository at this point in the history
  • Loading branch information
sincspecv committed Sep 14, 2020
1 parent f0a23b6 commit e99eeda
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions classes/Base/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,19 @@ class Group {
* @var $hidden_elements array
*/
protected $hidden_elements;

/*
* Menu order option
*
* @var $order int
*/
protected $order;
/*
* Position option
*
* @var $order int
*/
protected $position;

/**
* Group parameters
Expand Down Expand Up @@ -111,14 +117,15 @@ public function init() {
* @since 0.1.0
*/
public function getArray() {
return [
'key' => $this->getKey(),
'title' => isset( $this->title ) ? $this->title : ucwords( $this->key ),
'fields' => $this->getFields(),
'location' => $this->getLocations(),
'hide_on_screen' => isset( $this->hidden_elements ) ? $this->hidden_elements : [],
'menu_order' => $this->getOrder(),
];
return [
'key' => $this->getKey(),
'title' => isset( $this->title ) ? $this->title : ucwords( $this->key ),
'fields' => $this->getFields(),
'location' => $this->getLocations(),
'hide_on_screen' => isset( $this->hidden_elements ) ? $this->hidden_elements : [],
'menu_order' => $this->getOrder(),
'position' => $this->getPosition(),
];
}

/**
Expand Down Expand Up @@ -312,10 +319,10 @@ public function getLocations() {

return [$results];
}

/**
* Set the menu_order option
*
*
* @param int $order
*/
protected function setOrder($order = 0) {
Expand All @@ -324,10 +331,28 @@ protected function setOrder($order = 0) {

/**
* Get the menu_order option. Returns 0 if not set.
*
*
* @return int
*/
protected function getOrder() {
return empty($this->order) ? 0 : $this->order;
}

/**
* Set the position option
*
* @param string $position
*/
protected function setPosition($position = 'normal') {
$this->position = $position;
}

/**
* Get the position option
*
* @return string
*/
protected function getPosition() {
return empty($this->position) ? 'normal' : $this->position;
}
}

0 comments on commit e99eeda

Please sign in to comment.