| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This is the class that adds the main sidebar and declares the widgets |
| 5 |
*/ |
| 6 |
// Exit if called directly |
| 7 |
if ( !defined( 'ABSPATH' ) ) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
include_once 'class-basepress-products-widget.php'; |
| 11 |
include_once 'class-basepress-sections-widget.php'; |
| 12 |
include_once 'class-basepress-related-articles-widget.php'; |
| 13 |
include_once 'class-basepress-nav-widget.php'; |
| 14 |
if ( !class_exists( 'Basepress_Widgets' ) ) { |
| 15 |
class Basepress_Widgets { |
| 16 |
/** |
| 17 |
* basepress_widgets constructor. |
| 18 |
* |
| 19 |
* @since 1.0.0 |
| 20 |
*/ |
| 21 |
public function __construct() { |
| 22 |
//Add widget area and Widgets |
| 23 |
add_action( 'widgets_init', array($this, 'register_widgets'), 99 ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Creates Basepress sidebars |
| 28 |
* |
| 29 |
* @since 1.0.0 |
| 30 |
*/ |
| 31 |
public function register_widgets() { |
| 32 |
register_sidebar( array( |
| 33 |
'name' => esc_html__( 'Knowledge Base Sidebar', 'basepress' ), |
| 34 |
'id' => 'basepress-sidebar', |
| 35 |
'description' => esc_html__( 'Add here the widgets to appear on the knowledge base pages', 'basepress' ), |
| 36 |
'class' => '', |
| 37 |
'before_widget' => '<section id="%1$s" class="widget %2$s">', |
| 38 |
'after_widget' => '</section>', |
| 39 |
'before_title' => '<h2 class="widget-title">', |
| 40 |
'after_title' => '</h2>', |
| 41 |
) ); |
| 42 |
register_widget( 'basepress_products_widget' ); |
| 43 |
register_widget( 'basepress_sections_widget' ); |
| 44 |
register_widget( 'basepress_related_articles_widget' ); |
| 45 |
register_widget( 'basepress_nav_widget' ); |
| 46 |
} |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
// End of Class |
| 51 |
new Basepress_Widgets(); |
| 52 |
} |