-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathradioco.php
128 lines (107 loc) · 3.22 KB
/
radioco.php
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* Plugin Name: RadioCo
* Plugin URI: http://www.radiocorax.de
* Description: RadioCo wordpress frontend
* Version: 0.0.1
* Author: Stefan Walluhn
* Author URI: http://stefan.walluhn.de
* Text Domain: radioco
* Domain Path: /languages
*/
/**
* Use statements. Add any useful class import
* below.
*/
use Composer\Autoload\ClassLoader;
/*
* Default constants.
*/
defined('DS') ? DS : define('DS', DIRECTORY_SEPARATOR);
defined('RADIOCO_TD') ? RADIOCO_TD : define('RADIOCO_TD', 'radioco');
$vars = [
'slug' => 'radioco',
'name' => 'RadioCo',
'namespace' => 'de.radiocorax.radioco',
'config' => 'de_radiocorax_radioco',
];
/*
* Verify that the main framework is loaded.
*/
add_action('admin_notices', function () use ($vars) {
if (!class_exists('\Themosis\Foundation\Application')) {
printf('<div class="notice notice-error"><p>%s</p></div>', __('This plugin requires the Themosis framework in order to work.', RADIOCO_TD));
}
/*
* Define your plugin theme support key. Once defined, make sure to add the key
* into your theme `supports.config.php` in order to remove this admin notice.
*/
if (!current_theme_supports($vars['slug']) && current_user_can('switch_themes')) {
printf('<div class="notice notice-warning"><p>%s<strong>%s</strong></p></div>', __('Your application does not handle the following plugin: ', RADIOCO_TD), $vars['name']);
}
});
/*
* Setup the plugin paths.
*/
$paths['plugin.'.$vars['namespace']] = __DIR__.DS;
$paths['plugin.'.$vars['namespace'].'.resources'] = __DIR__.DS.'resources'.DS;
$paths['plugin.'.$vars['namespace'].'.admin'] = __DIR__.DS.'resources'.DS.'admin'.DS;
themosis_set_paths($paths);
/*
* Setup plugin config files.
*/
container('config.finder')->addPaths([
themosis_path('plugin.'.$vars['namespace'].'.resources').'config'.DS,
]);
/*
* Autoloading.
*/
$loader = new ClassLoader();
$classes = container('config.factory')->get($vars['config'].'_loading');
foreach ($classes as $prefix => $path) {
$loader->addPsr4($prefix, $path);
}
$loader->register();
/*
* Register plugin public assets folder [dist directory].
*/
container('asset.finder')->addPaths([
plugins_url('dist', __FILE__) => themosis_path('plugin.'.$vars['namespace']).'dist',
]);
/*
* Register plugin views.
*/
container('view.finder')->addLocation(themosis_path('plugin.'.$vars['namespace'].'.resources').'views');
/*
* Update Twig Loader registered paths.
*/
container('twig.loader')->setPaths(container('view.finder')->getPaths());
/*
* Service providers.
*/
$providers = container('config.factory')->get($vars['config'].'_providers');
foreach ($providers as $provider) {
container()->register($provider);
}
/*
* Admin files autoloading.
* I18n.
*/
container('action')->add('plugins_loaded', function () use ($vars) {
/**
* I18n
* Todo: #2 - Replace constant below.
*/
load_plugin_textdomain(RADIOCO_TD, false, trailingslashit(dirname(plugin_basename(__FILE__))).'languages');
/*
* Plugin admin files.
* Autoload files in alphabetical order.
*/
$loader = container('loader')->add([
themosis_path('plugin.'.$vars['namespace'].'.admin'),
]);
$loader->load();
});
/*
* Add extra features below.
*/