protected function registerContentNamespaces() { // Plugins foreach (WordPress::activePlugins() as $plugin_script) { if (!file_exists(wordpress_path('wp-content/plugins/') . $plugin_script)) { info("Error: Plugin '{$plugin_script}' is not found."); continue; } $plugin_data = get_file_data(wordpress_path('wp-content/plugins/') . $plugin_script, ['php_autoload_dir' => 'PHP Autoload', 'php_namespace' => 'PHP Namespace']); if (array_get($plugin_data, 'php_autoload_dir')) { $plugin = preg_replace('/(\\/.*$)|(.php$)/', '', $plugin_script); $plugin_path = wordpress_path('wp-content/plugins/' . $plugin); ContentClassLoader::addNamespace($plugin_path . '/' . $plugin_data['php_autoload_dir'], $plugin_data['php_namespace']); } } $theme = WordPress::activeTheme(); $theme_path = WordPress::themePath($theme); if (!file_exists($theme_path . '/style.css')) { info("Error: Theme '{$theme}' is not found."); return; } $theme_data = get_file_data($theme_path . '/style.css', ['php_autoload_dir' => 'PHP Autoload', 'php_namespace' => 'PHP Namespace']); if (array_get($theme_data, 'php_autoload_dir')) { ContentClassLoader::addNamespace($theme_path . '/' . array_get($theme_data, 'php_autoload_dir', 'classes'), $theme_data['php_namespace']); } }
protected function registerContentNamespaces() { // Plugins foreach (WordPress::activePlugins() as $plugin) { // $plugin_path = WordPress::pluginPath($plugin); $plugin_path = wordpress_path('wp-content/plugins/') . $plugin; $plugin_data = get_file_data($plugin_path, ['php_autoload_dir' => 'PHP Autoload', 'php_namespace' => 'PHP Namespace']); ContentClassLoader::addNamespace($plugin_path . '/' . array_get($plugin_data, 'php_autoload_dir', 'classes'), $plugin_data['php_namespace']); } $theme = WordPress::activeTheme(); $theme_path = WordPress::themePath($theme); $theme_data = get_file_data($theme_path . '/style.css', ['php_autoload_dir' => 'PHP Autoload', 'php_namespace' => 'PHP Namespace']); ContentClassLoader::addNamespace($theme_path . '/' . array_get($theme_data, 'php_autoload_dir', 'classes'), $theme_data['php_namespace']); }