@@ -16,98 +16,98 @@ |
||
16 | 16 | abstract class EE_Object_Repository extends EE_Object_Collection implements EEI_Repository |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * default persist method called on repository objects if none supplied |
|
21 | - * |
|
22 | - * @type string $persist_method |
|
23 | - */ |
|
24 | - protected $persist_method; |
|
19 | + /** |
|
20 | + * default persist method called on repository objects if none supplied |
|
21 | + * |
|
22 | + * @type string $persist_method |
|
23 | + */ |
|
24 | + protected $persist_method; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * _call_user_func_array_on_current |
|
29 | - * |
|
30 | - * calls the supplied callback method name on the current repository object, |
|
31 | - * an array of arguments can also be supplied that will be passed along to the callback method, |
|
32 | - * where each element of the $arguments array corresponds to a parameter for the callback method |
|
33 | - * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
34 | - * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
35 | - * |
|
36 | - * @access public |
|
37 | - * @param string $callback name of method found on object to be called. |
|
38 | - * @param array $arguments arrays of arguments that will be passed to the object's callback method |
|
39 | - * @return bool | int |
|
40 | - */ |
|
41 | - protected function _call_user_func_array_on_current($callback = '', $arguments = array()) |
|
42 | - { |
|
43 | - if ($callback !== '' && method_exists($this->current(), $callback)) { |
|
44 | - return call_user_func_array(array($this->current(), $callback), $arguments); |
|
45 | - } |
|
46 | - return false; |
|
47 | - } |
|
27 | + /** |
|
28 | + * _call_user_func_array_on_current |
|
29 | + * |
|
30 | + * calls the supplied callback method name on the current repository object, |
|
31 | + * an array of arguments can also be supplied that will be passed along to the callback method, |
|
32 | + * where each element of the $arguments array corresponds to a parameter for the callback method |
|
33 | + * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
34 | + * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
35 | + * |
|
36 | + * @access public |
|
37 | + * @param string $callback name of method found on object to be called. |
|
38 | + * @param array $arguments arrays of arguments that will be passed to the object's callback method |
|
39 | + * @return bool | int |
|
40 | + */ |
|
41 | + protected function _call_user_func_array_on_current($callback = '', $arguments = array()) |
|
42 | + { |
|
43 | + if ($callback !== '' && method_exists($this->current(), $callback)) { |
|
44 | + return call_user_func_array(array($this->current(), $callback), $arguments); |
|
45 | + } |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * _call_user_func_on_all |
|
52 | - * |
|
53 | - * calls the supplied callback method name on ALL repository objects, |
|
54 | - * |
|
55 | - * @access public |
|
56 | - * @param string $callback name of method found on repository objects to be called |
|
57 | - * @return bool | int |
|
58 | - */ |
|
59 | - protected function _call_user_func_on_all($callback = '') |
|
60 | - { |
|
61 | - $success = true; |
|
62 | - if ($this->valid()) { |
|
63 | - $this->rewind(); |
|
64 | - while ($this->valid()) { |
|
65 | - // any negative result will toggle success to false |
|
66 | - $success = $this->_call_user_func_array_on_current($callback) ? $success : false; |
|
67 | - $this->next(); |
|
68 | - } |
|
69 | - $this->rewind(); |
|
70 | - } |
|
71 | - return $success; |
|
72 | - } |
|
50 | + /** |
|
51 | + * _call_user_func_on_all |
|
52 | + * |
|
53 | + * calls the supplied callback method name on ALL repository objects, |
|
54 | + * |
|
55 | + * @access public |
|
56 | + * @param string $callback name of method found on repository objects to be called |
|
57 | + * @return bool | int |
|
58 | + */ |
|
59 | + protected function _call_user_func_on_all($callback = '') |
|
60 | + { |
|
61 | + $success = true; |
|
62 | + if ($this->valid()) { |
|
63 | + $this->rewind(); |
|
64 | + while ($this->valid()) { |
|
65 | + // any negative result will toggle success to false |
|
66 | + $success = $this->_call_user_func_array_on_current($callback) ? $success : false; |
|
67 | + $this->next(); |
|
68 | + } |
|
69 | + $this->rewind(); |
|
70 | + } |
|
71 | + return $success; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * persist |
|
77 | - * |
|
78 | - * primarily used for saving EE_Base_Class classes to the database, |
|
79 | - * but can be supplied with a "persistence callback" that can be used for classes that are not instances of |
|
80 | - * EE_Base_Class, or for providing alternate ways to persist an object such as session caching, etc... an array of |
|
81 | - * arguments can also be supplied that will be passed along to the object's persistence method |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @param string $persistence_callback name of method found on object that can |
|
85 | - * be used for persisting the object |
|
86 | - * defaults to |
|
87 | - * EE_Object_Repository::$persist_method |
|
88 | - * @param array $persistence_arguments arrays of arguments that will be passed |
|
89 | - * to the object's persistence method |
|
90 | - * @return bool | int |
|
91 | - */ |
|
92 | - public function persist($persistence_callback = '', $persistence_arguments = array()) |
|
93 | - { |
|
94 | - $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
95 | - return $this->_call_user_func_array_on_current($persistence_callback, $persistence_arguments); |
|
96 | - } |
|
75 | + /** |
|
76 | + * persist |
|
77 | + * |
|
78 | + * primarily used for saving EE_Base_Class classes to the database, |
|
79 | + * but can be supplied with a "persistence callback" that can be used for classes that are not instances of |
|
80 | + * EE_Base_Class, or for providing alternate ways to persist an object such as session caching, etc... an array of |
|
81 | + * arguments can also be supplied that will be passed along to the object's persistence method |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @param string $persistence_callback name of method found on object that can |
|
85 | + * be used for persisting the object |
|
86 | + * defaults to |
|
87 | + * EE_Object_Repository::$persist_method |
|
88 | + * @param array $persistence_arguments arrays of arguments that will be passed |
|
89 | + * to the object's persistence method |
|
90 | + * @return bool | int |
|
91 | + */ |
|
92 | + public function persist($persistence_callback = '', $persistence_arguments = array()) |
|
93 | + { |
|
94 | + $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
95 | + return $this->_call_user_func_array_on_current($persistence_callback, $persistence_arguments); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | |
99 | - /** |
|
100 | - * persist_all |
|
101 | - * |
|
102 | - * calls \EE_Object_Repository::persist() on all objects within the repository |
|
103 | - * |
|
104 | - * @access public |
|
105 | - * @param string $persistence_callback name of method found on object that can be used for persisting the object |
|
106 | - * @return bool | int |
|
107 | - */ |
|
108 | - public function persist_all($persistence_callback = '') |
|
109 | - { |
|
110 | - $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
111 | - return $this->_call_user_func_on_all($persistence_callback); |
|
112 | - } |
|
99 | + /** |
|
100 | + * persist_all |
|
101 | + * |
|
102 | + * calls \EE_Object_Repository::persist() on all objects within the repository |
|
103 | + * |
|
104 | + * @access public |
|
105 | + * @param string $persistence_callback name of method found on object that can be used for persisting the object |
|
106 | + * @return bool | int |
|
107 | + */ |
|
108 | + public function persist_all($persistence_callback = '') |
|
109 | + { |
|
110 | + $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
111 | + return $this->_call_user_func_on_all($persistence_callback); |
|
112 | + } |
|
113 | 113 | } |
@@ -12,110 +12,110 @@ |
||
12 | 12 | abstract class EED_Module extends EE_Configurable implements ResettableInterface |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * rendered output to be returned to WP |
|
17 | - * |
|
18 | - * @var string $output |
|
19 | - */ |
|
20 | - protected $output = ''; |
|
21 | - |
|
22 | - /** |
|
23 | - * the current active espresso template theme |
|
24 | - * |
|
25 | - * @var string $theme |
|
26 | - */ |
|
27 | - protected $theme = ''; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public static function reset() |
|
34 | - { |
|
35 | - $module_name = get_called_class(); |
|
36 | - new $module_name(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
42 | - * |
|
43 | - * @access public |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public static function set_hooks() |
|
47 | - { |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public static function set_hooks_admin() |
|
58 | - { |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * run - initial module setup |
|
64 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @var WP $WP |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - abstract public function run($WP); |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * EED_Module constructor. |
|
75 | - */ |
|
76 | - final public function __construct() |
|
77 | - { |
|
78 | - $this->theme = EE_Config::get_current_theme(); |
|
79 | - $module_name = $this->module_name(); |
|
80 | - EE_Registry::instance()->modules->{$module_name} = $this; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param $module_name |
|
86 | - * @return EED_Module |
|
87 | - */ |
|
88 | - protected static function get_instance($module_name = '') |
|
89 | - { |
|
90 | - $module_name = ! empty($module_name) |
|
91 | - ? $module_name |
|
92 | - : get_called_class(); |
|
93 | - if (! isset(EE_Registry::instance()->modules->{$module_name}) |
|
94 | - || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module |
|
95 | - ) { |
|
96 | - EE_Registry::instance()->add_module($module_name); |
|
97 | - } |
|
98 | - return EE_Registry::instance()->get_module($module_name); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * module_name |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function module_name() |
|
109 | - { |
|
110 | - return get_class($this); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - public function theme() |
|
118 | - { |
|
119 | - return $this->theme; |
|
120 | - } |
|
15 | + /** |
|
16 | + * rendered output to be returned to WP |
|
17 | + * |
|
18 | + * @var string $output |
|
19 | + */ |
|
20 | + protected $output = ''; |
|
21 | + |
|
22 | + /** |
|
23 | + * the current active espresso template theme |
|
24 | + * |
|
25 | + * @var string $theme |
|
26 | + */ |
|
27 | + protected $theme = ''; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public static function reset() |
|
34 | + { |
|
35 | + $module_name = get_called_class(); |
|
36 | + new $module_name(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
42 | + * |
|
43 | + * @access public |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public static function set_hooks() |
|
47 | + { |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public static function set_hooks_admin() |
|
58 | + { |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * run - initial module setup |
|
64 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @var WP $WP |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + abstract public function run($WP); |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * EED_Module constructor. |
|
75 | + */ |
|
76 | + final public function __construct() |
|
77 | + { |
|
78 | + $this->theme = EE_Config::get_current_theme(); |
|
79 | + $module_name = $this->module_name(); |
|
80 | + EE_Registry::instance()->modules->{$module_name} = $this; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param $module_name |
|
86 | + * @return EED_Module |
|
87 | + */ |
|
88 | + protected static function get_instance($module_name = '') |
|
89 | + { |
|
90 | + $module_name = ! empty($module_name) |
|
91 | + ? $module_name |
|
92 | + : get_called_class(); |
|
93 | + if (! isset(EE_Registry::instance()->modules->{$module_name}) |
|
94 | + || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module |
|
95 | + ) { |
|
96 | + EE_Registry::instance()->add_module($module_name); |
|
97 | + } |
|
98 | + return EE_Registry::instance()->get_module($module_name); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * module_name |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function module_name() |
|
109 | + { |
|
110 | + return get_class($this); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + public function theme() |
|
118 | + { |
|
119 | + return $this->theme; |
|
120 | + } |
|
121 | 121 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | $module_name = ! empty($module_name) |
91 | 91 | ? $module_name |
92 | 92 | : get_called_class(); |
93 | - if (! isset(EE_Registry::instance()->modules->{$module_name}) |
|
93 | + if ( ! isset(EE_Registry::instance()->modules->{$module_name}) |
|
94 | 94 | || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module |
95 | 95 | ) { |
96 | 96 | EE_Registry::instance()->add_module($module_name); |
@@ -11,42 +11,42 @@ |
||
11 | 11 | class EE_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @ override magic methods |
|
16 | - * @ return void |
|
17 | - */ |
|
18 | - public function __get($a) |
|
19 | - { |
|
20 | - return false; |
|
21 | - } |
|
14 | + /** |
|
15 | + * @ override magic methods |
|
16 | + * @ return void |
|
17 | + */ |
|
18 | + public function __get($a) |
|
19 | + { |
|
20 | + return false; |
|
21 | + } |
|
22 | 22 | |
23 | - public function __set($a, $b) |
|
24 | - { |
|
25 | - return false; |
|
26 | - } |
|
23 | + public function __set($a, $b) |
|
24 | + { |
|
25 | + return false; |
|
26 | + } |
|
27 | 27 | |
28 | - public function __isset($a) |
|
29 | - { |
|
30 | - return false; |
|
31 | - } |
|
28 | + public function __isset($a) |
|
29 | + { |
|
30 | + return false; |
|
31 | + } |
|
32 | 32 | |
33 | - public function __unset($a) |
|
34 | - { |
|
35 | - return false; |
|
36 | - } |
|
33 | + public function __unset($a) |
|
34 | + { |
|
35 | + return false; |
|
36 | + } |
|
37 | 37 | |
38 | - public function __clone() |
|
39 | - { |
|
40 | - return false; |
|
41 | - } |
|
38 | + public function __clone() |
|
39 | + { |
|
40 | + return false; |
|
41 | + } |
|
42 | 42 | |
43 | - public function __wakeup() |
|
44 | - { |
|
45 | - return false; |
|
46 | - } |
|
43 | + public function __wakeup() |
|
44 | + { |
|
45 | + return false; |
|
46 | + } |
|
47 | 47 | |
48 | - public function __destruct() |
|
49 | - { |
|
50 | - return false; |
|
51 | - } |
|
48 | + public function __destruct() |
|
49 | + { |
|
50 | + return false; |
|
51 | + } |
|
52 | 52 | } |
@@ -12,369 +12,369 @@ |
||
12 | 12 | final class EE_Request_Handler implements InterminableInterface |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @var EE_Request $request |
|
17 | - */ |
|
18 | - private $request; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var array $_notice |
|
22 | - */ |
|
23 | - private $_notice = array(); |
|
24 | - |
|
25 | - /** |
|
26 | - * rendered output to be returned to WP |
|
27 | - * |
|
28 | - * @var string $_output |
|
29 | - */ |
|
30 | - private $_output = ''; |
|
31 | - |
|
32 | - /** |
|
33 | - * whether current request is via AJAX |
|
34 | - * |
|
35 | - * @var boolean $ajax |
|
36 | - */ |
|
37 | - public $ajax = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * whether current request is via AJAX from the frontend of the site |
|
41 | - * |
|
42 | - * @var boolean $front_ajax |
|
43 | - */ |
|
44 | - public $front_ajax = false; |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @param EE_Request $request |
|
49 | - */ |
|
50 | - public function __construct(EE_Request $request) |
|
51 | - { |
|
52 | - $this->request = $request; |
|
53 | - $this->ajax = $this->request->ajax; |
|
54 | - $this->front_ajax = $this->request->front_ajax; |
|
55 | - do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @param WP $wp |
|
61 | - * @return void |
|
62 | - * @throws EE_Error |
|
63 | - * @throws ReflectionException |
|
64 | - */ |
|
65 | - public function parse_request($wp = null) |
|
66 | - { |
|
67 | - // if somebody forgot to provide us with WP, that's ok because its global |
|
68 | - if (! $wp instanceof WP) { |
|
69 | - global $wp; |
|
70 | - } |
|
71 | - $this->set_request_vars($wp); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @param WP $wp |
|
77 | - * @return void |
|
78 | - * @throws EE_Error |
|
79 | - * @throws ReflectionException |
|
80 | - */ |
|
81 | - public function set_request_vars($wp = null) |
|
82 | - { |
|
83 | - if (! is_admin()) { |
|
84 | - // set request post_id |
|
85 | - $this->request->set('post_id', $this->get_post_id_from_request($wp)); |
|
86 | - // set request post name |
|
87 | - $this->request->set('post_name', $this->get_post_name_from_request($wp)); |
|
88 | - // set request post_type |
|
89 | - $this->request->set('post_type', $this->get_post_type_from_request($wp)); |
|
90 | - // true or false ? is this page being used by EE ? |
|
91 | - $this->set_espresso_page(); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param WP $wp |
|
98 | - * @return int |
|
99 | - */ |
|
100 | - public function get_post_id_from_request($wp = null) |
|
101 | - { |
|
102 | - if (! $wp instanceof WP) { |
|
103 | - global $wp; |
|
104 | - } |
|
105 | - $post_id = null; |
|
106 | - if (isset($wp->query_vars['p'])) { |
|
107 | - $post_id = $wp->query_vars['p']; |
|
108 | - } |
|
109 | - if (! $post_id && isset($wp->query_vars['page_id'])) { |
|
110 | - $post_id = $wp->query_vars['page_id']; |
|
111 | - } |
|
112 | - if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { |
|
113 | - $post_id = basename($wp->request); |
|
114 | - } |
|
115 | - return $post_id; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @param WP $wp |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function get_post_name_from_request($wp = null) |
|
124 | - { |
|
125 | - if (! $wp instanceof WP) { |
|
126 | - global $wp; |
|
127 | - } |
|
128 | - $post_name = null; |
|
129 | - if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
130 | - $post_name = $wp->query_vars['name']; |
|
131 | - } |
|
132 | - if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
133 | - $post_name = $wp->query_vars['pagename']; |
|
134 | - } |
|
135 | - if (! $post_name && $wp->request !== null && ! empty($wp->request)) { |
|
136 | - $possible_post_name = basename($wp->request); |
|
137 | - if (! is_numeric($possible_post_name)) { |
|
138 | - /** @type WPDB $wpdb */ |
|
139 | - global $wpdb; |
|
140 | - $SQL = |
|
141 | - "SELECT ID from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s"; |
|
142 | - $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
143 | - if ($possible_post_name) { |
|
144 | - $post_name = $possible_post_name; |
|
145 | - } |
|
146 | - } |
|
147 | - } |
|
148 | - if (! $post_name && $this->get('post_id')) { |
|
149 | - /** @type WPDB $wpdb */ |
|
150 | - global $wpdb; |
|
151 | - $SQL = |
|
152 | - "SELECT post_name from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d"; |
|
153 | - $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
154 | - if ($possible_post_name) { |
|
155 | - $post_name = $possible_post_name; |
|
156 | - } |
|
157 | - } |
|
158 | - return $post_name; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param WP $wp |
|
164 | - * @return mixed |
|
165 | - */ |
|
166 | - public function get_post_type_from_request($wp = null) |
|
167 | - { |
|
168 | - if (! $wp instanceof WP) { |
|
169 | - global $wp; |
|
170 | - } |
|
171 | - return isset($wp->query_vars['post_type']) |
|
172 | - ? $wp->query_vars['post_type'] |
|
173 | - : null; |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * Just a helper method for getting the url for the displayed page. |
|
179 | - * |
|
180 | - * @param WP $wp |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function get_current_page_permalink($wp = null) |
|
184 | - { |
|
185 | - $post_id = $this->get_post_id_from_request($wp); |
|
186 | - if ($post_id) { |
|
187 | - $current_page_permalink = get_permalink($post_id); |
|
188 | - } else { |
|
189 | - if (! $wp instanceof WP) { |
|
190 | - global $wp; |
|
191 | - } |
|
192 | - if ($wp->request) { |
|
193 | - $current_page_permalink = site_url($wp->request); |
|
194 | - } else { |
|
195 | - $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
196 | - } |
|
197 | - } |
|
198 | - return $current_page_permalink; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @return bool |
|
204 | - * @throws EE_Error |
|
205 | - * @throws ReflectionException |
|
206 | - */ |
|
207 | - public function test_for_espresso_page() |
|
208 | - { |
|
209 | - global $wp; |
|
210 | - /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
|
211 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
212 | - $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
|
213 | - if (is_array($espresso_CPT_taxonomies)) { |
|
214 | - foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { |
|
215 | - if (isset($wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ])) { |
|
216 | - return true; |
|
217 | - } |
|
218 | - } |
|
219 | - } |
|
220 | - // load espresso CPT endpoints |
|
221 | - $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
|
222 | - $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
223 | - $post_types = (array) $this->get('post_type'); |
|
224 | - foreach ($post_types as $post_type) { |
|
225 | - // was a post name passed ? |
|
226 | - if (isset($post_type_CPT_endpoints[ $post_type ])) { |
|
227 | - // kk we know this is an espresso page, but is it a specific post ? |
|
228 | - if (! $this->get('post_name')) { |
|
229 | - // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
|
230 | - $post_name = isset($post_type_CPT_endpoints[ $this->get('post_type') ]) |
|
231 | - ? $post_type_CPT_endpoints[ $this->get('post_type') ] |
|
232 | - : ''; |
|
233 | - // if the post type matches on of our then set the endpoint |
|
234 | - if ($post_name) { |
|
235 | - $this->set('post_name', $post_name); |
|
236 | - } |
|
237 | - } |
|
238 | - return true; |
|
239 | - } |
|
240 | - } |
|
241 | - return false; |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * @param $key |
|
246 | - * @param $value |
|
247 | - * @return void |
|
248 | - */ |
|
249 | - public function set_notice($key, $value) |
|
250 | - { |
|
251 | - $this->_notice[ $key ] = $value; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * @param $key |
|
257 | - * @return mixed |
|
258 | - */ |
|
259 | - public function get_notice($key) |
|
260 | - { |
|
261 | - return isset($this->_notice[ $key ]) |
|
262 | - ? $this->_notice[ $key ] |
|
263 | - : null; |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * @param $string |
|
269 | - * @return void |
|
270 | - */ |
|
271 | - public function add_output($string) |
|
272 | - { |
|
273 | - $this->_output .= $string; |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * @return string |
|
279 | - */ |
|
280 | - public function get_output() |
|
281 | - { |
|
282 | - return $this->_output; |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * @param $item |
|
288 | - * @param $key |
|
289 | - */ |
|
290 | - public function sanitize_text_field_for_array_walk(&$item, &$key) |
|
291 | - { |
|
292 | - $item = strpos($item, 'email') !== false |
|
293 | - ? sanitize_email($item) |
|
294 | - : sanitize_text_field($item); |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - /** |
|
299 | - * @param null|bool $value |
|
300 | - * @return void |
|
301 | - * @throws EE_Error |
|
302 | - * @throws ReflectionException |
|
303 | - */ |
|
304 | - public function set_espresso_page($value = null) |
|
305 | - { |
|
306 | - $this->request->set( |
|
307 | - 'is_espresso_page', |
|
308 | - ! empty($value) |
|
309 | - ? $value |
|
310 | - : $this->test_for_espresso_page() |
|
311 | - ); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * @return mixed |
|
317 | - */ |
|
318 | - public function is_espresso_page() |
|
319 | - { |
|
320 | - return $this->request->is_set('is_espresso_page'); |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * returns contents of $_REQUEST |
|
326 | - * |
|
327 | - * @return array |
|
328 | - */ |
|
329 | - public function params() |
|
330 | - { |
|
331 | - return $this->request->params(); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @param $key |
|
337 | - * @param $value |
|
338 | - * @param bool $override_ee |
|
339 | - * @return void |
|
340 | - */ |
|
341 | - public function set($key, $value, $override_ee = false) |
|
342 | - { |
|
343 | - $this->request->set($key, $value, $override_ee); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * @param $key |
|
349 | - * @param null $default |
|
350 | - * @return mixed |
|
351 | - */ |
|
352 | - public function get($key, $default = null) |
|
353 | - { |
|
354 | - return $this->request->get($key, $default); |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - /** |
|
359 | - * check if param exists |
|
360 | - * |
|
361 | - * @param $key |
|
362 | - * @return boolean |
|
363 | - */ |
|
364 | - public function is_set($key) |
|
365 | - { |
|
366 | - return $this->request->is_set($key); |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - /** |
|
371 | - * remove param |
|
372 | - * |
|
373 | - * @param $key |
|
374 | - * @return void |
|
375 | - */ |
|
376 | - public function un_set($key) |
|
377 | - { |
|
378 | - $this->request->un_set($key); |
|
379 | - } |
|
15 | + /** |
|
16 | + * @var EE_Request $request |
|
17 | + */ |
|
18 | + private $request; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var array $_notice |
|
22 | + */ |
|
23 | + private $_notice = array(); |
|
24 | + |
|
25 | + /** |
|
26 | + * rendered output to be returned to WP |
|
27 | + * |
|
28 | + * @var string $_output |
|
29 | + */ |
|
30 | + private $_output = ''; |
|
31 | + |
|
32 | + /** |
|
33 | + * whether current request is via AJAX |
|
34 | + * |
|
35 | + * @var boolean $ajax |
|
36 | + */ |
|
37 | + public $ajax = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * whether current request is via AJAX from the frontend of the site |
|
41 | + * |
|
42 | + * @var boolean $front_ajax |
|
43 | + */ |
|
44 | + public $front_ajax = false; |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @param EE_Request $request |
|
49 | + */ |
|
50 | + public function __construct(EE_Request $request) |
|
51 | + { |
|
52 | + $this->request = $request; |
|
53 | + $this->ajax = $this->request->ajax; |
|
54 | + $this->front_ajax = $this->request->front_ajax; |
|
55 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @param WP $wp |
|
61 | + * @return void |
|
62 | + * @throws EE_Error |
|
63 | + * @throws ReflectionException |
|
64 | + */ |
|
65 | + public function parse_request($wp = null) |
|
66 | + { |
|
67 | + // if somebody forgot to provide us with WP, that's ok because its global |
|
68 | + if (! $wp instanceof WP) { |
|
69 | + global $wp; |
|
70 | + } |
|
71 | + $this->set_request_vars($wp); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @param WP $wp |
|
77 | + * @return void |
|
78 | + * @throws EE_Error |
|
79 | + * @throws ReflectionException |
|
80 | + */ |
|
81 | + public function set_request_vars($wp = null) |
|
82 | + { |
|
83 | + if (! is_admin()) { |
|
84 | + // set request post_id |
|
85 | + $this->request->set('post_id', $this->get_post_id_from_request($wp)); |
|
86 | + // set request post name |
|
87 | + $this->request->set('post_name', $this->get_post_name_from_request($wp)); |
|
88 | + // set request post_type |
|
89 | + $this->request->set('post_type', $this->get_post_type_from_request($wp)); |
|
90 | + // true or false ? is this page being used by EE ? |
|
91 | + $this->set_espresso_page(); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param WP $wp |
|
98 | + * @return int |
|
99 | + */ |
|
100 | + public function get_post_id_from_request($wp = null) |
|
101 | + { |
|
102 | + if (! $wp instanceof WP) { |
|
103 | + global $wp; |
|
104 | + } |
|
105 | + $post_id = null; |
|
106 | + if (isset($wp->query_vars['p'])) { |
|
107 | + $post_id = $wp->query_vars['p']; |
|
108 | + } |
|
109 | + if (! $post_id && isset($wp->query_vars['page_id'])) { |
|
110 | + $post_id = $wp->query_vars['page_id']; |
|
111 | + } |
|
112 | + if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { |
|
113 | + $post_id = basename($wp->request); |
|
114 | + } |
|
115 | + return $post_id; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @param WP $wp |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function get_post_name_from_request($wp = null) |
|
124 | + { |
|
125 | + if (! $wp instanceof WP) { |
|
126 | + global $wp; |
|
127 | + } |
|
128 | + $post_name = null; |
|
129 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
130 | + $post_name = $wp->query_vars['name']; |
|
131 | + } |
|
132 | + if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
133 | + $post_name = $wp->query_vars['pagename']; |
|
134 | + } |
|
135 | + if (! $post_name && $wp->request !== null && ! empty($wp->request)) { |
|
136 | + $possible_post_name = basename($wp->request); |
|
137 | + if (! is_numeric($possible_post_name)) { |
|
138 | + /** @type WPDB $wpdb */ |
|
139 | + global $wpdb; |
|
140 | + $SQL = |
|
141 | + "SELECT ID from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s"; |
|
142 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
143 | + if ($possible_post_name) { |
|
144 | + $post_name = $possible_post_name; |
|
145 | + } |
|
146 | + } |
|
147 | + } |
|
148 | + if (! $post_name && $this->get('post_id')) { |
|
149 | + /** @type WPDB $wpdb */ |
|
150 | + global $wpdb; |
|
151 | + $SQL = |
|
152 | + "SELECT post_name from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d"; |
|
153 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
154 | + if ($possible_post_name) { |
|
155 | + $post_name = $possible_post_name; |
|
156 | + } |
|
157 | + } |
|
158 | + return $post_name; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param WP $wp |
|
164 | + * @return mixed |
|
165 | + */ |
|
166 | + public function get_post_type_from_request($wp = null) |
|
167 | + { |
|
168 | + if (! $wp instanceof WP) { |
|
169 | + global $wp; |
|
170 | + } |
|
171 | + return isset($wp->query_vars['post_type']) |
|
172 | + ? $wp->query_vars['post_type'] |
|
173 | + : null; |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * Just a helper method for getting the url for the displayed page. |
|
179 | + * |
|
180 | + * @param WP $wp |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function get_current_page_permalink($wp = null) |
|
184 | + { |
|
185 | + $post_id = $this->get_post_id_from_request($wp); |
|
186 | + if ($post_id) { |
|
187 | + $current_page_permalink = get_permalink($post_id); |
|
188 | + } else { |
|
189 | + if (! $wp instanceof WP) { |
|
190 | + global $wp; |
|
191 | + } |
|
192 | + if ($wp->request) { |
|
193 | + $current_page_permalink = site_url($wp->request); |
|
194 | + } else { |
|
195 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
196 | + } |
|
197 | + } |
|
198 | + return $current_page_permalink; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @return bool |
|
204 | + * @throws EE_Error |
|
205 | + * @throws ReflectionException |
|
206 | + */ |
|
207 | + public function test_for_espresso_page() |
|
208 | + { |
|
209 | + global $wp; |
|
210 | + /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
|
211 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
212 | + $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
|
213 | + if (is_array($espresso_CPT_taxonomies)) { |
|
214 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { |
|
215 | + if (isset($wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ])) { |
|
216 | + return true; |
|
217 | + } |
|
218 | + } |
|
219 | + } |
|
220 | + // load espresso CPT endpoints |
|
221 | + $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
|
222 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
223 | + $post_types = (array) $this->get('post_type'); |
|
224 | + foreach ($post_types as $post_type) { |
|
225 | + // was a post name passed ? |
|
226 | + if (isset($post_type_CPT_endpoints[ $post_type ])) { |
|
227 | + // kk we know this is an espresso page, but is it a specific post ? |
|
228 | + if (! $this->get('post_name')) { |
|
229 | + // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
|
230 | + $post_name = isset($post_type_CPT_endpoints[ $this->get('post_type') ]) |
|
231 | + ? $post_type_CPT_endpoints[ $this->get('post_type') ] |
|
232 | + : ''; |
|
233 | + // if the post type matches on of our then set the endpoint |
|
234 | + if ($post_name) { |
|
235 | + $this->set('post_name', $post_name); |
|
236 | + } |
|
237 | + } |
|
238 | + return true; |
|
239 | + } |
|
240 | + } |
|
241 | + return false; |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * @param $key |
|
246 | + * @param $value |
|
247 | + * @return void |
|
248 | + */ |
|
249 | + public function set_notice($key, $value) |
|
250 | + { |
|
251 | + $this->_notice[ $key ] = $value; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * @param $key |
|
257 | + * @return mixed |
|
258 | + */ |
|
259 | + public function get_notice($key) |
|
260 | + { |
|
261 | + return isset($this->_notice[ $key ]) |
|
262 | + ? $this->_notice[ $key ] |
|
263 | + : null; |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * @param $string |
|
269 | + * @return void |
|
270 | + */ |
|
271 | + public function add_output($string) |
|
272 | + { |
|
273 | + $this->_output .= $string; |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * @return string |
|
279 | + */ |
|
280 | + public function get_output() |
|
281 | + { |
|
282 | + return $this->_output; |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * @param $item |
|
288 | + * @param $key |
|
289 | + */ |
|
290 | + public function sanitize_text_field_for_array_walk(&$item, &$key) |
|
291 | + { |
|
292 | + $item = strpos($item, 'email') !== false |
|
293 | + ? sanitize_email($item) |
|
294 | + : sanitize_text_field($item); |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + /** |
|
299 | + * @param null|bool $value |
|
300 | + * @return void |
|
301 | + * @throws EE_Error |
|
302 | + * @throws ReflectionException |
|
303 | + */ |
|
304 | + public function set_espresso_page($value = null) |
|
305 | + { |
|
306 | + $this->request->set( |
|
307 | + 'is_espresso_page', |
|
308 | + ! empty($value) |
|
309 | + ? $value |
|
310 | + : $this->test_for_espresso_page() |
|
311 | + ); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * @return mixed |
|
317 | + */ |
|
318 | + public function is_espresso_page() |
|
319 | + { |
|
320 | + return $this->request->is_set('is_espresso_page'); |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * returns contents of $_REQUEST |
|
326 | + * |
|
327 | + * @return array |
|
328 | + */ |
|
329 | + public function params() |
|
330 | + { |
|
331 | + return $this->request->params(); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * @param $key |
|
337 | + * @param $value |
|
338 | + * @param bool $override_ee |
|
339 | + * @return void |
|
340 | + */ |
|
341 | + public function set($key, $value, $override_ee = false) |
|
342 | + { |
|
343 | + $this->request->set($key, $value, $override_ee); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * @param $key |
|
349 | + * @param null $default |
|
350 | + * @return mixed |
|
351 | + */ |
|
352 | + public function get($key, $default = null) |
|
353 | + { |
|
354 | + return $this->request->get($key, $default); |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + /** |
|
359 | + * check if param exists |
|
360 | + * |
|
361 | + * @param $key |
|
362 | + * @return boolean |
|
363 | + */ |
|
364 | + public function is_set($key) |
|
365 | + { |
|
366 | + return $this->request->is_set($key); |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + /** |
|
371 | + * remove param |
|
372 | + * |
|
373 | + * @param $key |
|
374 | + * @return void |
|
375 | + */ |
|
376 | + public function un_set($key) |
|
377 | + { |
|
378 | + $this->request->un_set($key); |
|
379 | + } |
|
380 | 380 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public function parse_request($wp = null) |
66 | 66 | { |
67 | 67 | // if somebody forgot to provide us with WP, that's ok because its global |
68 | - if (! $wp instanceof WP) { |
|
68 | + if ( ! $wp instanceof WP) { |
|
69 | 69 | global $wp; |
70 | 70 | } |
71 | 71 | $this->set_request_vars($wp); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function set_request_vars($wp = null) |
82 | 82 | { |
83 | - if (! is_admin()) { |
|
83 | + if ( ! is_admin()) { |
|
84 | 84 | // set request post_id |
85 | 85 | $this->request->set('post_id', $this->get_post_id_from_request($wp)); |
86 | 86 | // set request post name |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function get_post_id_from_request($wp = null) |
101 | 101 | { |
102 | - if (! $wp instanceof WP) { |
|
102 | + if ( ! $wp instanceof WP) { |
|
103 | 103 | global $wp; |
104 | 104 | } |
105 | 105 | $post_id = null; |
106 | 106 | if (isset($wp->query_vars['p'])) { |
107 | 107 | $post_id = $wp->query_vars['p']; |
108 | 108 | } |
109 | - if (! $post_id && isset($wp->query_vars['page_id'])) { |
|
109 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
110 | 110 | $post_id = $wp->query_vars['page_id']; |
111 | 111 | } |
112 | - if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { |
|
112 | + if ( ! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) { |
|
113 | 113 | $post_id = basename($wp->request); |
114 | 114 | } |
115 | 115 | return $post_id; |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function get_post_name_from_request($wp = null) |
124 | 124 | { |
125 | - if (! $wp instanceof WP) { |
|
125 | + if ( ! $wp instanceof WP) { |
|
126 | 126 | global $wp; |
127 | 127 | } |
128 | 128 | $post_name = null; |
129 | 129 | if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
130 | 130 | $post_name = $wp->query_vars['name']; |
131 | 131 | } |
132 | - if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
132 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
133 | 133 | $post_name = $wp->query_vars['pagename']; |
134 | 134 | } |
135 | - if (! $post_name && $wp->request !== null && ! empty($wp->request)) { |
|
135 | + if ( ! $post_name && $wp->request !== null && ! empty($wp->request)) { |
|
136 | 136 | $possible_post_name = basename($wp->request); |
137 | - if (! is_numeric($possible_post_name)) { |
|
137 | + if ( ! is_numeric($possible_post_name)) { |
|
138 | 138 | /** @type WPDB $wpdb */ |
139 | 139 | global $wpdb; |
140 | 140 | $SQL = |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
148 | - if (! $post_name && $this->get('post_id')) { |
|
148 | + if ( ! $post_name && $this->get('post_id')) { |
|
149 | 149 | /** @type WPDB $wpdb */ |
150 | 150 | global $wpdb; |
151 | 151 | $SQL = |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function get_post_type_from_request($wp = null) |
167 | 167 | { |
168 | - if (! $wp instanceof WP) { |
|
168 | + if ( ! $wp instanceof WP) { |
|
169 | 169 | global $wp; |
170 | 170 | } |
171 | 171 | return isset($wp->query_vars['post_type']) |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | if ($post_id) { |
187 | 187 | $current_page_permalink = get_permalink($post_id); |
188 | 188 | } else { |
189 | - if (! $wp instanceof WP) { |
|
189 | + if ( ! $wp instanceof WP) { |
|
190 | 190 | global $wp; |
191 | 191 | } |
192 | 192 | if ($wp->request) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
213 | 213 | if (is_array($espresso_CPT_taxonomies)) { |
214 | 214 | foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) { |
215 | - if (isset($wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ])) { |
|
215 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
216 | 216 | return true; |
217 | 217 | } |
218 | 218 | } |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | $post_types = (array) $this->get('post_type'); |
224 | 224 | foreach ($post_types as $post_type) { |
225 | 225 | // was a post name passed ? |
226 | - if (isset($post_type_CPT_endpoints[ $post_type ])) { |
|
226 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
227 | 227 | // kk we know this is an espresso page, but is it a specific post ? |
228 | - if (! $this->get('post_name')) { |
|
228 | + if ( ! $this->get('post_name')) { |
|
229 | 229 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
230 | - $post_name = isset($post_type_CPT_endpoints[ $this->get('post_type') ]) |
|
231 | - ? $post_type_CPT_endpoints[ $this->get('post_type') ] |
|
230 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) |
|
231 | + ? $post_type_CPT_endpoints[$this->get('post_type')] |
|
232 | 232 | : ''; |
233 | 233 | // if the post type matches on of our then set the endpoint |
234 | 234 | if ($post_name) { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function set_notice($key, $value) |
250 | 250 | { |
251 | - $this->_notice[ $key ] = $value; |
|
251 | + $this->_notice[$key] = $value; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function get_notice($key) |
260 | 260 | { |
261 | - return isset($this->_notice[ $key ]) |
|
262 | - ? $this->_notice[ $key ] |
|
261 | + return isset($this->_notice[$key]) |
|
262 | + ? $this->_notice[$key] |
|
263 | 263 | : null; |
264 | 264 | } |
265 | 265 |
@@ -14,333 +14,333 @@ |
||
14 | 14 | class EE_Maintenance_Mode implements ResettableInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * constants available to client code for interpreting the values of EE_Maintenance_Mode::level(). |
|
19 | - * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal) |
|
20 | - */ |
|
21 | - const level_0_not_in_maintenance = 0; |
|
22 | - |
|
23 | - /** |
|
24 | - * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled |
|
25 | - * but the admin backend should be running as normal. Maybe an admin can view the frontend though |
|
26 | - */ |
|
27 | - const level_1_frontend_only_maintenance = 1; |
|
28 | - |
|
29 | - /** |
|
30 | - * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running |
|
31 | - * is the maintenance mode stuff, which will require users to update all addons, and then finish running all |
|
32 | - * migration scripts before taking the site out of maintenance mode |
|
33 | - */ |
|
34 | - const level_2_complete_maintenance = 2; |
|
35 | - |
|
36 | - /** |
|
37 | - * the name of the option which stores the current level of maintenance mode |
|
38 | - */ |
|
39 | - const option_name_maintenance_mode = 'ee_maintenance_mode'; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Maintenance_Mode $_instance |
|
44 | - */ |
|
45 | - private static $_instance; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Registry $EE |
|
49 | - */ |
|
50 | - protected $EE; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @singleton method used to instantiate class object |
|
55 | - * @return EE_Maintenance_Mode |
|
56 | - */ |
|
57 | - public static function instance() |
|
58 | - { |
|
59 | - // check if class object is instantiated |
|
60 | - if (! self::$_instance instanceof EE_Maintenance_Mode) { |
|
61 | - self::$_instance = new self(); |
|
62 | - } |
|
63 | - return self::$_instance; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
|
69 | - * |
|
70 | - * @return EE_Maintenance_Mode |
|
71 | - */ |
|
72 | - public static function reset() |
|
73 | - { |
|
74 | - self::instance()->set_maintenance_mode_if_db_old(); |
|
75 | - return self::instance(); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - *private constructor to prevent direct creation |
|
81 | - */ |
|
82 | - private function __construct() |
|
83 | - { |
|
84 | - // if M-Mode level 2 is engaged, we still need basic assets loaded |
|
85 | - add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
86 | - // shut 'er down down for maintenance ? |
|
87 | - add_filter('the_content', array($this, 'the_content'), 2); |
|
88 | - // add powered by EE msg |
|
89 | - add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * retrieves the maintenance mode option value from the db |
|
95 | - * |
|
96 | - * @return int |
|
97 | - */ |
|
98 | - public function real_level() |
|
99 | - { |
|
100 | - return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Returns whether or not the models reportedly are able to run queries or not |
|
106 | - * (ie, if the system thinks their tables are present and up-to-date). |
|
107 | - * |
|
108 | - * @return boolean |
|
109 | - */ |
|
110 | - public function models_can_query() |
|
111 | - { |
|
112 | - return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * Determines whether or not we're in maintenance mode and what level. However, while the site |
|
118 | - * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear |
|
119 | - * to them as if teh site isn't in maintenance mode. |
|
120 | - * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode) |
|
121 | - * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode |
|
122 | - * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
|
123 | - * |
|
124 | - * @return int |
|
125 | - */ |
|
126 | - public function level() |
|
127 | - { |
|
128 | - $maintenance_mode_level = $this->real_level(); |
|
129 | - // if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
|
130 | - if ($maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1 |
|
131 | - && ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests |
|
132 | - && current_user_can('administrator') // when the user is an admin |
|
133 | - ) { |
|
134 | - $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
|
135 | - } |
|
136 | - return $maintenance_mode_level; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * Determines if we need to put EE in maintenance mode because the database needs updating |
|
142 | - * |
|
143 | - * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
|
144 | - */ |
|
145 | - public function set_maintenance_mode_if_db_old() |
|
146 | - { |
|
147 | - EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
148 | - if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
149 | - update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
|
150 | - return true; |
|
151 | - } |
|
152 | - if ($this->level() === self::level_2_complete_maintenance) { |
|
153 | - // we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
|
154 | - // then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
|
155 | - update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
156 | - return false; |
|
157 | - } |
|
158 | - return false; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Updates the maintenance level on the site |
|
164 | - * |
|
165 | - * @param int $level |
|
166 | - * @return void |
|
167 | - */ |
|
168 | - public function set_maintenance_level($level) |
|
169 | - { |
|
170 | - do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
171 | - update_option(self::option_name_maintenance_mode, (int) $level); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * returns TRUE if M-Mode is engaged and the current request is not for the admin |
|
177 | - * |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public static function disable_frontend_for_maintenance() |
|
181 | - { |
|
182 | - return (! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * @return void |
|
188 | - */ |
|
189 | - public function load_assets_required_for_m_mode() |
|
190 | - { |
|
191 | - if ($this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance |
|
192 | - && ! wp_script_is('espresso_core') |
|
193 | - ) { |
|
194 | - wp_register_style( |
|
195 | - 'espresso_default', |
|
196 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
197 | - array('dashicons'), |
|
198 | - EVENT_ESPRESSO_VERSION |
|
199 | - ); |
|
200 | - wp_enqueue_style('espresso_default'); |
|
201 | - wp_register_script( |
|
202 | - 'espresso_core', |
|
203 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
204 | - array('jquery'), |
|
205 | - EVENT_ESPRESSO_VERSION, |
|
206 | - true |
|
207 | - ); |
|
208 | - wp_enqueue_script('espresso_core'); |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * replacement EE CPT template that displays message notifying site visitors |
|
215 | - * that EE has been temporarily placed into maintenance mode |
|
216 | - * does NOT get called on non-EE-CPT requests |
|
217 | - * |
|
218 | - * @return string |
|
219 | - */ |
|
220 | - public static function template_include() |
|
221 | - { |
|
222 | - // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
|
223 | - return get_template_directory() . '/index.php'; |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * displays message notifying site visitors that EE has been temporarily |
|
229 | - * placed into maintenance mode when post_type != EE CPT |
|
230 | - * |
|
231 | - * @param string $the_content |
|
232 | - * @return string |
|
233 | - */ |
|
234 | - public function the_content($the_content) |
|
235 | - { |
|
236 | - // check if M-mode is engaged and for EE shortcode |
|
237 | - if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) { |
|
238 | - // this can eventually be moved to a template, or edited via admin. But for now... |
|
239 | - $the_content = sprintf( |
|
240 | - esc_html__( |
|
241 | - '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', |
|
242 | - 'event_espresso' |
|
243 | - ), |
|
244 | - '<h3>', |
|
245 | - '</h3><p>', |
|
246 | - '</p>' |
|
247 | - ); |
|
248 | - } |
|
249 | - return $the_content; |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
255 | - */ |
|
256 | - public function display_maintenance_mode_notice() |
|
257 | - { |
|
258 | - // check if M-mode is engaged and for EE shortcode |
|
259 | - if (! (defined('DOING_AJAX') && DOING_AJAX) |
|
260 | - && $this->real_level() |
|
261 | - && ! is_admin() |
|
262 | - && current_user_can('administrator') |
|
263 | - && EE_Registry::instance()->REQ->is_espresso_page() |
|
264 | - ) { |
|
265 | - printf( |
|
266 | - esc_html__( |
|
267 | - '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', |
|
268 | - 'event_espresso' |
|
269 | - ), |
|
270 | - '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
|
271 | - '"><span class="dashicons dashicons-no"></span></a><p>', |
|
272 | - ' » <a href="' . add_query_arg( |
|
273 | - array('page' => 'espresso_maintenance_settings'), |
|
274 | - admin_url('admin.php') |
|
275 | - ) . '">', |
|
276 | - '</a></p></div>' |
|
277 | - ); |
|
278 | - } |
|
279 | - } |
|
280 | - // espresso-notices important-notice ee-attention |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * override magic methods |
|
285 | - */ |
|
286 | - final public function __destruct() |
|
287 | - { |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - final public function __call($a, $b) |
|
292 | - { |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - final public function __get($a) |
|
297 | - { |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - final public function __set($a, $b) |
|
302 | - { |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - final public function __isset($a) |
|
307 | - { |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - final public function __unset($a) |
|
312 | - { |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - final public function __sleep() |
|
317 | - { |
|
318 | - return array(); |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - final public function __wakeup() |
|
323 | - { |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - final public function __invoke() |
|
328 | - { |
|
329 | - } |
|
330 | - |
|
331 | - |
|
332 | - final public static function __set_state($a = null) |
|
333 | - { |
|
334 | - return EE_Maintenance_Mode::instance(); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - final public function __clone() |
|
339 | - { |
|
340 | - } |
|
17 | + /** |
|
18 | + * constants available to client code for interpreting the values of EE_Maintenance_Mode::level(). |
|
19 | + * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal) |
|
20 | + */ |
|
21 | + const level_0_not_in_maintenance = 0; |
|
22 | + |
|
23 | + /** |
|
24 | + * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled |
|
25 | + * but the admin backend should be running as normal. Maybe an admin can view the frontend though |
|
26 | + */ |
|
27 | + const level_1_frontend_only_maintenance = 1; |
|
28 | + |
|
29 | + /** |
|
30 | + * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running |
|
31 | + * is the maintenance mode stuff, which will require users to update all addons, and then finish running all |
|
32 | + * migration scripts before taking the site out of maintenance mode |
|
33 | + */ |
|
34 | + const level_2_complete_maintenance = 2; |
|
35 | + |
|
36 | + /** |
|
37 | + * the name of the option which stores the current level of maintenance mode |
|
38 | + */ |
|
39 | + const option_name_maintenance_mode = 'ee_maintenance_mode'; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Maintenance_Mode $_instance |
|
44 | + */ |
|
45 | + private static $_instance; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Registry $EE |
|
49 | + */ |
|
50 | + protected $EE; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @singleton method used to instantiate class object |
|
55 | + * @return EE_Maintenance_Mode |
|
56 | + */ |
|
57 | + public static function instance() |
|
58 | + { |
|
59 | + // check if class object is instantiated |
|
60 | + if (! self::$_instance instanceof EE_Maintenance_Mode) { |
|
61 | + self::$_instance = new self(); |
|
62 | + } |
|
63 | + return self::$_instance; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
|
69 | + * |
|
70 | + * @return EE_Maintenance_Mode |
|
71 | + */ |
|
72 | + public static function reset() |
|
73 | + { |
|
74 | + self::instance()->set_maintenance_mode_if_db_old(); |
|
75 | + return self::instance(); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + *private constructor to prevent direct creation |
|
81 | + */ |
|
82 | + private function __construct() |
|
83 | + { |
|
84 | + // if M-Mode level 2 is engaged, we still need basic assets loaded |
|
85 | + add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
86 | + // shut 'er down down for maintenance ? |
|
87 | + add_filter('the_content', array($this, 'the_content'), 2); |
|
88 | + // add powered by EE msg |
|
89 | + add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * retrieves the maintenance mode option value from the db |
|
95 | + * |
|
96 | + * @return int |
|
97 | + */ |
|
98 | + public function real_level() |
|
99 | + { |
|
100 | + return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Returns whether or not the models reportedly are able to run queries or not |
|
106 | + * (ie, if the system thinks their tables are present and up-to-date). |
|
107 | + * |
|
108 | + * @return boolean |
|
109 | + */ |
|
110 | + public function models_can_query() |
|
111 | + { |
|
112 | + return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * Determines whether or not we're in maintenance mode and what level. However, while the site |
|
118 | + * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear |
|
119 | + * to them as if teh site isn't in maintenance mode. |
|
120 | + * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode) |
|
121 | + * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode |
|
122 | + * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
|
123 | + * |
|
124 | + * @return int |
|
125 | + */ |
|
126 | + public function level() |
|
127 | + { |
|
128 | + $maintenance_mode_level = $this->real_level(); |
|
129 | + // if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
|
130 | + if ($maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1 |
|
131 | + && ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests |
|
132 | + && current_user_can('administrator') // when the user is an admin |
|
133 | + ) { |
|
134 | + $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
|
135 | + } |
|
136 | + return $maintenance_mode_level; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * Determines if we need to put EE in maintenance mode because the database needs updating |
|
142 | + * |
|
143 | + * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
|
144 | + */ |
|
145 | + public function set_maintenance_mode_if_db_old() |
|
146 | + { |
|
147 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
148 | + if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
149 | + update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
|
150 | + return true; |
|
151 | + } |
|
152 | + if ($this->level() === self::level_2_complete_maintenance) { |
|
153 | + // we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
|
154 | + // then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
|
155 | + update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
156 | + return false; |
|
157 | + } |
|
158 | + return false; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Updates the maintenance level on the site |
|
164 | + * |
|
165 | + * @param int $level |
|
166 | + * @return void |
|
167 | + */ |
|
168 | + public function set_maintenance_level($level) |
|
169 | + { |
|
170 | + do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
171 | + update_option(self::option_name_maintenance_mode, (int) $level); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * returns TRUE if M-Mode is engaged and the current request is not for the admin |
|
177 | + * |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public static function disable_frontend_for_maintenance() |
|
181 | + { |
|
182 | + return (! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * @return void |
|
188 | + */ |
|
189 | + public function load_assets_required_for_m_mode() |
|
190 | + { |
|
191 | + if ($this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance |
|
192 | + && ! wp_script_is('espresso_core') |
|
193 | + ) { |
|
194 | + wp_register_style( |
|
195 | + 'espresso_default', |
|
196 | + EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
197 | + array('dashicons'), |
|
198 | + EVENT_ESPRESSO_VERSION |
|
199 | + ); |
|
200 | + wp_enqueue_style('espresso_default'); |
|
201 | + wp_register_script( |
|
202 | + 'espresso_core', |
|
203 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
204 | + array('jquery'), |
|
205 | + EVENT_ESPRESSO_VERSION, |
|
206 | + true |
|
207 | + ); |
|
208 | + wp_enqueue_script('espresso_core'); |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * replacement EE CPT template that displays message notifying site visitors |
|
215 | + * that EE has been temporarily placed into maintenance mode |
|
216 | + * does NOT get called on non-EE-CPT requests |
|
217 | + * |
|
218 | + * @return string |
|
219 | + */ |
|
220 | + public static function template_include() |
|
221 | + { |
|
222 | + // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
|
223 | + return get_template_directory() . '/index.php'; |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * displays message notifying site visitors that EE has been temporarily |
|
229 | + * placed into maintenance mode when post_type != EE CPT |
|
230 | + * |
|
231 | + * @param string $the_content |
|
232 | + * @return string |
|
233 | + */ |
|
234 | + public function the_content($the_content) |
|
235 | + { |
|
236 | + // check if M-mode is engaged and for EE shortcode |
|
237 | + if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) { |
|
238 | + // this can eventually be moved to a template, or edited via admin. But for now... |
|
239 | + $the_content = sprintf( |
|
240 | + esc_html__( |
|
241 | + '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', |
|
242 | + 'event_espresso' |
|
243 | + ), |
|
244 | + '<h3>', |
|
245 | + '</h3><p>', |
|
246 | + '</p>' |
|
247 | + ); |
|
248 | + } |
|
249 | + return $the_content; |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
255 | + */ |
|
256 | + public function display_maintenance_mode_notice() |
|
257 | + { |
|
258 | + // check if M-mode is engaged and for EE shortcode |
|
259 | + if (! (defined('DOING_AJAX') && DOING_AJAX) |
|
260 | + && $this->real_level() |
|
261 | + && ! is_admin() |
|
262 | + && current_user_can('administrator') |
|
263 | + && EE_Registry::instance()->REQ->is_espresso_page() |
|
264 | + ) { |
|
265 | + printf( |
|
266 | + esc_html__( |
|
267 | + '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', |
|
268 | + 'event_espresso' |
|
269 | + ), |
|
270 | + '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
|
271 | + '"><span class="dashicons dashicons-no"></span></a><p>', |
|
272 | + ' » <a href="' . add_query_arg( |
|
273 | + array('page' => 'espresso_maintenance_settings'), |
|
274 | + admin_url('admin.php') |
|
275 | + ) . '">', |
|
276 | + '</a></p></div>' |
|
277 | + ); |
|
278 | + } |
|
279 | + } |
|
280 | + // espresso-notices important-notice ee-attention |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * override magic methods |
|
285 | + */ |
|
286 | + final public function __destruct() |
|
287 | + { |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + final public function __call($a, $b) |
|
292 | + { |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + final public function __get($a) |
|
297 | + { |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + final public function __set($a, $b) |
|
302 | + { |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + final public function __isset($a) |
|
307 | + { |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + final public function __unset($a) |
|
312 | + { |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + final public function __sleep() |
|
317 | + { |
|
318 | + return array(); |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + final public function __wakeup() |
|
323 | + { |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + final public function __invoke() |
|
328 | + { |
|
329 | + } |
|
330 | + |
|
331 | + |
|
332 | + final public static function __set_state($a = null) |
|
333 | + { |
|
334 | + return EE_Maintenance_Mode::instance(); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + final public function __clone() |
|
339 | + { |
|
340 | + } |
|
341 | 341 | |
342 | 342 | |
343 | - final public static function __callStatic($a, $b) |
|
344 | - { |
|
345 | - } |
|
343 | + final public static function __callStatic($a, $b) |
|
344 | + { |
|
345 | + } |
|
346 | 346 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public static function instance() |
58 | 58 | { |
59 | 59 | // check if class object is instantiated |
60 | - if (! self::$_instance instanceof EE_Maintenance_Mode) { |
|
60 | + if ( ! self::$_instance instanceof EE_Maintenance_Mode) { |
|
61 | 61 | self::$_instance = new self(); |
62 | 62 | } |
63 | 63 | return self::$_instance; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function disable_frontend_for_maintenance() |
181 | 181 | { |
182 | - return (! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
182 | + return ( ! is_admin() && EE_Maintenance_Mode::instance()->level()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | ) { |
194 | 194 | wp_register_style( |
195 | 195 | 'espresso_default', |
196 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
196 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
197 | 197 | array('dashicons'), |
198 | 198 | EVENT_ESPRESSO_VERSION |
199 | 199 | ); |
200 | 200 | wp_enqueue_style('espresso_default'); |
201 | 201 | wp_register_script( |
202 | 202 | 'espresso_core', |
203 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
203 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
204 | 204 | array('jquery'), |
205 | 205 | EVENT_ESPRESSO_VERSION, |
206 | 206 | true |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | public static function template_include() |
221 | 221 | { |
222 | 222 | // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
223 | - return get_template_directory() . '/index.php'; |
|
223 | + return get_template_directory().'/index.php'; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | public function display_maintenance_mode_notice() |
257 | 257 | { |
258 | 258 | // check if M-mode is engaged and for EE shortcode |
259 | - if (! (defined('DOING_AJAX') && DOING_AJAX) |
|
259 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) |
|
260 | 260 | && $this->real_level() |
261 | 261 | && ! is_admin() |
262 | 262 | && current_user_can('administrator') |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | ), |
270 | 270 | '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
271 | 271 | '"><span class="dashicons dashicons-no"></span></a><p>', |
272 | - ' » <a href="' . add_query_arg( |
|
272 | + ' » <a href="'.add_query_arg( |
|
273 | 273 | array('page' => 'espresso_maintenance_settings'), |
274 | 274 | admin_url('admin.php') |
275 | - ) . '">', |
|
275 | + ).'">', |
|
276 | 276 | '</a></p></div>' |
277 | 277 | ); |
278 | 278 | } |
@@ -11,257 +11,257 @@ discard block |
||
11 | 11 | { |
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * The title for the menu page. (the page the menu links to) |
|
16 | - * |
|
17 | - * @since 4.4.0 |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - public $title; |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * The label for the menu item. (What shows up in the actual menu). |
|
25 | - * |
|
26 | - * @since 4.4.0 |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - public $menu_label; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * What menu item is the parent of this menu item. |
|
34 | - * |
|
35 | - * @since 4.4.0 |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - public $parent_slug; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * What capability is required to access this page. |
|
43 | - * |
|
44 | - * @since 4.4.0 |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - public $capability = 'administrator'; |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * What slug should be used to reference this menu item. |
|
52 | - * |
|
53 | - * @since 4.4.0 |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $menu_slug; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * The callback for displaying the page that the menu references. |
|
61 | - * |
|
62 | - * @since 4.4.0 |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - public $menu_callback; |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * The EE_Admin_Page_Init attached to this map. |
|
70 | - * |
|
71 | - * @var EE_Admin_Page_Init |
|
72 | - */ |
|
73 | - public $admin_init_page; |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * The EE specific group this menu item belongs in (group slug). |
|
78 | - * |
|
79 | - * @since 4.4.0 |
|
80 | - * @var string |
|
81 | - */ |
|
82 | - public $menu_group; |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * What order this item should be in the menu. |
|
87 | - * |
|
88 | - * @since 4.4.0 |
|
89 | - * @var int |
|
90 | - */ |
|
91 | - public $menu_order; |
|
92 | - |
|
93 | - |
|
94 | - const NONE = 0; |
|
95 | - const BLOG_ADMIN_ONLY = 1; |
|
96 | - const BLOG_AND_NETWORK_ADMIN = 2; |
|
97 | - const NETWORK_ADMIN_ONLY = 3; |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * Whether this item is displayed in the menu or not. |
|
102 | - * Sometimes an EE Admin Page needs to register itself but is not accessible via the WordPress |
|
103 | - * admin menu. |
|
104 | - * |
|
105 | - * @since 4.4.0 |
|
106 | - * @var int |
|
107 | - */ |
|
108 | - public $show_on_menu = self::BLOG_ADMIN_ONLY; |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * Menu maps can define a parent slug that gets used instead of the main parent slug for the menu when |
|
113 | - * EE_Maintenance_Mode::level_2_complete_maintenance is active. |
|
114 | - * |
|
115 | - * @var bool |
|
116 | - */ |
|
117 | - public $maintenance_mode_parent = ''; |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * Constructor. |
|
122 | - * |
|
123 | - * @since 4.4.0 |
|
124 | - * |
|
125 | - * @param array $menu_args An array of arguments used to setup the menu |
|
126 | - * properties on construct. |
|
127 | - * @param array $required An array of keys that should be in the $menu_args, this |
|
128 | - * is used to validate that the items that should be defined |
|
129 | - * are present. |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - public function __construct($menu_args, $required) |
|
133 | - { |
|
134 | - // filter all args before processing so plugins can manipulate various settings for menus. |
|
135 | - $menu_args = apply_filters( |
|
136 | - 'FHEE__EE_Admin_Page_Menu_Map__construct__menu_args', |
|
137 | - $menu_args, |
|
138 | - $required, |
|
139 | - get_class($this) |
|
140 | - ); |
|
141 | - |
|
142 | - |
|
143 | - // verify that required keys are present in the incoming array. |
|
144 | - $missing = array_diff((array) $required, array_keys((array) $menu_args)); |
|
145 | - |
|
146 | - if (! empty($missing)) { |
|
147 | - throw new EE_Error( |
|
148 | - sprintf( |
|
149 | - __( |
|
150 | - '%s is missing some expected keys in the argument array. The following keys are missing: %s', |
|
151 | - 'event_espresso' |
|
152 | - ), |
|
153 | - get_class($this), |
|
154 | - implode(', ', $missing) |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
158 | - |
|
159 | - // made it here okay, so let's set the properties! |
|
160 | - foreach ($menu_args as $prop => $value) { |
|
161 | - switch ($prop) { |
|
162 | - case 'show_on_menu': |
|
163 | - $value = (int) $value; |
|
164 | - break; |
|
165 | - case 'admin_init_page': |
|
166 | - if (in_array('admin_init_page', $required) && ! $value instanceof EE_Admin_Page_Init) { |
|
167 | - throw new EE_Error( |
|
168 | - sprintf( |
|
169 | - __( |
|
170 | - 'The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object. Instead %s was given as the value.', |
|
171 | - 'event_espresso' |
|
172 | - ), |
|
173 | - print_r($value, true) |
|
174 | - ) |
|
175 | - ); |
|
176 | - } |
|
177 | - break; |
|
178 | - case 'menu_callback': |
|
179 | - break; |
|
180 | - |
|
181 | - default: |
|
182 | - $value = (string) $value; |
|
183 | - break; |
|
184 | - } |
|
185 | - if (! EEH_Class_Tools::has_property($this, $prop)) { |
|
186 | - throw new EE_Error( |
|
187 | - sprintf( |
|
188 | - __( |
|
189 | - 'The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', |
|
190 | - 'event_espresso' |
|
191 | - ), |
|
192 | - get_class($this), |
|
193 | - $prop |
|
194 | - ) |
|
195 | - ); |
|
196 | - } |
|
197 | - $this->{$prop} = $value; |
|
198 | - } |
|
199 | - |
|
200 | - // filter capabilities (both static and dynamic) |
|
201 | - $this->capability = apply_filters('FHEE_management_capability', $this->capability, null); |
|
202 | - $this->capability = apply_filters('FHEE_' . $this->menu_slug . '_capability', $this->capability, null); |
|
203 | - |
|
204 | - // Might need to change parent slug depending on maintenance mode. |
|
205 | - if (! empty($this->maintenance_mode_parent) |
|
206 | - && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
207 | - ) { |
|
208 | - $this->parent_slug = $this->maintenance_mode_parent; |
|
209 | - } |
|
210 | - |
|
211 | - // if empty menu_callback let's set default (but only if we have admin page init object) |
|
212 | - if (empty($this->menu_callback) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
213 | - $this->menu_callback = array($this->admin_init_page, 'initialize_admin_page'); |
|
214 | - } |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * This method should define how the menu page gets added for this particular item |
|
220 | - * and go ahead and define it. Note that child classes MUST also return the result of |
|
221 | - * the function used to register the WordPress admin page (the wp_page_slug string) |
|
222 | - * |
|
223 | - * @since 4.4.0 |
|
224 | - * @return string wp_page_slug. |
|
225 | - */ |
|
226 | - abstract protected function _add_menu_page(); |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * Called by client code to use this menu map for registering a WordPress admin page |
|
231 | - * |
|
232 | - * @param boolean $network_admin whether this is being added to the network admin page or not |
|
233 | - * @since 4.4.0 |
|
234 | - */ |
|
235 | - public function add_menu_page($network_admin = false) |
|
236 | - { |
|
237 | - |
|
238 | - $show_on_menu_int = (int) $this->show_on_menu; |
|
239 | - if (($network_admin |
|
240 | - && in_array( |
|
241 | - $show_on_menu_int, |
|
242 | - array(self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY), |
|
243 | - true |
|
244 | - )) |
|
245 | - || |
|
246 | - (! $network_admin |
|
247 | - && in_array( |
|
248 | - $show_on_menu_int, |
|
249 | - array(self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY), |
|
250 | - true |
|
251 | - ))) { |
|
252 | - $wp_page_slug = $this->_add_menu_page(); |
|
253 | - } else { |
|
254 | - $wp_page_slug = ''; |
|
255 | - } |
|
256 | - |
|
257 | - if (! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
258 | - try { |
|
259 | - $this->admin_init_page->set_page_dependencies($wp_page_slug); |
|
260 | - } catch (EE_Error $e) { |
|
261 | - $e->get_error(); |
|
262 | - } |
|
263 | - } |
|
264 | - } |
|
14 | + /** |
|
15 | + * The title for the menu page. (the page the menu links to) |
|
16 | + * |
|
17 | + * @since 4.4.0 |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + public $title; |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * The label for the menu item. (What shows up in the actual menu). |
|
25 | + * |
|
26 | + * @since 4.4.0 |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $menu_label; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * What menu item is the parent of this menu item. |
|
34 | + * |
|
35 | + * @since 4.4.0 |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + public $parent_slug; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * What capability is required to access this page. |
|
43 | + * |
|
44 | + * @since 4.4.0 |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + public $capability = 'administrator'; |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * What slug should be used to reference this menu item. |
|
52 | + * |
|
53 | + * @since 4.4.0 |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $menu_slug; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * The callback for displaying the page that the menu references. |
|
61 | + * |
|
62 | + * @since 4.4.0 |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + public $menu_callback; |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * The EE_Admin_Page_Init attached to this map. |
|
70 | + * |
|
71 | + * @var EE_Admin_Page_Init |
|
72 | + */ |
|
73 | + public $admin_init_page; |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * The EE specific group this menu item belongs in (group slug). |
|
78 | + * |
|
79 | + * @since 4.4.0 |
|
80 | + * @var string |
|
81 | + */ |
|
82 | + public $menu_group; |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * What order this item should be in the menu. |
|
87 | + * |
|
88 | + * @since 4.4.0 |
|
89 | + * @var int |
|
90 | + */ |
|
91 | + public $menu_order; |
|
92 | + |
|
93 | + |
|
94 | + const NONE = 0; |
|
95 | + const BLOG_ADMIN_ONLY = 1; |
|
96 | + const BLOG_AND_NETWORK_ADMIN = 2; |
|
97 | + const NETWORK_ADMIN_ONLY = 3; |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * Whether this item is displayed in the menu or not. |
|
102 | + * Sometimes an EE Admin Page needs to register itself but is not accessible via the WordPress |
|
103 | + * admin menu. |
|
104 | + * |
|
105 | + * @since 4.4.0 |
|
106 | + * @var int |
|
107 | + */ |
|
108 | + public $show_on_menu = self::BLOG_ADMIN_ONLY; |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * Menu maps can define a parent slug that gets used instead of the main parent slug for the menu when |
|
113 | + * EE_Maintenance_Mode::level_2_complete_maintenance is active. |
|
114 | + * |
|
115 | + * @var bool |
|
116 | + */ |
|
117 | + public $maintenance_mode_parent = ''; |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * Constructor. |
|
122 | + * |
|
123 | + * @since 4.4.0 |
|
124 | + * |
|
125 | + * @param array $menu_args An array of arguments used to setup the menu |
|
126 | + * properties on construct. |
|
127 | + * @param array $required An array of keys that should be in the $menu_args, this |
|
128 | + * is used to validate that the items that should be defined |
|
129 | + * are present. |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + public function __construct($menu_args, $required) |
|
133 | + { |
|
134 | + // filter all args before processing so plugins can manipulate various settings for menus. |
|
135 | + $menu_args = apply_filters( |
|
136 | + 'FHEE__EE_Admin_Page_Menu_Map__construct__menu_args', |
|
137 | + $menu_args, |
|
138 | + $required, |
|
139 | + get_class($this) |
|
140 | + ); |
|
141 | + |
|
142 | + |
|
143 | + // verify that required keys are present in the incoming array. |
|
144 | + $missing = array_diff((array) $required, array_keys((array) $menu_args)); |
|
145 | + |
|
146 | + if (! empty($missing)) { |
|
147 | + throw new EE_Error( |
|
148 | + sprintf( |
|
149 | + __( |
|
150 | + '%s is missing some expected keys in the argument array. The following keys are missing: %s', |
|
151 | + 'event_espresso' |
|
152 | + ), |
|
153 | + get_class($this), |
|
154 | + implode(', ', $missing) |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | + |
|
159 | + // made it here okay, so let's set the properties! |
|
160 | + foreach ($menu_args as $prop => $value) { |
|
161 | + switch ($prop) { |
|
162 | + case 'show_on_menu': |
|
163 | + $value = (int) $value; |
|
164 | + break; |
|
165 | + case 'admin_init_page': |
|
166 | + if (in_array('admin_init_page', $required) && ! $value instanceof EE_Admin_Page_Init) { |
|
167 | + throw new EE_Error( |
|
168 | + sprintf( |
|
169 | + __( |
|
170 | + 'The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object. Instead %s was given as the value.', |
|
171 | + 'event_espresso' |
|
172 | + ), |
|
173 | + print_r($value, true) |
|
174 | + ) |
|
175 | + ); |
|
176 | + } |
|
177 | + break; |
|
178 | + case 'menu_callback': |
|
179 | + break; |
|
180 | + |
|
181 | + default: |
|
182 | + $value = (string) $value; |
|
183 | + break; |
|
184 | + } |
|
185 | + if (! EEH_Class_Tools::has_property($this, $prop)) { |
|
186 | + throw new EE_Error( |
|
187 | + sprintf( |
|
188 | + __( |
|
189 | + 'The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', |
|
190 | + 'event_espresso' |
|
191 | + ), |
|
192 | + get_class($this), |
|
193 | + $prop |
|
194 | + ) |
|
195 | + ); |
|
196 | + } |
|
197 | + $this->{$prop} = $value; |
|
198 | + } |
|
199 | + |
|
200 | + // filter capabilities (both static and dynamic) |
|
201 | + $this->capability = apply_filters('FHEE_management_capability', $this->capability, null); |
|
202 | + $this->capability = apply_filters('FHEE_' . $this->menu_slug . '_capability', $this->capability, null); |
|
203 | + |
|
204 | + // Might need to change parent slug depending on maintenance mode. |
|
205 | + if (! empty($this->maintenance_mode_parent) |
|
206 | + && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
207 | + ) { |
|
208 | + $this->parent_slug = $this->maintenance_mode_parent; |
|
209 | + } |
|
210 | + |
|
211 | + // if empty menu_callback let's set default (but only if we have admin page init object) |
|
212 | + if (empty($this->menu_callback) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
213 | + $this->menu_callback = array($this->admin_init_page, 'initialize_admin_page'); |
|
214 | + } |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * This method should define how the menu page gets added for this particular item |
|
220 | + * and go ahead and define it. Note that child classes MUST also return the result of |
|
221 | + * the function used to register the WordPress admin page (the wp_page_slug string) |
|
222 | + * |
|
223 | + * @since 4.4.0 |
|
224 | + * @return string wp_page_slug. |
|
225 | + */ |
|
226 | + abstract protected function _add_menu_page(); |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * Called by client code to use this menu map for registering a WordPress admin page |
|
231 | + * |
|
232 | + * @param boolean $network_admin whether this is being added to the network admin page or not |
|
233 | + * @since 4.4.0 |
|
234 | + */ |
|
235 | + public function add_menu_page($network_admin = false) |
|
236 | + { |
|
237 | + |
|
238 | + $show_on_menu_int = (int) $this->show_on_menu; |
|
239 | + if (($network_admin |
|
240 | + && in_array( |
|
241 | + $show_on_menu_int, |
|
242 | + array(self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY), |
|
243 | + true |
|
244 | + )) |
|
245 | + || |
|
246 | + (! $network_admin |
|
247 | + && in_array( |
|
248 | + $show_on_menu_int, |
|
249 | + array(self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY), |
|
250 | + true |
|
251 | + ))) { |
|
252 | + $wp_page_slug = $this->_add_menu_page(); |
|
253 | + } else { |
|
254 | + $wp_page_slug = ''; |
|
255 | + } |
|
256 | + |
|
257 | + if (! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
258 | + try { |
|
259 | + $this->admin_init_page->set_page_dependencies($wp_page_slug); |
|
260 | + } catch (EE_Error $e) { |
|
261 | + $e->get_error(); |
|
262 | + } |
|
263 | + } |
|
264 | + } |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -275,75 +275,75 @@ discard block |
||
275 | 275 | class EE_Admin_Page_Main_Menu extends EE_Admin_Page_Menu_Map |
276 | 276 | { |
277 | 277 | |
278 | - /** |
|
279 | - * If included int incoming params, then this class will also register a Sub Menue Admin page with a different |
|
280 | - * subtitle than the main menu item. |
|
281 | - * |
|
282 | - * @since 4.4.0 |
|
283 | - * |
|
284 | - * @var string |
|
285 | - */ |
|
286 | - public $subtitle; |
|
287 | - |
|
288 | - /** |
|
289 | - * The page to a icon used for this menu. |
|
290 | - * |
|
291 | - * @since 4.4.0 |
|
292 | - * @see http://codex.wordpress.org/Function_Reference/add_menu_page#Parameters |
|
293 | - * for what can be set for this property. |
|
294 | - * @var string |
|
295 | - */ |
|
296 | - public $icon_url; |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * What position in the main menu order for the WP admin menu this menu item |
|
301 | - * should show. |
|
302 | - * |
|
303 | - * @since 4.4.0 |
|
304 | - * @see http://codex.wordpress.org/Function_Reference/add_menu_page#Parameters |
|
305 | - * for what can be set for this property. |
|
306 | - * @var integer |
|
307 | - */ |
|
308 | - public $position; |
|
309 | - |
|
310 | - |
|
311 | - public function __construct($menu_args) |
|
312 | - { |
|
313 | - $required = array('menu_label', 'parent_slug', 'menu_slug', 'menu_group', 'menu_order', 'admin_init_page'); |
|
314 | - |
|
315 | - parent::__construct($menu_args, $required); |
|
316 | - |
|
317 | - $this->position = ! empty($this->position) ? (int) $this->position : $this->position; |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - /** |
|
322 | - * Uses the proper WP utility for registering a menu page for the main WP pages. |
|
323 | - */ |
|
324 | - protected function _add_menu_page() |
|
325 | - { |
|
326 | - $main = add_menu_page( |
|
327 | - $this->title, |
|
328 | - $this->menu_label, |
|
329 | - $this->capability, |
|
330 | - $this->parent_slug, |
|
331 | - $this->menu_callback, |
|
332 | - $this->icon_url, |
|
333 | - $this->position |
|
334 | - ); |
|
335 | - if (! empty($this->subtitle)) { |
|
336 | - add_submenu_page( |
|
337 | - $this->parent_slug, |
|
338 | - $this->subtitle, |
|
339 | - $this->subtitle, |
|
340 | - $this->capability, |
|
341 | - $this->menu_slug, |
|
342 | - $this->menu_callback |
|
343 | - ); |
|
344 | - } |
|
345 | - return $main; |
|
346 | - } |
|
278 | + /** |
|
279 | + * If included int incoming params, then this class will also register a Sub Menue Admin page with a different |
|
280 | + * subtitle than the main menu item. |
|
281 | + * |
|
282 | + * @since 4.4.0 |
|
283 | + * |
|
284 | + * @var string |
|
285 | + */ |
|
286 | + public $subtitle; |
|
287 | + |
|
288 | + /** |
|
289 | + * The page to a icon used for this menu. |
|
290 | + * |
|
291 | + * @since 4.4.0 |
|
292 | + * @see http://codex.wordpress.org/Function_Reference/add_menu_page#Parameters |
|
293 | + * for what can be set for this property. |
|
294 | + * @var string |
|
295 | + */ |
|
296 | + public $icon_url; |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * What position in the main menu order for the WP admin menu this menu item |
|
301 | + * should show. |
|
302 | + * |
|
303 | + * @since 4.4.0 |
|
304 | + * @see http://codex.wordpress.org/Function_Reference/add_menu_page#Parameters |
|
305 | + * for what can be set for this property. |
|
306 | + * @var integer |
|
307 | + */ |
|
308 | + public $position; |
|
309 | + |
|
310 | + |
|
311 | + public function __construct($menu_args) |
|
312 | + { |
|
313 | + $required = array('menu_label', 'parent_slug', 'menu_slug', 'menu_group', 'menu_order', 'admin_init_page'); |
|
314 | + |
|
315 | + parent::__construct($menu_args, $required); |
|
316 | + |
|
317 | + $this->position = ! empty($this->position) ? (int) $this->position : $this->position; |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + /** |
|
322 | + * Uses the proper WP utility for registering a menu page for the main WP pages. |
|
323 | + */ |
|
324 | + protected function _add_menu_page() |
|
325 | + { |
|
326 | + $main = add_menu_page( |
|
327 | + $this->title, |
|
328 | + $this->menu_label, |
|
329 | + $this->capability, |
|
330 | + $this->parent_slug, |
|
331 | + $this->menu_callback, |
|
332 | + $this->icon_url, |
|
333 | + $this->position |
|
334 | + ); |
|
335 | + if (! empty($this->subtitle)) { |
|
336 | + add_submenu_page( |
|
337 | + $this->parent_slug, |
|
338 | + $this->subtitle, |
|
339 | + $this->subtitle, |
|
340 | + $this->capability, |
|
341 | + $this->menu_slug, |
|
342 | + $this->menu_callback |
|
343 | + ); |
|
344 | + } |
|
345 | + return $main; |
|
346 | + } |
|
347 | 347 | } //end EE_Admin_Page_Main_Menu |
348 | 348 | |
349 | 349 | |
@@ -357,23 +357,23 @@ discard block |
||
357 | 357 | class EE_Admin_Page_Sub_Menu extends EE_Admin_Page_Main_Menu |
358 | 358 | { |
359 | 359 | |
360 | - public function __construct($menu_args) |
|
361 | - { |
|
362 | - parent::__construct($menu_args); |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - protected function _add_menu_page() |
|
367 | - { |
|
368 | - return add_submenu_page( |
|
369 | - $this->parent_slug, |
|
370 | - $this->title, |
|
371 | - $this->menu_label, |
|
372 | - $this->capability, |
|
373 | - $this->menu_slug, |
|
374 | - $this->menu_callback |
|
375 | - ); |
|
376 | - } |
|
360 | + public function __construct($menu_args) |
|
361 | + { |
|
362 | + parent::__construct($menu_args); |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + protected function _add_menu_page() |
|
367 | + { |
|
368 | + return add_submenu_page( |
|
369 | + $this->parent_slug, |
|
370 | + $this->title, |
|
371 | + $this->menu_label, |
|
372 | + $this->capability, |
|
373 | + $this->menu_slug, |
|
374 | + $this->menu_callback |
|
375 | + ); |
|
376 | + } |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -392,28 +392,28 @@ discard block |
||
392 | 392 | { |
393 | 393 | |
394 | 394 | |
395 | - public function __construct($menu_args = array()) |
|
396 | - { |
|
397 | - $required = array('menu_label', 'menu_slug', 'menu_order', 'parent_slug'); |
|
398 | - parent::__construct($menu_args, $required); |
|
399 | - } |
|
395 | + public function __construct($menu_args = array()) |
|
396 | + { |
|
397 | + $required = array('menu_label', 'menu_slug', 'menu_order', 'parent_slug'); |
|
398 | + parent::__construct($menu_args, $required); |
|
399 | + } |
|
400 | 400 | |
401 | 401 | |
402 | - protected function _add_menu_page() |
|
403 | - { |
|
404 | - return add_submenu_page( |
|
405 | - $this->parent_slug, |
|
406 | - $this->menu_label, |
|
407 | - $this->_group_link(), |
|
408 | - $this->capability, |
|
409 | - $this->menu_slug, |
|
410 | - '__return_false' |
|
411 | - ); |
|
412 | - } |
|
402 | + protected function _add_menu_page() |
|
403 | + { |
|
404 | + return add_submenu_page( |
|
405 | + $this->parent_slug, |
|
406 | + $this->menu_label, |
|
407 | + $this->_group_link(), |
|
408 | + $this->capability, |
|
409 | + $this->menu_slug, |
|
410 | + '__return_false' |
|
411 | + ); |
|
412 | + } |
|
413 | 413 | |
414 | 414 | |
415 | - private function _group_link() |
|
416 | - { |
|
417 | - return '<span class="ee_menu_group" onclick="return false;">' . $this->menu_label . '</span>'; |
|
418 | - } |
|
415 | + private function _group_link() |
|
416 | + { |
|
417 | + return '<span class="ee_menu_group" onclick="return false;">' . $this->menu_label . '</span>'; |
|
418 | + } |
|
419 | 419 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | // verify that required keys are present in the incoming array. |
144 | 144 | $missing = array_diff((array) $required, array_keys((array) $menu_args)); |
145 | 145 | |
146 | - if (! empty($missing)) { |
|
146 | + if ( ! empty($missing)) { |
|
147 | 147 | throw new EE_Error( |
148 | 148 | sprintf( |
149 | 149 | __( |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $value = (string) $value; |
183 | 183 | break; |
184 | 184 | } |
185 | - if (! EEH_Class_Tools::has_property($this, $prop)) { |
|
185 | + if ( ! EEH_Class_Tools::has_property($this, $prop)) { |
|
186 | 186 | throw new EE_Error( |
187 | 187 | sprintf( |
188 | 188 | __( |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | |
200 | 200 | // filter capabilities (both static and dynamic) |
201 | 201 | $this->capability = apply_filters('FHEE_management_capability', $this->capability, null); |
202 | - $this->capability = apply_filters('FHEE_' . $this->menu_slug . '_capability', $this->capability, null); |
|
202 | + $this->capability = apply_filters('FHEE_'.$this->menu_slug.'_capability', $this->capability, null); |
|
203 | 203 | |
204 | 204 | // Might need to change parent slug depending on maintenance mode. |
205 | - if (! empty($this->maintenance_mode_parent) |
|
205 | + if ( ! empty($this->maintenance_mode_parent) |
|
206 | 206 | && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
207 | 207 | ) { |
208 | 208 | $this->parent_slug = $this->maintenance_mode_parent; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | true |
244 | 244 | )) |
245 | 245 | || |
246 | - (! $network_admin |
|
246 | + ( ! $network_admin |
|
247 | 247 | && in_array( |
248 | 248 | $show_on_menu_int, |
249 | 249 | array(self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY), |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $wp_page_slug = ''; |
255 | 255 | } |
256 | 256 | |
257 | - if (! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
257 | + if ( ! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
258 | 258 | try { |
259 | 259 | $this->admin_init_page->set_page_dependencies($wp_page_slug); |
260 | 260 | } catch (EE_Error $e) { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $this->icon_url, |
333 | 333 | $this->position |
334 | 334 | ); |
335 | - if (! empty($this->subtitle)) { |
|
335 | + if ( ! empty($this->subtitle)) { |
|
336 | 336 | add_submenu_page( |
337 | 337 | $this->parent_slug, |
338 | 338 | $this->subtitle, |
@@ -414,6 +414,6 @@ discard block |
||
414 | 414 | |
415 | 415 | private function _group_link() |
416 | 416 | { |
417 | - return '<span class="ee_menu_group" onclick="return false;">' . $this->menu_label . '</span>'; |
|
417 | + return '<span class="ee_menu_group" onclick="return false;">'.$this->menu_label.'</span>'; |
|
418 | 418 | } |
419 | 419 | } |
@@ -14,43 +14,43 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - public function do_initial_loads() |
|
18 | - { |
|
19 | - // we want to use the corresponding admin page object (but not route it!). To do this we just set _routing to false. That way this page object is being loaded on all pages to make sure we hook into admin properly. But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;) |
|
20 | - // This is important because we have hooks that help redirect custom post type saves |
|
21 | - if (! isset($_REQUEST['page']) |
|
22 | - || (isset($_REQUEST['page']) |
|
23 | - && $_REQUEST['page'] |
|
24 | - != $this->_menu_map->menu_slug)) { |
|
25 | - $this->_routing = false; |
|
26 | - $this->_initialize_admin_page(); |
|
27 | - } else { |
|
28 | - // normal init loads |
|
29 | - $this->_initialize_admin_page(); |
|
30 | - // added for 4.1 to completely disable autosave for our pages. This can be removed once we fully enable autosave functionality |
|
31 | - remove_filter('wp_print_scripts', 'wp_just_in_time_script_localization'); |
|
32 | - add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100); |
|
33 | - // end removal of autosave functionality. |
|
34 | - } |
|
35 | - } |
|
17 | + public function do_initial_loads() |
|
18 | + { |
|
19 | + // we want to use the corresponding admin page object (but not route it!). To do this we just set _routing to false. That way this page object is being loaded on all pages to make sure we hook into admin properly. But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;) |
|
20 | + // This is important because we have hooks that help redirect custom post type saves |
|
21 | + if (! isset($_REQUEST['page']) |
|
22 | + || (isset($_REQUEST['page']) |
|
23 | + && $_REQUEST['page'] |
|
24 | + != $this->_menu_map->menu_slug)) { |
|
25 | + $this->_routing = false; |
|
26 | + $this->_initialize_admin_page(); |
|
27 | + } else { |
|
28 | + // normal init loads |
|
29 | + $this->_initialize_admin_page(); |
|
30 | + // added for 4.1 to completely disable autosave for our pages. This can be removed once we fully enable autosave functionality |
|
31 | + remove_filter('wp_print_scripts', 'wp_just_in_time_script_localization'); |
|
32 | + add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100); |
|
33 | + // end removal of autosave functionality. |
|
34 | + } |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - public function wp_just_in_time_script_localization() |
|
39 | - { |
|
40 | - wp_localize_script( |
|
41 | - 'autosave', |
|
42 | - 'autosaveL10n', |
|
43 | - array( |
|
44 | - 'autosaveInterval' => 172800, |
|
45 | - 'savingText' => __('Saving Draft…', 'event_espresso'), |
|
46 | - 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.', 'event_espresso'), |
|
47 | - ) |
|
48 | - ); |
|
49 | - } |
|
38 | + public function wp_just_in_time_script_localization() |
|
39 | + { |
|
40 | + wp_localize_script( |
|
41 | + 'autosave', |
|
42 | + 'autosaveL10n', |
|
43 | + array( |
|
44 | + 'autosaveInterval' => 172800, |
|
45 | + 'savingText' => __('Saving Draft…', 'event_espresso'), |
|
46 | + 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.', 'event_espresso'), |
|
47 | + ) |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - public function adjust_post_lock_window($interval) |
|
53 | - { |
|
54 | - return 172800; |
|
55 | - } |
|
52 | + public function adjust_post_lock_window($interval) |
|
53 | + { |
|
54 | + return 172800; |
|
55 | + } |
|
56 | 56 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | { |
19 | 19 | // we want to use the corresponding admin page object (but not route it!). To do this we just set _routing to false. That way this page object is being loaded on all pages to make sure we hook into admin properly. But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;) |
20 | 20 | // This is important because we have hooks that help redirect custom post type saves |
21 | - if (! isset($_REQUEST['page']) |
|
21 | + if ( ! isset($_REQUEST['page']) |
|
22 | 22 | || (isset($_REQUEST['page']) |
23 | 23 | && $_REQUEST['page'] |
24 | 24 | != $this->_menu_map->menu_slug)) { |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | public function get_stops() |
257 | 257 | { |
258 | 258 | foreach ($this->_stops as $ind => $stop) { |
259 | - if (! isset($stop['button_text'])) { |
|
260 | - $this->_stops[ $ind ]['button_text'] = $this->_options['button_text']; |
|
259 | + if ( ! isset($stop['button_text'])) { |
|
260 | + $this->_stops[$ind]['button_text'] = $this->_options['button_text']; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | return $this->_stops; |
@@ -277,6 +277,6 @@ discard block |
||
277 | 277 | $this->_options['pauseAfter'][] = $ind; |
278 | 278 | } |
279 | 279 | } |
280 | - return apply_filters('FHEE__' . get_class($this) . '__get_options', $this->_options, $this); |
|
280 | + return apply_filters('FHEE__'.get_class($this).'__get_options', $this->_options, $this); |
|
281 | 281 | } |
282 | 282 | } |
@@ -15,269 +15,269 @@ |
||
15 | 15 | abstract class EE_Help_Tour extends EE_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * This is the label for the tour. It is used when regenerating restart buttons for the tour. Set this in the |
|
20 | - * constructor of the child class. |
|
21 | - * |
|
22 | - * @access protected |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_label = ''; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * This is the slug for the tour. It should be unique from all tours and is used for starting a tour and setting |
|
30 | - * cookies for the tour. Set this in the constructor of the child class. |
|
31 | - * |
|
32 | - * @access protected |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_slug = ''; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * This will contain the formatted array for the stops that gets used by EE_Admin_Page->_add_help_tour() for |
|
40 | - * setting up a tour on a given page. format for array is: array( |
|
41 | - * 0 => array( |
|
42 | - * 'id' => 'id_element', //if attached to an css id for an element then use this param. id's will take |
|
43 | - * precendence even if you also set class. |
|
44 | - * 'class' => 'class_element', //if attached to a css class for an element anchoring the stop then use |
|
45 | - * this param. The first element for that class is the anchor. If the class or the id are empty then the |
|
46 | - * stop will be a modal on the page anchored to the main body. |
|
47 | - * 'custom_class' => 'some_custom_class', //optional custom class to add for this stop. |
|
48 | - * 'button_text' => 'custom text for button', //optional |
|
49 | - * 'content' => 'The content for the stop', //required |
|
50 | - * 'pause_after' => false, //indicate if you want the tour to pause after this stop and it will get |
|
51 | - * added to the pauseAfter global option array setup for the joyride instance. This is only applicable |
|
52 | - * when this tour has been set to run on timer. |
|
53 | - * 'options' => array( |
|
54 | - * //override any of the global options set via the help_tour "option_callback" for the joyride |
|
55 | - * instance on this specific stop. |
|
56 | - * ) |
|
57 | - * ) |
|
58 | - * ); |
|
59 | - * |
|
60 | - * @access protected |
|
61 | - * @var array |
|
62 | - */ |
|
63 | - protected $_stops = array(); |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * This contains any stop specific options for the tour. |
|
68 | - * defaults are set but child classes can override. |
|
69 | - * |
|
70 | - * @access protected |
|
71 | - * @var array |
|
72 | - */ |
|
73 | - protected $_options = array(); |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * holds anything found in the $_REQUEST object (however we override any _gets with _post data). |
|
78 | - * |
|
79 | - * @access protected |
|
80 | - * @var array |
|
81 | - */ |
|
82 | - protected $_req_data = array(); |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * a flag that is set on init for whether this help_tour is happening on a caf install or not. |
|
87 | - * |
|
88 | - * @var boolean |
|
89 | - */ |
|
90 | - protected $_is_caf = false; |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * _constructor |
|
95 | - * initialized the tour object and sets up important properties required to setup the tour. |
|
96 | - * |
|
97 | - * @access public |
|
98 | - * @param boolean $caf used to indicate if this tour is happening on caf install or not. |
|
99 | - * @return void |
|
100 | - */ |
|
101 | - public function __construct($caf = false) |
|
102 | - { |
|
103 | - $this->_is_caf = $caf; |
|
104 | - $this->_req_data = array_merge($_GET, $_POST); |
|
105 | - $this->_set_tour_properties(); |
|
106 | - $this->_set_tour_stops(); |
|
107 | - $this->_set_tour_options(); |
|
108 | - |
|
109 | - // make sure the last tour stop has "end tour" for its button |
|
110 | - $end = array_pop($this->_stops); |
|
111 | - $end['button_text'] = __('End Tour', 'event_espresso'); |
|
112 | - // add back to stops |
|
113 | - $this->_stops[] = $end; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * required method that has the sole purpose of setting up the tour $_label and $_slug properties |
|
119 | - * |
|
120 | - * @abstract |
|
121 | - * @access protected |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - abstract protected function _set_tour_properties(); |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * required method that's sole purpose is to setup the $_stops property |
|
129 | - * |
|
130 | - * @abstract |
|
131 | - * @access protected |
|
132 | - * @return void |
|
133 | - */ |
|
134 | - abstract protected function _set_tour_stops(); |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * The method can optionally be overridden by child classes to set the _options array if there are any default |
|
139 | - * options the child wishes to override for a this tour. See property definition for more info |
|
140 | - * |
|
141 | - * @access protected |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - protected function _set_tour_options($options = array()) |
|
145 | - { |
|
146 | - $defaults = array( |
|
147 | - 'tipLocation' => 'bottom', |
|
148 | - // 'top', 'bottom', 'right', 'left' in relation to parent |
|
149 | - 'nubPosition' => 'auto', |
|
150 | - // override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left" |
|
151 | - 'tipAdjustmentY' => 0, |
|
152 | - // allow for adjustment of tip |
|
153 | - 'tipAdjustmentX' => 0, |
|
154 | - // allow for adjustment of tip |
|
155 | - 'scroll' => true, |
|
156 | - // whether to scrollTo the next step or not |
|
157 | - 'scrollSpeed' => 300, |
|
158 | - // Page scrolling speed in ms |
|
159 | - 'timer' => 0, |
|
160 | - // 0 = off, all other numbers = time(ms) |
|
161 | - 'autoStart' => true, |
|
162 | - // true or false - false tour starts when restart called |
|
163 | - 'startTimerOnClick' => true, |
|
164 | - // true/false to start timer on first click |
|
165 | - 'nextButton' => true, |
|
166 | - // true/false for next button visibility |
|
167 | - 'button_text' => __('Next', 'event_espresso'), |
|
168 | - 'tipAnimation' => 'fade', |
|
169 | - // 'pop' or 'fade' in each tip |
|
170 | - 'pauseAfter' => array(), |
|
171 | - // array of indexes where to pause the tour after |
|
172 | - 'tipAnimationFadeSpeed' => 300, |
|
173 | - // if 'fade'- speed in ms of transition |
|
174 | - 'cookieMonster' => true, |
|
175 | - // true/false for whether cookies are used |
|
176 | - 'cookieName' => $this->get_slug(), |
|
177 | - // choose your own cookie name (setup will add the prefix for the specific page joyride) |
|
178 | - // set to false or yoursite.com |
|
179 | - 'cookieDomain' => false, |
|
180 | - // Where the tip be attached if not inline |
|
181 | - // 'tipContainer' => 'body', |
|
182 | - 'modal' => false, |
|
183 | - // Whether to cover page with modal during the tour |
|
184 | - 'expose' => false, |
|
185 | - // Whether to expose the elements at each step in the tour (requires modal:true), |
|
186 | - 'postExposeCallback' => 'EEHelpTour.postExposeCallback', |
|
187 | - // A method to call after an element has been exposed |
|
188 | - 'preRideCallback' => 'EEHelpTour_preRideCallback', |
|
189 | - // A method to call before the tour starts (passed index, tip, and cloned exposed element) |
|
190 | - 'postRideCallback' => 'EEHelpTour_postRideCallback', |
|
191 | - // a method to call once the tour closes. This will correspond to the name of a js method that will have to be defined in loaded js. |
|
192 | - 'preStepCallback' => 'EEHelpTour_preStepCallback', |
|
193 | - // A method to call before each step |
|
194 | - 'postStepCallback' => 'EEHelpTour_postStepCallback', |
|
195 | - // A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/ |
|
196 | - ); |
|
197 | - |
|
198 | - $options = ! empty($options) && is_array($options) ? array_merge($defaults, $options) : $defaults; |
|
199 | - $this->_options = $options; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * getter functions to return all the properties for the tour. |
|
205 | - */ |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * get_slug |
|
210 | - * |
|
211 | - * @return string slug for the tour |
|
212 | - */ |
|
213 | - public function get_slug() |
|
214 | - { |
|
215 | - if (empty($this->_slug)) { |
|
216 | - throw new EE_Error( |
|
217 | - sprintf( |
|
218 | - __( |
|
219 | - 'There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - get_class($this) |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
226 | - return $this->_slug; |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * get_label |
|
232 | - * |
|
233 | - * @return string |
|
234 | - */ |
|
235 | - public function get_label() |
|
236 | - { |
|
237 | - if (empty($this->_label)) { |
|
238 | - throw new EE_Error( |
|
239 | - sprintf( |
|
240 | - __( |
|
241 | - 'There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', |
|
242 | - 'event_espresso' |
|
243 | - ), |
|
244 | - get_class($this) |
|
245 | - ) |
|
246 | - ); |
|
247 | - } |
|
248 | - return $this->_label; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * get_stops |
|
254 | - * |
|
255 | - * @return array |
|
256 | - */ |
|
257 | - public function get_stops() |
|
258 | - { |
|
259 | - foreach ($this->_stops as $ind => $stop) { |
|
260 | - if (! isset($stop['button_text'])) { |
|
261 | - $this->_stops[ $ind ]['button_text'] = $this->_options['button_text']; |
|
262 | - } |
|
263 | - } |
|
264 | - return $this->_stops; |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * get options |
|
270 | - * |
|
271 | - * @return array |
|
272 | - */ |
|
273 | - public function get_options() |
|
274 | - { |
|
275 | - // let's make sure there are not pauses set |
|
276 | - foreach ($this->_stops as $ind => $stop) { |
|
277 | - if (isset($stop['pause_after']) && $stop['pause_after']) { |
|
278 | - $this->_options['pauseAfter'][] = $ind; |
|
279 | - } |
|
280 | - } |
|
281 | - return apply_filters('FHEE__' . get_class($this) . '__get_options', $this->_options, $this); |
|
282 | - } |
|
18 | + /** |
|
19 | + * This is the label for the tour. It is used when regenerating restart buttons for the tour. Set this in the |
|
20 | + * constructor of the child class. |
|
21 | + * |
|
22 | + * @access protected |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_label = ''; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * This is the slug for the tour. It should be unique from all tours and is used for starting a tour and setting |
|
30 | + * cookies for the tour. Set this in the constructor of the child class. |
|
31 | + * |
|
32 | + * @access protected |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_slug = ''; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * This will contain the formatted array for the stops that gets used by EE_Admin_Page->_add_help_tour() for |
|
40 | + * setting up a tour on a given page. format for array is: array( |
|
41 | + * 0 => array( |
|
42 | + * 'id' => 'id_element', //if attached to an css id for an element then use this param. id's will take |
|
43 | + * precendence even if you also set class. |
|
44 | + * 'class' => 'class_element', //if attached to a css class for an element anchoring the stop then use |
|
45 | + * this param. The first element for that class is the anchor. If the class or the id are empty then the |
|
46 | + * stop will be a modal on the page anchored to the main body. |
|
47 | + * 'custom_class' => 'some_custom_class', //optional custom class to add for this stop. |
|
48 | + * 'button_text' => 'custom text for button', //optional |
|
49 | + * 'content' => 'The content for the stop', //required |
|
50 | + * 'pause_after' => false, //indicate if you want the tour to pause after this stop and it will get |
|
51 | + * added to the pauseAfter global option array setup for the joyride instance. This is only applicable |
|
52 | + * when this tour has been set to run on timer. |
|
53 | + * 'options' => array( |
|
54 | + * //override any of the global options set via the help_tour "option_callback" for the joyride |
|
55 | + * instance on this specific stop. |
|
56 | + * ) |
|
57 | + * ) |
|
58 | + * ); |
|
59 | + * |
|
60 | + * @access protected |
|
61 | + * @var array |
|
62 | + */ |
|
63 | + protected $_stops = array(); |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * This contains any stop specific options for the tour. |
|
68 | + * defaults are set but child classes can override. |
|
69 | + * |
|
70 | + * @access protected |
|
71 | + * @var array |
|
72 | + */ |
|
73 | + protected $_options = array(); |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * holds anything found in the $_REQUEST object (however we override any _gets with _post data). |
|
78 | + * |
|
79 | + * @access protected |
|
80 | + * @var array |
|
81 | + */ |
|
82 | + protected $_req_data = array(); |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * a flag that is set on init for whether this help_tour is happening on a caf install or not. |
|
87 | + * |
|
88 | + * @var boolean |
|
89 | + */ |
|
90 | + protected $_is_caf = false; |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * _constructor |
|
95 | + * initialized the tour object and sets up important properties required to setup the tour. |
|
96 | + * |
|
97 | + * @access public |
|
98 | + * @param boolean $caf used to indicate if this tour is happening on caf install or not. |
|
99 | + * @return void |
|
100 | + */ |
|
101 | + public function __construct($caf = false) |
|
102 | + { |
|
103 | + $this->_is_caf = $caf; |
|
104 | + $this->_req_data = array_merge($_GET, $_POST); |
|
105 | + $this->_set_tour_properties(); |
|
106 | + $this->_set_tour_stops(); |
|
107 | + $this->_set_tour_options(); |
|
108 | + |
|
109 | + // make sure the last tour stop has "end tour" for its button |
|
110 | + $end = array_pop($this->_stops); |
|
111 | + $end['button_text'] = __('End Tour', 'event_espresso'); |
|
112 | + // add back to stops |
|
113 | + $this->_stops[] = $end; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * required method that has the sole purpose of setting up the tour $_label and $_slug properties |
|
119 | + * |
|
120 | + * @abstract |
|
121 | + * @access protected |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + abstract protected function _set_tour_properties(); |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * required method that's sole purpose is to setup the $_stops property |
|
129 | + * |
|
130 | + * @abstract |
|
131 | + * @access protected |
|
132 | + * @return void |
|
133 | + */ |
|
134 | + abstract protected function _set_tour_stops(); |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * The method can optionally be overridden by child classes to set the _options array if there are any default |
|
139 | + * options the child wishes to override for a this tour. See property definition for more info |
|
140 | + * |
|
141 | + * @access protected |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + protected function _set_tour_options($options = array()) |
|
145 | + { |
|
146 | + $defaults = array( |
|
147 | + 'tipLocation' => 'bottom', |
|
148 | + // 'top', 'bottom', 'right', 'left' in relation to parent |
|
149 | + 'nubPosition' => 'auto', |
|
150 | + // override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left" |
|
151 | + 'tipAdjustmentY' => 0, |
|
152 | + // allow for adjustment of tip |
|
153 | + 'tipAdjustmentX' => 0, |
|
154 | + // allow for adjustment of tip |
|
155 | + 'scroll' => true, |
|
156 | + // whether to scrollTo the next step or not |
|
157 | + 'scrollSpeed' => 300, |
|
158 | + // Page scrolling speed in ms |
|
159 | + 'timer' => 0, |
|
160 | + // 0 = off, all other numbers = time(ms) |
|
161 | + 'autoStart' => true, |
|
162 | + // true or false - false tour starts when restart called |
|
163 | + 'startTimerOnClick' => true, |
|
164 | + // true/false to start timer on first click |
|
165 | + 'nextButton' => true, |
|
166 | + // true/false for next button visibility |
|
167 | + 'button_text' => __('Next', 'event_espresso'), |
|
168 | + 'tipAnimation' => 'fade', |
|
169 | + // 'pop' or 'fade' in each tip |
|
170 | + 'pauseAfter' => array(), |
|
171 | + // array of indexes where to pause the tour after |
|
172 | + 'tipAnimationFadeSpeed' => 300, |
|
173 | + // if 'fade'- speed in ms of transition |
|
174 | + 'cookieMonster' => true, |
|
175 | + // true/false for whether cookies are used |
|
176 | + 'cookieName' => $this->get_slug(), |
|
177 | + // choose your own cookie name (setup will add the prefix for the specific page joyride) |
|
178 | + // set to false or yoursite.com |
|
179 | + 'cookieDomain' => false, |
|
180 | + // Where the tip be attached if not inline |
|
181 | + // 'tipContainer' => 'body', |
|
182 | + 'modal' => false, |
|
183 | + // Whether to cover page with modal during the tour |
|
184 | + 'expose' => false, |
|
185 | + // Whether to expose the elements at each step in the tour (requires modal:true), |
|
186 | + 'postExposeCallback' => 'EEHelpTour.postExposeCallback', |
|
187 | + // A method to call after an element has been exposed |
|
188 | + 'preRideCallback' => 'EEHelpTour_preRideCallback', |
|
189 | + // A method to call before the tour starts (passed index, tip, and cloned exposed element) |
|
190 | + 'postRideCallback' => 'EEHelpTour_postRideCallback', |
|
191 | + // a method to call once the tour closes. This will correspond to the name of a js method that will have to be defined in loaded js. |
|
192 | + 'preStepCallback' => 'EEHelpTour_preStepCallback', |
|
193 | + // A method to call before each step |
|
194 | + 'postStepCallback' => 'EEHelpTour_postStepCallback', |
|
195 | + // A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/ |
|
196 | + ); |
|
197 | + |
|
198 | + $options = ! empty($options) && is_array($options) ? array_merge($defaults, $options) : $defaults; |
|
199 | + $this->_options = $options; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * getter functions to return all the properties for the tour. |
|
205 | + */ |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * get_slug |
|
210 | + * |
|
211 | + * @return string slug for the tour |
|
212 | + */ |
|
213 | + public function get_slug() |
|
214 | + { |
|
215 | + if (empty($this->_slug)) { |
|
216 | + throw new EE_Error( |
|
217 | + sprintf( |
|
218 | + __( |
|
219 | + 'There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + get_class($this) |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | + return $this->_slug; |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * get_label |
|
232 | + * |
|
233 | + * @return string |
|
234 | + */ |
|
235 | + public function get_label() |
|
236 | + { |
|
237 | + if (empty($this->_label)) { |
|
238 | + throw new EE_Error( |
|
239 | + sprintf( |
|
240 | + __( |
|
241 | + 'There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', |
|
242 | + 'event_espresso' |
|
243 | + ), |
|
244 | + get_class($this) |
|
245 | + ) |
|
246 | + ); |
|
247 | + } |
|
248 | + return $this->_label; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * get_stops |
|
254 | + * |
|
255 | + * @return array |
|
256 | + */ |
|
257 | + public function get_stops() |
|
258 | + { |
|
259 | + foreach ($this->_stops as $ind => $stop) { |
|
260 | + if (! isset($stop['button_text'])) { |
|
261 | + $this->_stops[ $ind ]['button_text'] = $this->_options['button_text']; |
|
262 | + } |
|
263 | + } |
|
264 | + return $this->_stops; |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * get options |
|
270 | + * |
|
271 | + * @return array |
|
272 | + */ |
|
273 | + public function get_options() |
|
274 | + { |
|
275 | + // let's make sure there are not pauses set |
|
276 | + foreach ($this->_stops as $ind => $stop) { |
|
277 | + if (isset($stop['pause_after']) && $stop['pause_after']) { |
|
278 | + $this->_options['pauseAfter'][] = $ind; |
|
279 | + } |
|
280 | + } |
|
281 | + return apply_filters('FHEE__' . get_class($this) . '__get_options', $this->_options, $this); |
|
282 | + } |
|
283 | 283 | } |
@@ -4,19 +4,19 @@ |
||
4 | 4 | <div class="about-text"><?php echo ! empty($admin_page_subtitle) ? $admin_page_subtitle : ''; ?></div> |
5 | 5 | <div class="ee-badge"><img class="" src=" <?php echo EE_GLOBAL_ASSETS_URL; ?>images/event-espresso-cup-90x90.png" |
6 | 6 | width="90" height="90" alt="<?php |
7 | - printf( |
|
8 | - esc_attr__('%s Logo', 'event_espresso'), |
|
9 | - 'Event Espresso' |
|
10 | - ); ?>"/> |
|
7 | + printf( |
|
8 | + esc_attr__('%s Logo', 'event_espresso'), |
|
9 | + 'Event Espresso' |
|
10 | + ); ?>"/> |
|
11 | 11 | <br/><?php printf(__('Version %s', 'event_espresso'), EVENT_ESPRESSO_VERSION); ?></div> |
12 | 12 | |
13 | 13 | <?php echo $nav_tabs; ?> |
14 | 14 | |
15 | 15 | |
16 | 16 | <?php |
17 | - do_action('AHEE__admin_wrapper__template__before_about_admin_page_content'); |
|
18 | - echo $about_admin_page_content; |
|
19 | - do_action('AHEE__admin_wrapper__template__after_about_admin_page_content'); |
|
20 | - ?> |
|
17 | + do_action('AHEE__admin_wrapper__template__before_about_admin_page_content'); |
|
18 | + echo $about_admin_page_content; |
|
19 | + do_action('AHEE__admin_wrapper__template__after_about_admin_page_content'); |
|
20 | + ?> |
|
21 | 21 | |
22 | 22 | </div> |