Skip to content

Commit a82079b

Browse files
committed
Split up init processes again
This makes it easier to short circuit different parts of the init and add things in more specifically
1 parent 60b01e6 commit a82079b

File tree

4 files changed

+104
-22
lines changed

4 files changed

+104
-22
lines changed

admin/init.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Defines all default globals used throughout the library.
4+
*
5+
* @package CareLib\Globals
6+
* @author WP Site Care
7+
* @copyright Copyright (c) 2016, WP Site Care, LLC
8+
* @license GPL-2.0+
9+
* @since 1.0.0
10+
*/
11+
12+
defined( 'ABSPATH' ) || exit;
13+
14+
/**
15+
* Provide reliable access to the library's functions before the global
16+
* actions, filters, and classes are initialized.
17+
*
18+
* @since 1.0.0
19+
* @access public
20+
*/
21+
do_action( 'carelib_admin_before_init' );
22+
23+
require_once CARELIB_DIR . 'admin/dashboard.php';
24+
require_once CARELIB_DIR . 'admin/layouts.php';
25+
require_once CARELIB_DIR . 'admin/metabox-post-layouts.php';
26+
require_once CARELIB_DIR . 'admin/metabox-post-styles.php';
27+
require_once CARELIB_DIR . 'admin/metabox-post-templates.php';
28+
require_once CARELIB_DIR . 'admin/scripts.php';
29+
require_once CARELIB_DIR . 'admin/styles.php';
30+
require_once CARELIB_DIR . 'admin/actions.php';
31+
32+
/**
33+
* Provide reliable access to the library's functions before the global
34+
* actions, filters, and classes are initialized.
35+
*
36+
* @since 1.0.0
37+
* @access public
38+
*/
39+
do_action( 'carelib_admin_after_init' );

carelib.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,31 @@
103103
function carelib_init() {
104104
require_once CARELIB_DIR . 'includes/init.php';
105105
}
106+
107+
add_action( 'after_setup_theme', 'carelib_admin_init', -95 );
108+
/**
109+
* Load and initialize all library functionality.
110+
*
111+
* @since 1.0.0
112+
* @access public
113+
* @return void
114+
*/
115+
function carelib_admin_init() {
116+
if ( is_admin() ) {
117+
require_once CARELIB_DIR . 'admin/init.php';
118+
}
119+
}
120+
121+
add_action( 'after_setup_theme', 'carelib_customize_init', -95 );
122+
/**
123+
* Load and initialize all library functionality.
124+
*
125+
* @since 1.0.0
126+
* @access public
127+
* @return void
128+
*/
129+
function carelib_customize_init() {
130+
if ( is_customize_preview() ) {
131+
require_once CARELIB_DIR . 'customize/init.php';
132+
}
133+
}

customize/init.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Defines all default globals used throughout the library.
4+
*
5+
* @package CareLib\Globals
6+
* @author WP Site Care
7+
* @copyright Copyright (c) 2016, WP Site Care, LLC
8+
* @license GPL-2.0+
9+
* @since 1.0.0
10+
*/
11+
12+
defined( 'ABSPATH' ) || exit;
13+
14+
/**
15+
* Provide reliable access to the library's functions before the global
16+
* actions, filters, and classes are initialized.
17+
*
18+
* @since 1.0.0
19+
* @access public
20+
*/
21+
do_action( 'carelib_customize_before_init' );
22+
23+
require_once CARELIB_DIR . 'customize/control-radio-image.php';
24+
require_once CARELIB_DIR . 'customize/control-layout.php';
25+
require_once CARELIB_DIR . 'customize/register.php';
26+
require_once CARELIB_DIR . 'customize/scripts.php';
27+
require_once CARELIB_DIR . 'customize/styles.php';
28+
require_once CARELIB_DIR . 'customize/actions.php';
29+
30+
/**
31+
* Provide reliable access to the library's functions before the global
32+
* actions, filters, and classes are initialized.
33+
*
34+
* @since 1.0.0
35+
* @access public
36+
*/
37+
do_action( 'carelib_customize_after_init' );

includes/init.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*
1818
* @since 1.0.0
1919
* @access public
20-
* @param string $version the current library version
2120
*/
2221
do_action( 'carelib_before_init' );
2322

@@ -51,32 +50,11 @@
5150
require_once CARELIB_DIR . 'includes/actions.php';
5251
require_once CARELIB_DIR . 'includes/filters.php';
5352

54-
if ( is_admin() ) {
55-
require_once CARELIB_DIR . 'admin/dashboard.php';
56-
require_once CARELIB_DIR . 'admin/layouts.php';
57-
require_once CARELIB_DIR . 'admin/metabox-post-layouts.php';
58-
require_once CARELIB_DIR . 'admin/metabox-post-styles.php';
59-
require_once CARELIB_DIR . 'admin/metabox-post-templates.php';
60-
require_once CARELIB_DIR . 'admin/scripts.php';
61-
require_once CARELIB_DIR . 'admin/styles.php';
62-
require_once CARELIB_DIR . 'admin/actions.php';
63-
}
64-
65-
if ( is_customize_preview() ) {
66-
require_once CARELIB_DIR . 'customize/control-radio-image.php';
67-
require_once CARELIB_DIR . 'customize/control-layout.php';
68-
require_once CARELIB_DIR . 'customize/register.php';
69-
require_once CARELIB_DIR . 'customize/scripts.php';
70-
require_once CARELIB_DIR . 'customize/styles.php';
71-
require_once CARELIB_DIR . 'customize/actions.php';
72-
}
73-
7453
/**
7554
* Provide reliable access to the library's functions before the global
7655
* actions, filters, and classes are initialized.
7756
*
7857
* @since 1.0.0
7958
* @access public
80-
* @param string $version the current library version
8159
*/
8260
do_action( 'carelib_after_init' );

0 commit comments

Comments
 (0)