Skip to content

Commit

Permalink
Adds ability for editor-xtd plugin to generate multiple buttons
Browse files Browse the repository at this point in the history
This creates the ability for an editor-xtd plugin to return an array of buttons, instead of just one button object.

### Testing
To test, replace this code in
/plugins/editors-xtd/readmore/readmore.php
```
return $button;
```

with:
```
		$button2 = new JObject;
		$button2->modal = false;
		$button2->class = 'btn';
		$button2->onclick = 'alert("Hurray!");return false;';
		$button2->text = 'An extra button!';
		$button2->name = 'smiley-2';
		$button2->link = '#';

		return array($button, $button2);
```
  • Loading branch information
Peter van Westen committed Mar 4, 2016
1 parent 78d51eb commit b50885b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libraries/cms/editor/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,20 @@ public function getButtons($editor, $buttons = true)
}

// Try to authenticate
if (method_exists($plugin, 'onDisplay') && $temp = $plugin->onDisplay($editor, $this->asset, $this->author))

This comment has been minimized.

Copy link
@yvesh

yvesh Mar 6, 2016

Member

You removed the && $temp = .. (which allowed to return false etc.)

See issue #9316

if (!method_exists($plugin, 'onDisplay'))
{
$result[] = $temp;
continue;
}

$button = $plugin->onDisplay($editor, $this->asset, $this->author);

if (is_array($button))
{
$result = array_merge($result, $button);
continue;
}

$result[] = $button;
}

return $result;
Expand Down

0 comments on commit b50885b

Please sign in to comment.