Last active
December 5, 2015 13:54
-
-
Save merianos/1e1a5b2fbef1a02a11bb to your computer and use it in GitHub Desktop.
Explain Page Builder how to load your widgets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function manually_load_widgets() { | |
$widgets_folder = dirname( __FILE__ ) . '/widgets/'; | |
$contents = scandir( $widgets_folder ); | |
foreach( $contents as $item ) { | |
if ( '.' === $item || '..' === $item || !is_dir( $widgets_folder . $item ) ) { | |
continue; | |
} | |
foreach ( glob( $widgets_folder . $item . '/*.php' ) as $file ) { | |
$file_data = get_file_data( | |
$file, | |
array( | |
'Widget Name' => 'Widget Name', | |
'Description' => 'Description', | |
'Author' => 'Author', | |
'Author URI' => 'Author URI', | |
'Widget URI' => 'Widget URI', | |
'Video URI' => 'Video URI', | |
) | |
); | |
if ( isset( $file_data[ 'Widget Name' ] ) && ! empty( $file_data[ 'Widget Name' ] ) ) { | |
require_once $file; | |
} | |
} | |
} | |
} | |
add_action( 'after_setup_theme', array( $this, 'manually_load_widgets' ), 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment