22namespace VendorName \MyPlugin ;
33use Carbon_Fields \Container ;
44use Carbon_Fields \Field ;
5+ use Config ;
56
67class Plugin {
78
@@ -10,9 +11,11 @@ class Plugin {
1011
1112 function __construct ( $ _settings ) {
1213
13- // Set text domain and option prefix
14+ // Initialize plugin settings
15+ $ plugin_config = new Config \Config ( $ _settings ['path ' ] . 'plugin.json ' );
1416 self ::$ textdomain = $ _settings ['data ' ]['TextDomain ' ];
15- self ::$ settings = $ _settings ;
17+ self ::$ settings = array_merge ( $ _settings , $ plugin_config ->get () );
18+ //var_dump(self::$settings); exit;
1619
1720 // Verify dependecies and load plugin logic
1821 register_activation_hook ( self ::$ settings ['plugin_file ' ], array ( $ this , 'activate ' ) );
@@ -89,8 +92,8 @@ public function load_plugin() {
8992 */
9093 private function verify_dependencies ( $ deps = true , $ args = array () ) {
9194
92- if ( is_bool ( $ deps ) && $ deps ) $ deps = self ::$ settings ['deps ' ];
93- if ( !is_array ( $ deps ) ) $ deps = array ( $ deps => self ::$ settings ['deps ' ][$ deps ] );
95+ if ( is_bool ( $ deps ) && $ deps ) $ deps = self ::$ settings ['dependencies ' ];
96+ if ( !is_array ( $ deps ) ) $ deps = array ( $ deps => self ::$ settings ['dependencies ' ][$ deps ] );
9497
9598 $ args = Utils::set_default_atts ( array (
9699 'echo ' => true ,
@@ -106,7 +109,7 @@ private function verify_dependencies( $deps = true, $args = array() ) {
106109 case 'php ' :
107110
108111 if ( version_compare ( phpversion (), $ version , '< ' ) ) {
109- $ notices [] = __ ( 'This plugin is not supported on versions of PHP below ' , self ::$ textdomain ) . ' ' . self ::$ settings ['deps ' ]['php ' ] . '. ' ;
112+ $ notices [] = __ ( 'This plugin is not supported on versions of PHP below ' , self ::$ textdomain ) . ' ' . self ::$ settings ['dependencies ' ]['php ' ] . '. ' ;
110113 }
111114 break ;
112115
@@ -116,7 +119,7 @@ private function verify_dependencies( $deps = true, $args = array() ) {
116119 if ( !$ args ['activate ' ] && !defined ('\\Carbon_Fields \\VERSION ' ) ) {
117120 $ notices [] = __ ( 'An unknown error occurred while trying to load the Carbon Fields framework. ' , self ::$ textdomain );
118121 } else if ( defined ('\\Carbon_Fields \\VERSION ' ) && version_compare ( \Carbon_Fields \VERSION , $ version , '< ' ) ) {
119- $ notices [] = __ ( 'An outdated version of Carbon Fields has been detected: ' , self ::$ textdomain ) . ' ' . \Carbon_Fields \VERSION . ' (>= ' .self ::$ settings ['deps ' ]['carbon_fields ' ] . ' ' . __ ( 'required ' , self ::$ textdomain ) . '). ' . ' <strong> ' . self ::$ settings ['data ' ]['Name ' ] . '</strong> ' . __ ( 'deactivated. ' , self ::$ textdomain ) ;
122+ $ notices [] = __ ( 'An outdated version of Carbon Fields has been detected: ' , self ::$ textdomain ) . ' ' . \Carbon_Fields \VERSION . ' (>= ' .self ::$ settings ['dependencies ' ]['carbon_fields ' ] . ' ' . __ ( 'required ' , self ::$ textdomain ) . '). ' . ' <strong> ' . self ::$ settings ['data ' ]['Name ' ] . '</strong> ' . __ ( 'deactivated. ' , self ::$ textdomain ) ;
120123 }
121124 break ;
122125
0 commit comments