Provider.php
2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Provider for initializing theme implementations and hooks.
*
* @since 4.6.0
*
* @package LearnDash\Core
*/
/** NOTICE: This code is currently under development and may not be stable.
* Its functionality, behavior, and interfaces may change at any time without notice.
* Please refrain from using it in production or other critical systems.
* By using this code, you assume all risks and liabilities associated with its use.
* Thank you for your understanding and cooperation.
**/
namespace LearnDash\Core\Themes;
use LearnDash\Core\Template\Steps;
use StellarWP\Learndash\lucatume\DI52\ServiceProvider;
/**
* Class Provider for initializing theme implementations and hooks.
*
* @since 4.6.0
*/
class Provider extends ServiceProvider {
/**
* Registers the service provider bindings.
*
* @since 4.6.0
*
* @return void
*/
public function register(): void {
// Bindings.
$this->container->singleton( Breezy::class, Breezy::class );
$this->container->singleton( Steps\Loader::class, Steps\Loader::class );
// Initializations.
$this->initialize_themes();
$this->hooks();
}
/**
* Register hooks for the provider.
*
* @since 4.6.0
*
* @return void
*
* @ignore
*/
private function hooks(): void {
// Steps loader hooks.
add_filter(
'learndash_breezy_localize_script_data',
$this->container->callback( Steps\Loader::class, 'add_scripts_data' )
);
add_action(
'wp_ajax_' . Steps\Loader::$sub_steps_ajax_action_name,
$this->container->callback( Steps\Loader::class, 'handle_sub_steps_ajax_request' )
);
add_action(
'wp_ajax_nopriv_' . Steps\Loader::$sub_steps_ajax_action_name,
$this->container->callback( Steps\Loader::class, 'handle_sub_steps_ajax_request' )
);
}
/**
* Initializes the themes.
*
* @since 4.6.0
*
* @return void
*/
private function initialize_themes(): void {
add_action(
'learndash_themes_init',
function(): void {
/**
* Breezy theme.
*
* @var Breezy $breezy_theme Breezy theme.
*/
$breezy_theme = $this->container->get( Breezy::class );
$breezy_theme::add_theme_instance( 'breezy' );
}
);
}
}