forked from sheadawson/silverstripe-shortcodable
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path_config.php
More file actions
31 lines (25 loc) · 1.42 KB
/
_config.php
File metadata and controls
31 lines (25 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
use Shortcodable\Shortcodable;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\TinyMCE\TinyMCEConfig;
// Register classes added via yml config.
// NOTE: Shortcodes must be registered via YAML config (not programmatically in _config.php)
// because placeholder codes are collected here for TinyMCE. If your shortcode isn't showing
// placeholders, ensure it's registered in yml config, not in another module's _config.php.
Shortcodable::register_classes(Config::inst()->get(Shortcodable::class, 'shortcodable_classes'));
// enable shortcodable buttons and add to HtmlEditorConfig
$htmlEditorNames = Config::inst()->get(Shortcodable::class, 'htmleditor_names');
if (is_array($htmlEditorNames)) {
$shortcodableModuleResourceLoader = ModuleLoader::inst()->getManifest()->getModule('restruct/silverstripe-shortcodable');
$sc_placeholder_code_class_map = Shortcodable::get_shortcodable_classes_with_placeholders();
$sc_placeholder_codes = array_keys($sc_placeholder_code_class_map);
foreach ($htmlEditorNames as $htmlEditorName) {
TinyMCEConfig::get($htmlEditorName)
->enablePlugins([
'shortcodable' => $shortcodableModuleResourceLoader->getResource('client/dist/js/editor_plugin.js'),
])
->addButtonsToLine(1, '| shortcodable')
->setOption('shortcodable_placeholder_codes', $sc_placeholder_codes);
}
}