-
Notifications
You must be signed in to change notification settings - Fork 1
/
loader.php
116 lines (98 loc) · 2.3 KB
/
loader.php
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* Framework loader
*
* @package PuppyFW
*/
if ( ! defined( 'PUPPYFW_PATH' ) ) {
define( 'PUPPYFW_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'PUPPYFW_URL' ) ) {
define( 'PUPPYFW_URL', plugin_dir_url( __FILE__ ) );
}
/**
* Gets framework instance.
*
* @return \PuppyFW\Framework
*/
function puppyfw() {
return \PuppyFW\Framework::get_instance();
}
/**
* Framework init.
*/
function puppyfw_init() {
$framework = puppyfw();
/**
* Fires before init framework.
*
* @since 0.3.0
*
* @param \PuppyFW\Framework $framework Framework instance.
*/
do_action( 'puppyfw_before_init', $framework );
/**
* Registers settings for framework.
*
* @since 0.1.0
*
* @param \PuppyFW\Framework $framework Framework instance.
*/
do_action( 'puppyfw_init', $framework );
$framework->init();
/**
* Fires after init framework.
*
* @since 0.2.0
*
* @param \PuppyFW\Framework $framework Framework instance.
*/
do_action( 'puppyfw_after_init', $framework );
}
add_action( 'plugins_loaded', 'puppyfw_init' );
/**
* Runs something before init framework.
*
* @param \PuppyFW\Framework $framework Framework instance.
*/
function puppyfw_before_init( \PuppyFW\Framework $framework ) {
\PuppyFW\StaticCache::set( 'rendered_fields', array() );
$rest = new \PuppyFW\REST();
$rest->init();
/**
* Filters for enabling/disabling options page builder.
*
* @since 0.3.0
*
* @param bool $enable Whether to enable options page builder or not.
*/
if ( apply_filters( 'puppyfw_show_builder', true ) ) {
$builder = new \PuppyFW\Builder\Builder();
$builder->init();
}
}
add_action( 'puppyfw_before_init', 'puppyfw_before_init' );
/**
* Load Localisation files.
*/
function puppyfw_load_plugin_textdomain() {
load_plugin_textdomain( 'puppyfw', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'puppyfw_load_plugin_textdomain' );
/**
* Gets option api.
* This method automatically get default value if value is not set.
*
* @since 0.2.0
*
* @param string $page_slug Option page slug.
* @param string $option_id Option ID.
* @return mixed
*/
function puppyfw_get_option( $page_slug, $option_id ) {
$page = puppyfw()->get_page( $page_slug );
if ( ! $page ) {
return null;
}
return $page->get_option( $option_id );
}