1: <?php
2: /**
3: * Define the widgets class
4: *
5: * @since 1.1.0
6: *
7: * @package Simmer\Widgets
8: */
9:
10: // Die if this file is called directly.
11: if ( ! defined( 'WPINC' ) ) {
12: die;
13: }
14:
15: class Simmer_Widgets {
16:
17: /**
18: * The only instance of this class.
19: *
20: * @since 1.1.0
21: * @access protected
22: * @var object The only instance of this class.
23: */
24: protected static $instance = null;
25:
26: /**
27: * Get the main instance.
28: *
29: * @since 1.1.0
30: *
31: * @return The only instance of this class.
32: */
33: public static function get_instance() {
34:
35: if ( is_null( self::$instance ) ) {
36: self::$instance = new self();
37: self::$instance->include_files();
38: self::$instance->register_widgets();
39: }
40:
41: return self::$instance;
42: }
43:
44: /**
45: * Include the necessary widget class definitions.
46: *
47: * @since 1.1.0
48: *
49: * @return void
50: */
51: public function include_files() {
52:
53: /**
54: * Include the Recipe Categories widget class.
55: */
56: include plugin_dir_path( __FILE__ ) . 'class-simmer-categories-widget.php';
57:
58: /**
59: * Include the Recipe Recipes widget class.
60: */
61: include plugin_dir_path( __FILE__ ) . 'class-simmer-recent-recipes-widget.php';
62: }
63:
64: /**
65: * Register the widgets.
66: *
67: * @since 1.1.0
68: *
69: * @return void
70: */
71: public function register_widgets() {
72:
73: // Register the Recipe Categories widget.
74: register_widget( 'Simmer_Categories_Widget' );
75:
76: // Register the Recent Recipes widget.
77: register_widget( 'Simmer_Recent_Recipes_Widget' );
78:
79: /**
80: * Execute after Simmer's default widgets are registered.
81: *
82: * @since 1.1.0
83: */
84: do_action( 'simmer_widgets_init' );
85: }
86: }
87: