22namespace VendorName \PluginName ;
33use WordPress_ToolKit \ObjectCache ;
44use WordPress_ToolKit \ConfigRegistry ;
5+ use WordPress_ToolKit \PluginTools ;
56use WordPress_ToolKit \Helpers \ArrayHelper ;
67use Carbon_Fields \Container ;
78use Carbon_Fields \Field ;
@@ -15,25 +16,15 @@ class Plugin {
1516
1617 function __construct () {
1718
18- // Initialize plugin settings
19-
20- // Get plugin path, URL, identifier and slug
21- $ plugin_data ['path ' ] = plugin_dir_path ( __DIR__ );
22- $ plugin_data ['slug ' ] = end ( explode ( '/ ' , trim ( $ plugin_data ['path ' ], '/ ' ) ) );
23- $ plugin_data ['file ' ] = end ( explode ( '/ ' , debug_backtrace ()[0 ]['file ' ] ) );
24- $ plugin_data = array ( 'plugin ' => array (
25- 'identifier ' => $ plugin_data ['slug ' ] . DIRECTORY_SEPARATOR . $ plugin_data ['file ' ],
26- 'slug ' => $ plugin_data ['slug ' ],
27- 'path ' => $ plugin_data ['path ' ],
28- 'url ' => plugin_dir_url ( __DIR__ ),
29- 'meta ' => get_plugin_data ( $ plugin_data ['path ' ] . $ plugin_data ['file ' ] )
30- ));
31-
32- self ::$ config = new ConfigRegistry ( $ plugin_data ['plugin ' ]['path ' ] . 'plugin.json ' );
33- self ::$ config = self ::$ config ->merge ( new ConfigRegistry ( $ plugin_data ) );
19+ // Get plugin properties and meta data
20+ $ plugin_obj = new PluginTools ();
21+ $ plugin_data = $ plugin_obj ->get_current_plugin_data ( null , ARRAY_A );
22+
23+ self ::$ config = new ConfigRegistry ( $ plugin_data ['path ' ] . 'plugin.json ' );
24+ self ::$ config = self ::$ config ->merge ( new ConfigRegistry ( [ 'plugin ' => $ plugin_data ] ) );
3425 self ::$ textdomain = self ::$ config ->get ( 'plugin/meta/TextDomain ' ) ?: self ::$ config ->get ( 'plugin/slug ' );
3526
36- // Define plugin version constant
27+ // Define plugin VERSION constant
3728 if ( !defined ( __NAMESPACE__ . '\VERSION ' ) ) define ( __NAMESPACE__ . '\VERSION ' , self ::$ config ->get ( 'plugin/meta/Version ' ) );
3829
3930 // Initialize ObjectCache
0 commit comments