File tree Expand file tree Collapse file tree 1 file changed +35
-4
lines changed Expand file tree Collapse file tree 1 file changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -198,11 +198,42 @@ public static function constants() {
198198
199199 }
200200
201- public static function include_plugin_file ( $ file ) {
202- $ path = self ::$ dir .'/ ' . ltrim ( $ file , '/ ' );
203- if ( file_exists ( $ path ) ) {
204- require_once $ path ;
201+ public static function include_plugin_file ( $ file , $ load = true ) {
202+
203+ $ path = '' ;
204+ $ file = ltrim ( $ file , '/ ' );
205+ $ override = apply_filters ( 'csf_override ' , 'csf-override ' );
206+
207+ if ( file_exists ( get_parent_theme_file_path ( $ override .'/ ' . $ file ) ) ) {
208+ $ path = get_parent_theme_file_path ( $ override .'/ ' . $ file );
209+ } elseif ( file_exists ( get_theme_file_path ( $ override .'/ ' . $ file ) ) ) {
210+ $ path = get_theme_file_path ( $ override .'/ ' . $ file );
211+ } elseif ( file_exists ( self ::$ dir .'/ ' . $ override .'/ ' . $ file ) ) {
212+ $ path = self ::$ dir .'/ ' . $ override .'/ ' . $ file ;
213+ } elseif ( file_exists ( self ::$ dir .'/ ' . $ file ) ) {
214+ $ path = self ::$ dir .'/ ' . $ file ;
205215 }
216+
217+ if ( ! empty ( $ path ) && ! empty ( $ file ) && $ load ) {
218+
219+ global $ wp_query ;
220+
221+ if ( is_object ( $ wp_query ) && function_exists ( 'load_template ' ) ) {
222+
223+ load_template ( $ path , true );
224+
225+ } else {
226+
227+ require_once ( $ path );
228+
229+ }
230+
231+ } else {
232+
233+ return self ::$ dir .'/ ' . $ file ;
234+
235+ }
236+
206237 }
207238
208239 // Sanitize dirname
You can’t perform that action at this time.
0 commit comments