Skip to content

Commit

Permalink
Posttypes and taxonomies register upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjacoby committed Jan 23, 2021
1 parent e86aba1 commit 3302825
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
22 changes: 16 additions & 6 deletions src/Application/Support/Posttypes/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,13 @@ public function setDefaults()
* @param string $this->config
*/
public function setSupports()
{

{
if ($this->config->has('supports')) {
$this->config->put('supports', array_keys($this->config->pull('supports')));
$keys = Arr::collect($this->config->get('supports'))->keys()->toArray();
$keys = array_map(function ($value) {
return str_replace('_', '-', $value);
}, $keys);
$this->config->put('supports', $keys);
}
}

Expand All @@ -83,10 +86,17 @@ public function setSupports()
* @param string $this->config
*/
public function setTaxonomies()
{
{
$taxonomies = $this->config->has('taxonomies') ?
$this->config->pull('taxonomies') :
false;

if ($taxonomies) {
$taxonomies = is_string($taxonomies) ?
[$taxonomies] :
Arr::collect($taxonomies)->keys()->toArray();

if ($this->config->has('taxonomies')) {
$this->config->put('taxonomies', array_keys($this->config->pull('taxonomies')));
$this->config->put('taxonomies', $taxonomies);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/Application/Support/Taxonomies/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ public function setLabels()
*/
public function setLinks()
{
$this->links = $this->config->has('links') ?
array_keys($this->config->pull('links')) :
$links = $this->config->has('links') ?
$this->config->pull('links') :
'post';

$this->links = is_string($links) ?
[$links] :
Arr::collect($links)->keys()->toArray();
}

/**
Expand Down

0 comments on commit 3302825

Please sign in to comment.