File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,18 +60,18 @@ public function load_plugin() {
6060 // Enqueue scripts and stylesheets
6161 new EnqueueScripts ();
6262
63- // Perform core plugin logic
64- new Core ();
65-
6663 // Create custom post types
67- new PostTypes \Clients ();
64+ new PostTypes \PostTypes_Loader ();
6865
6966 // Load custom widgets
70- new Widgets \WidgetLoader ();
67+ new Widgets \Widget_Loader ();
7168
7269 // Load shortcodes
7370 new Shortcodes \Shortcode_Loader ();
7471
72+ // Perform core plugin logic
73+ new Core ();
74+
7575 }
7676
7777 /**
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace VendorName \PluginName \PostTypes ;
3+ use VendorName \PluginName \Plugin ;
4+
5+ class PostTypes_Loader extends Plugin {
6+
7+ /**
8+ * @var array Shortcode class name to register
9+ * @since 0.4.0
10+ */
11+ protected $ posttypes ;
12+
13+ public function __construct () {
14+
15+ $ this ->posttypes = array (
16+ Clients::class
17+ );
18+
19+ foreach ( $ this ->posttypes as $ posttypesClass ) {
20+
21+ $ posttype = new $ posttypesClass ();
22+ if ( $ posttype instanceof PostTypeInterface ) {
23+ new $ posttype ();
24+ }
25+
26+ }
27+
28+ }
29+
30+ }
Original file line number Diff line number Diff line change @@ -21,9 +21,9 @@ public function __construct() {
2121
2222 $ shortcode = new $ shortcodeClass ();
2323 if ( $ shortcode instanceof ShortcodeInterface ) {
24- new $ shortcode ();
24+ new $ shortcode ();
2525 } else {
26- // Log or show error notices
26+ // Log or show error notices
2727 }
2828
2929 }
Original file line number Diff line number Diff line change 22namespace VendorName \PluginName \Widgets ;
33use VendorName \PluginName \Plugin ;
44
5- class WidgetLoader extends Plugin {
5+ class Widget_Loader extends Plugin {
66
77 public function __construct () {
88
99 // Register widgets
1010 add_action ( 'widgets_init ' , function () {
11- register_widget ( new ExampleWidget () );
12- } );
11+
12+ register_widget ( new Example_Widget () );
13+
14+ });
1315
1416 }
1517
You can’t perform that action at this time.
0 commit comments