PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / trunk
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / inc / functions / globals.php

globals.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More trunk, at inc/functions/globals.php

101 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Global (non namespaced) functions.
4 *
5 * @package ContentControl
6 */
7
8 use function ContentControl\plugin;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Easy access to all plugin services from the container.
14 *
15 * @see \ContentControl\plugin_instance
16 *
17 * @param string|null $service_or_config Key of service or config to fetch.
18 * @return \ContentControl\Plugin\Core|mixed
19 */
20 function content_control( $service_or_config = null ) {
21 return plugin( $service_or_config );
22 }
23
24 /**
25 * Get a value from the globals service.
26 *
27 * @param string $key Context key.
28 * @param mixed $default_value Default value.
29 *
30 * @return mixed
31 */
32 function get_global( $key, $default_value = null ) {
33 return plugin( 'globals' )->get( $key, $default_value );
34 }
35
36 /**
37 * Set a value in the globals service.
38 *
39 * @param string $key Context key.
40 * @param mixed $value Context value.
41 *
42 * @return void
43 */
44 function set_global( $key, $value ) {
45 plugin( 'globals' )->set( $key, $value );
46 }
47
48 /**
49 * Reset a value in the globals service.
50 *
51 * @param string $key Context key.
52 *
53 * @return void
54 */
55 function reset_global( $key ) {
56 plugin( 'globals' )->reset( $key );
57 }
58
59 /**
60 * Reset all values in the globals service.
61 *
62 * @return void
63 */
64 function reset_all_globals() {
65 plugin( 'globals' )->reset_all();
66 }
67
68 /**
69 * Push to global stack.
70 *
71 * @param string $key Context key.
72 * @param mixed $value Context value.
73 *
74 * @return void
75 */
76 function push_to_global( $key, $value ) {
77 plugin( 'globals' )->push_to_stack( $key, $value );
78 }
79
80 /**
81 * Pop from globals stack.
82 *
83 * @param string $key Context key.
84 *
85 * @return mixed
86 */
87 function pop_from_global( $key ) {
88 return plugin( 'globals' )->pop_from_stack( $key );
89 }
90
91 /**
92 * Check if global stack is empty.
93 *
94 * @param string $key Context key.
95 *
96 * @return bool
97 */
98 function global_is_empty( $key ) {
99 return plugin( 'globals' )->is_empty( $key );
100 }
101