globals.php
1.84 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
95
96
97
98
99
100
<?php
/**
* Global (non namespaced) functions.
*
* @package ContentControl
*/
use function ContentControl\plugin;
defined( 'ABSPATH' ) || exit;
/**
* Easy access to all plugin services from the container.
*
* @see \ContentControl\plugin_instance
*
* @param string|null $service_or_config Key of service or config to fetch.
* @return \ContentControl\Plugin\Core|mixed
*/
function content_control( $service_or_config = null ) {
return plugin( $service_or_config );
}
/**
* Get a value from the globals service.
*
* @param string $key Context key.
* @param mixed $default_value Default value.
*
* @return mixed
*/
function get_global( $key, $default_value = null ) {
return plugin( 'globals' )->get( $key, $default_value );
}
/**
* Set a value in the globals service.
*
* @param string $key Context key.
* @param mixed $value Context value.
*
* @return void
*/
function set_global( $key, $value ) {
plugin( 'globals' )->set( $key, $value );
}
/**
* Reset a value in the globals service.
*
* @param string $key Context key.
*
* @return void
*/
function reset_global( $key ) {
plugin( 'globals' )->reset( $key );
}
/**
* Reset all values in the globals service.
*
* @return void
*/
function reset_all_globals() {
plugin( 'globals' )->reset_all();
}
/**
* Push to global stack.
*
* @param string $key Context key.
* @param mixed $value Context value.
*
* @return void
*/
function push_to_global( $key, $value ) {
plugin( 'globals' )->push_to_stack( $key, $value );
}
/**
* Pop from globals stack.
*
* @param string $key Context key.
*
* @return mixed
*/
function pop_from_global( $key ) {
return plugin( 'globals' )->pop_from_stack( $key );
}
/**
* Check if global stack is empty.
*
* @param string $key Context key.
*
* @return bool
*/
function global_is_empty( $key ) {
return plugin( 'globals' )->is_empty( $key );
}