| @@ -1,5 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-scope variables used immediately below; file is included inside a function scope. | |
| 3 | + | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; // Exit if accessed directly. | |
| 6 | +} | |
| 7 | + | |
| 2 | 8 | /** |
| 3 | 9 | * The template for adding Custom Sidebars and Widgets |
| 4 | 10 | * |
| 5 | 11 | * @package Essential_Widgets |
| @@ -5,23 +11,16 @@ | ||
| 5 | 11 | * @package Essential_Widgets |
| 6 | 12 | */ |
| 7 | 13 | |
| 8 | 14 | // Load Archives Widget |
| 9 | -include plugin_dir_path( __FILE__ ) . 'class-ew-archives.php'; | |
| 10 | 15 | |
| 11 | -// Load Authors Widget | |
| 12 | -include plugin_dir_path( __FILE__ ) . 'class-ew-authors.php'; | |
| 16 | +$option = essential_widgets_get_options(); | |
| 17 | +$widget_list = essential_widgets_list(); | |
| 13 | 18 | |
| 14 | -// Load Categories Widget | |
| 15 | -include plugin_dir_path( __FILE__ ) . 'class-ew-categories.php'; | |
| 19 | +foreach( $widget_list as $key => $value ) { | |
| 20 | + if( 1 === (int) $option[ $key ] ) { | |
| 21 | + $widget_file = str_replace( '_', '-', $key ); | |
| 16 | 22 | |
| 17 | -// Load Menu Widget | |
| 18 | -include plugin_dir_path( __FILE__ ) . 'class-ew-menus.php'; | |
| 19 | - | |
| 20 | -// Load Pages Widget | |
| 21 | -include plugin_dir_path( __FILE__ ) . 'class-ew-pages.php'; | |
| 22 | - | |
| 23 | -// Load Posts Widget | |
| 24 | -include plugin_dir_path( __FILE__ ) . 'class-ew-posts.php'; | |
| 25 | - | |
| 26 | -// Load Tags Widget | |
| 27 | -include plugin_dir_path( __FILE__ ) . 'class-ew-tags.php'; | |
| 23 | + // Enqueue active widget files | |
| 24 | + include plugin_dir_path( __FILE__ ) . 'class-' . $widget_file . '.php'; | |
| 25 | + } | |
| 26 | +} | |