Completed
Branch decaf-fixes/replace-request-ha... (dd0ac0)
by
unknown
04:45 queued 03:02
created
core/services/loaders/ClassInterfaceCache.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -17,166 +17,166 @@
 block discarded – undo
17 17
 class ClassInterfaceCache
18 18
 {
19 19
 
20
-    /**
21
-     * array of interfaces indexed by FQCNs where values are arrays of interface FQNs
22
-     *
23
-     * @var string[][] $interfaces
24
-     */
25
-    private $interfaces = array();
26
-
27
-    /**
28
-     * @type string[][] $aliases
29
-     */
30
-    protected $aliases = array();
31
-
32
-
33
-    /**
34
-     * @param string $fqn
35
-     * @return string
36
-     */
37
-    public function getFqn($fqn)
38
-    {
39
-        $fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn;
40
-        return ltrim($fqn, '\\');
41
-    }
42
-
43
-
44
-    /**
45
-     * @param string $fqn
46
-     * @return array
47
-     */
48
-    public function getInterfaces($fqn)
49
-    {
50
-        $fqn = $this->getFqn($fqn);
51
-        // have we already seen this FQCN ?
52
-        if (! array_key_exists($fqn, $this->interfaces)) {
53
-            $this->interfaces[ $fqn ] = array();
54
-            if (class_exists($fqn)) {
55
-                $this->interfaces[ $fqn ] = class_implements($fqn, false);
56
-                $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
57
-                    ? $this->interfaces[ $fqn ]
58
-                    : array();
59
-            }
60
-        }
61
-        return $this->interfaces[ $fqn ];
62
-    }
63
-
64
-
65
-    /**
66
-     * @param string $fqn
67
-     * @param string $interface
68
-     * @return bool
69
-     */
70
-    public function hasInterface($fqn, $interface)
71
-    {
72
-        $fqn        = $this->getFqn($fqn);
73
-        $interfaces = $this->getInterfaces($fqn);
74
-        return in_array($interface, $interfaces, true);
75
-    }
76
-
77
-
78
-    /**
79
-     * adds an alias for a classname
80
-     *
81
-     * @param string $fqn       the class name that should be used (concrete class to replace interface)
82
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
83
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
84
-     * @throws InvalidAliasException
85
-     */
86
-    public function addAlias($fqn, $alias, $for_class = '')
87
-    {
88
-        $fqn   = $this->getFqn($fqn);
89
-        $alias = $this->getFqn($alias);
90
-        if (strpos($alias, '\\') !== false && ! is_subclass_of($fqn, $alias)) {
91
-            throw new InvalidAliasException($fqn, $alias);
92
-        }
93
-        // are we adding an alias for a specific class?
94
-        if ($for_class !== '') {
95
-            // make sure it's set up as an array
96
-            if (! isset($this->aliases[ $for_class ])) {
97
-                $this->aliases[ $for_class ] = array();
98
-            }
99
-            $this->aliases[ $for_class ][ $alias ] = $fqn;
100
-            return;
101
-        }
102
-        $this->aliases[ $alias ] = $fqn;
103
-    }
104
-
105
-
106
-    /**
107
-     * returns TRUE if the provided FQN is an alias
108
-     *
109
-     * @param string $fqn
110
-     * @param string $for_class
111
-     * @return bool
112
-     */
113
-    public function isAlias($fqn = '', $for_class = '')
114
-    {
115
-        $fqn = $this->getFqn($fqn);
116
-        if ($this->isAliasForClass($fqn, $for_class)) {
117
-            return true;
118
-        }
119
-        if ($this->isDirectAlias($fqn)) {
120
-            return true;
121
-        }
122
-        return false;
123
-    }
124
-
125
-
126
-    /**
127
-     * returns TRUE if the provided FQN is an alias
128
-     *
129
-     * @param string $fqn
130
-     * @return bool
131
-     */
132
-    protected function isDirectAlias($fqn = '')
133
-    {
134
-        return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
135
-    }
136
-
137
-
138
-    /**
139
-     * returns TRUE if the provided FQN is an alias for the specified class
140
-     *
141
-     * @param string $fqn
142
-     * @param string $for_class
143
-     * @return bool
144
-     */
145
-    protected function isAliasForClass($fqn = '', $for_class = '')
146
-    {
147
-        return (
148
-            $for_class !== ''
149
-            && isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     * returns FQN for provided alias if one exists, otherwise returns the original FQN
156
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
157
-     *  for example:
158
-     *      if the following two entries were added to the aliases array:
159
-     *          array(
160
-     *              'interface_alias'           => 'some\namespace\interface'
161
-     *              'some\namespace\interface'  => 'some\namespace\classname'
162
-     *          )
163
-     *      then one could use Loader::getNew( 'interface_alias' )
164
-     *      to load an instance of 'some\namespace\classname'
165
-     *
166
-     * @param string $alias
167
-     * @param string $for_class
168
-     * @return string
169
-     */
170
-    public function getFqnForAlias($alias = '', $for_class = '')
171
-    {
172
-        $alias = $this->getFqn($alias);
173
-        if ($this->isAliasForClass($alias, $for_class)) {
174
-            return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
175
-        }
176
-        if ($this->isDirectAlias($alias)) {
177
-            // note: changed '' to $for_class
178
-            return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
179
-        }
180
-        return $alias;
181
-    }
20
+	/**
21
+	 * array of interfaces indexed by FQCNs where values are arrays of interface FQNs
22
+	 *
23
+	 * @var string[][] $interfaces
24
+	 */
25
+	private $interfaces = array();
26
+
27
+	/**
28
+	 * @type string[][] $aliases
29
+	 */
30
+	protected $aliases = array();
31
+
32
+
33
+	/**
34
+	 * @param string $fqn
35
+	 * @return string
36
+	 */
37
+	public function getFqn($fqn)
38
+	{
39
+		$fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn;
40
+		return ltrim($fqn, '\\');
41
+	}
42
+
43
+
44
+	/**
45
+	 * @param string $fqn
46
+	 * @return array
47
+	 */
48
+	public function getInterfaces($fqn)
49
+	{
50
+		$fqn = $this->getFqn($fqn);
51
+		// have we already seen this FQCN ?
52
+		if (! array_key_exists($fqn, $this->interfaces)) {
53
+			$this->interfaces[ $fqn ] = array();
54
+			if (class_exists($fqn)) {
55
+				$this->interfaces[ $fqn ] = class_implements($fqn, false);
56
+				$this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
57
+					? $this->interfaces[ $fqn ]
58
+					: array();
59
+			}
60
+		}
61
+		return $this->interfaces[ $fqn ];
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param string $fqn
67
+	 * @param string $interface
68
+	 * @return bool
69
+	 */
70
+	public function hasInterface($fqn, $interface)
71
+	{
72
+		$fqn        = $this->getFqn($fqn);
73
+		$interfaces = $this->getInterfaces($fqn);
74
+		return in_array($interface, $interfaces, true);
75
+	}
76
+
77
+
78
+	/**
79
+	 * adds an alias for a classname
80
+	 *
81
+	 * @param string $fqn       the class name that should be used (concrete class to replace interface)
82
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
83
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
84
+	 * @throws InvalidAliasException
85
+	 */
86
+	public function addAlias($fqn, $alias, $for_class = '')
87
+	{
88
+		$fqn   = $this->getFqn($fqn);
89
+		$alias = $this->getFqn($alias);
90
+		if (strpos($alias, '\\') !== false && ! is_subclass_of($fqn, $alias)) {
91
+			throw new InvalidAliasException($fqn, $alias);
92
+		}
93
+		// are we adding an alias for a specific class?
94
+		if ($for_class !== '') {
95
+			// make sure it's set up as an array
96
+			if (! isset($this->aliases[ $for_class ])) {
97
+				$this->aliases[ $for_class ] = array();
98
+			}
99
+			$this->aliases[ $for_class ][ $alias ] = $fqn;
100
+			return;
101
+		}
102
+		$this->aliases[ $alias ] = $fqn;
103
+	}
104
+
105
+
106
+	/**
107
+	 * returns TRUE if the provided FQN is an alias
108
+	 *
109
+	 * @param string $fqn
110
+	 * @param string $for_class
111
+	 * @return bool
112
+	 */
113
+	public function isAlias($fqn = '', $for_class = '')
114
+	{
115
+		$fqn = $this->getFqn($fqn);
116
+		if ($this->isAliasForClass($fqn, $for_class)) {
117
+			return true;
118
+		}
119
+		if ($this->isDirectAlias($fqn)) {
120
+			return true;
121
+		}
122
+		return false;
123
+	}
124
+
125
+
126
+	/**
127
+	 * returns TRUE if the provided FQN is an alias
128
+	 *
129
+	 * @param string $fqn
130
+	 * @return bool
131
+	 */
132
+	protected function isDirectAlias($fqn = '')
133
+	{
134
+		return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
135
+	}
136
+
137
+
138
+	/**
139
+	 * returns TRUE if the provided FQN is an alias for the specified class
140
+	 *
141
+	 * @param string $fqn
142
+	 * @param string $for_class
143
+	 * @return bool
144
+	 */
145
+	protected function isAliasForClass($fqn = '', $for_class = '')
146
+	{
147
+		return (
148
+			$for_class !== ''
149
+			&& isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 * returns FQN for provided alias if one exists, otherwise returns the original FQN
156
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
157
+	 *  for example:
158
+	 *      if the following two entries were added to the aliases array:
159
+	 *          array(
160
+	 *              'interface_alias'           => 'some\namespace\interface'
161
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
162
+	 *          )
163
+	 *      then one could use Loader::getNew( 'interface_alias' )
164
+	 *      to load an instance of 'some\namespace\classname'
165
+	 *
166
+	 * @param string $alias
167
+	 * @param string $for_class
168
+	 * @return string
169
+	 */
170
+	public function getFqnForAlias($alias = '', $for_class = '')
171
+	{
172
+		$alias = $this->getFqn($alias);
173
+		if ($this->isAliasForClass($alias, $for_class)) {
174
+			return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
175
+		}
176
+		if ($this->isDirectAlias($alias)) {
177
+			// note: changed '' to $for_class
178
+			return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
179
+		}
180
+		return $alias;
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $fqn = $this->getFqn($fqn);
51 51
         // have we already seen this FQCN ?
52
-        if (! array_key_exists($fqn, $this->interfaces)) {
53
-            $this->interfaces[ $fqn ] = array();
52
+        if ( ! array_key_exists($fqn, $this->interfaces)) {
53
+            $this->interfaces[$fqn] = array();
54 54
             if (class_exists($fqn)) {
55
-                $this->interfaces[ $fqn ] = class_implements($fqn, false);
56
-                $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
57
-                    ? $this->interfaces[ $fqn ]
55
+                $this->interfaces[$fqn] = class_implements($fqn, false);
56
+                $this->interfaces[$fqn] = $this->interfaces[$fqn] !== false
57
+                    ? $this->interfaces[$fqn]
58 58
                     : array();
59 59
             }
60 60
         }
61
-        return $this->interfaces[ $fqn ];
61
+        return $this->interfaces[$fqn];
62 62
     }
63 63
 
64 64
 
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
         // are we adding an alias for a specific class?
94 94
         if ($for_class !== '') {
95 95
             // make sure it's set up as an array
96
-            if (! isset($this->aliases[ $for_class ])) {
97
-                $this->aliases[ $for_class ] = array();
96
+            if ( ! isset($this->aliases[$for_class])) {
97
+                $this->aliases[$for_class] = array();
98 98
             }
99
-            $this->aliases[ $for_class ][ $alias ] = $fqn;
99
+            $this->aliases[$for_class][$alias] = $fqn;
100 100
             return;
101 101
         }
102
-        $this->aliases[ $alias ] = $fqn;
102
+        $this->aliases[$alias] = $fqn;
103 103
     }
104 104
 
105 105
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function isDirectAlias($fqn = '')
133 133
     {
134
-        return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
134
+        return isset($this->aliases[(string) $fqn]) && ! is_array($this->aliases[(string) $fqn]);
135 135
     }
136 136
 
137 137
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     {
147 147
         return (
148 148
             $for_class !== ''
149
-            && isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
149
+            && isset($this->aliases[(string) $for_class][(string) $fqn])
150 150
         );
151 151
     }
152 152
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
     {
172 172
         $alias = $this->getFqn($alias);
173 173
         if ($this->isAliasForClass($alias, $for_class)) {
174
-            return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
174
+            return $this->getFqnForAlias($this->aliases[(string) $for_class][(string) $alias], $for_class);
175 175
         }
176 176
         if ($this->isDirectAlias($alias)) {
177 177
             // note: changed '' to $for_class
178
-            return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
178
+            return $this->getFqnForAlias($this->aliases[(string) $alias], $for_class);
179 179
         }
180 180
         return $alias;
181 181
     }
Please login to merge, or discard this patch.
core/services/shortcodes/LegacyShortcodesManager.php 1 patch
Indentation   +414 added lines, -414 removed lines patch added patch discarded remove patch
@@ -23,418 +23,418 @@
 block discarded – undo
23 23
  */
24 24
 class LegacyShortcodesManager
25 25
 {
26
-    /**
27
-     * @type CurrentPage
28
-     */
29
-    protected $current_page;
30
-
31
-    /**
32
-     * @var EE_Registry $registry
33
-     */
34
-    private $registry;
35
-
36
-
37
-    /**
38
-     * LegacyShortcodesManager constructor.
39
-     *
40
-     * @param EE_Registry $registry
41
-     * @param CurrentPage $current_page
42
-     */
43
-    public function __construct(EE_Registry $registry, CurrentPage $current_page)
44
-    {
45
-        $this->registry = $registry;
46
-        $this->current_page = $current_page;
47
-    }
48
-
49
-
50
-    /**
51
-     * @return EE_Registry
52
-     */
53
-    public function registry()
54
-    {
55
-        return $this->registry;
56
-    }
57
-
58
-
59
-    /**
60
-     * registerShortcodes
61
-     *
62
-     * @return void
63
-     */
64
-    public function registerShortcodes()
65
-    {
66
-        $this->registry->shortcodes = $this->getShortcodes();
67
-    }
68
-
69
-
70
-    /**
71
-     * getShortcodes
72
-     *
73
-     * @return array
74
-     */
75
-    public function getShortcodes()
76
-    {
77
-        // previously this method would glob the shortcodes directory
78
-        // then filter that list of shortcodes to register,
79
-        // but now we are going to just supply an empty array.
80
-        // this allows any shortcodes that have not yet been converted to the new system
81
-        // to still get loaded and processed, albeit using the same legacy logic as before
82
-        $shortcodes_to_register = apply_filters(
83
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
84
-            array()
85
-        );
86
-        if (! empty($shortcodes_to_register)) {
87
-            // cycle thru shortcode folders
88
-            foreach ($shortcodes_to_register as $shortcode_path) {
89
-                // add to list of installed shortcode modules
90
-                $this->registerShortcode($shortcode_path);
91
-            }
92
-        }
93
-        // filter list of installed modules
94
-        return apply_filters(
95
-            'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
96
-            ! empty($this->registry->shortcodes)
97
-                ? $this->registry->shortcodes
98
-                : array()
99
-        );
100
-    }
101
-
102
-
103
-    /**
104
-     * register_shortcode - makes core aware of this shortcode
105
-     *
106
-     * @param    string $shortcode_path - full path up to and including shortcode folder
107
-     * @return    bool
108
-     */
109
-    public function registerShortcode($shortcode_path = null)
110
-    {
111
-        do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
112
-        $shortcode_ext = '.shortcode.php';
113
-        // make all separators match
114
-        $shortcode_path = str_replace(array('\\', '/'), '/', $shortcode_path);
115
-        // does the file path INCLUDE the actual file name as part of the path ?
116
-        if (strpos($shortcode_path, $shortcode_ext) !== false) {
117
-            // grab shortcode file name from directory name and break apart at dots
118
-            $shortcode_file = explode('.', basename($shortcode_path));
119
-            // take first segment from file name pieces and remove class prefix if it exists
120
-            $shortcode = strpos($shortcode_file[0], 'EES_') === 0
121
-                ? substr($shortcode_file[0], 4)
122
-                : $shortcode_file[0];
123
-            // sanitize shortcode directory name
124
-            $shortcode = sanitize_key($shortcode);
125
-            // now we need to rebuild the shortcode path
126
-            $shortcode_path = explode('/', $shortcode_path);
127
-            // remove last segment
128
-            array_pop($shortcode_path);
129
-            // glue it back together
130
-            $shortcode_path = implode('/', $shortcode_path) . '/';
131
-        } else {
132
-            // we need to generate the filename based off of the folder name
133
-            // grab and sanitize shortcode directory name
134
-            $shortcode = sanitize_key(basename($shortcode_path));
135
-            $shortcode_path = rtrim($shortcode_path, '/') . '/';
136
-        }
137
-        // create classname from shortcode directory or file name
138
-        $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
139
-        // add class prefix
140
-        $shortcode_class = 'EES_' . $shortcode;
141
-        // does the shortcode exist ?
142
-        if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) {
143
-            $msg = sprintf(
144
-                esc_html__(
145
-                    'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',
146
-                    'event_espresso'
147
-                ),
148
-                $shortcode_class,
149
-                $shortcode_path . '/' . $shortcode_class . $shortcode_ext
150
-            );
151
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
152
-            return false;
153
-        }
154
-        // load the shortcode class file
155
-        require_once($shortcode_path . $shortcode_class . $shortcode_ext);
156
-        // verify that class exists
157
-        if (! class_exists($shortcode_class)) {
158
-            $msg = sprintf(
159
-                esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'),
160
-                $shortcode_class
161
-            );
162
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
163
-            return false;
164
-        }
165
-        $shortcode = strtoupper($shortcode);
166
-        // add to array of registered shortcodes
167
-        $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
168
-        return true;
169
-    }
170
-
171
-
172
-    /**
173
-     *    _initialize_shortcodes
174
-     *    allow shortcodes to set hooks for the rest of the system
175
-     *
176
-     * @return void
177
-     */
178
-    public function addShortcodes()
179
-    {
180
-        // cycle thru shortcode folders
181
-        foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) {
182
-            // add class prefix
183
-            $shortcode_class = 'EES_' . $shortcode;
184
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
185
-            // which set hooks ?
186
-            if (is_admin()) {
187
-                // fire immediately
188
-                call_user_func(array($shortcode_class, 'set_hooks_admin'));
189
-            } else {
190
-                // delay until other systems are online
191
-                add_action(
192
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
193
-                    array($shortcode_class, 'set_hooks')
194
-                );
195
-                // convert classname to UPPERCASE and create WP shortcode.
196
-                $shortcode_tag = strtoupper($shortcode);
197
-                // but first check if the shortcode has already
198
-                // been added before assigning 'fallback_shortcode_processor'
199
-                if (! shortcode_exists($shortcode_tag)) {
200
-                    // NOTE: this shortcode declaration will get overridden if the shortcode
201
-                    // is successfully detected in the post content in initializeShortcode()
202
-                    add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
203
-                }
204
-            }
205
-        }
206
-    }
207
-
208
-
209
-    /**
210
-     * callback for the WP "get_header" hook point
211
-     * checks posts for EE shortcodes, and initializes them,
212
-     * then toggles filter switch that loads core default assets
213
-     *
214
-     * @param WP_Query $wp_query
215
-     * @return void
216
-     * @throws ReflectionException
217
-     */
218
-    public function initializeShortcodes(WP_Query $wp_query)
219
-    {
220
-        if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) {
221
-            return;
222
-        }
223
-        global $wp;
224
-        /** @var EE_Front_controller $Front_Controller */
225
-        $Front_Controller = LoaderFactory::getLoader()->getShared('EE_Front_Controller');
226
-        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller);
227
-        $this->current_page->parseQueryVars();
228
-        // grab post_name from request
229
-        $current_post = apply_filters(
230
-            'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',
231
-            $this->current_page->postName()
232
-        );
233
-        $show_on_front = get_option('show_on_front');
234
-        // if it's not set, then check if frontpage is blog
235
-        if (empty($current_post)) {
236
-            // yup.. this is the posts page, prepare to load all shortcode modules
237
-            $current_post = 'posts';
238
-            // unless..
239
-            if ($show_on_front === 'page') {
240
-                // some other page is set as the homepage
241
-                $page_on_front = get_option('page_on_front');
242
-                if ($page_on_front) {
243
-                    // k now we need to find the post_name for this page
244
-                    global $wpdb;
245
-                    $page_on_front = $wpdb->get_var(
246
-                        $wpdb->prepare(
247
-                            "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d",
248
-                            $page_on_front
249
-                        )
250
-                    );
251
-                    // set the current post slug to what it actually is
252
-                    $current_post = $page_on_front ?: $current_post;
253
-                }
254
-            }
255
-        }
256
-        // in case $current_post is hierarchical like: /parent-page/current-page
257
-        $current_post = basename($current_post);
258
-        if (// is current page/post the "blog" page ?
259
-            $current_post === EE_Config::get_page_for_posts()
260
-            // or are we on a category page?
261
-            || (
262
-                is_array(term_exists($current_post, 'category'))
263
-                || array_key_exists('category_name', $wp->query_vars)
264
-            )
265
-        ) {
266
-            // initialize all legacy shortcodes
267
-            $load_assets = $this->parseContentForShortcodes('', true);
268
-        } else {
269
-            global $wpdb;
270
-            $post_content = $wpdb->get_var(
271
-                $wpdb->prepare(
272
-                    "SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s",
273
-                    $current_post
274
-                )
275
-            );
276
-            $load_assets = $this->parseContentForShortcodes($post_content);
277
-        }
278
-        if ($load_assets) {
279
-            $this->current_page->setEspressoPage(true);
280
-            add_filter('FHEE_load_css', '__return_true');
281
-            add_filter('FHEE_load_js', '__return_true');
282
-        }
283
-        do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller);
284
-    }
285
-
286
-
287
-    /**
288
-     * checks supplied content against list of legacy shortcodes,
289
-     * then initializes any found shortcodes, and returns true.
290
-     * returns false if no shortcodes found.
291
-     *
292
-     * @param string $content
293
-     * @param bool   $load_all if true, then ALL active legacy shortcodes will be initialized
294
-     * @return bool
295
-     * @throws ReflectionException
296
-     */
297
-    public function parseContentForShortcodes($content = '', $load_all = false)
298
-    {
299
-        $has_shortcode = false;
300
-        foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) {
301
-            if ($load_all || has_shortcode($content, $shortcode_class)) {
302
-                // load up the shortcode
303
-                $this->initializeShortcode($shortcode_class);
304
-                $has_shortcode = true;
305
-            }
306
-        }
307
-        return $has_shortcode;
308
-    }
309
-
310
-
311
-    /**
312
-     * given a shortcode name, will instantiate the shortcode and call it's run() method
313
-     *
314
-     * @param string $shortcode_class
315
-     * @param WP     $wp
316
-     * @throws ReflectionException
317
-     */
318
-    public function initializeShortcode($shortcode_class = '', WP $wp = null)
319
-    {
320
-        // don't do anything if shortcode is already initialized
321
-        if (empty($this->registry->shortcodes->{$shortcode_class})
322
-            || ! is_string($this->registry->shortcodes->{$shortcode_class})
323
-        ) {
324
-            return;
325
-        }
326
-        // let's pause to reflect on this...
327
-        $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));
328
-        // ensure that class is actually a shortcode
329
-        if (defined('WP_DEBUG')
330
-            && WP_DEBUG === true
331
-            && ! $sc_reflector->isSubclassOf('EES_Shortcode')
332
-        ) {
333
-            EE_Error::add_error(
334
-                sprintf(
335
-                    esc_html__(
336
-                        'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',
337
-                        'event_espresso'
338
-                    ),
339
-                    $shortcode_class
340
-                ),
341
-                __FILE__,
342
-                __FUNCTION__,
343
-                __LINE__
344
-            );
345
-            add_filter('FHEE_run_EE_the_content', '__return_true');
346
-            return;
347
-        }
348
-        global $wp;
349
-        // and pass the request object to the run method
350
-        $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance();
351
-        // fire the shortcode class's run method, so that it can activate resources
352
-        $this->registry->shortcodes->{$shortcode_class}->run($wp);
353
-    }
354
-
355
-
356
-    /**
357
-     * get classname, remove EES_prefix, and convert to UPPERCASE
358
-     *
359
-     * @param string $class_name
360
-     * @return string
361
-     */
362
-    public static function generateShortcodeTagFromClassName($class_name)
363
-    {
364
-        return strtoupper(str_replace('EES_', '', $class_name));
365
-    }
366
-
367
-
368
-    /**
369
-     * add EES_prefix and Capitalize words
370
-     *
371
-     * @param string $tag
372
-     * @return string
373
-     */
374
-    public static function generateShortcodeClassNameFromTag($tag)
375
-    {
376
-        // order of operation runs from inside to out
377
-        // 5) maybe add prefix
378
-        return LegacyShortcodesManager::addShortcodeClassPrefix(
379
-            // 4) find spaces, replace with underscores
380
-            str_replace(
381
-                ' ',
382
-                '_',
383
-                // 3) capitalize first letter of each word
384
-                ucwords(
385
-                    // 2) also change to lowercase so ucwords() will work
386
-                    strtolower(
387
-                        // 1) find underscores, replace with spaces so ucwords() will work
388
-                        str_replace(
389
-                            '_',
390
-                            ' ',
391
-                            $tag
392
-                        )
393
-                    )
394
-                )
395
-            )
396
-        );
397
-    }
398
-
399
-
400
-    /**
401
-     * maybe add EES_prefix
402
-     *
403
-     * @param string $class_name
404
-     * @return string
405
-     */
406
-    public static function addShortcodeClassPrefix($class_name)
407
-    {
408
-        return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;
409
-    }
410
-
411
-
412
-    /**
413
-     * @return array
414
-     */
415
-    public function getEspressoShortcodeTags()
416
-    {
417
-        static $shortcode_tags = array();
418
-        if (empty($shortcode_tags)) {
419
-            $shortcode_tags = array_keys((array) $this->registry->shortcodes);
420
-        }
421
-        return $shortcode_tags;
422
-    }
423
-
424
-
425
-    /**
426
-     * @param string $content
427
-     * @return string
428
-     * @throws ReflectionException
429
-     */
430
-    public function doShortcode($content)
431
-    {
432
-        foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) {
433
-            if (strpos($content, $shortcode_tag) !== false) {
434
-                $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);
435
-                $this->initializeShortcode($shortcode_class);
436
-            }
437
-        }
438
-        return do_shortcode($content);
439
-    }
26
+	/**
27
+	 * @type CurrentPage
28
+	 */
29
+	protected $current_page;
30
+
31
+	/**
32
+	 * @var EE_Registry $registry
33
+	 */
34
+	private $registry;
35
+
36
+
37
+	/**
38
+	 * LegacyShortcodesManager constructor.
39
+	 *
40
+	 * @param EE_Registry $registry
41
+	 * @param CurrentPage $current_page
42
+	 */
43
+	public function __construct(EE_Registry $registry, CurrentPage $current_page)
44
+	{
45
+		$this->registry = $registry;
46
+		$this->current_page = $current_page;
47
+	}
48
+
49
+
50
+	/**
51
+	 * @return EE_Registry
52
+	 */
53
+	public function registry()
54
+	{
55
+		return $this->registry;
56
+	}
57
+
58
+
59
+	/**
60
+	 * registerShortcodes
61
+	 *
62
+	 * @return void
63
+	 */
64
+	public function registerShortcodes()
65
+	{
66
+		$this->registry->shortcodes = $this->getShortcodes();
67
+	}
68
+
69
+
70
+	/**
71
+	 * getShortcodes
72
+	 *
73
+	 * @return array
74
+	 */
75
+	public function getShortcodes()
76
+	{
77
+		// previously this method would glob the shortcodes directory
78
+		// then filter that list of shortcodes to register,
79
+		// but now we are going to just supply an empty array.
80
+		// this allows any shortcodes that have not yet been converted to the new system
81
+		// to still get loaded and processed, albeit using the same legacy logic as before
82
+		$shortcodes_to_register = apply_filters(
83
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
84
+			array()
85
+		);
86
+		if (! empty($shortcodes_to_register)) {
87
+			// cycle thru shortcode folders
88
+			foreach ($shortcodes_to_register as $shortcode_path) {
89
+				// add to list of installed shortcode modules
90
+				$this->registerShortcode($shortcode_path);
91
+			}
92
+		}
93
+		// filter list of installed modules
94
+		return apply_filters(
95
+			'FHEE__EE_Config___register_shortcodes__installed_shortcodes',
96
+			! empty($this->registry->shortcodes)
97
+				? $this->registry->shortcodes
98
+				: array()
99
+		);
100
+	}
101
+
102
+
103
+	/**
104
+	 * register_shortcode - makes core aware of this shortcode
105
+	 *
106
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
107
+	 * @return    bool
108
+	 */
109
+	public function registerShortcode($shortcode_path = null)
110
+	{
111
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
112
+		$shortcode_ext = '.shortcode.php';
113
+		// make all separators match
114
+		$shortcode_path = str_replace(array('\\', '/'), '/', $shortcode_path);
115
+		// does the file path INCLUDE the actual file name as part of the path ?
116
+		if (strpos($shortcode_path, $shortcode_ext) !== false) {
117
+			// grab shortcode file name from directory name and break apart at dots
118
+			$shortcode_file = explode('.', basename($shortcode_path));
119
+			// take first segment from file name pieces and remove class prefix if it exists
120
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0
121
+				? substr($shortcode_file[0], 4)
122
+				: $shortcode_file[0];
123
+			// sanitize shortcode directory name
124
+			$shortcode = sanitize_key($shortcode);
125
+			// now we need to rebuild the shortcode path
126
+			$shortcode_path = explode('/', $shortcode_path);
127
+			// remove last segment
128
+			array_pop($shortcode_path);
129
+			// glue it back together
130
+			$shortcode_path = implode('/', $shortcode_path) . '/';
131
+		} else {
132
+			// we need to generate the filename based off of the folder name
133
+			// grab and sanitize shortcode directory name
134
+			$shortcode = sanitize_key(basename($shortcode_path));
135
+			$shortcode_path = rtrim($shortcode_path, '/') . '/';
136
+		}
137
+		// create classname from shortcode directory or file name
138
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
139
+		// add class prefix
140
+		$shortcode_class = 'EES_' . $shortcode;
141
+		// does the shortcode exist ?
142
+		if (! is_readable($shortcode_path . '/' . $shortcode_class . $shortcode_ext)) {
143
+			$msg = sprintf(
144
+				esc_html__(
145
+					'The requested %1$s shortcode file could not be found or is not readable due to file permissions. It should be in %2$s',
146
+					'event_espresso'
147
+				),
148
+				$shortcode_class,
149
+				$shortcode_path . '/' . $shortcode_class . $shortcode_ext
150
+			);
151
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
152
+			return false;
153
+		}
154
+		// load the shortcode class file
155
+		require_once($shortcode_path . $shortcode_class . $shortcode_ext);
156
+		// verify that class exists
157
+		if (! class_exists($shortcode_class)) {
158
+			$msg = sprintf(
159
+				esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'),
160
+				$shortcode_class
161
+			);
162
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
163
+			return false;
164
+		}
165
+		$shortcode = strtoupper($shortcode);
166
+		// add to array of registered shortcodes
167
+		$this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
168
+		return true;
169
+	}
170
+
171
+
172
+	/**
173
+	 *    _initialize_shortcodes
174
+	 *    allow shortcodes to set hooks for the rest of the system
175
+	 *
176
+	 * @return void
177
+	 */
178
+	public function addShortcodes()
179
+	{
180
+		// cycle thru shortcode folders
181
+		foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) {
182
+			// add class prefix
183
+			$shortcode_class = 'EES_' . $shortcode;
184
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
185
+			// which set hooks ?
186
+			if (is_admin()) {
187
+				// fire immediately
188
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
189
+			} else {
190
+				// delay until other systems are online
191
+				add_action(
192
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
193
+					array($shortcode_class, 'set_hooks')
194
+				);
195
+				// convert classname to UPPERCASE and create WP shortcode.
196
+				$shortcode_tag = strtoupper($shortcode);
197
+				// but first check if the shortcode has already
198
+				// been added before assigning 'fallback_shortcode_processor'
199
+				if (! shortcode_exists($shortcode_tag)) {
200
+					// NOTE: this shortcode declaration will get overridden if the shortcode
201
+					// is successfully detected in the post content in initializeShortcode()
202
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
203
+				}
204
+			}
205
+		}
206
+	}
207
+
208
+
209
+	/**
210
+	 * callback for the WP "get_header" hook point
211
+	 * checks posts for EE shortcodes, and initializes them,
212
+	 * then toggles filter switch that loads core default assets
213
+	 *
214
+	 * @param WP_Query $wp_query
215
+	 * @return void
216
+	 * @throws ReflectionException
217
+	 */
218
+	public function initializeShortcodes(WP_Query $wp_query)
219
+	{
220
+		if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) {
221
+			return;
222
+		}
223
+		global $wp;
224
+		/** @var EE_Front_controller $Front_Controller */
225
+		$Front_Controller = LoaderFactory::getLoader()->getShared('EE_Front_Controller');
226
+		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller);
227
+		$this->current_page->parseQueryVars();
228
+		// grab post_name from request
229
+		$current_post = apply_filters(
230
+			'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name',
231
+			$this->current_page->postName()
232
+		);
233
+		$show_on_front = get_option('show_on_front');
234
+		// if it's not set, then check if frontpage is blog
235
+		if (empty($current_post)) {
236
+			// yup.. this is the posts page, prepare to load all shortcode modules
237
+			$current_post = 'posts';
238
+			// unless..
239
+			if ($show_on_front === 'page') {
240
+				// some other page is set as the homepage
241
+				$page_on_front = get_option('page_on_front');
242
+				if ($page_on_front) {
243
+					// k now we need to find the post_name for this page
244
+					global $wpdb;
245
+					$page_on_front = $wpdb->get_var(
246
+						$wpdb->prepare(
247
+							"SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d",
248
+							$page_on_front
249
+						)
250
+					);
251
+					// set the current post slug to what it actually is
252
+					$current_post = $page_on_front ?: $current_post;
253
+				}
254
+			}
255
+		}
256
+		// in case $current_post is hierarchical like: /parent-page/current-page
257
+		$current_post = basename($current_post);
258
+		if (// is current page/post the "blog" page ?
259
+			$current_post === EE_Config::get_page_for_posts()
260
+			// or are we on a category page?
261
+			|| (
262
+				is_array(term_exists($current_post, 'category'))
263
+				|| array_key_exists('category_name', $wp->query_vars)
264
+			)
265
+		) {
266
+			// initialize all legacy shortcodes
267
+			$load_assets = $this->parseContentForShortcodes('', true);
268
+		} else {
269
+			global $wpdb;
270
+			$post_content = $wpdb->get_var(
271
+				$wpdb->prepare(
272
+					"SELECT post_content from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s",
273
+					$current_post
274
+				)
275
+			);
276
+			$load_assets = $this->parseContentForShortcodes($post_content);
277
+		}
278
+		if ($load_assets) {
279
+			$this->current_page->setEspressoPage(true);
280
+			add_filter('FHEE_load_css', '__return_true');
281
+			add_filter('FHEE_load_js', '__return_true');
282
+		}
283
+		do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller);
284
+	}
285
+
286
+
287
+	/**
288
+	 * checks supplied content against list of legacy shortcodes,
289
+	 * then initializes any found shortcodes, and returns true.
290
+	 * returns false if no shortcodes found.
291
+	 *
292
+	 * @param string $content
293
+	 * @param bool   $load_all if true, then ALL active legacy shortcodes will be initialized
294
+	 * @return bool
295
+	 * @throws ReflectionException
296
+	 */
297
+	public function parseContentForShortcodes($content = '', $load_all = false)
298
+	{
299
+		$has_shortcode = false;
300
+		foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) {
301
+			if ($load_all || has_shortcode($content, $shortcode_class)) {
302
+				// load up the shortcode
303
+				$this->initializeShortcode($shortcode_class);
304
+				$has_shortcode = true;
305
+			}
306
+		}
307
+		return $has_shortcode;
308
+	}
309
+
310
+
311
+	/**
312
+	 * given a shortcode name, will instantiate the shortcode and call it's run() method
313
+	 *
314
+	 * @param string $shortcode_class
315
+	 * @param WP     $wp
316
+	 * @throws ReflectionException
317
+	 */
318
+	public function initializeShortcode($shortcode_class = '', WP $wp = null)
319
+	{
320
+		// don't do anything if shortcode is already initialized
321
+		if (empty($this->registry->shortcodes->{$shortcode_class})
322
+			|| ! is_string($this->registry->shortcodes->{$shortcode_class})
323
+		) {
324
+			return;
325
+		}
326
+		// let's pause to reflect on this...
327
+		$sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class));
328
+		// ensure that class is actually a shortcode
329
+		if (defined('WP_DEBUG')
330
+			&& WP_DEBUG === true
331
+			&& ! $sc_reflector->isSubclassOf('EES_Shortcode')
332
+		) {
333
+			EE_Error::add_error(
334
+				sprintf(
335
+					esc_html__(
336
+						'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.',
337
+						'event_espresso'
338
+					),
339
+					$shortcode_class
340
+				),
341
+				__FILE__,
342
+				__FUNCTION__,
343
+				__LINE__
344
+			);
345
+			add_filter('FHEE_run_EE_the_content', '__return_true');
346
+			return;
347
+		}
348
+		global $wp;
349
+		// and pass the request object to the run method
350
+		$this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance();
351
+		// fire the shortcode class's run method, so that it can activate resources
352
+		$this->registry->shortcodes->{$shortcode_class}->run($wp);
353
+	}
354
+
355
+
356
+	/**
357
+	 * get classname, remove EES_prefix, and convert to UPPERCASE
358
+	 *
359
+	 * @param string $class_name
360
+	 * @return string
361
+	 */
362
+	public static function generateShortcodeTagFromClassName($class_name)
363
+	{
364
+		return strtoupper(str_replace('EES_', '', $class_name));
365
+	}
366
+
367
+
368
+	/**
369
+	 * add EES_prefix and Capitalize words
370
+	 *
371
+	 * @param string $tag
372
+	 * @return string
373
+	 */
374
+	public static function generateShortcodeClassNameFromTag($tag)
375
+	{
376
+		// order of operation runs from inside to out
377
+		// 5) maybe add prefix
378
+		return LegacyShortcodesManager::addShortcodeClassPrefix(
379
+			// 4) find spaces, replace with underscores
380
+			str_replace(
381
+				' ',
382
+				'_',
383
+				// 3) capitalize first letter of each word
384
+				ucwords(
385
+					// 2) also change to lowercase so ucwords() will work
386
+					strtolower(
387
+						// 1) find underscores, replace with spaces so ucwords() will work
388
+						str_replace(
389
+							'_',
390
+							' ',
391
+							$tag
392
+						)
393
+					)
394
+				)
395
+			)
396
+		);
397
+	}
398
+
399
+
400
+	/**
401
+	 * maybe add EES_prefix
402
+	 *
403
+	 * @param string $class_name
404
+	 * @return string
405
+	 */
406
+	public static function addShortcodeClassPrefix($class_name)
407
+	{
408
+		return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name;
409
+	}
410
+
411
+
412
+	/**
413
+	 * @return array
414
+	 */
415
+	public function getEspressoShortcodeTags()
416
+	{
417
+		static $shortcode_tags = array();
418
+		if (empty($shortcode_tags)) {
419
+			$shortcode_tags = array_keys((array) $this->registry->shortcodes);
420
+		}
421
+		return $shortcode_tags;
422
+	}
423
+
424
+
425
+	/**
426
+	 * @param string $content
427
+	 * @return string
428
+	 * @throws ReflectionException
429
+	 */
430
+	public function doShortcode($content)
431
+	{
432
+		foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) {
433
+			if (strpos($content, $shortcode_tag) !== false) {
434
+				$shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag);
435
+				$this->initializeShortcode($shortcode_class);
436
+			}
437
+		}
438
+		return do_shortcode($content);
439
+	}
440 440
 }
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodesManager.php 2 patches
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -29,210 +29,210 @@
 block discarded – undo
29 29
  */
30 30
 class ShortcodesManager
31 31
 {
32
-    /**
33
-     * @type CurrentPage
34
-     */
35
-    protected $current_page;
36
-
37
-    /**
38
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
-     */
40
-    private $legacy_shortcodes_manager;
41
-
42
-    /**
43
-     * @var ShortcodeInterface[] $shortcodes
44
-     */
45
-    private $shortcodes;
46
-
47
-
48
-    /**
49
-     * ShortcodesManager constructor
50
-     *
51
-     * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
-     * @param CurrentPage             $current_page
53
-     */
54
-    public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
-    {
56
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
-        $this->current_page              = $current_page;
58
-        // assemble a list of installed and active shortcodes
59
-        add_action(
60
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
-            [$this, 'registerShortcodes'],
62
-            999
63
-        );
64
-        //  call add_shortcode() for all installed shortcodes
65
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
-        // check content for shortcodes the old way
67
-        add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
-        // check content for shortcodes the NEW more efficient way
69
-        add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
-    }
71
-
72
-
73
-    /**
74
-     * @return CollectionInterface|ShortcodeInterface[]
75
-     * @throws InvalidIdentifierException
76
-     * @throws InvalidInterfaceException
77
-     * @throws InvalidFilePathException
78
-     * @throws InvalidEntityException
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidClassException
81
-     */
82
-    public function getShortcodes()
83
-    {
84
-        if (! $this->shortcodes instanceof CollectionInterface) {
85
-            $this->shortcodes = $this->loadShortcodesCollection();
86
-        }
87
-        return $this->shortcodes;
88
-    }
89
-
90
-
91
-    /**
92
-     * @return CollectionInterface|ShortcodeInterface[]
93
-     * @throws InvalidIdentifierException
94
-     * @throws InvalidInterfaceException
95
-     * @throws InvalidFilePathException
96
-     * @throws InvalidEntityException
97
-     * @throws InvalidDataTypeException
98
-     * @throws InvalidClassException
99
-     */
100
-    protected function loadShortcodesCollection()
101
-    {
102
-        $loader = new CollectionLoader(
103
-            new CollectionDetails(
104
-            // collection name
105
-                'shortcodes',
106
-                // collection interface
107
-                'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
109
-                ['EventEspresso\core\domain\entities\shortcodes'],
110
-                // filepaths to classes to add
111
-                [],
112
-                // file mask to use if parsing folder for files to add
113
-                '',
114
-                // what to use as identifier for collection entities
115
-                // using CLASS NAME prevents duplicates (works like a singleton)
116
-                CollectionDetails::ID_CLASS_NAME
117
-            )
118
-        );
119
-        return $loader->getCollection();
120
-    }
121
-
122
-
123
-    /**
124
-     * @return void
125
-     * @throws DomainException
126
-     * @throws InvalidInterfaceException
127
-     * @throws InvalidIdentifierException
128
-     * @throws InvalidFilePathException
129
-     * @throws InvalidEntityException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidClassException
132
-     * @throws Exception
133
-     */
134
-    public function registerShortcodes()
135
-    {
136
-        try {
137
-            $this->shortcodes = apply_filters(
138
-                'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
-                $this->getShortcodes()
140
-            );
141
-            if (! $this->shortcodes instanceof CollectionInterface) {
142
-                throw new InvalidEntityException(
143
-                    $this->shortcodes,
144
-                    'CollectionInterface',
145
-                    sprintf(
146
-                        esc_html__(
147
-                            'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
-                            'event_espresso'
149
-                        ),
150
-                        is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
-                    )
152
-                );
153
-            }
154
-            $this->legacy_shortcodes_manager->registerShortcodes();
155
-        } catch (Exception $exception) {
156
-            new ExceptionStackTraceDisplay($exception);
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * @return void
163
-     * @throws Exception
164
-     */
165
-    public function addShortcodes()
166
-    {
167
-        try {
168
-            // cycle thru shortcode folders
169
-            foreach ($this->shortcodes as $shortcode) {
170
-                if ($shortcode instanceof EnqueueAssetsInterface) {
171
-                    add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
-                    add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
-                }
174
-                // add_shortcode() if it has not already been added
175
-                if (! shortcode_exists($shortcode->getTag())) {
176
-                    add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
-                }
178
-            }
179
-            $this->legacy_shortcodes_manager->addShortcodes();
180
-        } catch (Exception $exception) {
181
-            new ExceptionStackTraceDisplay($exception);
182
-        }
183
-    }
184
-
185
-
186
-    /**
187
-     * callback for the "template_redirect" hook point
188
-     * checks posts for EE shortcodes, and initializes them,
189
-     * then toggles filter switch that loads core default assets
190
-     *
191
-     * @return void
192
-     */
193
-    public function templateRedirect()
194
-    {
195
-        global $wp_query;
196
-        if (empty($wp_query->posts)) {
197
-            return;
198
-        }
199
-        $load_assets = false;
200
-        // array of posts displayed in current request
201
-        $posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
-        foreach ($posts as $post) {
203
-            // now check post content and excerpt for EE shortcodes
204
-            $load_assets = $this->parseContentForShortcodes($post->post_content)
205
-                ? true
206
-                : $load_assets;
207
-        }
208
-        if ($load_assets) {
209
-            $this->current_page->setEspressoPage(true);
210
-            add_filter('FHEE_load_css', '__return_true');
211
-            add_filter('FHEE_load_js', '__return_true');
212
-        }
213
-    }
214
-
215
-
216
-    /**
217
-     * checks supplied content against list of shortcodes,
218
-     * then initializes any found shortcodes, and returns true.
219
-     * returns false if no shortcodes found.
220
-     *
221
-     * @param string $content
222
-     * @return bool
223
-     */
224
-    public function parseContentForShortcodes($content)
225
-    {
226
-        $has_shortcode = false;
227
-        if (empty($this->shortcodes)) {
228
-            return $has_shortcode;
229
-        }
230
-        foreach ($this->shortcodes as $shortcode) {
231
-            if (has_shortcode($content, $shortcode->getTag())) {
232
-                $shortcode->initializeShortcode();
233
-                $has_shortcode = true;
234
-            }
235
-        }
236
-        return $has_shortcode;
237
-    }
32
+	/**
33
+	 * @type CurrentPage
34
+	 */
35
+	protected $current_page;
36
+
37
+	/**
38
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
+	 */
40
+	private $legacy_shortcodes_manager;
41
+
42
+	/**
43
+	 * @var ShortcodeInterface[] $shortcodes
44
+	 */
45
+	private $shortcodes;
46
+
47
+
48
+	/**
49
+	 * ShortcodesManager constructor
50
+	 *
51
+	 * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
+	 * @param CurrentPage             $current_page
53
+	 */
54
+	public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
+	{
56
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
+		$this->current_page              = $current_page;
58
+		// assemble a list of installed and active shortcodes
59
+		add_action(
60
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
+			[$this, 'registerShortcodes'],
62
+			999
63
+		);
64
+		//  call add_shortcode() for all installed shortcodes
65
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
+		// check content for shortcodes the old way
67
+		add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
+		// check content for shortcodes the NEW more efficient way
69
+		add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return CollectionInterface|ShortcodeInterface[]
75
+	 * @throws InvalidIdentifierException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws InvalidFilePathException
78
+	 * @throws InvalidEntityException
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidClassException
81
+	 */
82
+	public function getShortcodes()
83
+	{
84
+		if (! $this->shortcodes instanceof CollectionInterface) {
85
+			$this->shortcodes = $this->loadShortcodesCollection();
86
+		}
87
+		return $this->shortcodes;
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return CollectionInterface|ShortcodeInterface[]
93
+	 * @throws InvalidIdentifierException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws InvalidFilePathException
96
+	 * @throws InvalidEntityException
97
+	 * @throws InvalidDataTypeException
98
+	 * @throws InvalidClassException
99
+	 */
100
+	protected function loadShortcodesCollection()
101
+	{
102
+		$loader = new CollectionLoader(
103
+			new CollectionDetails(
104
+			// collection name
105
+				'shortcodes',
106
+				// collection interface
107
+				'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
109
+				['EventEspresso\core\domain\entities\shortcodes'],
110
+				// filepaths to classes to add
111
+				[],
112
+				// file mask to use if parsing folder for files to add
113
+				'',
114
+				// what to use as identifier for collection entities
115
+				// using CLASS NAME prevents duplicates (works like a singleton)
116
+				CollectionDetails::ID_CLASS_NAME
117
+			)
118
+		);
119
+		return $loader->getCollection();
120
+	}
121
+
122
+
123
+	/**
124
+	 * @return void
125
+	 * @throws DomainException
126
+	 * @throws InvalidInterfaceException
127
+	 * @throws InvalidIdentifierException
128
+	 * @throws InvalidFilePathException
129
+	 * @throws InvalidEntityException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidClassException
132
+	 * @throws Exception
133
+	 */
134
+	public function registerShortcodes()
135
+	{
136
+		try {
137
+			$this->shortcodes = apply_filters(
138
+				'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
+				$this->getShortcodes()
140
+			);
141
+			if (! $this->shortcodes instanceof CollectionInterface) {
142
+				throw new InvalidEntityException(
143
+					$this->shortcodes,
144
+					'CollectionInterface',
145
+					sprintf(
146
+						esc_html__(
147
+							'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
+							'event_espresso'
149
+						),
150
+						is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
+					)
152
+				);
153
+			}
154
+			$this->legacy_shortcodes_manager->registerShortcodes();
155
+		} catch (Exception $exception) {
156
+			new ExceptionStackTraceDisplay($exception);
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return void
163
+	 * @throws Exception
164
+	 */
165
+	public function addShortcodes()
166
+	{
167
+		try {
168
+			// cycle thru shortcode folders
169
+			foreach ($this->shortcodes as $shortcode) {
170
+				if ($shortcode instanceof EnqueueAssetsInterface) {
171
+					add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
+					add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
+				}
174
+				// add_shortcode() if it has not already been added
175
+				if (! shortcode_exists($shortcode->getTag())) {
176
+					add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
+				}
178
+			}
179
+			$this->legacy_shortcodes_manager->addShortcodes();
180
+		} catch (Exception $exception) {
181
+			new ExceptionStackTraceDisplay($exception);
182
+		}
183
+	}
184
+
185
+
186
+	/**
187
+	 * callback for the "template_redirect" hook point
188
+	 * checks posts for EE shortcodes, and initializes them,
189
+	 * then toggles filter switch that loads core default assets
190
+	 *
191
+	 * @return void
192
+	 */
193
+	public function templateRedirect()
194
+	{
195
+		global $wp_query;
196
+		if (empty($wp_query->posts)) {
197
+			return;
198
+		}
199
+		$load_assets = false;
200
+		// array of posts displayed in current request
201
+		$posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
+		foreach ($posts as $post) {
203
+			// now check post content and excerpt for EE shortcodes
204
+			$load_assets = $this->parseContentForShortcodes($post->post_content)
205
+				? true
206
+				: $load_assets;
207
+		}
208
+		if ($load_assets) {
209
+			$this->current_page->setEspressoPage(true);
210
+			add_filter('FHEE_load_css', '__return_true');
211
+			add_filter('FHEE_load_js', '__return_true');
212
+		}
213
+	}
214
+
215
+
216
+	/**
217
+	 * checks supplied content against list of shortcodes,
218
+	 * then initializes any found shortcodes, and returns true.
219
+	 * returns false if no shortcodes found.
220
+	 *
221
+	 * @param string $content
222
+	 * @return bool
223
+	 */
224
+	public function parseContentForShortcodes($content)
225
+	{
226
+		$has_shortcode = false;
227
+		if (empty($this->shortcodes)) {
228
+			return $has_shortcode;
229
+		}
230
+		foreach ($this->shortcodes as $shortcode) {
231
+			if (has_shortcode($content, $shortcode->getTag())) {
232
+				$shortcode->initializeShortcode();
233
+				$has_shortcode = true;
234
+			}
235
+		}
236
+		return $has_shortcode;
237
+	}
238 238
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function getShortcodes()
83 83
     {
84
-        if (! $this->shortcodes instanceof CollectionInterface) {
84
+        if ( ! $this->shortcodes instanceof CollectionInterface) {
85 85
             $this->shortcodes = $this->loadShortcodesCollection();
86 86
         }
87 87
         return $this->shortcodes;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139 139
                 $this->getShortcodes()
140 140
             );
141
-            if (! $this->shortcodes instanceof CollectionInterface) {
141
+            if ( ! $this->shortcodes instanceof CollectionInterface) {
142 142
                 throw new InvalidEntityException(
143 143
                     $this->shortcodes,
144 144
                     'CollectionInterface',
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                     add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173 173
                 }
174 174
                 // add_shortcode() if it has not already been added
175
-                if (! shortcode_exists($shortcode->getTag())) {
175
+                if ( ! shortcode_exists($shortcode->getTag())) {
176 176
                     add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177 177
                 }
178 178
             }
Please login to merge, or discard this patch.
core/EE_Registry.core.php 1 patch
Indentation   +1676 added lines, -1676 removed lines patch added patch discarded remove patch
@@ -23,1680 +23,1680 @@
 block discarded – undo
23 23
 class EE_Registry implements ResettableInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Registry $_instance
28
-     */
29
-    private static $_instance;
30
-
31
-    /**
32
-     * @var EE_Dependency_Map $_dependency_map
33
-     */
34
-    protected $_dependency_map;
35
-
36
-    /**
37
-     * @var Mirror
38
-     */
39
-    private $mirror;
40
-
41
-    /**
42
-     * @var ClassInterfaceCache $class_cache
43
-     */
44
-    private $class_cache;
45
-
46
-    /**
47
-     * @var array $_class_abbreviations
48
-     */
49
-    protected $_class_abbreviations = array();
50
-
51
-    /**
52
-     * @var CommandBusInterface $BUS
53
-     */
54
-    public $BUS;
55
-
56
-    /**
57
-     * @var EE_Cart $CART
58
-     */
59
-    public $CART;
60
-
61
-    /**
62
-     * @var EE_Config $CFG
63
-     */
64
-    public $CFG;
65
-
66
-    /**
67
-     * @var EE_Network_Config $NET_CFG
68
-     */
69
-    public $NET_CFG;
70
-
71
-    /**
72
-     * StdClass object for storing library classes in
73
-     *
74
-     * @var RegistryContainer $LIB
75
-     */
76
-    public $LIB;
77
-
78
-    /**
79
-     * @var EE_Request_Handler $REQ
80
-     * @deprecated $VID:$
81
-     */
82
-    public $REQ;
83
-
84
-    /**
85
-     * @var EE_Session $SSN
86
-     */
87
-    public $SSN;
88
-
89
-    /**
90
-     * @since 4.5.0
91
-     * @var EE_Capabilities $CAP
92
-     */
93
-    public $CAP;
94
-
95
-    /**
96
-     * @since 4.9.0
97
-     * @var EE_Message_Resource_Manager $MRM
98
-     */
99
-    public $MRM;
100
-
101
-    /**
102
-     * @var Registry $AssetsRegistry
103
-     */
104
-    public $AssetsRegistry;
105
-
106
-    /**
107
-     * StdClass object for holding addons which have registered themselves to work with EE core
108
-     *
109
-     * @var EE_Addon[] $addons
110
-     */
111
-    public $addons;
112
-
113
-    /**
114
-     * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
115
-     *
116
-     * @var EEM_Base[] $models
117
-     */
118
-    public $models = array();
119
-
120
-    /**
121
-     * @var EED_Module[] $modules
122
-     */
123
-    public $modules;
124
-
125
-    /**
126
-     * @var EES_Shortcode[] $shortcodes
127
-     */
128
-    public $shortcodes;
129
-
130
-    /**
131
-     * @var WP_Widget[] $widgets
132
-     */
133
-    public $widgets;
134
-
135
-    /**
136
-     * this is an array of all implemented model names (i.e. not the parent abstract models, or models
137
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
138
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
139
-     * classnames (eg "EEM_Event")
140
-     *
141
-     * @var array $non_abstract_db_models
142
-     */
143
-    public $non_abstract_db_models = array();
144
-
145
-    /**
146
-     * internationalization for JS strings
147
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
148
-     *    in js file:  var translatedString = eei18n.string_key;
149
-     *
150
-     * @var array $i18n_js_strings
151
-     */
152
-    public static $i18n_js_strings = array();
153
-
154
-    /**
155
-     * $main_file - path to espresso.php
156
-     *
157
-     * @var array $main_file
158
-     */
159
-    public $main_file;
160
-
161
-    /**
162
-     * array of ReflectionClass objects where the key is the class name
163
-     *
164
-     * @deprecated 4.9.62.p
165
-     * @var ReflectionClass[] $_reflectors
166
-     */
167
-    public $_reflectors;
168
-
169
-    /**
170
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
171
-     *
172
-     * @var boolean $_cache_on
173
-     */
174
-    protected $_cache_on = true;
175
-
176
-    /**
177
-     * @var ObjectIdentifier
178
-     */
179
-    private $object_identifier;
180
-
181
-
182
-    /**
183
-     * @singleton method used to instantiate class object
184
-     * @param EE_Dependency_Map|null   $dependency_map
185
-     * @param Mirror|null              $mirror
186
-     * @param ClassInterfaceCache|null $class_cache
187
-     * @param ObjectIdentifier|null    $object_identifier
188
-     * @return EE_Registry instance
189
-     */
190
-    public static function instance(
191
-        EE_Dependency_Map $dependency_map = null,
192
-        Mirror $mirror = null,
193
-        ClassInterfaceCache $class_cache = null,
194
-        ObjectIdentifier $object_identifier = null
195
-    ) {
196
-        // check if class object is instantiated
197
-        if (! self::$_instance instanceof EE_Registry
198
-            && $dependency_map instanceof EE_Dependency_Map
199
-            && $mirror instanceof Mirror
200
-            && $class_cache instanceof ClassInterfaceCache
201
-            && $object_identifier instanceof ObjectIdentifier
202
-        ) {
203
-            self::$_instance = new self(
204
-                $dependency_map,
205
-                $mirror,
206
-                $class_cache,
207
-                $object_identifier
208
-            );
209
-        }
210
-        return self::$_instance;
211
-    }
212
-
213
-
214
-    /**
215
-     * protected constructor to prevent direct creation
216
-     *
217
-     * @Constructor
218
-     * @param  EE_Dependency_Map  $dependency_map
219
-     * @param Mirror              $mirror
220
-     * @param ClassInterfaceCache $class_cache
221
-     * @param ObjectIdentifier    $object_identifier
222
-     */
223
-    protected function __construct(
224
-        EE_Dependency_Map $dependency_map,
225
-        Mirror $mirror,
226
-        ClassInterfaceCache $class_cache,
227
-        ObjectIdentifier $object_identifier
228
-    ) {
229
-        $this->_dependency_map = $dependency_map;
230
-        $this->mirror = $mirror;
231
-        $this->class_cache = $class_cache;
232
-        $this->object_identifier = $object_identifier;
233
-        // $registry_container = new RegistryContainer();
234
-        $this->LIB = new RegistryContainer();
235
-        $this->addons = new RegistryContainer();
236
-        $this->modules = new RegistryContainer();
237
-        $this->shortcodes = new RegistryContainer();
238
-        $this->widgets = new RegistryContainer();
239
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
240
-    }
241
-
242
-
243
-    /**
244
-     * initialize
245
-     *
246
-     * @throws OutOfBoundsException
247
-     * @throws InvalidArgumentException
248
-     * @throws InvalidInterfaceException
249
-     * @throws InvalidDataTypeException
250
-     * @throws EE_Error
251
-     * @throws ReflectionException
252
-     */
253
-    public function initialize()
254
-    {
255
-        $this->_class_abbreviations = apply_filters(
256
-            'FHEE__EE_Registry____construct___class_abbreviations',
257
-            array(
258
-                'EE_Config'                                       => 'CFG',
259
-                'EE_Session'                                      => 'SSN',
260
-                'EE_Capabilities'                                 => 'CAP',
261
-                'EE_Cart'                                         => 'CART',
262
-                'EE_Network_Config'                               => 'NET_CFG',
263
-                'EE_Request_Handler'                              => 'REQ',
264
-                'EE_Message_Resource_Manager'                     => 'MRM',
265
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
266
-                'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
267
-            )
268
-        );
269
-        $this->load_core('Base', array(), true);
270
-        // add our request and response objects to the cache
271
-        $request_loader = $this->_dependency_map->class_loader(
272
-            'EventEspresso\core\services\request\Request'
273
-        );
274
-        $this->_set_cached_class(
275
-            $request_loader(),
276
-            'EventEspresso\core\services\request\Request'
277
-        );
278
-        $response_loader = $this->_dependency_map->class_loader(
279
-            'EventEspresso\core\services\request\Response'
280
-        );
281
-        $this->_set_cached_class(
282
-            $response_loader(),
283
-            'EventEspresso\core\services\request\Response'
284
-        );
285
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
286
-    }
287
-
288
-
289
-    /**
290
-     * @return void
291
-     */
292
-    public function init()
293
-    {
294
-        // Get current page protocol
295
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
296
-        // Output admin-ajax.php URL with same protocol as current page
297
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
298
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
299
-    }
300
-
301
-
302
-    /**
303
-     * localize_i18n_js_strings
304
-     *
305
-     * @return string
306
-     */
307
-    public static function localize_i18n_js_strings()
308
-    {
309
-        $i18n_js_strings = (array) self::$i18n_js_strings;
310
-        foreach ($i18n_js_strings as $key => $value) {
311
-            if (is_scalar($value)) {
312
-                $i18n_js_strings[ $key ] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
313
-            }
314
-        }
315
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
316
-    }
317
-
318
-
319
-    /**
320
-     * @param mixed string | EED_Module $module
321
-     * @throws OutOfBoundsException
322
-     * @throws InvalidArgumentException
323
-     * @throws InvalidInterfaceException
324
-     * @throws InvalidDataTypeException
325
-     * @throws EE_Error
326
-     * @throws ReflectionException
327
-     */
328
-    public function add_module($module)
329
-    {
330
-        if ($module instanceof EED_Module) {
331
-            $module_class = get_class($module);
332
-            $this->modules->{$module_class} = $module;
333
-        } else {
334
-            if (! class_exists('EE_Module_Request_Router', false)) {
335
-                $this->load_core('Module_Request_Router');
336
-            }
337
-            EE_Module_Request_Router::module_factory($module);
338
-        }
339
-    }
340
-
341
-
342
-    /**
343
-     * @param string $module_name
344
-     * @return mixed EED_Module | NULL
345
-     */
346
-    public function get_module($module_name = '')
347
-    {
348
-        return isset($this->modules->{$module_name})
349
-            ? $this->modules->{$module_name}
350
-            : null;
351
-    }
352
-
353
-
354
-    /**
355
-     * loads core classes - must be singletons
356
-     *
357
-     * @param string $class_name - simple class name ie: session
358
-     * @param mixed  $arguments
359
-     * @param bool   $load_only
360
-     * @return mixed
361
-     * @throws InvalidInterfaceException
362
-     * @throws InvalidDataTypeException
363
-     * @throws EE_Error
364
-     * @throws ReflectionException
365
-     * @throws InvalidArgumentException
366
-     */
367
-    public function load_core($class_name, $arguments = array(), $load_only = false)
368
-    {
369
-        $core_paths = apply_filters(
370
-            'FHEE__EE_Registry__load_core__core_paths',
371
-            array(
372
-                EE_CORE,
373
-                EE_ADMIN,
374
-                EE_CPTS,
375
-                EE_CORE . 'data_migration_scripts/',
376
-                EE_CORE . 'capabilities/',
377
-                EE_CORE . 'request_stack/',
378
-                EE_CORE . 'middleware/',
379
-            )
380
-        );
381
-        // retrieve instantiated class
382
-        return $this->_load(
383
-            $core_paths,
384
-            'EE_',
385
-            $class_name,
386
-            'core',
387
-            $arguments,
388
-            false,
389
-            true,
390
-            $load_only
391
-        );
392
-    }
393
-
394
-
395
-    /**
396
-     * loads service classes
397
-     *
398
-     * @param string $class_name - simple class name ie: session
399
-     * @param mixed  $arguments
400
-     * @param bool   $load_only
401
-     * @return mixed
402
-     * @throws InvalidInterfaceException
403
-     * @throws InvalidDataTypeException
404
-     * @throws EE_Error
405
-     * @throws ReflectionException
406
-     * @throws InvalidArgumentException
407
-     */
408
-    public function load_service($class_name, $arguments = array(), $load_only = false)
409
-    {
410
-        $service_paths = apply_filters(
411
-            'FHEE__EE_Registry__load_service__service_paths',
412
-            array(
413
-                EE_CORE . 'services/',
414
-            )
415
-        );
416
-        // retrieve instantiated class
417
-        return $this->_load(
418
-            $service_paths,
419
-            'EE_',
420
-            $class_name,
421
-            'class',
422
-            $arguments,
423
-            false,
424
-            true,
425
-            $load_only
426
-        );
427
-    }
428
-
429
-
430
-    /**
431
-     * loads data_migration_scripts
432
-     *
433
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
434
-     * @param mixed  $arguments
435
-     * @return EE_Data_Migration_Script_Base|mixed
436
-     * @throws InvalidInterfaceException
437
-     * @throws InvalidDataTypeException
438
-     * @throws EE_Error
439
-     * @throws ReflectionException
440
-     * @throws InvalidArgumentException
441
-     */
442
-    public function load_dms($class_name, $arguments = array())
443
-    {
444
-        // retrieve instantiated class
445
-        return $this->_load(
446
-            EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
447
-            'EE_DMS_',
448
-            $class_name,
449
-            'dms',
450
-            $arguments,
451
-            false,
452
-            false
453
-        );
454
-    }
455
-
456
-
457
-    /**
458
-     * loads object creating classes - must be singletons
459
-     *
460
-     * @param string $class_name - simple class name ie: attendee
461
-     * @param mixed  $arguments  - an array of arguments to pass to the class
462
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
463
-     *                           instantiate
464
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
465
-     *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
466
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
467
-     *                           (default)
468
-     * @return EE_Base_Class | bool
469
-     * @throws InvalidInterfaceException
470
-     * @throws InvalidDataTypeException
471
-     * @throws EE_Error
472
-     * @throws ReflectionException
473
-     * @throws InvalidArgumentException
474
-     */
475
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
476
-    {
477
-        $paths = apply_filters(
478
-            'FHEE__EE_Registry__load_class__paths',
479
-            array(
480
-                EE_CORE,
481
-                EE_CLASSES,
482
-                EE_BUSINESS,
483
-            )
484
-        );
485
-        // retrieve instantiated class
486
-        return $this->_load(
487
-            $paths,
488
-            'EE_',
489
-            $class_name,
490
-            'class',
491
-            $arguments,
492
-            $from_db,
493
-            $cache,
494
-            $load_only
495
-        );
496
-    }
497
-
498
-
499
-    /**
500
-     * loads helper classes - must be singletons
501
-     *
502
-     * @param string $class_name - simple class name ie: price
503
-     * @param mixed  $arguments
504
-     * @param bool   $load_only
505
-     * @return EEH_Base | bool
506
-     * @throws InvalidInterfaceException
507
-     * @throws InvalidDataTypeException
508
-     * @throws EE_Error
509
-     * @throws ReflectionException
510
-     * @throws InvalidArgumentException
511
-     */
512
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
513
-    {
514
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
515
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
516
-        // retrieve instantiated class
517
-        return $this->_load(
518
-            $helper_paths,
519
-            'EEH_',
520
-            $class_name,
521
-            'helper',
522
-            $arguments,
523
-            false,
524
-            true,
525
-            $load_only
526
-        );
527
-    }
528
-
529
-
530
-    /**
531
-     * loads core classes - must be singletons
532
-     *
533
-     * @param string $class_name - simple class name ie: session
534
-     * @param mixed  $arguments
535
-     * @param bool   $load_only
536
-     * @param bool   $cache      whether to cache the object or not.
537
-     * @return mixed
538
-     * @throws InvalidInterfaceException
539
-     * @throws InvalidDataTypeException
540
-     * @throws EE_Error
541
-     * @throws ReflectionException
542
-     * @throws InvalidArgumentException
543
-     */
544
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
545
-    {
546
-        $paths = array(
547
-            EE_LIBRARIES,
548
-            EE_LIBRARIES . 'messages/',
549
-            EE_LIBRARIES . 'shortcodes/',
550
-            EE_LIBRARIES . 'qtips/',
551
-            EE_LIBRARIES . 'payment_methods/',
552
-        );
553
-        // retrieve instantiated class
554
-        return $this->_load(
555
-            $paths,
556
-            'EE_',
557
-            $class_name,
558
-            'lib',
559
-            $arguments,
560
-            false,
561
-            $cache,
562
-            $load_only
563
-        );
564
-    }
565
-
566
-
567
-    /**
568
-     * loads model classes - must be singletons
569
-     *
570
-     * @param string $class_name - simple class name ie: price
571
-     * @param mixed  $arguments
572
-     * @param bool   $load_only
573
-     * @return EEM_Base | bool
574
-     * @throws InvalidInterfaceException
575
-     * @throws InvalidDataTypeException
576
-     * @throws EE_Error
577
-     * @throws ReflectionException
578
-     * @throws InvalidArgumentException
579
-     */
580
-    public function load_model($class_name, $arguments = array(), $load_only = false)
581
-    {
582
-        $paths = apply_filters(
583
-            'FHEE__EE_Registry__load_model__paths',
584
-            array(
585
-                EE_MODELS,
586
-                EE_CORE,
587
-            )
588
-        );
589
-        // retrieve instantiated class
590
-        return $this->_load(
591
-            $paths,
592
-            'EEM_',
593
-            $class_name,
594
-            'model',
595
-            $arguments,
596
-            false,
597
-            true,
598
-            $load_only
599
-        );
600
-    }
601
-
602
-
603
-    /**
604
-     * loads model classes - must be singletons
605
-     *
606
-     * @param string $class_name - simple class name ie: price
607
-     * @param mixed  $arguments
608
-     * @param bool   $load_only
609
-     * @return mixed | bool
610
-     * @throws InvalidInterfaceException
611
-     * @throws InvalidDataTypeException
612
-     * @throws EE_Error
613
-     * @throws ReflectionException
614
-     * @throws InvalidArgumentException
615
-     */
616
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
617
-    {
618
-        $paths = array(
619
-            EE_MODELS . 'fields/',
620
-            EE_MODELS . 'helpers/',
621
-            EE_MODELS . 'relations/',
622
-            EE_MODELS . 'strategies/',
623
-        );
624
-        // retrieve instantiated class
625
-        return $this->_load(
626
-            $paths,
627
-            'EE_',
628
-            $class_name,
629
-            '',
630
-            $arguments,
631
-            false,
632
-            true,
633
-            $load_only
634
-        );
635
-    }
636
-
637
-
638
-    /**
639
-     * Determines if $model_name is the name of an actual EE model.
640
-     *
641
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
642
-     * @return boolean
643
-     */
644
-    public function is_model_name($model_name)
645
-    {
646
-        return isset($this->models[ $model_name ]);
647
-    }
648
-
649
-
650
-    /**
651
-     * generic class loader
652
-     *
653
-     * @param string $path_to_file - directory path to file location, not including filename
654
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
655
-     * @param string $type         - file type - core? class? helper? model?
656
-     * @param mixed  $arguments
657
-     * @param bool   $load_only
658
-     * @return mixed
659
-     * @throws InvalidInterfaceException
660
-     * @throws InvalidDataTypeException
661
-     * @throws EE_Error
662
-     * @throws ReflectionException
663
-     * @throws InvalidArgumentException
664
-     */
665
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
666
-    {
667
-        // retrieve instantiated class
668
-        return $this->_load(
669
-            $path_to_file,
670
-            '',
671
-            $file_name,
672
-            $type,
673
-            $arguments,
674
-            false,
675
-            true,
676
-            $load_only
677
-        );
678
-    }
679
-
680
-
681
-    /**
682
-     * @param string $path_to_file - directory path to file location, not including filename
683
-     * @param string $class_name   - full class name  ie:  My_Class
684
-     * @param string $type         - file type - core? class? helper? model?
685
-     * @param mixed  $arguments
686
-     * @param bool   $load_only
687
-     * @return bool|EE_Addon|object
688
-     * @throws InvalidInterfaceException
689
-     * @throws InvalidDataTypeException
690
-     * @throws EE_Error
691
-     * @throws ReflectionException
692
-     * @throws InvalidArgumentException
693
-     */
694
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
695
-    {
696
-        // retrieve instantiated class
697
-        return $this->_load(
698
-            $path_to_file,
699
-            'addon',
700
-            $class_name,
701
-            $type,
702
-            $arguments,
703
-            false,
704
-            true,
705
-            $load_only
706
-        );
707
-    }
708
-
709
-
710
-    /**
711
-     * instantiates, caches, and automatically resolves dependencies
712
-     * for classes that use a Fully Qualified Class Name.
713
-     * if the class is not capable of being loaded using PSR-4 autoloading,
714
-     * then you need to use one of the existing load_*() methods
715
-     * which can resolve the classname and filepath from the passed arguments
716
-     *
717
-     * @param bool|string $class_name   Fully Qualified Class Name
718
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
719
-     * @param bool        $cache        whether to cache the instantiated object for reuse
720
-     * @param bool        $from_db      some classes are instantiated from the db
721
-     *                                  and thus call a different method to instantiate
722
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
723
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
724
-     * @return bool|null|mixed          null = failure to load or instantiate class object.
725
-     *                                  object = class loaded and instantiated successfully.
726
-     *                                  bool = fail or success when $load_only is true
727
-     * @throws InvalidInterfaceException
728
-     * @throws InvalidDataTypeException
729
-     * @throws EE_Error
730
-     * @throws ReflectionException
731
-     * @throws InvalidArgumentException
732
-     */
733
-    public function create(
734
-        $class_name = false,
735
-        $arguments = array(),
736
-        $cache = false,
737
-        $from_db = false,
738
-        $load_only = false,
739
-        $addon = false
740
-    ) {
741
-        $class_name = ltrim($class_name, '\\');
742
-        $class_name = $this->class_cache->getFqnForAlias($class_name);
743
-        $class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
744
-        // if a non-FQCN was passed, then
745
-        // verifyClassExists() might return an object
746
-        // or it could return null if the class just could not be found anywhere
747
-        if ($class_exists instanceof $class_name || $class_exists === null) {
748
-            // either way, return the results
749
-            return $class_exists;
750
-        }
751
-        $class_name = $class_exists;
752
-        // if we're only loading the class and it already exists, then let's just return true immediately
753
-        if ($load_only) {
754
-            return true;
755
-        }
756
-        $addon = $addon ? 'addon' : '';
757
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
758
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
759
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
760
-        if ($this->_cache_on && $cache && ! $load_only) {
761
-            // return object if it's already cached
762
-            $cached_class = $this->_get_cached_class($class_name, $addon, $arguments);
763
-            if ($cached_class !== null) {
764
-                return $cached_class;
765
-            }
766
-        }// obtain the loader method from the dependency map
767
-        $loader = $this->_dependency_map->class_loader($class_name);// instantiate the requested object
768
-        if ($loader instanceof Closure) {
769
-            $class_obj = $loader($arguments);
770
-        } else {
771
-            if ($loader && method_exists($this, $loader)) {
772
-                $class_obj = $this->{$loader}($class_name, $arguments);
773
-            } else {
774
-                $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
775
-            }
776
-        }
777
-        if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
778
-            // save it for later... kinda like gum  { : $
779
-            $this->_set_cached_class(
780
-                $class_obj,
781
-                $class_name,
782
-                $addon,
783
-                $from_db,
784
-                $arguments
785
-            );
786
-        }
787
-        $this->_cache_on = true;
788
-        return $class_obj;
789
-    }
790
-
791
-
792
-    /**
793
-     * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
794
-     *
795
-     * @param string|object $class_name
796
-     * @param array         $arguments
797
-     * @param int           $attempt
798
-     * @return mixed
799
-     */
800
-    private function loadOrVerifyClassExists($class_name, array $arguments, $attempt = 1)
801
-    {
802
-        if (is_object($class_name) || class_exists($class_name)) {
803
-            return $class_name;
804
-        }
805
-        switch ($attempt) {
806
-            case 1:
807
-                // if it's a FQCN then maybe the class is registered with a preceding \
808
-                $class_name = strpos($class_name, '\\') !== false
809
-                    ? '\\' . ltrim($class_name, '\\')
810
-                    : $class_name;
811
-                break;
812
-            case 2:
813
-                //
814
-                $loader = $this->_dependency_map->class_loader($class_name);
815
-                if ($loader && method_exists($this, $loader)) {
816
-                    return $this->{$loader}($class_name, $arguments);
817
-                }
818
-                break;
819
-            case 3:
820
-            default:
821
-                return null;
822
-        }
823
-        $attempt++;
824
-        return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
825
-    }
826
-
827
-
828
-    /**
829
-     * instantiates, caches, and injects dependencies for classes
830
-     *
831
-     * @param array       $file_paths   an array of paths to folders to look in
832
-     * @param string      $class_prefix EE  or EEM or... ???
833
-     * @param bool|string $class_name   $class name
834
-     * @param string      $type         file type - core? class? helper? model?
835
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
836
-     * @param bool        $from_db      some classes are instantiated from the db
837
-     *                                  and thus call a different method to instantiate
838
-     * @param bool        $cache        whether to cache the instantiated object for reuse
839
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
840
-     * @return bool|null|object null = failure to load or instantiate class object.
841
-     *                                  object = class loaded and instantiated successfully.
842
-     *                                  bool = fail or success when $load_only is true
843
-     * @throws EE_Error
844
-     * @throws ReflectionException
845
-     * @throws InvalidInterfaceException
846
-     * @throws InvalidDataTypeException
847
-     * @throws InvalidArgumentException
848
-     */
849
-    protected function _load(
850
-        $file_paths = array(),
851
-        $class_prefix = 'EE_',
852
-        $class_name = false,
853
-        $type = 'class',
854
-        $arguments = array(),
855
-        $from_db = false,
856
-        $cache = true,
857
-        $load_only = false
858
-    ) {
859
-        $class_name = ltrim($class_name, '\\');
860
-        // strip php file extension
861
-        $class_name = str_replace('.php', '', trim($class_name));
862
-        // does the class have a prefix ?
863
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
864
-            // make sure $class_prefix is uppercase
865
-            $class_prefix = strtoupper(trim($class_prefix));
866
-            // add class prefix ONCE!!!
867
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
868
-        }
869
-        $class_name = $this->class_cache->getFqnForAlias($class_name);
870
-        $class_exists = class_exists($class_name, false);
871
-        // if we're only loading the class and it already exists, then let's just return true immediately
872
-        if ($load_only && $class_exists) {
873
-            return true;
874
-        }
875
-        $arguments = is_array($arguments) ? $arguments : array($arguments);
876
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
877
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
878
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
879
-        if ($this->_cache_on && $cache && ! $load_only) {
880
-            // return object if it's already cached
881
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix, $arguments);
882
-            if ($cached_class !== null) {
883
-                return $cached_class;
884
-            }
885
-        }
886
-        // if the class doesn't already exist.. then we need to try and find the file and load it
887
-        if (! $class_exists) {
888
-            // get full path to file
889
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
890
-            // load the file
891
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
892
-            // if we are only loading a file but NOT instantiating an object
893
-            // then return boolean for whether class was loaded or not
894
-            if ($load_only) {
895
-                return $loaded;
896
-            }
897
-            // if an object was expected but loading failed, then return nothing
898
-            if (! $loaded) {
899
-                return null;
900
-            }
901
-        }
902
-        // instantiate the requested object
903
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
904
-        if ($this->_cache_on && $cache) {
905
-            // save it for later... kinda like gum  { : $
906
-            $this->_set_cached_class(
907
-                $class_obj,
908
-                $class_name,
909
-                $class_prefix,
910
-                $from_db,
911
-                $arguments
912
-            );
913
-        }
914
-        $this->_cache_on = true;
915
-        return $class_obj;
916
-    }
917
-
918
-
919
-    /**
920
-     * @param string $class_name
921
-     * @param string $default have to specify something, but not anything that will conflict
922
-     * @return mixed|string
923
-     */
924
-    protected function get_class_abbreviation($class_name, $default = 'FANCY_BATMAN_PANTS')
925
-    {
926
-        return isset($this->_class_abbreviations[ $class_name ])
927
-            ? $this->_class_abbreviations[ $class_name ]
928
-            : $default;
929
-    }
930
-
931
-
932
-    /**
933
-     * attempts to find a cached version of the requested class
934
-     * by looking in the following places:
935
-     *        $this->{$class_abbreviation}            ie:    $this->CART
936
-     *        $this->{$class_name}                        ie:    $this->Some_Class
937
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
938
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
939
-     *
940
-     * @param string $class_name
941
-     * @param string $class_prefix
942
-     * @param array  $arguments
943
-     * @return mixed
944
-     */
945
-    protected function _get_cached_class(
946
-        $class_name,
947
-        $class_prefix = '',
948
-        $arguments = array()
949
-    ) {
950
-        if ($class_name === 'EE_Registry') {
951
-            return $this;
952
-        }
953
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
954
-        // check if class has already been loaded, and return it if it has been
955
-        if (isset($this->{$class_abbreviation})) {
956
-            return $this->{$class_abbreviation};
957
-        }
958
-        $class_name = str_replace('\\', '_', $class_name);
959
-        if (isset($this->{$class_name})) {
960
-            return $this->{$class_name};
961
-        }
962
-        if ($class_prefix === 'addon' && isset($this->addons->{$class_name})) {
963
-            return $this->addons->{$class_name};
964
-        }
965
-        $object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
966
-        if (isset($this->LIB->{$object_identifier})) {
967
-            return $this->LIB->{$object_identifier};
968
-        }
969
-        foreach ($this->LIB as $key => $object) {
970
-            if (// request does not contain new arguments and therefore no args identifier
971
-                ! $this->object_identifier->hasArguments($object_identifier)
972
-                // but previously cached class with args was found
973
-                && $this->object_identifier->fqcnMatchesObjectIdentifier($class_name, $key)
974
-            ) {
975
-                return $object;
976
-            }
977
-        }
978
-        return null;
979
-    }
980
-
981
-
982
-    /**
983
-     * removes a cached version of the requested class
984
-     *
985
-     * @param string  $class_name
986
-     * @param boolean $addon
987
-     * @param array   $arguments
988
-     * @return boolean
989
-     */
990
-    public function clear_cached_class(
991
-        $class_name,
992
-        $addon = false,
993
-        $arguments = array()
994
-    ) {
995
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
996
-        // check if class has already been loaded, and return it if it has been
997
-        if (isset($this->{$class_abbreviation})) {
998
-            $this->{$class_abbreviation} = null;
999
-            return true;
1000
-        }
1001
-        $class_name = str_replace('\\', '_', $class_name);
1002
-        if (isset($this->{$class_name})) {
1003
-            $this->{$class_name} = null;
1004
-            return true;
1005
-        }
1006
-        if ($addon && isset($this->addons->{$class_name})) {
1007
-            unset($this->addons->{$class_name});
1008
-            return true;
1009
-        }
1010
-        $class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1011
-        if (isset($this->LIB->{$class_name})) {
1012
-            unset($this->LIB->{$class_name});
1013
-            return true;
1014
-        }
1015
-        return false;
1016
-    }
1017
-
1018
-
1019
-    /**
1020
-     * _set_cached_class
1021
-     * attempts to cache the instantiated class locally
1022
-     * in one of the following places, in the following order:
1023
-     *        $this->{class_abbreviation}   ie:    $this->CART
1024
-     *        $this->{$class_name}          ie:    $this->Some_Class
1025
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1026
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1027
-     *
1028
-     * @param object $class_obj
1029
-     * @param string $class_name
1030
-     * @param string $class_prefix
1031
-     * @param bool   $from_db
1032
-     * @param array  $arguments
1033
-     * @return void
1034
-     */
1035
-    protected function _set_cached_class(
1036
-        $class_obj,
1037
-        $class_name,
1038
-        $class_prefix = '',
1039
-        $from_db = false,
1040
-        $arguments = array()
1041
-    ) {
1042
-        if ($class_name === 'EE_Registry' || empty($class_obj)) {
1043
-            return;
1044
-        }
1045
-        // return newly instantiated class
1046
-        $class_abbreviation = $this->get_class_abbreviation($class_name, '');
1047
-        if ($class_abbreviation) {
1048
-            $this->{$class_abbreviation} = $class_obj;
1049
-            return;
1050
-        }
1051
-        $class_name = str_replace('\\', '_', $class_name);
1052
-        if (property_exists($this, $class_name)) {
1053
-            $this->{$class_name} = $class_obj;
1054
-            return;
1055
-        }
1056
-        if ($class_prefix === 'addon') {
1057
-            $this->addons->{$class_name} = $class_obj;
1058
-            return;
1059
-        }
1060
-        if (! $from_db) {
1061
-            $class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1062
-            $this->LIB->{$class_name} = $class_obj;
1063
-        }
1064
-    }
1065
-
1066
-
1067
-    /**
1068
-     * attempts to find a full valid filepath for the requested class.
1069
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
1070
-     * then returns that path if the target file has been found and is readable
1071
-     *
1072
-     * @param string $class_name
1073
-     * @param string $type
1074
-     * @param array  $file_paths
1075
-     * @return string | bool
1076
-     */
1077
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
1078
-    {
1079
-        // make sure $file_paths is an array
1080
-        $file_paths = is_array($file_paths)
1081
-            ? $file_paths
1082
-            : array($file_paths);
1083
-        // cycle thru paths
1084
-        foreach ($file_paths as $key => $file_path) {
1085
-            // convert all separators to proper /, if no filepath, then use EE_CLASSES
1086
-            $file_path = $file_path
1087
-                ? str_replace(array('/', '\\'), '/', $file_path)
1088
-                : EE_CLASSES;
1089
-            // prep file type
1090
-            $type = ! empty($type)
1091
-                ? trim($type, '.') . '.'
1092
-                : '';
1093
-            // build full file path
1094
-            $file_paths[ $key ] = rtrim($file_path, '/') . '/' . $class_name . '.' . $type . 'php';
1095
-            // does the file exist and can be read ?
1096
-            if (is_readable($file_paths[ $key ])) {
1097
-                return $file_paths[ $key ];
1098
-            }
1099
-        }
1100
-        return false;
1101
-    }
1102
-
1103
-
1104
-    /**
1105
-     * basically just performs a require_once()
1106
-     * but with some error handling
1107
-     *
1108
-     * @param  string $path
1109
-     * @param  string $class_name
1110
-     * @param  string $type
1111
-     * @param  array  $file_paths
1112
-     * @return bool
1113
-     * @throws EE_Error
1114
-     * @throws ReflectionException
1115
-     */
1116
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
1117
-    {
1118
-        $this->resolve_legacy_class_parent($class_name);
1119
-        // don't give up! you gotta...
1120
-        try {
1121
-            // does the file exist and can it be read ?
1122
-            if (! $path) {
1123
-                // just in case the file has already been autoloaded,
1124
-                // but discrepancies in the naming schema are preventing it from
1125
-                // being loaded via one of the EE_Registry::load_*() methods,
1126
-                // then let's try one last hail mary before throwing an exception
1127
-                // and call class_exists() again, but with autoloading turned ON
1128
-                if (class_exists($class_name)) {
1129
-                    return true;
1130
-                }
1131
-                // so sorry, can't find the file
1132
-                throw new EE_Error(
1133
-                    sprintf(
1134
-                        esc_html__(
1135
-                            'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
1136
-                            'event_espresso'
1137
-                        ),
1138
-                        trim($type, '.'),
1139
-                        $class_name,
1140
-                        '<br />' . implode(',<br />', $file_paths)
1141
-                    )
1142
-                );
1143
-            }
1144
-            // get the file
1145
-            require_once($path);
1146
-            // if the class isn't already declared somewhere
1147
-            if (class_exists($class_name, false) === false) {
1148
-                // so sorry, not a class
1149
-                throw new EE_Error(
1150
-                    sprintf(
1151
-                        esc_html__(
1152
-                            'The %s file %s does not appear to contain the %s Class.',
1153
-                            'event_espresso'
1154
-                        ),
1155
-                        $type,
1156
-                        $path,
1157
-                        $class_name
1158
-                    )
1159
-                );
1160
-            }
1161
-        } catch (EE_Error $e) {
1162
-            $e->get_error();
1163
-            return false;
1164
-        }
1165
-        return true;
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     * Some of our legacy classes that extended a parent class would simply use a require() statement
1171
-     * before their class declaration in order to ensure that the parent class was loaded.
1172
-     * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1173
-     * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1174
-     *
1175
-     * @param string $class_name
1176
-     */
1177
-    protected function resolve_legacy_class_parent($class_name = '')
1178
-    {
1179
-        try {
1180
-            $legacy_parent_class_map = array(
1181
-                'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php',
1182
-            );
1183
-            if (isset($legacy_parent_class_map[ $class_name ])) {
1184
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[ $class_name ];
1185
-            }
1186
-        } catch (Exception $exception) {
1187
-        }
1188
-    }
1189
-
1190
-
1191
-    /**
1192
-     * _create_object
1193
-     * Attempts to instantiate the requested class via any of the
1194
-     * commonly used instantiation methods employed throughout EE.
1195
-     * The priority for instantiation is as follows:
1196
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1197
-     *        - model objects via their 'new_instance_from_db' method
1198
-     *        - model objects via their 'new_instance' method
1199
-     *        - "singleton" classes" via their 'instance' method
1200
-     *    - standard instantiable classes via their __constructor
1201
-     * Prior to instantiation, if the classname exists in the dependency_map,
1202
-     * then the constructor for the requested class will be examined to determine
1203
-     * if any dependencies exist, and if they can be injected.
1204
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1205
-     *
1206
-     * @param string $class_name
1207
-     * @param array  $arguments
1208
-     * @param string $type
1209
-     * @param bool   $from_db
1210
-     * @return null|object|bool
1211
-     * @throws InvalidArgumentException
1212
-     * @throws InvalidInterfaceException
1213
-     * @throws EE_Error
1214
-     * @throws ReflectionException
1215
-     * @throws InvalidDataTypeException
1216
-     */
1217
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
1218
-    {
1219
-        // create reflection
1220
-        $reflector = $this->mirror->getReflectionClass($class_name);
1221
-        // make sure arguments are an array
1222
-        $arguments = is_array($arguments)
1223
-            ? $arguments
1224
-            : array($arguments);
1225
-        // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1226
-        // else wrap it in an additional array so that it doesn't get split into multiple parameters
1227
-        $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1228
-            ? $arguments
1229
-            : array($arguments);
1230
-        // attempt to inject dependencies ?
1231
-        if ($this->_dependency_map->has($class_name)) {
1232
-            $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1233
-        }
1234
-        // instantiate the class if possible
1235
-        if ($reflector->isAbstract()) {
1236
-            // nothing to instantiate, loading file was enough
1237
-            // does not throw an exception so $instantiation_mode is unused
1238
-            // $instantiation_mode = "1) no constructor abstract class";
1239
-            return true;
1240
-        }
1241
-        if (empty($arguments)
1242
-            && $this->mirror->getConstructorFromReflection($reflector) === null
1243
-            && $reflector->isInstantiable()
1244
-        ) {
1245
-            // no constructor = static methods only... nothing to instantiate, loading file was enough
1246
-            // $instantiation_mode = "2) no constructor but instantiable";
1247
-            return $reflector->newInstance();
1248
-        }
1249
-        if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1250
-            // $instantiation_mode = "3) new_instance_from_db()";
1251
-            return call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1252
-        }
1253
-        if (method_exists($class_name, 'new_instance')) {
1254
-            // $instantiation_mode = "4) new_instance()";
1255
-            return call_user_func_array(array($class_name, 'new_instance'), $arguments);
1256
-        }
1257
-        if (method_exists($class_name, 'instance')) {
1258
-            // $instantiation_mode = "5) instance()";
1259
-            return call_user_func_array(array($class_name, 'instance'), $arguments);
1260
-        }
1261
-        if ($reflector->isInstantiable()) {
1262
-            // $instantiation_mode = "6) constructor";
1263
-            return $reflector->newInstanceArgs($arguments);
1264
-        }
1265
-        // heh ? something's not right !
1266
-        throw new EE_Error(
1267
-            sprintf(
1268
-                __('The %s file %s could not be instantiated.', 'event_espresso'),
1269
-                $type,
1270
-                $class_name
1271
-            )
1272
-        );
1273
-    }
1274
-
1275
-
1276
-    /**
1277
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1278
-     * @param array $array
1279
-     * @return bool
1280
-     */
1281
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
1282
-    {
1283
-        return ! empty($array)
1284
-            ? array_keys($array) === range(0, count($array) - 1)
1285
-            : true;
1286
-    }
1287
-
1288
-
1289
-    /**
1290
-     * _resolve_dependencies
1291
-     * examines the constructor for the requested class to determine
1292
-     * if any dependencies exist, and if they can be injected.
1293
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1294
-     * PLZ NOTE: this is achieved by type hinting the constructor params
1295
-     * For example:
1296
-     *        if attempting to load a class "Foo" with the following constructor:
1297
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
1298
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
1299
-     *        but only IF they are NOT already present in the incoming arguments array,
1300
-     *        and the correct classes can be loaded
1301
-     *
1302
-     * @param ReflectionClass $reflector
1303
-     * @param string          $class_name
1304
-     * @param array           $arguments
1305
-     * @return array
1306
-     * @throws InvalidArgumentException
1307
-     * @throws InvalidDataTypeException
1308
-     * @throws InvalidInterfaceException
1309
-     * @throws ReflectionException
1310
-     */
1311
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, array $arguments = array())
1312
-    {
1313
-        // let's examine the constructor
1314
-        $constructor = $this->mirror->getConstructorFromReflection($reflector);
1315
-        // whu? huh? nothing?
1316
-        if (! $constructor) {
1317
-            return $arguments;
1318
-        }
1319
-        // get constructor parameters
1320
-        $params = $this->mirror->getParametersFromReflection($reflector);
1321
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1322
-        $argument_keys = array_keys($arguments);
1323
-        // now loop thru all of the constructors expected parameters
1324
-        foreach ($params as $index => $param) {
1325
-            try {
1326
-                // is this a dependency for a specific class ?
1327
-                $param_class = $this->mirror->getParameterClassName($param, $class_name, $index);
1328
-            } catch (ReflectionException $exception) {
1329
-                // uh-oh... most likely a legacy class that has not been autoloaded
1330
-                // let's try to derive the classname from what we have now
1331
-                // and hope that the property var name is close to the class name
1332
-                $param_class = $param->getName();
1333
-                $param_class = str_replace('_', ' ', $param_class);
1334
-                $param_class = ucwords($param_class);
1335
-                $param_class = str_replace(' ', '_', $param_class);
1336
-            }
1337
-            // BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1338
-            $param_class = $this->class_cache->isAlias($param_class, $class_name)
1339
-                ? $this->class_cache->getFqnForAlias($param_class, $class_name)
1340
-                : $param_class;
1341
-            if (// param is not even a class
1342
-                $param_class === null
1343
-                // and something already exists in the incoming arguments for this param
1344
-                && array_key_exists($index, $argument_keys)
1345
-                && array_key_exists($argument_keys[ $index ], $arguments)
1346
-            ) {
1347
-                // so let's skip this argument and move on to the next
1348
-                continue;
1349
-            }
1350
-            if (// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1351
-                $param_class !== null
1352
-                && isset($argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ])
1353
-                && $arguments[ $argument_keys[ $index ] ] instanceof $param_class
1354
-            ) {
1355
-                // skip this argument and move on to the next
1356
-                continue;
1357
-            }
1358
-            if (// parameter is type hinted as a class, and should be injected
1359
-                $param_class !== null
1360
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1361
-            ) {
1362
-                $arguments = $this->_resolve_dependency(
1363
-                    $class_name,
1364
-                    $param_class,
1365
-                    $arguments,
1366
-                    $index
1367
-                );
1368
-            }
1369
-            if (empty($arguments[ $index ])) {
1370
-                $arguments[ $index ] = $this->mirror->getParameterDefaultValue(
1371
-                    $param,
1372
-                    $class_name,
1373
-                    $index
1374
-                );
1375
-            }
1376
-        }
1377
-        return $arguments;
1378
-    }
1379
-
1380
-
1381
-    /**
1382
-     * @param string $class_name
1383
-     * @param string $param_class
1384
-     * @param array  $arguments
1385
-     * @param mixed  $index
1386
-     * @return array
1387
-     * @throws InvalidArgumentException
1388
-     * @throws InvalidInterfaceException
1389
-     * @throws InvalidDataTypeException
1390
-     */
1391
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1392
-    {
1393
-        $dependency = null;
1394
-        // should dependency be loaded from cache ?
1395
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1396
-            $class_name,
1397
-            $param_class
1398
-        );
1399
-        $cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1400
-        // we might have a dependency...
1401
-        // let's MAYBE try and find it in our cache if that's what's been requested
1402
-        $cached_class = $cache_on
1403
-            ? $this->_get_cached_class($param_class)
1404
-            : null;
1405
-        // and grab it if it exists
1406
-        if ($cached_class instanceof $param_class) {
1407
-            $dependency = $cached_class;
1408
-        } elseif ($param_class !== $class_name) {
1409
-            // obtain the loader method from the dependency map
1410
-            $loader = $this->_dependency_map->class_loader($param_class);
1411
-            // is loader a custom closure ?
1412
-            if ($loader instanceof Closure) {
1413
-                $dependency = $loader($arguments);
1414
-            } else {
1415
-                // set the cache on property for the recursive loading call
1416
-                $this->_cache_on = $cache_on;
1417
-                // if not, then let's try and load it via the registry
1418
-                if ($loader && method_exists($this, $loader)) {
1419
-                    $dependency = $this->{$loader}($param_class);
1420
-                } else {
1421
-                    $dependency = LoaderFactory::getLoader()->load(
1422
-                        $param_class,
1423
-                        array(),
1424
-                        $cache_on
1425
-                    );
1426
-                }
1427
-            }
1428
-        }
1429
-        // did we successfully find the correct dependency ?
1430
-        if ($dependency instanceof $param_class) {
1431
-            // then let's inject it into the incoming array of arguments at the correct location
1432
-            $arguments[ $index ] = $dependency;
1433
-        }
1434
-        return $arguments;
1435
-    }
1436
-
1437
-
1438
-    /**
1439
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1440
-     *
1441
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1442
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1443
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1444
-     * @param array  $arguments
1445
-     * @return object
1446
-     */
1447
-    public static function factory($classname, $arguments = array())
1448
-    {
1449
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1450
-        if ($loader instanceof Closure) {
1451
-            return $loader($arguments);
1452
-        }
1453
-        if (method_exists(self::instance(), $loader)) {
1454
-            return self::instance()->{$loader}($classname, $arguments);
1455
-        }
1456
-        return null;
1457
-    }
1458
-
1459
-
1460
-    /**
1461
-     * Gets the addon by its class name
1462
-     *
1463
-     * @param string $class_name
1464
-     * @return EE_Addon
1465
-     */
1466
-    public function getAddon($class_name)
1467
-    {
1468
-        $class_name = str_replace('\\', '_', $class_name);
1469
-        if (isset($this->addons->{$class_name})) {
1470
-            return $this->addons->{$class_name};
1471
-        } else {
1472
-            return null;
1473
-        }
1474
-    }
1475
-
1476
-
1477
-    /**
1478
-     * removes the addon from the internal cache
1479
-     *
1480
-     * @param string $class_name
1481
-     * @return void
1482
-     */
1483
-    public function removeAddon($class_name)
1484
-    {
1485
-        $class_name = str_replace('\\', '_', $class_name);
1486
-        unset($this->addons->{$class_name});
1487
-    }
1488
-
1489
-
1490
-    /**
1491
-     * Gets the addon by its name/slug (not classname. For that, just
1492
-     * use the get_addon() method above
1493
-     *
1494
-     * @param string $name
1495
-     * @return EE_Addon
1496
-     */
1497
-    public function get_addon_by_name($name)
1498
-    {
1499
-        foreach ($this->addons as $addon) {
1500
-            if ($addon->name() === $name) {
1501
-                return $addon;
1502
-            }
1503
-        }
1504
-        return null;
1505
-    }
1506
-
1507
-
1508
-    /**
1509
-     * Gets an array of all the registered addons, where the keys are their names.
1510
-     * (ie, what each returns for their name() function)
1511
-     * They're already available on EE_Registry::instance()->addons as properties,
1512
-     * where each property's name is the addon's classname,
1513
-     * So if you just want to get the addon by classname,
1514
-     * OR use the get_addon() method above.
1515
-     * PLEASE  NOTE:
1516
-     * addons with Fully Qualified Class Names
1517
-     * have had the namespace separators converted to underscores,
1518
-     * so a classname like Fully\Qualified\ClassName
1519
-     * would have been converted to Fully_Qualified_ClassName
1520
-     *
1521
-     * @return EE_Addon[] where the KEYS are the addon's name()
1522
-     */
1523
-    public function get_addons_by_name()
1524
-    {
1525
-        $addons = array();
1526
-        foreach ($this->addons as $addon) {
1527
-            $addons[ $addon->name() ] = $addon;
1528
-        }
1529
-        return $addons;
1530
-    }
1531
-
1532
-
1533
-    /**
1534
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1535
-     * a stale copy of it around
1536
-     *
1537
-     * @param string $model_name
1538
-     * @return \EEM_Base
1539
-     * @throws \EE_Error
1540
-     */
1541
-    public function reset_model($model_name)
1542
-    {
1543
-        $model_class_name = strpos($model_name, 'EEM_') !== 0
1544
-            ? "EEM_{$model_name}"
1545
-            : $model_name;
1546
-        if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1547
-            return null;
1548
-        }
1549
-        // get that model reset it and make sure we nuke the old reference to it
1550
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name
1551
-            && is_callable(
1552
-                array($model_class_name, 'reset')
1553
-            )) {
1554
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1555
-        } else {
1556
-            throw new EE_Error(
1557
-                sprintf(
1558
-                    esc_html__('Model %s does not have a method "reset"', 'event_espresso'),
1559
-                    $model_name
1560
-                )
1561
-            );
1562
-        }
1563
-        return $this->LIB->{$model_class_name};
1564
-    }
1565
-
1566
-
1567
-    /**
1568
-     * Resets the registry.
1569
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when
1570
-     * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1571
-     * - $_dependency_map
1572
-     * - $_class_abbreviations
1573
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1574
-     * - $REQ:  Still on the same request so no need to change.
1575
-     * - $CAP: There is no site specific state in the EE_Capability class.
1576
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1577
-     * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1578
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1579
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1580
-     *             switch or on the restore.
1581
-     * - $modules
1582
-     * - $shortcodes
1583
-     * - $widgets
1584
-     *
1585
-     * @param boolean $hard             [deprecated]
1586
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1587
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1588
-     *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1589
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1590
-     *                                  client
1591
-     *                                  code instead can just change the model context to a different blog id if
1592
-     *                                  necessary
1593
-     * @return EE_Registry
1594
-     * @throws InvalidInterfaceException
1595
-     * @throws InvalidDataTypeException
1596
-     * @throws EE_Error
1597
-     * @throws ReflectionException
1598
-     * @throws InvalidArgumentException
1599
-     */
1600
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1601
-    {
1602
-        $instance = self::instance();
1603
-        $instance->_cache_on = true;
1604
-        // reset some "special" classes
1605
-        EEH_Activation::reset();
1606
-        $hard = apply_filters('FHEE__EE_Registry__reset__hard', $hard);
1607
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1608
-        $instance->CART = null;
1609
-        $instance->MRM = null;
1610
-        $instance->AssetsRegistry = LoaderFactory::getLoader()->getShared(
1611
-            'EventEspresso\core\services\assets\Registry'
1612
-        );
1613
-        // messages reset
1614
-        EED_Messages::reset();
1615
-        // handle of objects cached on LIB
1616
-        foreach (array('LIB', 'modules') as $cache) {
1617
-            foreach ($instance->{$cache} as $class_name => $class) {
1618
-                if (self::_reset_and_unset_object($class, $reset_models)) {
1619
-                    unset($instance->{$cache}->{$class_name});
1620
-                }
1621
-            }
1622
-        }
1623
-        return $instance;
1624
-    }
1625
-
1626
-
1627
-    /**
1628
-     * if passed object implements ResettableInterface, then call it's reset() method
1629
-     * if passed object implements InterminableInterface, then return false,
1630
-     * to indicate that it should NOT be cleared from the Registry cache
1631
-     *
1632
-     * @param      $object
1633
-     * @param bool $reset_models
1634
-     * @return bool returns true if cached object should be unset
1635
-     */
1636
-    private static function _reset_and_unset_object($object, $reset_models)
1637
-    {
1638
-        if (! is_object($object)) {
1639
-            // don't unset anything that's not an object
1640
-            return false;
1641
-        }
1642
-        if ($object instanceof EED_Module) {
1643
-            $object::reset();
1644
-            // don't unset modules
1645
-            return false;
1646
-        }
1647
-        if ($object instanceof ResettableInterface) {
1648
-            if ($object instanceof EEM_Base) {
1649
-                if ($reset_models) {
1650
-                    $object->reset();
1651
-                    return true;
1652
-                }
1653
-                return false;
1654
-            }
1655
-            $object->reset();
1656
-            return true;
1657
-        }
1658
-        if (! $object instanceof InterminableInterface) {
1659
-            return true;
1660
-        }
1661
-        return false;
1662
-    }
1663
-
1664
-
1665
-    /**
1666
-     * Gets all the custom post type models defined
1667
-     *
1668
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1669
-     */
1670
-    public function cpt_models()
1671
-    {
1672
-        $cpt_models = array();
1673
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1674
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1675
-                $cpt_models[ $short_name ] = $classname;
1676
-            }
1677
-        }
1678
-        return $cpt_models;
1679
-    }
1680
-
1681
-
1682
-    /**
1683
-     * @return \EE_Config
1684
-     */
1685
-    public static function CFG()
1686
-    {
1687
-        return self::instance()->CFG;
1688
-    }
1689
-
1690
-
1691
-    /**
1692
-     * @deprecated 4.9.62.p
1693
-     * @param string $class_name
1694
-     * @return ReflectionClass
1695
-     * @throws ReflectionException
1696
-     * @throws InvalidDataTypeException
1697
-     */
1698
-    public function get_ReflectionClass($class_name)
1699
-    {
1700
-        return $this->mirror->getReflectionClass($class_name);
1701
-    }
26
+	/**
27
+	 * @var EE_Registry $_instance
28
+	 */
29
+	private static $_instance;
30
+
31
+	/**
32
+	 * @var EE_Dependency_Map $_dependency_map
33
+	 */
34
+	protected $_dependency_map;
35
+
36
+	/**
37
+	 * @var Mirror
38
+	 */
39
+	private $mirror;
40
+
41
+	/**
42
+	 * @var ClassInterfaceCache $class_cache
43
+	 */
44
+	private $class_cache;
45
+
46
+	/**
47
+	 * @var array $_class_abbreviations
48
+	 */
49
+	protected $_class_abbreviations = array();
50
+
51
+	/**
52
+	 * @var CommandBusInterface $BUS
53
+	 */
54
+	public $BUS;
55
+
56
+	/**
57
+	 * @var EE_Cart $CART
58
+	 */
59
+	public $CART;
60
+
61
+	/**
62
+	 * @var EE_Config $CFG
63
+	 */
64
+	public $CFG;
65
+
66
+	/**
67
+	 * @var EE_Network_Config $NET_CFG
68
+	 */
69
+	public $NET_CFG;
70
+
71
+	/**
72
+	 * StdClass object for storing library classes in
73
+	 *
74
+	 * @var RegistryContainer $LIB
75
+	 */
76
+	public $LIB;
77
+
78
+	/**
79
+	 * @var EE_Request_Handler $REQ
80
+	 * @deprecated $VID:$
81
+	 */
82
+	public $REQ;
83
+
84
+	/**
85
+	 * @var EE_Session $SSN
86
+	 */
87
+	public $SSN;
88
+
89
+	/**
90
+	 * @since 4.5.0
91
+	 * @var EE_Capabilities $CAP
92
+	 */
93
+	public $CAP;
94
+
95
+	/**
96
+	 * @since 4.9.0
97
+	 * @var EE_Message_Resource_Manager $MRM
98
+	 */
99
+	public $MRM;
100
+
101
+	/**
102
+	 * @var Registry $AssetsRegistry
103
+	 */
104
+	public $AssetsRegistry;
105
+
106
+	/**
107
+	 * StdClass object for holding addons which have registered themselves to work with EE core
108
+	 *
109
+	 * @var EE_Addon[] $addons
110
+	 */
111
+	public $addons;
112
+
113
+	/**
114
+	 * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
115
+	 *
116
+	 * @var EEM_Base[] $models
117
+	 */
118
+	public $models = array();
119
+
120
+	/**
121
+	 * @var EED_Module[] $modules
122
+	 */
123
+	public $modules;
124
+
125
+	/**
126
+	 * @var EES_Shortcode[] $shortcodes
127
+	 */
128
+	public $shortcodes;
129
+
130
+	/**
131
+	 * @var WP_Widget[] $widgets
132
+	 */
133
+	public $widgets;
134
+
135
+	/**
136
+	 * this is an array of all implemented model names (i.e. not the parent abstract models, or models
137
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
138
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
139
+	 * classnames (eg "EEM_Event")
140
+	 *
141
+	 * @var array $non_abstract_db_models
142
+	 */
143
+	public $non_abstract_db_models = array();
144
+
145
+	/**
146
+	 * internationalization for JS strings
147
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
148
+	 *    in js file:  var translatedString = eei18n.string_key;
149
+	 *
150
+	 * @var array $i18n_js_strings
151
+	 */
152
+	public static $i18n_js_strings = array();
153
+
154
+	/**
155
+	 * $main_file - path to espresso.php
156
+	 *
157
+	 * @var array $main_file
158
+	 */
159
+	public $main_file;
160
+
161
+	/**
162
+	 * array of ReflectionClass objects where the key is the class name
163
+	 *
164
+	 * @deprecated 4.9.62.p
165
+	 * @var ReflectionClass[] $_reflectors
166
+	 */
167
+	public $_reflectors;
168
+
169
+	/**
170
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
171
+	 *
172
+	 * @var boolean $_cache_on
173
+	 */
174
+	protected $_cache_on = true;
175
+
176
+	/**
177
+	 * @var ObjectIdentifier
178
+	 */
179
+	private $object_identifier;
180
+
181
+
182
+	/**
183
+	 * @singleton method used to instantiate class object
184
+	 * @param EE_Dependency_Map|null   $dependency_map
185
+	 * @param Mirror|null              $mirror
186
+	 * @param ClassInterfaceCache|null $class_cache
187
+	 * @param ObjectIdentifier|null    $object_identifier
188
+	 * @return EE_Registry instance
189
+	 */
190
+	public static function instance(
191
+		EE_Dependency_Map $dependency_map = null,
192
+		Mirror $mirror = null,
193
+		ClassInterfaceCache $class_cache = null,
194
+		ObjectIdentifier $object_identifier = null
195
+	) {
196
+		// check if class object is instantiated
197
+		if (! self::$_instance instanceof EE_Registry
198
+			&& $dependency_map instanceof EE_Dependency_Map
199
+			&& $mirror instanceof Mirror
200
+			&& $class_cache instanceof ClassInterfaceCache
201
+			&& $object_identifier instanceof ObjectIdentifier
202
+		) {
203
+			self::$_instance = new self(
204
+				$dependency_map,
205
+				$mirror,
206
+				$class_cache,
207
+				$object_identifier
208
+			);
209
+		}
210
+		return self::$_instance;
211
+	}
212
+
213
+
214
+	/**
215
+	 * protected constructor to prevent direct creation
216
+	 *
217
+	 * @Constructor
218
+	 * @param  EE_Dependency_Map  $dependency_map
219
+	 * @param Mirror              $mirror
220
+	 * @param ClassInterfaceCache $class_cache
221
+	 * @param ObjectIdentifier    $object_identifier
222
+	 */
223
+	protected function __construct(
224
+		EE_Dependency_Map $dependency_map,
225
+		Mirror $mirror,
226
+		ClassInterfaceCache $class_cache,
227
+		ObjectIdentifier $object_identifier
228
+	) {
229
+		$this->_dependency_map = $dependency_map;
230
+		$this->mirror = $mirror;
231
+		$this->class_cache = $class_cache;
232
+		$this->object_identifier = $object_identifier;
233
+		// $registry_container = new RegistryContainer();
234
+		$this->LIB = new RegistryContainer();
235
+		$this->addons = new RegistryContainer();
236
+		$this->modules = new RegistryContainer();
237
+		$this->shortcodes = new RegistryContainer();
238
+		$this->widgets = new RegistryContainer();
239
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
240
+	}
241
+
242
+
243
+	/**
244
+	 * initialize
245
+	 *
246
+	 * @throws OutOfBoundsException
247
+	 * @throws InvalidArgumentException
248
+	 * @throws InvalidInterfaceException
249
+	 * @throws InvalidDataTypeException
250
+	 * @throws EE_Error
251
+	 * @throws ReflectionException
252
+	 */
253
+	public function initialize()
254
+	{
255
+		$this->_class_abbreviations = apply_filters(
256
+			'FHEE__EE_Registry____construct___class_abbreviations',
257
+			array(
258
+				'EE_Config'                                       => 'CFG',
259
+				'EE_Session'                                      => 'SSN',
260
+				'EE_Capabilities'                                 => 'CAP',
261
+				'EE_Cart'                                         => 'CART',
262
+				'EE_Network_Config'                               => 'NET_CFG',
263
+				'EE_Request_Handler'                              => 'REQ',
264
+				'EE_Message_Resource_Manager'                     => 'MRM',
265
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
266
+				'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
267
+			)
268
+		);
269
+		$this->load_core('Base', array(), true);
270
+		// add our request and response objects to the cache
271
+		$request_loader = $this->_dependency_map->class_loader(
272
+			'EventEspresso\core\services\request\Request'
273
+		);
274
+		$this->_set_cached_class(
275
+			$request_loader(),
276
+			'EventEspresso\core\services\request\Request'
277
+		);
278
+		$response_loader = $this->_dependency_map->class_loader(
279
+			'EventEspresso\core\services\request\Response'
280
+		);
281
+		$this->_set_cached_class(
282
+			$response_loader(),
283
+			'EventEspresso\core\services\request\Response'
284
+		);
285
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
286
+	}
287
+
288
+
289
+	/**
290
+	 * @return void
291
+	 */
292
+	public function init()
293
+	{
294
+		// Get current page protocol
295
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
296
+		// Output admin-ajax.php URL with same protocol as current page
297
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
298
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
299
+	}
300
+
301
+
302
+	/**
303
+	 * localize_i18n_js_strings
304
+	 *
305
+	 * @return string
306
+	 */
307
+	public static function localize_i18n_js_strings()
308
+	{
309
+		$i18n_js_strings = (array) self::$i18n_js_strings;
310
+		foreach ($i18n_js_strings as $key => $value) {
311
+			if (is_scalar($value)) {
312
+				$i18n_js_strings[ $key ] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
313
+			}
314
+		}
315
+		return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
316
+	}
317
+
318
+
319
+	/**
320
+	 * @param mixed string | EED_Module $module
321
+	 * @throws OutOfBoundsException
322
+	 * @throws InvalidArgumentException
323
+	 * @throws InvalidInterfaceException
324
+	 * @throws InvalidDataTypeException
325
+	 * @throws EE_Error
326
+	 * @throws ReflectionException
327
+	 */
328
+	public function add_module($module)
329
+	{
330
+		if ($module instanceof EED_Module) {
331
+			$module_class = get_class($module);
332
+			$this->modules->{$module_class} = $module;
333
+		} else {
334
+			if (! class_exists('EE_Module_Request_Router', false)) {
335
+				$this->load_core('Module_Request_Router');
336
+			}
337
+			EE_Module_Request_Router::module_factory($module);
338
+		}
339
+	}
340
+
341
+
342
+	/**
343
+	 * @param string $module_name
344
+	 * @return mixed EED_Module | NULL
345
+	 */
346
+	public function get_module($module_name = '')
347
+	{
348
+		return isset($this->modules->{$module_name})
349
+			? $this->modules->{$module_name}
350
+			: null;
351
+	}
352
+
353
+
354
+	/**
355
+	 * loads core classes - must be singletons
356
+	 *
357
+	 * @param string $class_name - simple class name ie: session
358
+	 * @param mixed  $arguments
359
+	 * @param bool   $load_only
360
+	 * @return mixed
361
+	 * @throws InvalidInterfaceException
362
+	 * @throws InvalidDataTypeException
363
+	 * @throws EE_Error
364
+	 * @throws ReflectionException
365
+	 * @throws InvalidArgumentException
366
+	 */
367
+	public function load_core($class_name, $arguments = array(), $load_only = false)
368
+	{
369
+		$core_paths = apply_filters(
370
+			'FHEE__EE_Registry__load_core__core_paths',
371
+			array(
372
+				EE_CORE,
373
+				EE_ADMIN,
374
+				EE_CPTS,
375
+				EE_CORE . 'data_migration_scripts/',
376
+				EE_CORE . 'capabilities/',
377
+				EE_CORE . 'request_stack/',
378
+				EE_CORE . 'middleware/',
379
+			)
380
+		);
381
+		// retrieve instantiated class
382
+		return $this->_load(
383
+			$core_paths,
384
+			'EE_',
385
+			$class_name,
386
+			'core',
387
+			$arguments,
388
+			false,
389
+			true,
390
+			$load_only
391
+		);
392
+	}
393
+
394
+
395
+	/**
396
+	 * loads service classes
397
+	 *
398
+	 * @param string $class_name - simple class name ie: session
399
+	 * @param mixed  $arguments
400
+	 * @param bool   $load_only
401
+	 * @return mixed
402
+	 * @throws InvalidInterfaceException
403
+	 * @throws InvalidDataTypeException
404
+	 * @throws EE_Error
405
+	 * @throws ReflectionException
406
+	 * @throws InvalidArgumentException
407
+	 */
408
+	public function load_service($class_name, $arguments = array(), $load_only = false)
409
+	{
410
+		$service_paths = apply_filters(
411
+			'FHEE__EE_Registry__load_service__service_paths',
412
+			array(
413
+				EE_CORE . 'services/',
414
+			)
415
+		);
416
+		// retrieve instantiated class
417
+		return $this->_load(
418
+			$service_paths,
419
+			'EE_',
420
+			$class_name,
421
+			'class',
422
+			$arguments,
423
+			false,
424
+			true,
425
+			$load_only
426
+		);
427
+	}
428
+
429
+
430
+	/**
431
+	 * loads data_migration_scripts
432
+	 *
433
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
434
+	 * @param mixed  $arguments
435
+	 * @return EE_Data_Migration_Script_Base|mixed
436
+	 * @throws InvalidInterfaceException
437
+	 * @throws InvalidDataTypeException
438
+	 * @throws EE_Error
439
+	 * @throws ReflectionException
440
+	 * @throws InvalidArgumentException
441
+	 */
442
+	public function load_dms($class_name, $arguments = array())
443
+	{
444
+		// retrieve instantiated class
445
+		return $this->_load(
446
+			EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
447
+			'EE_DMS_',
448
+			$class_name,
449
+			'dms',
450
+			$arguments,
451
+			false,
452
+			false
453
+		);
454
+	}
455
+
456
+
457
+	/**
458
+	 * loads object creating classes - must be singletons
459
+	 *
460
+	 * @param string $class_name - simple class name ie: attendee
461
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
462
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
463
+	 *                           instantiate
464
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
465
+	 *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
466
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
467
+	 *                           (default)
468
+	 * @return EE_Base_Class | bool
469
+	 * @throws InvalidInterfaceException
470
+	 * @throws InvalidDataTypeException
471
+	 * @throws EE_Error
472
+	 * @throws ReflectionException
473
+	 * @throws InvalidArgumentException
474
+	 */
475
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
476
+	{
477
+		$paths = apply_filters(
478
+			'FHEE__EE_Registry__load_class__paths',
479
+			array(
480
+				EE_CORE,
481
+				EE_CLASSES,
482
+				EE_BUSINESS,
483
+			)
484
+		);
485
+		// retrieve instantiated class
486
+		return $this->_load(
487
+			$paths,
488
+			'EE_',
489
+			$class_name,
490
+			'class',
491
+			$arguments,
492
+			$from_db,
493
+			$cache,
494
+			$load_only
495
+		);
496
+	}
497
+
498
+
499
+	/**
500
+	 * loads helper classes - must be singletons
501
+	 *
502
+	 * @param string $class_name - simple class name ie: price
503
+	 * @param mixed  $arguments
504
+	 * @param bool   $load_only
505
+	 * @return EEH_Base | bool
506
+	 * @throws InvalidInterfaceException
507
+	 * @throws InvalidDataTypeException
508
+	 * @throws EE_Error
509
+	 * @throws ReflectionException
510
+	 * @throws InvalidArgumentException
511
+	 */
512
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
513
+	{
514
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
515
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
516
+		// retrieve instantiated class
517
+		return $this->_load(
518
+			$helper_paths,
519
+			'EEH_',
520
+			$class_name,
521
+			'helper',
522
+			$arguments,
523
+			false,
524
+			true,
525
+			$load_only
526
+		);
527
+	}
528
+
529
+
530
+	/**
531
+	 * loads core classes - must be singletons
532
+	 *
533
+	 * @param string $class_name - simple class name ie: session
534
+	 * @param mixed  $arguments
535
+	 * @param bool   $load_only
536
+	 * @param bool   $cache      whether to cache the object or not.
537
+	 * @return mixed
538
+	 * @throws InvalidInterfaceException
539
+	 * @throws InvalidDataTypeException
540
+	 * @throws EE_Error
541
+	 * @throws ReflectionException
542
+	 * @throws InvalidArgumentException
543
+	 */
544
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
545
+	{
546
+		$paths = array(
547
+			EE_LIBRARIES,
548
+			EE_LIBRARIES . 'messages/',
549
+			EE_LIBRARIES . 'shortcodes/',
550
+			EE_LIBRARIES . 'qtips/',
551
+			EE_LIBRARIES . 'payment_methods/',
552
+		);
553
+		// retrieve instantiated class
554
+		return $this->_load(
555
+			$paths,
556
+			'EE_',
557
+			$class_name,
558
+			'lib',
559
+			$arguments,
560
+			false,
561
+			$cache,
562
+			$load_only
563
+		);
564
+	}
565
+
566
+
567
+	/**
568
+	 * loads model classes - must be singletons
569
+	 *
570
+	 * @param string $class_name - simple class name ie: price
571
+	 * @param mixed  $arguments
572
+	 * @param bool   $load_only
573
+	 * @return EEM_Base | bool
574
+	 * @throws InvalidInterfaceException
575
+	 * @throws InvalidDataTypeException
576
+	 * @throws EE_Error
577
+	 * @throws ReflectionException
578
+	 * @throws InvalidArgumentException
579
+	 */
580
+	public function load_model($class_name, $arguments = array(), $load_only = false)
581
+	{
582
+		$paths = apply_filters(
583
+			'FHEE__EE_Registry__load_model__paths',
584
+			array(
585
+				EE_MODELS,
586
+				EE_CORE,
587
+			)
588
+		);
589
+		// retrieve instantiated class
590
+		return $this->_load(
591
+			$paths,
592
+			'EEM_',
593
+			$class_name,
594
+			'model',
595
+			$arguments,
596
+			false,
597
+			true,
598
+			$load_only
599
+		);
600
+	}
601
+
602
+
603
+	/**
604
+	 * loads model classes - must be singletons
605
+	 *
606
+	 * @param string $class_name - simple class name ie: price
607
+	 * @param mixed  $arguments
608
+	 * @param bool   $load_only
609
+	 * @return mixed | bool
610
+	 * @throws InvalidInterfaceException
611
+	 * @throws InvalidDataTypeException
612
+	 * @throws EE_Error
613
+	 * @throws ReflectionException
614
+	 * @throws InvalidArgumentException
615
+	 */
616
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
617
+	{
618
+		$paths = array(
619
+			EE_MODELS . 'fields/',
620
+			EE_MODELS . 'helpers/',
621
+			EE_MODELS . 'relations/',
622
+			EE_MODELS . 'strategies/',
623
+		);
624
+		// retrieve instantiated class
625
+		return $this->_load(
626
+			$paths,
627
+			'EE_',
628
+			$class_name,
629
+			'',
630
+			$arguments,
631
+			false,
632
+			true,
633
+			$load_only
634
+		);
635
+	}
636
+
637
+
638
+	/**
639
+	 * Determines if $model_name is the name of an actual EE model.
640
+	 *
641
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
642
+	 * @return boolean
643
+	 */
644
+	public function is_model_name($model_name)
645
+	{
646
+		return isset($this->models[ $model_name ]);
647
+	}
648
+
649
+
650
+	/**
651
+	 * generic class loader
652
+	 *
653
+	 * @param string $path_to_file - directory path to file location, not including filename
654
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
655
+	 * @param string $type         - file type - core? class? helper? model?
656
+	 * @param mixed  $arguments
657
+	 * @param bool   $load_only
658
+	 * @return mixed
659
+	 * @throws InvalidInterfaceException
660
+	 * @throws InvalidDataTypeException
661
+	 * @throws EE_Error
662
+	 * @throws ReflectionException
663
+	 * @throws InvalidArgumentException
664
+	 */
665
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
666
+	{
667
+		// retrieve instantiated class
668
+		return $this->_load(
669
+			$path_to_file,
670
+			'',
671
+			$file_name,
672
+			$type,
673
+			$arguments,
674
+			false,
675
+			true,
676
+			$load_only
677
+		);
678
+	}
679
+
680
+
681
+	/**
682
+	 * @param string $path_to_file - directory path to file location, not including filename
683
+	 * @param string $class_name   - full class name  ie:  My_Class
684
+	 * @param string $type         - file type - core? class? helper? model?
685
+	 * @param mixed  $arguments
686
+	 * @param bool   $load_only
687
+	 * @return bool|EE_Addon|object
688
+	 * @throws InvalidInterfaceException
689
+	 * @throws InvalidDataTypeException
690
+	 * @throws EE_Error
691
+	 * @throws ReflectionException
692
+	 * @throws InvalidArgumentException
693
+	 */
694
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
695
+	{
696
+		// retrieve instantiated class
697
+		return $this->_load(
698
+			$path_to_file,
699
+			'addon',
700
+			$class_name,
701
+			$type,
702
+			$arguments,
703
+			false,
704
+			true,
705
+			$load_only
706
+		);
707
+	}
708
+
709
+
710
+	/**
711
+	 * instantiates, caches, and automatically resolves dependencies
712
+	 * for classes that use a Fully Qualified Class Name.
713
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
714
+	 * then you need to use one of the existing load_*() methods
715
+	 * which can resolve the classname and filepath from the passed arguments
716
+	 *
717
+	 * @param bool|string $class_name   Fully Qualified Class Name
718
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
719
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
720
+	 * @param bool        $from_db      some classes are instantiated from the db
721
+	 *                                  and thus call a different method to instantiate
722
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
723
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
724
+	 * @return bool|null|mixed          null = failure to load or instantiate class object.
725
+	 *                                  object = class loaded and instantiated successfully.
726
+	 *                                  bool = fail or success when $load_only is true
727
+	 * @throws InvalidInterfaceException
728
+	 * @throws InvalidDataTypeException
729
+	 * @throws EE_Error
730
+	 * @throws ReflectionException
731
+	 * @throws InvalidArgumentException
732
+	 */
733
+	public function create(
734
+		$class_name = false,
735
+		$arguments = array(),
736
+		$cache = false,
737
+		$from_db = false,
738
+		$load_only = false,
739
+		$addon = false
740
+	) {
741
+		$class_name = ltrim($class_name, '\\');
742
+		$class_name = $this->class_cache->getFqnForAlias($class_name);
743
+		$class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
744
+		// if a non-FQCN was passed, then
745
+		// verifyClassExists() might return an object
746
+		// or it could return null if the class just could not be found anywhere
747
+		if ($class_exists instanceof $class_name || $class_exists === null) {
748
+			// either way, return the results
749
+			return $class_exists;
750
+		}
751
+		$class_name = $class_exists;
752
+		// if we're only loading the class and it already exists, then let's just return true immediately
753
+		if ($load_only) {
754
+			return true;
755
+		}
756
+		$addon = $addon ? 'addon' : '';
757
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
758
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
759
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
760
+		if ($this->_cache_on && $cache && ! $load_only) {
761
+			// return object if it's already cached
762
+			$cached_class = $this->_get_cached_class($class_name, $addon, $arguments);
763
+			if ($cached_class !== null) {
764
+				return $cached_class;
765
+			}
766
+		}// obtain the loader method from the dependency map
767
+		$loader = $this->_dependency_map->class_loader($class_name);// instantiate the requested object
768
+		if ($loader instanceof Closure) {
769
+			$class_obj = $loader($arguments);
770
+		} else {
771
+			if ($loader && method_exists($this, $loader)) {
772
+				$class_obj = $this->{$loader}($class_name, $arguments);
773
+			} else {
774
+				$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
775
+			}
776
+		}
777
+		if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
778
+			// save it for later... kinda like gum  { : $
779
+			$this->_set_cached_class(
780
+				$class_obj,
781
+				$class_name,
782
+				$addon,
783
+				$from_db,
784
+				$arguments
785
+			);
786
+		}
787
+		$this->_cache_on = true;
788
+		return $class_obj;
789
+	}
790
+
791
+
792
+	/**
793
+	 * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
794
+	 *
795
+	 * @param string|object $class_name
796
+	 * @param array         $arguments
797
+	 * @param int           $attempt
798
+	 * @return mixed
799
+	 */
800
+	private function loadOrVerifyClassExists($class_name, array $arguments, $attempt = 1)
801
+	{
802
+		if (is_object($class_name) || class_exists($class_name)) {
803
+			return $class_name;
804
+		}
805
+		switch ($attempt) {
806
+			case 1:
807
+				// if it's a FQCN then maybe the class is registered with a preceding \
808
+				$class_name = strpos($class_name, '\\') !== false
809
+					? '\\' . ltrim($class_name, '\\')
810
+					: $class_name;
811
+				break;
812
+			case 2:
813
+				//
814
+				$loader = $this->_dependency_map->class_loader($class_name);
815
+				if ($loader && method_exists($this, $loader)) {
816
+					return $this->{$loader}($class_name, $arguments);
817
+				}
818
+				break;
819
+			case 3:
820
+			default:
821
+				return null;
822
+		}
823
+		$attempt++;
824
+		return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
825
+	}
826
+
827
+
828
+	/**
829
+	 * instantiates, caches, and injects dependencies for classes
830
+	 *
831
+	 * @param array       $file_paths   an array of paths to folders to look in
832
+	 * @param string      $class_prefix EE  or EEM or... ???
833
+	 * @param bool|string $class_name   $class name
834
+	 * @param string      $type         file type - core? class? helper? model?
835
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
836
+	 * @param bool        $from_db      some classes are instantiated from the db
837
+	 *                                  and thus call a different method to instantiate
838
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
839
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
840
+	 * @return bool|null|object null = failure to load or instantiate class object.
841
+	 *                                  object = class loaded and instantiated successfully.
842
+	 *                                  bool = fail or success when $load_only is true
843
+	 * @throws EE_Error
844
+	 * @throws ReflectionException
845
+	 * @throws InvalidInterfaceException
846
+	 * @throws InvalidDataTypeException
847
+	 * @throws InvalidArgumentException
848
+	 */
849
+	protected function _load(
850
+		$file_paths = array(),
851
+		$class_prefix = 'EE_',
852
+		$class_name = false,
853
+		$type = 'class',
854
+		$arguments = array(),
855
+		$from_db = false,
856
+		$cache = true,
857
+		$load_only = false
858
+	) {
859
+		$class_name = ltrim($class_name, '\\');
860
+		// strip php file extension
861
+		$class_name = str_replace('.php', '', trim($class_name));
862
+		// does the class have a prefix ?
863
+		if (! empty($class_prefix) && $class_prefix !== 'addon') {
864
+			// make sure $class_prefix is uppercase
865
+			$class_prefix = strtoupper(trim($class_prefix));
866
+			// add class prefix ONCE!!!
867
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
868
+		}
869
+		$class_name = $this->class_cache->getFqnForAlias($class_name);
870
+		$class_exists = class_exists($class_name, false);
871
+		// if we're only loading the class and it already exists, then let's just return true immediately
872
+		if ($load_only && $class_exists) {
873
+			return true;
874
+		}
875
+		$arguments = is_array($arguments) ? $arguments : array($arguments);
876
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
877
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
878
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
879
+		if ($this->_cache_on && $cache && ! $load_only) {
880
+			// return object if it's already cached
881
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix, $arguments);
882
+			if ($cached_class !== null) {
883
+				return $cached_class;
884
+			}
885
+		}
886
+		// if the class doesn't already exist.. then we need to try and find the file and load it
887
+		if (! $class_exists) {
888
+			// get full path to file
889
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
890
+			// load the file
891
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
892
+			// if we are only loading a file but NOT instantiating an object
893
+			// then return boolean for whether class was loaded or not
894
+			if ($load_only) {
895
+				return $loaded;
896
+			}
897
+			// if an object was expected but loading failed, then return nothing
898
+			if (! $loaded) {
899
+				return null;
900
+			}
901
+		}
902
+		// instantiate the requested object
903
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
904
+		if ($this->_cache_on && $cache) {
905
+			// save it for later... kinda like gum  { : $
906
+			$this->_set_cached_class(
907
+				$class_obj,
908
+				$class_name,
909
+				$class_prefix,
910
+				$from_db,
911
+				$arguments
912
+			);
913
+		}
914
+		$this->_cache_on = true;
915
+		return $class_obj;
916
+	}
917
+
918
+
919
+	/**
920
+	 * @param string $class_name
921
+	 * @param string $default have to specify something, but not anything that will conflict
922
+	 * @return mixed|string
923
+	 */
924
+	protected function get_class_abbreviation($class_name, $default = 'FANCY_BATMAN_PANTS')
925
+	{
926
+		return isset($this->_class_abbreviations[ $class_name ])
927
+			? $this->_class_abbreviations[ $class_name ]
928
+			: $default;
929
+	}
930
+
931
+
932
+	/**
933
+	 * attempts to find a cached version of the requested class
934
+	 * by looking in the following places:
935
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
936
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
937
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
938
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
939
+	 *
940
+	 * @param string $class_name
941
+	 * @param string $class_prefix
942
+	 * @param array  $arguments
943
+	 * @return mixed
944
+	 */
945
+	protected function _get_cached_class(
946
+		$class_name,
947
+		$class_prefix = '',
948
+		$arguments = array()
949
+	) {
950
+		if ($class_name === 'EE_Registry') {
951
+			return $this;
952
+		}
953
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
954
+		// check if class has already been loaded, and return it if it has been
955
+		if (isset($this->{$class_abbreviation})) {
956
+			return $this->{$class_abbreviation};
957
+		}
958
+		$class_name = str_replace('\\', '_', $class_name);
959
+		if (isset($this->{$class_name})) {
960
+			return $this->{$class_name};
961
+		}
962
+		if ($class_prefix === 'addon' && isset($this->addons->{$class_name})) {
963
+			return $this->addons->{$class_name};
964
+		}
965
+		$object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
966
+		if (isset($this->LIB->{$object_identifier})) {
967
+			return $this->LIB->{$object_identifier};
968
+		}
969
+		foreach ($this->LIB as $key => $object) {
970
+			if (// request does not contain new arguments and therefore no args identifier
971
+				! $this->object_identifier->hasArguments($object_identifier)
972
+				// but previously cached class with args was found
973
+				&& $this->object_identifier->fqcnMatchesObjectIdentifier($class_name, $key)
974
+			) {
975
+				return $object;
976
+			}
977
+		}
978
+		return null;
979
+	}
980
+
981
+
982
+	/**
983
+	 * removes a cached version of the requested class
984
+	 *
985
+	 * @param string  $class_name
986
+	 * @param boolean $addon
987
+	 * @param array   $arguments
988
+	 * @return boolean
989
+	 */
990
+	public function clear_cached_class(
991
+		$class_name,
992
+		$addon = false,
993
+		$arguments = array()
994
+	) {
995
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
996
+		// check if class has already been loaded, and return it if it has been
997
+		if (isset($this->{$class_abbreviation})) {
998
+			$this->{$class_abbreviation} = null;
999
+			return true;
1000
+		}
1001
+		$class_name = str_replace('\\', '_', $class_name);
1002
+		if (isset($this->{$class_name})) {
1003
+			$this->{$class_name} = null;
1004
+			return true;
1005
+		}
1006
+		if ($addon && isset($this->addons->{$class_name})) {
1007
+			unset($this->addons->{$class_name});
1008
+			return true;
1009
+		}
1010
+		$class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1011
+		if (isset($this->LIB->{$class_name})) {
1012
+			unset($this->LIB->{$class_name});
1013
+			return true;
1014
+		}
1015
+		return false;
1016
+	}
1017
+
1018
+
1019
+	/**
1020
+	 * _set_cached_class
1021
+	 * attempts to cache the instantiated class locally
1022
+	 * in one of the following places, in the following order:
1023
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1024
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1025
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1026
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1027
+	 *
1028
+	 * @param object $class_obj
1029
+	 * @param string $class_name
1030
+	 * @param string $class_prefix
1031
+	 * @param bool   $from_db
1032
+	 * @param array  $arguments
1033
+	 * @return void
1034
+	 */
1035
+	protected function _set_cached_class(
1036
+		$class_obj,
1037
+		$class_name,
1038
+		$class_prefix = '',
1039
+		$from_db = false,
1040
+		$arguments = array()
1041
+	) {
1042
+		if ($class_name === 'EE_Registry' || empty($class_obj)) {
1043
+			return;
1044
+		}
1045
+		// return newly instantiated class
1046
+		$class_abbreviation = $this->get_class_abbreviation($class_name, '');
1047
+		if ($class_abbreviation) {
1048
+			$this->{$class_abbreviation} = $class_obj;
1049
+			return;
1050
+		}
1051
+		$class_name = str_replace('\\', '_', $class_name);
1052
+		if (property_exists($this, $class_name)) {
1053
+			$this->{$class_name} = $class_obj;
1054
+			return;
1055
+		}
1056
+		if ($class_prefix === 'addon') {
1057
+			$this->addons->{$class_name} = $class_obj;
1058
+			return;
1059
+		}
1060
+		if (! $from_db) {
1061
+			$class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1062
+			$this->LIB->{$class_name} = $class_obj;
1063
+		}
1064
+	}
1065
+
1066
+
1067
+	/**
1068
+	 * attempts to find a full valid filepath for the requested class.
1069
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
1070
+	 * then returns that path if the target file has been found and is readable
1071
+	 *
1072
+	 * @param string $class_name
1073
+	 * @param string $type
1074
+	 * @param array  $file_paths
1075
+	 * @return string | bool
1076
+	 */
1077
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
1078
+	{
1079
+		// make sure $file_paths is an array
1080
+		$file_paths = is_array($file_paths)
1081
+			? $file_paths
1082
+			: array($file_paths);
1083
+		// cycle thru paths
1084
+		foreach ($file_paths as $key => $file_path) {
1085
+			// convert all separators to proper /, if no filepath, then use EE_CLASSES
1086
+			$file_path = $file_path
1087
+				? str_replace(array('/', '\\'), '/', $file_path)
1088
+				: EE_CLASSES;
1089
+			// prep file type
1090
+			$type = ! empty($type)
1091
+				? trim($type, '.') . '.'
1092
+				: '';
1093
+			// build full file path
1094
+			$file_paths[ $key ] = rtrim($file_path, '/') . '/' . $class_name . '.' . $type . 'php';
1095
+			// does the file exist and can be read ?
1096
+			if (is_readable($file_paths[ $key ])) {
1097
+				return $file_paths[ $key ];
1098
+			}
1099
+		}
1100
+		return false;
1101
+	}
1102
+
1103
+
1104
+	/**
1105
+	 * basically just performs a require_once()
1106
+	 * but with some error handling
1107
+	 *
1108
+	 * @param  string $path
1109
+	 * @param  string $class_name
1110
+	 * @param  string $type
1111
+	 * @param  array  $file_paths
1112
+	 * @return bool
1113
+	 * @throws EE_Error
1114
+	 * @throws ReflectionException
1115
+	 */
1116
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
1117
+	{
1118
+		$this->resolve_legacy_class_parent($class_name);
1119
+		// don't give up! you gotta...
1120
+		try {
1121
+			// does the file exist and can it be read ?
1122
+			if (! $path) {
1123
+				// just in case the file has already been autoloaded,
1124
+				// but discrepancies in the naming schema are preventing it from
1125
+				// being loaded via one of the EE_Registry::load_*() methods,
1126
+				// then let's try one last hail mary before throwing an exception
1127
+				// and call class_exists() again, but with autoloading turned ON
1128
+				if (class_exists($class_name)) {
1129
+					return true;
1130
+				}
1131
+				// so sorry, can't find the file
1132
+				throw new EE_Error(
1133
+					sprintf(
1134
+						esc_html__(
1135
+							'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
1136
+							'event_espresso'
1137
+						),
1138
+						trim($type, '.'),
1139
+						$class_name,
1140
+						'<br />' . implode(',<br />', $file_paths)
1141
+					)
1142
+				);
1143
+			}
1144
+			// get the file
1145
+			require_once($path);
1146
+			// if the class isn't already declared somewhere
1147
+			if (class_exists($class_name, false) === false) {
1148
+				// so sorry, not a class
1149
+				throw new EE_Error(
1150
+					sprintf(
1151
+						esc_html__(
1152
+							'The %s file %s does not appear to contain the %s Class.',
1153
+							'event_espresso'
1154
+						),
1155
+						$type,
1156
+						$path,
1157
+						$class_name
1158
+					)
1159
+				);
1160
+			}
1161
+		} catch (EE_Error $e) {
1162
+			$e->get_error();
1163
+			return false;
1164
+		}
1165
+		return true;
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 * Some of our legacy classes that extended a parent class would simply use a require() statement
1171
+	 * before their class declaration in order to ensure that the parent class was loaded.
1172
+	 * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1173
+	 * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1174
+	 *
1175
+	 * @param string $class_name
1176
+	 */
1177
+	protected function resolve_legacy_class_parent($class_name = '')
1178
+	{
1179
+		try {
1180
+			$legacy_parent_class_map = array(
1181
+				'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php',
1182
+			);
1183
+			if (isset($legacy_parent_class_map[ $class_name ])) {
1184
+				require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[ $class_name ];
1185
+			}
1186
+		} catch (Exception $exception) {
1187
+		}
1188
+	}
1189
+
1190
+
1191
+	/**
1192
+	 * _create_object
1193
+	 * Attempts to instantiate the requested class via any of the
1194
+	 * commonly used instantiation methods employed throughout EE.
1195
+	 * The priority for instantiation is as follows:
1196
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1197
+	 *        - model objects via their 'new_instance_from_db' method
1198
+	 *        - model objects via their 'new_instance' method
1199
+	 *        - "singleton" classes" via their 'instance' method
1200
+	 *    - standard instantiable classes via their __constructor
1201
+	 * Prior to instantiation, if the classname exists in the dependency_map,
1202
+	 * then the constructor for the requested class will be examined to determine
1203
+	 * if any dependencies exist, and if they can be injected.
1204
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1205
+	 *
1206
+	 * @param string $class_name
1207
+	 * @param array  $arguments
1208
+	 * @param string $type
1209
+	 * @param bool   $from_db
1210
+	 * @return null|object|bool
1211
+	 * @throws InvalidArgumentException
1212
+	 * @throws InvalidInterfaceException
1213
+	 * @throws EE_Error
1214
+	 * @throws ReflectionException
1215
+	 * @throws InvalidDataTypeException
1216
+	 */
1217
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
1218
+	{
1219
+		// create reflection
1220
+		$reflector = $this->mirror->getReflectionClass($class_name);
1221
+		// make sure arguments are an array
1222
+		$arguments = is_array($arguments)
1223
+			? $arguments
1224
+			: array($arguments);
1225
+		// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1226
+		// else wrap it in an additional array so that it doesn't get split into multiple parameters
1227
+		$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1228
+			? $arguments
1229
+			: array($arguments);
1230
+		// attempt to inject dependencies ?
1231
+		if ($this->_dependency_map->has($class_name)) {
1232
+			$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1233
+		}
1234
+		// instantiate the class if possible
1235
+		if ($reflector->isAbstract()) {
1236
+			// nothing to instantiate, loading file was enough
1237
+			// does not throw an exception so $instantiation_mode is unused
1238
+			// $instantiation_mode = "1) no constructor abstract class";
1239
+			return true;
1240
+		}
1241
+		if (empty($arguments)
1242
+			&& $this->mirror->getConstructorFromReflection($reflector) === null
1243
+			&& $reflector->isInstantiable()
1244
+		) {
1245
+			// no constructor = static methods only... nothing to instantiate, loading file was enough
1246
+			// $instantiation_mode = "2) no constructor but instantiable";
1247
+			return $reflector->newInstance();
1248
+		}
1249
+		if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1250
+			// $instantiation_mode = "3) new_instance_from_db()";
1251
+			return call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1252
+		}
1253
+		if (method_exists($class_name, 'new_instance')) {
1254
+			// $instantiation_mode = "4) new_instance()";
1255
+			return call_user_func_array(array($class_name, 'new_instance'), $arguments);
1256
+		}
1257
+		if (method_exists($class_name, 'instance')) {
1258
+			// $instantiation_mode = "5) instance()";
1259
+			return call_user_func_array(array($class_name, 'instance'), $arguments);
1260
+		}
1261
+		if ($reflector->isInstantiable()) {
1262
+			// $instantiation_mode = "6) constructor";
1263
+			return $reflector->newInstanceArgs($arguments);
1264
+		}
1265
+		// heh ? something's not right !
1266
+		throw new EE_Error(
1267
+			sprintf(
1268
+				__('The %s file %s could not be instantiated.', 'event_espresso'),
1269
+				$type,
1270
+				$class_name
1271
+			)
1272
+		);
1273
+	}
1274
+
1275
+
1276
+	/**
1277
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1278
+	 * @param array $array
1279
+	 * @return bool
1280
+	 */
1281
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
1282
+	{
1283
+		return ! empty($array)
1284
+			? array_keys($array) === range(0, count($array) - 1)
1285
+			: true;
1286
+	}
1287
+
1288
+
1289
+	/**
1290
+	 * _resolve_dependencies
1291
+	 * examines the constructor for the requested class to determine
1292
+	 * if any dependencies exist, and if they can be injected.
1293
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1294
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
1295
+	 * For example:
1296
+	 *        if attempting to load a class "Foo" with the following constructor:
1297
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
1298
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
1299
+	 *        but only IF they are NOT already present in the incoming arguments array,
1300
+	 *        and the correct classes can be loaded
1301
+	 *
1302
+	 * @param ReflectionClass $reflector
1303
+	 * @param string          $class_name
1304
+	 * @param array           $arguments
1305
+	 * @return array
1306
+	 * @throws InvalidArgumentException
1307
+	 * @throws InvalidDataTypeException
1308
+	 * @throws InvalidInterfaceException
1309
+	 * @throws ReflectionException
1310
+	 */
1311
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, array $arguments = array())
1312
+	{
1313
+		// let's examine the constructor
1314
+		$constructor = $this->mirror->getConstructorFromReflection($reflector);
1315
+		// whu? huh? nothing?
1316
+		if (! $constructor) {
1317
+			return $arguments;
1318
+		}
1319
+		// get constructor parameters
1320
+		$params = $this->mirror->getParametersFromReflection($reflector);
1321
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1322
+		$argument_keys = array_keys($arguments);
1323
+		// now loop thru all of the constructors expected parameters
1324
+		foreach ($params as $index => $param) {
1325
+			try {
1326
+				// is this a dependency for a specific class ?
1327
+				$param_class = $this->mirror->getParameterClassName($param, $class_name, $index);
1328
+			} catch (ReflectionException $exception) {
1329
+				// uh-oh... most likely a legacy class that has not been autoloaded
1330
+				// let's try to derive the classname from what we have now
1331
+				// and hope that the property var name is close to the class name
1332
+				$param_class = $param->getName();
1333
+				$param_class = str_replace('_', ' ', $param_class);
1334
+				$param_class = ucwords($param_class);
1335
+				$param_class = str_replace(' ', '_', $param_class);
1336
+			}
1337
+			// BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1338
+			$param_class = $this->class_cache->isAlias($param_class, $class_name)
1339
+				? $this->class_cache->getFqnForAlias($param_class, $class_name)
1340
+				: $param_class;
1341
+			if (// param is not even a class
1342
+				$param_class === null
1343
+				// and something already exists in the incoming arguments for this param
1344
+				&& array_key_exists($index, $argument_keys)
1345
+				&& array_key_exists($argument_keys[ $index ], $arguments)
1346
+			) {
1347
+				// so let's skip this argument and move on to the next
1348
+				continue;
1349
+			}
1350
+			if (// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1351
+				$param_class !== null
1352
+				&& isset($argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ])
1353
+				&& $arguments[ $argument_keys[ $index ] ] instanceof $param_class
1354
+			) {
1355
+				// skip this argument and move on to the next
1356
+				continue;
1357
+			}
1358
+			if (// parameter is type hinted as a class, and should be injected
1359
+				$param_class !== null
1360
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1361
+			) {
1362
+				$arguments = $this->_resolve_dependency(
1363
+					$class_name,
1364
+					$param_class,
1365
+					$arguments,
1366
+					$index
1367
+				);
1368
+			}
1369
+			if (empty($arguments[ $index ])) {
1370
+				$arguments[ $index ] = $this->mirror->getParameterDefaultValue(
1371
+					$param,
1372
+					$class_name,
1373
+					$index
1374
+				);
1375
+			}
1376
+		}
1377
+		return $arguments;
1378
+	}
1379
+
1380
+
1381
+	/**
1382
+	 * @param string $class_name
1383
+	 * @param string $param_class
1384
+	 * @param array  $arguments
1385
+	 * @param mixed  $index
1386
+	 * @return array
1387
+	 * @throws InvalidArgumentException
1388
+	 * @throws InvalidInterfaceException
1389
+	 * @throws InvalidDataTypeException
1390
+	 */
1391
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1392
+	{
1393
+		$dependency = null;
1394
+		// should dependency be loaded from cache ?
1395
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1396
+			$class_name,
1397
+			$param_class
1398
+		);
1399
+		$cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1400
+		// we might have a dependency...
1401
+		// let's MAYBE try and find it in our cache if that's what's been requested
1402
+		$cached_class = $cache_on
1403
+			? $this->_get_cached_class($param_class)
1404
+			: null;
1405
+		// and grab it if it exists
1406
+		if ($cached_class instanceof $param_class) {
1407
+			$dependency = $cached_class;
1408
+		} elseif ($param_class !== $class_name) {
1409
+			// obtain the loader method from the dependency map
1410
+			$loader = $this->_dependency_map->class_loader($param_class);
1411
+			// is loader a custom closure ?
1412
+			if ($loader instanceof Closure) {
1413
+				$dependency = $loader($arguments);
1414
+			} else {
1415
+				// set the cache on property for the recursive loading call
1416
+				$this->_cache_on = $cache_on;
1417
+				// if not, then let's try and load it via the registry
1418
+				if ($loader && method_exists($this, $loader)) {
1419
+					$dependency = $this->{$loader}($param_class);
1420
+				} else {
1421
+					$dependency = LoaderFactory::getLoader()->load(
1422
+						$param_class,
1423
+						array(),
1424
+						$cache_on
1425
+					);
1426
+				}
1427
+			}
1428
+		}
1429
+		// did we successfully find the correct dependency ?
1430
+		if ($dependency instanceof $param_class) {
1431
+			// then let's inject it into the incoming array of arguments at the correct location
1432
+			$arguments[ $index ] = $dependency;
1433
+		}
1434
+		return $arguments;
1435
+	}
1436
+
1437
+
1438
+	/**
1439
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1440
+	 *
1441
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1442
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1443
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1444
+	 * @param array  $arguments
1445
+	 * @return object
1446
+	 */
1447
+	public static function factory($classname, $arguments = array())
1448
+	{
1449
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1450
+		if ($loader instanceof Closure) {
1451
+			return $loader($arguments);
1452
+		}
1453
+		if (method_exists(self::instance(), $loader)) {
1454
+			return self::instance()->{$loader}($classname, $arguments);
1455
+		}
1456
+		return null;
1457
+	}
1458
+
1459
+
1460
+	/**
1461
+	 * Gets the addon by its class name
1462
+	 *
1463
+	 * @param string $class_name
1464
+	 * @return EE_Addon
1465
+	 */
1466
+	public function getAddon($class_name)
1467
+	{
1468
+		$class_name = str_replace('\\', '_', $class_name);
1469
+		if (isset($this->addons->{$class_name})) {
1470
+			return $this->addons->{$class_name};
1471
+		} else {
1472
+			return null;
1473
+		}
1474
+	}
1475
+
1476
+
1477
+	/**
1478
+	 * removes the addon from the internal cache
1479
+	 *
1480
+	 * @param string $class_name
1481
+	 * @return void
1482
+	 */
1483
+	public function removeAddon($class_name)
1484
+	{
1485
+		$class_name = str_replace('\\', '_', $class_name);
1486
+		unset($this->addons->{$class_name});
1487
+	}
1488
+
1489
+
1490
+	/**
1491
+	 * Gets the addon by its name/slug (not classname. For that, just
1492
+	 * use the get_addon() method above
1493
+	 *
1494
+	 * @param string $name
1495
+	 * @return EE_Addon
1496
+	 */
1497
+	public function get_addon_by_name($name)
1498
+	{
1499
+		foreach ($this->addons as $addon) {
1500
+			if ($addon->name() === $name) {
1501
+				return $addon;
1502
+			}
1503
+		}
1504
+		return null;
1505
+	}
1506
+
1507
+
1508
+	/**
1509
+	 * Gets an array of all the registered addons, where the keys are their names.
1510
+	 * (ie, what each returns for their name() function)
1511
+	 * They're already available on EE_Registry::instance()->addons as properties,
1512
+	 * where each property's name is the addon's classname,
1513
+	 * So if you just want to get the addon by classname,
1514
+	 * OR use the get_addon() method above.
1515
+	 * PLEASE  NOTE:
1516
+	 * addons with Fully Qualified Class Names
1517
+	 * have had the namespace separators converted to underscores,
1518
+	 * so a classname like Fully\Qualified\ClassName
1519
+	 * would have been converted to Fully_Qualified_ClassName
1520
+	 *
1521
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1522
+	 */
1523
+	public function get_addons_by_name()
1524
+	{
1525
+		$addons = array();
1526
+		foreach ($this->addons as $addon) {
1527
+			$addons[ $addon->name() ] = $addon;
1528
+		}
1529
+		return $addons;
1530
+	}
1531
+
1532
+
1533
+	/**
1534
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1535
+	 * a stale copy of it around
1536
+	 *
1537
+	 * @param string $model_name
1538
+	 * @return \EEM_Base
1539
+	 * @throws \EE_Error
1540
+	 */
1541
+	public function reset_model($model_name)
1542
+	{
1543
+		$model_class_name = strpos($model_name, 'EEM_') !== 0
1544
+			? "EEM_{$model_name}"
1545
+			: $model_name;
1546
+		if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1547
+			return null;
1548
+		}
1549
+		// get that model reset it and make sure we nuke the old reference to it
1550
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name
1551
+			&& is_callable(
1552
+				array($model_class_name, 'reset')
1553
+			)) {
1554
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1555
+		} else {
1556
+			throw new EE_Error(
1557
+				sprintf(
1558
+					esc_html__('Model %s does not have a method "reset"', 'event_espresso'),
1559
+					$model_name
1560
+				)
1561
+			);
1562
+		}
1563
+		return $this->LIB->{$model_class_name};
1564
+	}
1565
+
1566
+
1567
+	/**
1568
+	 * Resets the registry.
1569
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when
1570
+	 * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1571
+	 * - $_dependency_map
1572
+	 * - $_class_abbreviations
1573
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1574
+	 * - $REQ:  Still on the same request so no need to change.
1575
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1576
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1577
+	 * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1578
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1579
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1580
+	 *             switch or on the restore.
1581
+	 * - $modules
1582
+	 * - $shortcodes
1583
+	 * - $widgets
1584
+	 *
1585
+	 * @param boolean $hard             [deprecated]
1586
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1587
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1588
+	 *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1589
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1590
+	 *                                  client
1591
+	 *                                  code instead can just change the model context to a different blog id if
1592
+	 *                                  necessary
1593
+	 * @return EE_Registry
1594
+	 * @throws InvalidInterfaceException
1595
+	 * @throws InvalidDataTypeException
1596
+	 * @throws EE_Error
1597
+	 * @throws ReflectionException
1598
+	 * @throws InvalidArgumentException
1599
+	 */
1600
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1601
+	{
1602
+		$instance = self::instance();
1603
+		$instance->_cache_on = true;
1604
+		// reset some "special" classes
1605
+		EEH_Activation::reset();
1606
+		$hard = apply_filters('FHEE__EE_Registry__reset__hard', $hard);
1607
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1608
+		$instance->CART = null;
1609
+		$instance->MRM = null;
1610
+		$instance->AssetsRegistry = LoaderFactory::getLoader()->getShared(
1611
+			'EventEspresso\core\services\assets\Registry'
1612
+		);
1613
+		// messages reset
1614
+		EED_Messages::reset();
1615
+		// handle of objects cached on LIB
1616
+		foreach (array('LIB', 'modules') as $cache) {
1617
+			foreach ($instance->{$cache} as $class_name => $class) {
1618
+				if (self::_reset_and_unset_object($class, $reset_models)) {
1619
+					unset($instance->{$cache}->{$class_name});
1620
+				}
1621
+			}
1622
+		}
1623
+		return $instance;
1624
+	}
1625
+
1626
+
1627
+	/**
1628
+	 * if passed object implements ResettableInterface, then call it's reset() method
1629
+	 * if passed object implements InterminableInterface, then return false,
1630
+	 * to indicate that it should NOT be cleared from the Registry cache
1631
+	 *
1632
+	 * @param      $object
1633
+	 * @param bool $reset_models
1634
+	 * @return bool returns true if cached object should be unset
1635
+	 */
1636
+	private static function _reset_and_unset_object($object, $reset_models)
1637
+	{
1638
+		if (! is_object($object)) {
1639
+			// don't unset anything that's not an object
1640
+			return false;
1641
+		}
1642
+		if ($object instanceof EED_Module) {
1643
+			$object::reset();
1644
+			// don't unset modules
1645
+			return false;
1646
+		}
1647
+		if ($object instanceof ResettableInterface) {
1648
+			if ($object instanceof EEM_Base) {
1649
+				if ($reset_models) {
1650
+					$object->reset();
1651
+					return true;
1652
+				}
1653
+				return false;
1654
+			}
1655
+			$object->reset();
1656
+			return true;
1657
+		}
1658
+		if (! $object instanceof InterminableInterface) {
1659
+			return true;
1660
+		}
1661
+		return false;
1662
+	}
1663
+
1664
+
1665
+	/**
1666
+	 * Gets all the custom post type models defined
1667
+	 *
1668
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1669
+	 */
1670
+	public function cpt_models()
1671
+	{
1672
+		$cpt_models = array();
1673
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1674
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1675
+				$cpt_models[ $short_name ] = $classname;
1676
+			}
1677
+		}
1678
+		return $cpt_models;
1679
+	}
1680
+
1681
+
1682
+	/**
1683
+	 * @return \EE_Config
1684
+	 */
1685
+	public static function CFG()
1686
+	{
1687
+		return self::instance()->CFG;
1688
+	}
1689
+
1690
+
1691
+	/**
1692
+	 * @deprecated 4.9.62.p
1693
+	 * @param string $class_name
1694
+	 * @return ReflectionClass
1695
+	 * @throws ReflectionException
1696
+	 * @throws InvalidDataTypeException
1697
+	 */
1698
+	public function get_ReflectionClass($class_name)
1699
+	{
1700
+		return $this->mirror->getReflectionClass($class_name);
1701
+	}
1702 1702
 }
Please login to merge, or discard this patch.
core/EE_Module_Request_Router.core.php 1 patch
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -16,254 +16,254 @@
 block discarded – undo
16 16
 final class EE_Module_Request_Router implements InterminableInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var RequestInterface $request
21
-     */
22
-    private $request;
19
+	/**
20
+	 * @var RequestInterface $request
21
+	 */
22
+	private $request;
23 23
 
24
-    /**
25
-     * @var array $_previous_routes
26
-     */
27
-    private static $_previous_routes = array();
24
+	/**
25
+	 * @var array $_previous_routes
26
+	 */
27
+	private static $_previous_routes = array();
28 28
 
29
-    /**
30
-     * @var WP_Query $WP_Query
31
-     */
32
-    public $WP_Query;
29
+	/**
30
+	 * @var WP_Query $WP_Query
31
+	 */
32
+	public $WP_Query;
33 33
 
34 34
 
35
-    /**
36
-     * EE_Module_Request_Router constructor.
37
-     *
38
-     * @param RequestInterface $request
39
-     */
40
-    public function __construct(RequestInterface $request)
41
-    {
42
-        $this->request = $request;
43
-    }
35
+	/**
36
+	 * EE_Module_Request_Router constructor.
37
+	 *
38
+	 * @param RequestInterface $request
39
+	 */
40
+	public function __construct(RequestInterface $request)
41
+	{
42
+		$this->request = $request;
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * on the first call  to this method, it checks the Request for a "route"
48
-     * on subsequent calls to this method,
49
-     * instead of checking the Request for a route, it checks the previous routes array,
50
-     * and checks if the last called route has any forwarding routes registered for it
51
-     *
52
-     * @param WP_Query $WP_Query
53
-     * @return NULL|string
54
-     * @throws EE_Error
55
-     * @throws ReflectionException
56
-     */
57
-    public function get_route(WP_Query $WP_Query)
58
-    {
59
-        $this->WP_Query = $WP_Query;
60
-        // assume this if first route being called
61
-        $previous_route = false;
62
-        // but is it really ???
63
-        if (! empty(self::$_previous_routes)) {
64
-            // get last run route
65
-            $previous_routes = array_values(self::$_previous_routes);
66
-            $previous_route = array_pop($previous_routes);
67
-        }
68
-        //  has another route already been run ?
69
-        if ($previous_route) {
70
-            // check if  forwarding has been set
71
-            $current_route = $this->get_forward($previous_route);
72
-            try {
73
-                // check for recursive forwarding
74
-                if (isset(self::$_previous_routes[ $current_route ])) {
75
-                    throw new EE_Error(
76
-                        sprintf(
77
-                            __(
78
-                                'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
79
-                                'event_espresso'
80
-                            ),
81
-                            $current_route
82
-                        )
83
-                    );
84
-                }
85
-            } catch (EE_Error $e) {
86
-                $e->get_error();
87
-                return null;
88
-            }
89
-        } else {
90
-            // first route called
91
-            $current_route = null;
92
-            // grab all routes
93
-            $routes = EE_Config::get_routes();
94
-            foreach ($routes as $key => $route) {
95
-                // first determine if route key uses w?ldc*rds
96
-                $uses_wildcards = strpos($key, '?') !== false
97
-                                  || strpos($key, '*') !== false;
98
-                // check request for module route
99
-                $route_found = $uses_wildcards
100
-                    ? $this->request->matches($key)
101
-                    : $this->request->requestParamIsSet($key);
102
-                if ($route_found) {
103
-                    $current_route = $uses_wildcards
104
-                        ? $this->request->getMatch($key)
105
-                        : $this->request->getRequestParam($key);
106
-                    $current_route = sanitize_text_field($current_route);
107
-                    if ($current_route) {
108
-                        $current_route = array($key, $current_route);
109
-                        break;
110
-                    }
111
-                }
112
-            }
113
-        }
114
-        // sorry, but I can't read what you route !
115
-        if (empty($current_route)) {
116
-            return null;
117
-        }
118
-        // add route to previous routes array
119
-        self::$_previous_routes[] = $current_route;
120
-        return $current_route;
121
-    }
46
+	/**
47
+	 * on the first call  to this method, it checks the Request for a "route"
48
+	 * on subsequent calls to this method,
49
+	 * instead of checking the Request for a route, it checks the previous routes array,
50
+	 * and checks if the last called route has any forwarding routes registered for it
51
+	 *
52
+	 * @param WP_Query $WP_Query
53
+	 * @return NULL|string
54
+	 * @throws EE_Error
55
+	 * @throws ReflectionException
56
+	 */
57
+	public function get_route(WP_Query $WP_Query)
58
+	{
59
+		$this->WP_Query = $WP_Query;
60
+		// assume this if first route being called
61
+		$previous_route = false;
62
+		// but is it really ???
63
+		if (! empty(self::$_previous_routes)) {
64
+			// get last run route
65
+			$previous_routes = array_values(self::$_previous_routes);
66
+			$previous_route = array_pop($previous_routes);
67
+		}
68
+		//  has another route already been run ?
69
+		if ($previous_route) {
70
+			// check if  forwarding has been set
71
+			$current_route = $this->get_forward($previous_route);
72
+			try {
73
+				// check for recursive forwarding
74
+				if (isset(self::$_previous_routes[ $current_route ])) {
75
+					throw new EE_Error(
76
+						sprintf(
77
+							__(
78
+								'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
79
+								'event_espresso'
80
+							),
81
+							$current_route
82
+						)
83
+					);
84
+				}
85
+			} catch (EE_Error $e) {
86
+				$e->get_error();
87
+				return null;
88
+			}
89
+		} else {
90
+			// first route called
91
+			$current_route = null;
92
+			// grab all routes
93
+			$routes = EE_Config::get_routes();
94
+			foreach ($routes as $key => $route) {
95
+				// first determine if route key uses w?ldc*rds
96
+				$uses_wildcards = strpos($key, '?') !== false
97
+								  || strpos($key, '*') !== false;
98
+				// check request for module route
99
+				$route_found = $uses_wildcards
100
+					? $this->request->matches($key)
101
+					: $this->request->requestParamIsSet($key);
102
+				if ($route_found) {
103
+					$current_route = $uses_wildcards
104
+						? $this->request->getMatch($key)
105
+						: $this->request->getRequestParam($key);
106
+					$current_route = sanitize_text_field($current_route);
107
+					if ($current_route) {
108
+						$current_route = array($key, $current_route);
109
+						break;
110
+					}
111
+				}
112
+			}
113
+		}
114
+		// sorry, but I can't read what you route !
115
+		if (empty($current_route)) {
116
+			return null;
117
+		}
118
+		// add route to previous routes array
119
+		self::$_previous_routes[] = $current_route;
120
+		return $current_route;
121
+	}
122 122
 
123 123
 
124
-    /**
125
-     * this method simply takes a valid route, and resolves what module class method the route points to
126
-     *
127
-     * @param string $key
128
-     * @param string $current_route
129
-     * @return EED_Module|object|boolean|null
130
-     * @throws EE_Error
131
-     * @throws ReflectionException
132
-     */
133
-    public function resolve_route($key, $current_route)
134
-    {
135
-        // get module method that route has been mapped to
136
-        $module_method = EE_Config::get_route($current_route, $key);
137
-        // verify result was returned
138
-        if (empty($module_method)) {
139
-            $msg = sprintf(
140
-                __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
141
-                $current_route
142
-            );
143
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
144
-            return false;
145
-        }
146
-        // verify that result is an array
147
-        if (! is_array($module_method)) {
148
-            $msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
149
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
150
-            return false;
151
-        }
152
-        // grab module name
153
-        $module_name = $module_method[0];
154
-        // verify that a class method was registered properly
155
-        if (! isset($module_method[1])) {
156
-            $msg = sprintf(
157
-                __('A class method for the %s  route has not been properly registered.', 'event_espresso'),
158
-                $current_route
159
-            );
160
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
161
-            return false;
162
-        }
163
-        // grab method
164
-        $method = $module_method[1];
165
-        // verify that class exists
166
-        if (! class_exists($module_name)) {
167
-            $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
168
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
169
-            return false;
170
-        }
171
-        // verify that method exists
172
-        if (! method_exists($module_name, $method)) {
173
-            $msg = sprintf(
174
-                __('The class method %s for the %s route is in invalid.', 'event_espresso'),
175
-                $method,
176
-                $current_route
177
-            );
178
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
179
-            return false;
180
-        }
181
-        // instantiate module and call route method
182
-        return $this->_module_router($module_name, $method);
183
-    }
124
+	/**
125
+	 * this method simply takes a valid route, and resolves what module class method the route points to
126
+	 *
127
+	 * @param string $key
128
+	 * @param string $current_route
129
+	 * @return EED_Module|object|boolean|null
130
+	 * @throws EE_Error
131
+	 * @throws ReflectionException
132
+	 */
133
+	public function resolve_route($key, $current_route)
134
+	{
135
+		// get module method that route has been mapped to
136
+		$module_method = EE_Config::get_route($current_route, $key);
137
+		// verify result was returned
138
+		if (empty($module_method)) {
139
+			$msg = sprintf(
140
+				__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
141
+				$current_route
142
+			);
143
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
144
+			return false;
145
+		}
146
+		// verify that result is an array
147
+		if (! is_array($module_method)) {
148
+			$msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
149
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
150
+			return false;
151
+		}
152
+		// grab module name
153
+		$module_name = $module_method[0];
154
+		// verify that a class method was registered properly
155
+		if (! isset($module_method[1])) {
156
+			$msg = sprintf(
157
+				__('A class method for the %s  route has not been properly registered.', 'event_espresso'),
158
+				$current_route
159
+			);
160
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
161
+			return false;
162
+		}
163
+		// grab method
164
+		$method = $module_method[1];
165
+		// verify that class exists
166
+		if (! class_exists($module_name)) {
167
+			$msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
168
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
169
+			return false;
170
+		}
171
+		// verify that method exists
172
+		if (! method_exists($module_name, $method)) {
173
+			$msg = sprintf(
174
+				__('The class method %s for the %s route is in invalid.', 'event_espresso'),
175
+				$method,
176
+				$current_route
177
+			);
178
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
179
+			return false;
180
+		}
181
+		// instantiate module and call route method
182
+		return $this->_module_router($module_name, $method);
183
+	}
184 184
 
185 185
 
186
-    /**
187
-     * this method instantiates modules and calls the method that was defined when the route was registered
188
-     *
189
-     * @param string $module_name
190
-     * @return EED_Module|object|null
191
-     */
192
-    public static function module_factory($module_name)
193
-    {
194
-        if ($module_name === 'EED_Module') {
195
-            EE_Error::add_error(
196
-                sprintf(
197
-                    __(
198
-                        'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
199
-                        'event_espresso'
200
-                    ),
201
-                    $module_name
202
-                ),
203
-                __FILE__,
204
-                __FUNCTION__,
205
-                __LINE__
206
-            );
207
-            return null;
208
-        }
209
-        // instantiate module class
210
-        $module = new $module_name();
211
-        // ensure that class is actually a module
212
-        if (! $module instanceof EED_Module) {
213
-            EE_Error::add_error(
214
-                sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
215
-                __FILE__,
216
-                __FUNCTION__,
217
-                __LINE__
218
-            );
219
-            return null;
220
-        }
221
-        return $module;
222
-    }
186
+	/**
187
+	 * this method instantiates modules and calls the method that was defined when the route was registered
188
+	 *
189
+	 * @param string $module_name
190
+	 * @return EED_Module|object|null
191
+	 */
192
+	public static function module_factory($module_name)
193
+	{
194
+		if ($module_name === 'EED_Module') {
195
+			EE_Error::add_error(
196
+				sprintf(
197
+					__(
198
+						'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
199
+						'event_espresso'
200
+					),
201
+					$module_name
202
+				),
203
+				__FILE__,
204
+				__FUNCTION__,
205
+				__LINE__
206
+			);
207
+			return null;
208
+		}
209
+		// instantiate module class
210
+		$module = new $module_name();
211
+		// ensure that class is actually a module
212
+		if (! $module instanceof EED_Module) {
213
+			EE_Error::add_error(
214
+				sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
215
+				__FILE__,
216
+				__FUNCTION__,
217
+				__LINE__
218
+			);
219
+			return null;
220
+		}
221
+		return $module;
222
+	}
223 223
 
224 224
 
225
-    /**
226
-     * this method instantiates modules and calls the method that was defined when the route was registered
227
-     *
228
-     * @param string $module_name
229
-     * @param string $method
230
-     * @return EED_Module|null
231
-     * @throws EE_Error
232
-     * @throws ReflectionException
233
-     */
234
-    private function _module_router($module_name, $method)
235
-    {
236
-        // instantiate module class
237
-        $module = EE_Module_Request_Router::module_factory($module_name);
238
-        if ($module instanceof EED_Module) {
239
-            // and call whatever action the route was for
240
-            try {
241
-                $module->{$method}($this->WP_Query);
242
-            } catch (EE_Error $e) {
243
-                $e->get_error();
244
-                return null;
245
-            }
246
-        }
247
-        return $module;
248
-    }
225
+	/**
226
+	 * this method instantiates modules and calls the method that was defined when the route was registered
227
+	 *
228
+	 * @param string $module_name
229
+	 * @param string $method
230
+	 * @return EED_Module|null
231
+	 * @throws EE_Error
232
+	 * @throws ReflectionException
233
+	 */
234
+	private function _module_router($module_name, $method)
235
+	{
236
+		// instantiate module class
237
+		$module = EE_Module_Request_Router::module_factory($module_name);
238
+		if ($module instanceof EED_Module) {
239
+			// and call whatever action the route was for
240
+			try {
241
+				$module->{$method}($this->WP_Query);
242
+			} catch (EE_Error $e) {
243
+				$e->get_error();
244
+				return null;
245
+			}
246
+		}
247
+		return $module;
248
+	}
249 249
 
250 250
 
251
-    /**
252
-     * @param $current_route
253
-     * @return string
254
-     */
255
-    public function get_forward($current_route)
256
-    {
257
-        return EE_Config::get_forward($current_route);
258
-    }
251
+	/**
252
+	 * @param $current_route
253
+	 * @return string
254
+	 */
255
+	public function get_forward($current_route)
256
+	{
257
+		return EE_Config::get_forward($current_route);
258
+	}
259 259
 
260 260
 
261
-    /**
262
-     * @param $current_route
263
-     * @return string
264
-     */
265
-    public function get_view($current_route)
266
-    {
267
-        return EE_Config::get_view($current_route);
268
-    }
261
+	/**
262
+	 * @param $current_route
263
+	 * @return string
264
+	 */
265
+	public function get_view($current_route)
266
+	{
267
+		return EE_Config::get_view($current_route);
268
+	}
269 269
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 2 patches
Indentation   +3179 added lines, -3179 removed lines patch added patch discarded remove patch
@@ -15,2540 +15,2540 @@  discard block
 block discarded – undo
15 15
 final class EE_Config implements ResettableInterface
16 16
 {
17 17
 
18
-    const OPTION_NAME = 'ee_config';
19
-
20
-    const LOG_NAME = 'ee_config_log';
21
-
22
-    const LOG_LENGTH = 100;
23
-
24
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
25
-
26
-    /**
27
-     *    instance of the EE_Config object
28
-     *
29
-     * @var    EE_Config $_instance
30
-     * @access    private
31
-     */
32
-    private static $_instance;
33
-
34
-    /**
35
-     * @var boolean $_logging_enabled
36
-     */
37
-    private static $_logging_enabled = false;
38
-
39
-    /**
40
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
41
-     */
42
-    private $legacy_shortcodes_manager;
43
-
44
-    /**
45
-     * An StdClass whose property names are addon slugs,
46
-     * and values are their config classes
47
-     *
48
-     * @var StdClass
49
-     */
50
-    public $addons;
51
-
52
-    /**
53
-     * @var EE_Admin_Config
54
-     */
55
-    public $admin;
56
-
57
-    /**
58
-     * @var EE_Core_Config
59
-     */
60
-    public $core;
61
-
62
-    /**
63
-     * @var EE_Currency_Config
64
-     */
65
-    public $currency;
66
-
67
-    /**
68
-     * @var EE_Organization_Config
69
-     */
70
-    public $organization;
71
-
72
-    /**
73
-     * @var EE_Registration_Config
74
-     */
75
-    public $registration;
76
-
77
-    /**
78
-     * @var EE_Template_Config
79
-     */
80
-    public $template_settings;
81
-
82
-    /**
83
-     * Holds EE environment values.
84
-     *
85
-     * @var EE_Environment_Config
86
-     */
87
-    public $environment;
88
-
89
-    /**
90
-     * settings pertaining to Google maps
91
-     *
92
-     * @var EE_Map_Config
93
-     */
94
-    public $map_settings;
95
-
96
-    /**
97
-     * settings pertaining to Taxes
98
-     *
99
-     * @var EE_Tax_Config
100
-     */
101
-    public $tax_settings;
102
-
103
-    /**
104
-     * Settings pertaining to global messages settings.
105
-     *
106
-     * @var EE_Messages_Config
107
-     */
108
-    public $messages;
109
-
110
-    /**
111
-     * @deprecated
112
-     * @var EE_Gateway_Config
113
-     */
114
-    public $gateway;
115
-
116
-    /**
117
-     * @var    array $_addon_option_names
118
-     * @access    private
119
-     */
120
-    private $_addon_option_names = array();
121
-
122
-    /**
123
-     * @var    array $_module_route_map
124
-     * @access    private
125
-     */
126
-    private static $_module_route_map = array();
127
-
128
-    /**
129
-     * @var    array $_module_forward_map
130
-     * @access    private
131
-     */
132
-    private static $_module_forward_map = array();
133
-
134
-    /**
135
-     * @var    array $_module_view_map
136
-     * @access    private
137
-     */
138
-    private static $_module_view_map = array();
139
-
140
-
141
-    /**
142
-     * @singleton method used to instantiate class object
143
-     * @access    public
144
-     * @return EE_Config instance
145
-     */
146
-    public static function instance()
147
-    {
148
-        // check if class object is instantiated, and instantiated properly
149
-        if (! self::$_instance instanceof EE_Config) {
150
-            self::$_instance = new self();
151
-        }
152
-        return self::$_instance;
153
-    }
154
-
155
-
156
-    /**
157
-     * Resets the config
158
-     *
159
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
160
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
161
-     *                               reflect its state in the database
162
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
163
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
164
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
165
-     *                               site was put into maintenance mode)
166
-     * @return EE_Config
167
-     */
168
-    public static function reset($hard_reset = false, $reinstantiate = true)
169
-    {
170
-        if (self::$_instance instanceof EE_Config) {
171
-            if ($hard_reset) {
172
-                self::$_instance->legacy_shortcodes_manager = null;
173
-                self::$_instance->_addon_option_names = array();
174
-                self::$_instance->_initialize_config();
175
-                self::$_instance->update_espresso_config();
176
-            }
177
-            self::$_instance->update_addon_option_names();
178
-        }
179
-        self::$_instance = null;
180
-        // we don't need to reset the static properties imo because those should
181
-        // only change when a module is added or removed. Currently we don't
182
-        // support removing a module during a request when it previously existed
183
-        if ($reinstantiate) {
184
-            return self::instance();
185
-        } else {
186
-            return null;
187
-        }
188
-    }
189
-
190
-
191
-    /**
192
-     *    class constructor
193
-     *
194
-     * @access    private
195
-     */
196
-    private function __construct()
197
-    {
198
-        do_action('AHEE__EE_Config__construct__begin', $this);
199
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
200
-        // setup empty config classes
201
-        $this->_initialize_config();
202
-        // load existing EE site settings
203
-        $this->_load_core_config();
204
-        // confirm everything loaded correctly and set filtered defaults if not
205
-        $this->_verify_config();
206
-        //  register shortcodes and modules
207
-        add_action(
208
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
209
-            array($this, 'register_shortcodes_and_modules'),
210
-            999
211
-        );
212
-        //  initialize shortcodes and modules
213
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
214
-        // register widgets
215
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
216
-        // shutdown
217
-        add_action('shutdown', array($this, 'shutdown'), 10);
218
-        // construct__end hook
219
-        do_action('AHEE__EE_Config__construct__end', $this);
220
-        // hardcoded hack
221
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
222
-    }
223
-
224
-
225
-    /**
226
-     * @return boolean
227
-     */
228
-    public static function logging_enabled()
229
-    {
230
-        return self::$_logging_enabled;
231
-    }
232
-
233
-
234
-    /**
235
-     * use to get the current theme if needed from static context
236
-     *
237
-     * @return string current theme set.
238
-     */
239
-    public static function get_current_theme()
240
-    {
241
-        return isset(self::$_instance->template_settings->current_espresso_theme)
242
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
243
-    }
244
-
245
-
246
-    /**
247
-     *        _initialize_config
248
-     *
249
-     * @access private
250
-     * @return void
251
-     */
252
-    private function _initialize_config()
253
-    {
254
-        EE_Config::trim_log();
255
-        // set defaults
256
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
257
-        $this->addons = new stdClass();
258
-        // set _module_route_map
259
-        EE_Config::$_module_route_map = array();
260
-        // set _module_forward_map
261
-        EE_Config::$_module_forward_map = array();
262
-        // set _module_view_map
263
-        EE_Config::$_module_view_map = array();
264
-    }
265
-
266
-
267
-    /**
268
-     *        load core plugin configuration
269
-     *
270
-     * @access private
271
-     * @return void
272
-     */
273
-    private function _load_core_config()
274
-    {
275
-        // load_core_config__start hook
276
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
277
-        $espresso_config = $this->get_espresso_config();
278
-        foreach ($espresso_config as $config => $settings) {
279
-            // load_core_config__start hook
280
-            $settings = apply_filters(
281
-                'FHEE__EE_Config___load_core_config__config_settings',
282
-                $settings,
283
-                $config,
284
-                $this
285
-            );
286
-            if (is_object($settings) && property_exists($this, $config)) {
287
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
288
-                // call configs populate method to ensure any defaults are set for empty values.
289
-                if (method_exists($settings, 'populate')) {
290
-                    $this->{$config}->populate();
291
-                }
292
-                if (method_exists($settings, 'do_hooks')) {
293
-                    $this->{$config}->do_hooks();
294
-                }
295
-            }
296
-        }
297
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
298
-            $this->update_espresso_config();
299
-        }
300
-        // load_core_config__end hook
301
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
302
-    }
303
-
304
-
305
-    /**
306
-     *    _verify_config
307
-     *
308
-     * @access    protected
309
-     * @return    void
310
-     */
311
-    protected function _verify_config()
312
-    {
313
-        $this->core = $this->core instanceof EE_Core_Config
314
-            ? $this->core
315
-            : new EE_Core_Config();
316
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
317
-        $this->organization = $this->organization instanceof EE_Organization_Config
318
-            ? $this->organization
319
-            : new EE_Organization_Config();
320
-        $this->organization = apply_filters(
321
-            'FHEE__EE_Config___initialize_config__organization',
322
-            $this->organization
323
-        );
324
-        $this->currency = $this->currency instanceof EE_Currency_Config
325
-            ? $this->currency
326
-            : new EE_Currency_Config();
327
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
328
-        $this->registration = $this->registration instanceof EE_Registration_Config
329
-            ? $this->registration
330
-            : new EE_Registration_Config();
331
-        $this->registration = apply_filters(
332
-            'FHEE__EE_Config___initialize_config__registration',
333
-            $this->registration
334
-        );
335
-        $this->admin = $this->admin instanceof EE_Admin_Config
336
-            ? $this->admin
337
-            : new EE_Admin_Config();
338
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
339
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
340
-            ? $this->template_settings
341
-            : new EE_Template_Config();
342
-        $this->template_settings = apply_filters(
343
-            'FHEE__EE_Config___initialize_config__template_settings',
344
-            $this->template_settings
345
-        );
346
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
347
-            ? $this->map_settings
348
-            : new EE_Map_Config();
349
-        $this->map_settings = apply_filters(
350
-            'FHEE__EE_Config___initialize_config__map_settings',
351
-            $this->map_settings
352
-        );
353
-        $this->environment = $this->environment instanceof EE_Environment_Config
354
-            ? $this->environment
355
-            : new EE_Environment_Config();
356
-        $this->environment = apply_filters(
357
-            'FHEE__EE_Config___initialize_config__environment',
358
-            $this->environment
359
-        );
360
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
361
-            ? $this->tax_settings
362
-            : new EE_Tax_Config();
363
-        $this->tax_settings = apply_filters(
364
-            'FHEE__EE_Config___initialize_config__tax_settings',
365
-            $this->tax_settings
366
-        );
367
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
368
-        $this->messages = $this->messages instanceof EE_Messages_Config
369
-            ? $this->messages
370
-            : new EE_Messages_Config();
371
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
372
-            ? $this->gateway
373
-            : new EE_Gateway_Config();
374
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
375
-        $this->legacy_shortcodes_manager = null;
376
-    }
377
-
378
-
379
-    /**
380
-     *    get_espresso_config
381
-     *
382
-     * @access    public
383
-     * @return    array of espresso config stuff
384
-     */
385
-    public function get_espresso_config()
386
-    {
387
-        // grab espresso configuration
388
-        return apply_filters(
389
-            'FHEE__EE_Config__get_espresso_config__CFG',
390
-            get_option(EE_Config::OPTION_NAME, array())
391
-        );
392
-    }
393
-
394
-
395
-    /**
396
-     *    double_check_config_comparison
397
-     *
398
-     * @access    public
399
-     * @param string $option
400
-     * @param        $old_value
401
-     * @param        $value
402
-     */
403
-    public function double_check_config_comparison($option = '', $old_value, $value)
404
-    {
405
-        // make sure we're checking the ee config
406
-        if ($option === EE_Config::OPTION_NAME) {
407
-            // run a loose comparison of the old value against the new value for type and properties,
408
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
409
-            if ($value != $old_value) {
410
-                // if they are NOT the same, then remove the hook,
411
-                // which means the subsequent update results will be based solely on the update query results
412
-                // the reason we do this is because, as stated above,
413
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
414
-                // this happens PRIOR to serialization and any subsequent update.
415
-                // If values are found to match their previous old value,
416
-                // then WP bails before performing any update.
417
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
418
-                // it just pulled from the db, with the one being passed to it (which will not match).
419
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
420
-                // MySQL MAY ALSO NOT perform the update because
421
-                // the string it sees in the db looks the same as the new one it has been passed!!!
422
-                // This results in the query returning an "affected rows" value of ZERO,
423
-                // which gets returned immediately by WP update_option and looks like an error.
424
-                remove_action('update_option', array($this, 'check_config_updated'));
425
-            }
426
-        }
427
-    }
428
-
429
-
430
-    /**
431
-     *    update_espresso_config
432
-     *
433
-     * @access   public
434
-     */
435
-    protected function _reset_espresso_addon_config()
436
-    {
437
-        $this->_addon_option_names = array();
438
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
439
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
440
-            if ($addon_config_obj instanceof EE_Config_Base) {
441
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
442
-            }
443
-            $this->addons->{$addon_name} = null;
444
-        }
445
-    }
446
-
447
-
448
-    /**
449
-     *    update_espresso_config
450
-     *
451
-     * @access   public
452
-     * @param   bool $add_success
453
-     * @param   bool $add_error
454
-     * @return   bool
455
-     */
456
-    public function update_espresso_config($add_success = false, $add_error = true)
457
-    {
458
-        // don't allow config updates during WP heartbeats
459
-        /** @var RequestInterface $request */
460
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
461
-        if ($request->isWordPressHeartbeat()) {
462
-            return false;
463
-        }
464
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
465
-        // $clone = clone( self::$_instance );
466
-        // self::$_instance = NULL;
467
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
468
-        $this->_reset_espresso_addon_config();
469
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
470
-        // but BEFORE the actual update occurs
471
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
472
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
473
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
474
-        $this->legacy_shortcodes_manager = null;
475
-        // now update "ee_config"
476
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
477
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
478
-        EE_Config::log(EE_Config::OPTION_NAME);
479
-        // if not saved... check if the hook we just added still exists;
480
-        // if it does, it means one of two things:
481
-        // that update_option bailed at the($value === $old_value) conditional,
482
-        // or...
483
-        // the db update query returned 0 rows affected
484
-        // (probably because the data  value was the same from it's perspective)
485
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
486
-        // but just means no update occurred, so don't display an error to the user.
487
-        // BUT... if update_option returns FALSE, AND the hook is missing,
488
-        // then it means that something truly went wrong
489
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
490
-        // remove our action since we don't want it in the system anymore
491
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
492
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
493
-        // self::$_instance = $clone;
494
-        // unset( $clone );
495
-        // if config remains the same or was updated successfully
496
-        if ($saved) {
497
-            if ($add_success) {
498
-                EE_Error::add_success(
499
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
500
-                    __FILE__,
501
-                    __FUNCTION__,
502
-                    __LINE__
503
-                );
504
-            }
505
-            return true;
506
-        } else {
507
-            if ($add_error) {
508
-                EE_Error::add_error(
509
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
510
-                    __FILE__,
511
-                    __FUNCTION__,
512
-                    __LINE__
513
-                );
514
-            }
515
-            return false;
516
-        }
517
-    }
518
-
519
-
520
-    /**
521
-     *    _verify_config_params
522
-     *
523
-     * @access    private
524
-     * @param    string         $section
525
-     * @param    string         $name
526
-     * @param    string         $config_class
527
-     * @param    EE_Config_Base $config_obj
528
-     * @param    array          $tests_to_run
529
-     * @param    bool           $display_errors
530
-     * @return    bool    TRUE on success, FALSE on fail
531
-     */
532
-    private function _verify_config_params(
533
-        $section = '',
534
-        $name = '',
535
-        $config_class = '',
536
-        $config_obj = null,
537
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
538
-        $display_errors = true
539
-    ) {
540
-        try {
541
-            foreach ($tests_to_run as $test) {
542
-                switch ($test) {
543
-                    // TEST #1 : check that section was set
544
-                    case 1:
545
-                        if (empty($section)) {
546
-                            if ($display_errors) {
547
-                                throw new EE_Error(
548
-                                    sprintf(
549
-                                        __(
550
-                                            'No configuration section has been provided while attempting to save "%s".',
551
-                                            'event_espresso'
552
-                                        ),
553
-                                        $config_class
554
-                                    )
555
-                                );
556
-                            }
557
-                            return false;
558
-                        }
559
-                        break;
560
-                    // TEST #2 : check that settings section exists
561
-                    case 2:
562
-                        if (! isset($this->{$section})) {
563
-                            if ($display_errors) {
564
-                                throw new EE_Error(
565
-                                    sprintf(
566
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
567
-                                        $section
568
-                                    )
569
-                                );
570
-                            }
571
-                            return false;
572
-                        }
573
-                        break;
574
-                    // TEST #3 : check that section is the proper format
575
-                    case 3:
576
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
577
-                        ) {
578
-                            if ($display_errors) {
579
-                                throw new EE_Error(
580
-                                    sprintf(
581
-                                        __(
582
-                                            'The "%s" configuration settings have not been formatted correctly.',
583
-                                            'event_espresso'
584
-                                        ),
585
-                                        $section
586
-                                    )
587
-                                );
588
-                            }
589
-                            return false;
590
-                        }
591
-                        break;
592
-                    // TEST #4 : check that config section name has been set
593
-                    case 4:
594
-                        if (empty($name)) {
595
-                            if ($display_errors) {
596
-                                throw new EE_Error(
597
-                                    __(
598
-                                        'No name has been provided for the specific configuration section.',
599
-                                        'event_espresso'
600
-                                    )
601
-                                );
602
-                            }
603
-                            return false;
604
-                        }
605
-                        break;
606
-                    // TEST #5 : check that a config class name has been set
607
-                    case 5:
608
-                        if (empty($config_class)) {
609
-                            if ($display_errors) {
610
-                                throw new EE_Error(
611
-                                    __(
612
-                                        'No class name has been provided for the specific configuration section.',
613
-                                        'event_espresso'
614
-                                    )
615
-                                );
616
-                            }
617
-                            return false;
618
-                        }
619
-                        break;
620
-                    // TEST #6 : verify config class is accessible
621
-                    case 6:
622
-                        if (! class_exists($config_class)) {
623
-                            if ($display_errors) {
624
-                                throw new EE_Error(
625
-                                    sprintf(
626
-                                        __(
627
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
628
-                                            'event_espresso'
629
-                                        ),
630
-                                        $config_class
631
-                                    )
632
-                                );
633
-                            }
634
-                            return false;
635
-                        }
636
-                        break;
637
-                    // TEST #7 : check that config has even been set
638
-                    case 7:
639
-                        if (! isset($this->{$section}->{$name})) {
640
-                            if ($display_errors) {
641
-                                throw new EE_Error(
642
-                                    sprintf(
643
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
644
-                                        $section,
645
-                                        $name
646
-                                    )
647
-                                );
648
-                            }
649
-                            return false;
650
-                        } else {
651
-                            // and make sure it's not serialized
652
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
653
-                        }
654
-                        break;
655
-                    // TEST #8 : check that config is the requested type
656
-                    case 8:
657
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
658
-                            if ($display_errors) {
659
-                                throw new EE_Error(
660
-                                    sprintf(
661
-                                        __(
662
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
663
-                                            'event_espresso'
664
-                                        ),
665
-                                        $section,
666
-                                        $name,
667
-                                        $config_class
668
-                                    )
669
-                                );
670
-                            }
671
-                            return false;
672
-                        }
673
-                        break;
674
-                    // TEST #9 : verify config object
675
-                    case 9:
676
-                        if (! $config_obj instanceof EE_Config_Base) {
677
-                            if ($display_errors) {
678
-                                throw new EE_Error(
679
-                                    sprintf(
680
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
681
-                                        print_r($config_obj, true)
682
-                                    )
683
-                                );
684
-                            }
685
-                            return false;
686
-                        }
687
-                        break;
688
-                }
689
-            }
690
-        } catch (EE_Error $e) {
691
-            $e->get_error();
692
-        }
693
-        // you have successfully run the gauntlet
694
-        return true;
695
-    }
696
-
697
-
698
-    /**
699
-     *    _generate_config_option_name
700
-     *
701
-     * @access        protected
702
-     * @param        string $section
703
-     * @param        string $name
704
-     * @return        string
705
-     */
706
-    private function _generate_config_option_name($section = '', $name = '')
707
-    {
708
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
709
-    }
710
-
711
-
712
-    /**
713
-     *    _set_config_class
714
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
715
-     *
716
-     * @access    private
717
-     * @param    string $config_class
718
-     * @param    string $name
719
-     * @return    string
720
-     */
721
-    private function _set_config_class($config_class = '', $name = '')
722
-    {
723
-        return ! empty($config_class)
724
-            ? $config_class
725
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
726
-    }
727
-
728
-
729
-    /**
730
-     *    set_config
731
-     *
732
-     * @access    protected
733
-     * @param    string         $section
734
-     * @param    string         $name
735
-     * @param    string         $config_class
736
-     * @param    EE_Config_Base $config_obj
737
-     * @return    EE_Config_Base
738
-     */
739
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
740
-    {
741
-        // ensure config class is set to something
742
-        $config_class = $this->_set_config_class($config_class, $name);
743
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
744
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
745
-            return null;
746
-        }
747
-        $config_option_name = $this->_generate_config_option_name($section, $name);
748
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
749
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
750
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
751
-            $this->update_addon_option_names();
752
-        }
753
-        // verify the incoming config object but suppress errors
754
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
755
-            $config_obj = new $config_class();
756
-        }
757
-        if (get_option($config_option_name)) {
758
-            EE_Config::log($config_option_name);
759
-            update_option($config_option_name, $config_obj);
760
-            $this->{$section}->{$name} = $config_obj;
761
-            return $this->{$section}->{$name};
762
-        } else {
763
-            // create a wp-option for this config
764
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
765
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
766
-                return $this->{$section}->{$name};
767
-            } else {
768
-                EE_Error::add_error(
769
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
770
-                    __FILE__,
771
-                    __FUNCTION__,
772
-                    __LINE__
773
-                );
774
-                return null;
775
-            }
776
-        }
777
-    }
778
-
779
-
780
-    /**
781
-     *    update_config
782
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
783
-     *
784
-     * @access    public
785
-     * @param    string                $section
786
-     * @param    string                $name
787
-     * @param    EE_Config_Base|string $config_obj
788
-     * @param    bool                  $throw_errors
789
-     * @return    bool
790
-     */
791
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
792
-    {
793
-        // don't allow config updates during WP heartbeats
794
-        /** @var RequestInterface $request */
795
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
796
-        if ($request->isWordPressHeartbeat()) {
797
-            return false;
798
-        }
799
-        $config_obj = maybe_unserialize($config_obj);
800
-        // get class name of the incoming object
801
-        $config_class = get_class($config_obj);
802
-        // run tests 1-5 and 9 to verify config
803
-        if (! $this->_verify_config_params(
804
-            $section,
805
-            $name,
806
-            $config_class,
807
-            $config_obj,
808
-            array(1, 2, 3, 4, 7, 9)
809
-        )
810
-        ) {
811
-            return false;
812
-        }
813
-        $config_option_name = $this->_generate_config_option_name($section, $name);
814
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
815
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
816
-            // save new config to db
817
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
818
-                return true;
819
-            }
820
-        } else {
821
-            // first check if the record already exists
822
-            $existing_config = get_option($config_option_name);
823
-            $config_obj = serialize($config_obj);
824
-            // just return if db record is already up to date (NOT type safe comparison)
825
-            if ($existing_config == $config_obj) {
826
-                $this->{$section}->{$name} = $config_obj;
827
-                return true;
828
-            } elseif (update_option($config_option_name, $config_obj)) {
829
-                EE_Config::log($config_option_name);
830
-                // update wp-option for this config class
831
-                $this->{$section}->{$name} = $config_obj;
832
-                return true;
833
-            } elseif ($throw_errors) {
834
-                EE_Error::add_error(
835
-                    sprintf(
836
-                        __(
837
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
838
-                            'event_espresso'
839
-                        ),
840
-                        $config_class,
841
-                        'EE_Config->' . $section . '->' . $name
842
-                    ),
843
-                    __FILE__,
844
-                    __FUNCTION__,
845
-                    __LINE__
846
-                );
847
-            }
848
-        }
849
-        return false;
850
-    }
851
-
852
-
853
-    /**
854
-     *    get_config
855
-     *
856
-     * @access    public
857
-     * @param    string $section
858
-     * @param    string $name
859
-     * @param    string $config_class
860
-     * @return    mixed EE_Config_Base | NULL
861
-     */
862
-    public function get_config($section = '', $name = '', $config_class = '')
863
-    {
864
-        // ensure config class is set to something
865
-        $config_class = $this->_set_config_class($config_class, $name);
866
-        // run tests 1-4, 6 and 7 to verify that all params have been set
867
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
868
-            return null;
869
-        }
870
-        // now test if the requested config object exists, but suppress errors
871
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
872
-            // config already exists, so pass it back
873
-            return $this->{$section}->{$name};
874
-        }
875
-        // load config option from db if it exists
876
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
877
-        // verify the newly retrieved config object, but suppress errors
878
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
879
-            // config is good, so set it and pass it back
880
-            $this->{$section}->{$name} = $config_obj;
881
-            return $this->{$section}->{$name};
882
-        }
883
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
884
-        $config_obj = $this->set_config($section, $name, $config_class);
885
-        // verify the newly created config object
886
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
887
-            return $this->{$section}->{$name};
888
-        } else {
889
-            EE_Error::add_error(
890
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
891
-                __FILE__,
892
-                __FUNCTION__,
893
-                __LINE__
894
-            );
895
-        }
896
-        return null;
897
-    }
898
-
899
-
900
-    /**
901
-     *    get_config_option
902
-     *
903
-     * @access    public
904
-     * @param    string $config_option_name
905
-     * @return    mixed EE_Config_Base | FALSE
906
-     */
907
-    public function get_config_option($config_option_name = '')
908
-    {
909
-        // retrieve the wp-option for this config class.
910
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
911
-        if (empty($config_option)) {
912
-            EE_Config::log($config_option_name . '-NOT-FOUND');
913
-        }
914
-        return $config_option;
915
-    }
916
-
917
-
918
-    /**
919
-     * log
920
-     *
921
-     * @param string $config_option_name
922
-     */
923
-    public static function log($config_option_name = '')
924
-    {
925
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
926
-            $config_log = get_option(EE_Config::LOG_NAME, array());
927
-            // copy incoming $_REQUEST and sanitize it so we can save it
928
-            $_request = $_REQUEST;
929
-            array_walk_recursive($_request, 'sanitize_text_field');
930
-            $config_log[ (string) microtime(true) ] = array(
931
-                'config_name' => $config_option_name,
932
-                'request'     => $_request,
933
-            );
934
-            update_option(EE_Config::LOG_NAME, $config_log);
935
-        }
936
-    }
937
-
938
-
939
-    /**
940
-     * trim_log
941
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
942
-     */
943
-    public static function trim_log()
944
-    {
945
-        if (! EE_Config::logging_enabled()) {
946
-            return;
947
-        }
948
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
949
-        $log_length = count($config_log);
950
-        if ($log_length > EE_Config::LOG_LENGTH) {
951
-            ksort($config_log);
952
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
953
-            update_option(EE_Config::LOG_NAME, $config_log);
954
-        }
955
-    }
956
-
957
-
958
-    /**
959
-     *    get_page_for_posts
960
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
961
-     *    wp-option "page_for_posts", or "posts" if no page is selected
962
-     *
963
-     * @access    public
964
-     * @return    string
965
-     */
966
-    public static function get_page_for_posts()
967
-    {
968
-        $page_for_posts = get_option('page_for_posts');
969
-        if (! $page_for_posts) {
970
-            return 'posts';
971
-        }
972
-        /** @type WPDB $wpdb */
973
-        global $wpdb;
974
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
975
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
976
-    }
977
-
978
-
979
-    /**
980
-     *    register_shortcodes_and_modules.
981
-     *    At this point, it's too early to tell if we're maintenance mode or not.
982
-     *    In fact, this is where we give modules a chance to let core know they exist
983
-     *    so they can help trigger maintenance mode if it's needed
984
-     *
985
-     * @access    public
986
-     * @return    void
987
-     */
988
-    public function register_shortcodes_and_modules()
989
-    {
990
-        // allow modules to set hooks for the rest of the system
991
-        EE_Registry::instance()->modules = $this->_register_modules();
992
-    }
993
-
994
-
995
-    /**
996
-     *    initialize_shortcodes_and_modules
997
-     *    meaning they can start adding their hooks to get stuff done
998
-     *
999
-     * @access    public
1000
-     * @return    void
1001
-     */
1002
-    public function initialize_shortcodes_and_modules()
1003
-    {
1004
-        // allow modules to set hooks for the rest of the system
1005
-        $this->_initialize_modules();
1006
-    }
1007
-
1008
-
1009
-    /**
1010
-     *    widgets_init
1011
-     *
1012
-     * @access private
1013
-     * @return void
1014
-     */
1015
-    public function widgets_init()
1016
-    {
1017
-        // only init widgets on admin pages when not in complete maintenance, and
1018
-        // on frontend when not in any maintenance mode
1019
-        if (! EE_Maintenance_Mode::instance()->level()
1020
-            || (
1021
-                is_admin()
1022
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1023
-            )
1024
-        ) {
1025
-            // grab list of installed widgets
1026
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1027
-            // filter list of modules to register
1028
-            $widgets_to_register = apply_filters(
1029
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1030
-                $widgets_to_register
1031
-            );
1032
-            if (! empty($widgets_to_register)) {
1033
-                // cycle thru widget folders
1034
-                foreach ($widgets_to_register as $widget_path) {
1035
-                    // add to list of installed widget modules
1036
-                    EE_Config::register_ee_widget($widget_path);
1037
-                }
1038
-            }
1039
-            // filter list of installed modules
1040
-            EE_Registry::instance()->widgets = apply_filters(
1041
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1042
-                EE_Registry::instance()->widgets
1043
-            );
1044
-        }
1045
-    }
1046
-
1047
-
1048
-    /**
1049
-     *    register_ee_widget - makes core aware of this widget
1050
-     *
1051
-     * @access    public
1052
-     * @param    string $widget_path - full path up to and including widget folder
1053
-     * @return    void
1054
-     */
1055
-    public static function register_ee_widget($widget_path = null)
1056
-    {
1057
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1058
-        $widget_ext = '.widget.php';
1059
-        // make all separators match
1060
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1061
-        // does the file path INCLUDE the actual file name as part of the path ?
1062
-        if (strpos($widget_path, $widget_ext) !== false) {
1063
-            // grab and shortcode file name from directory name and break apart at dots
1064
-            $file_name = explode('.', basename($widget_path));
1065
-            // take first segment from file name pieces and remove class prefix if it exists
1066
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1067
-            // sanitize shortcode directory name
1068
-            $widget = sanitize_key($widget);
1069
-            // now we need to rebuild the shortcode path
1070
-            $widget_path = explode('/', $widget_path);
1071
-            // remove last segment
1072
-            array_pop($widget_path);
1073
-            // glue it back together
1074
-            $widget_path = implode(DS, $widget_path);
1075
-        } else {
1076
-            // grab and sanitize widget directory name
1077
-            $widget = sanitize_key(basename($widget_path));
1078
-        }
1079
-        // create classname from widget directory name
1080
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1081
-        // add class prefix
1082
-        $widget_class = 'EEW_' . $widget;
1083
-        // does the widget exist ?
1084
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1085
-            $msg = sprintf(
1086
-                __(
1087
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1088
-                    'event_espresso'
1089
-                ),
1090
-                $widget_class,
1091
-                $widget_path . '/' . $widget_class . $widget_ext
1092
-            );
1093
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1094
-            return;
1095
-        }
1096
-        // load the widget class file
1097
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1098
-        // verify that class exists
1099
-        if (! class_exists($widget_class)) {
1100
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1101
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1102
-            return;
1103
-        }
1104
-        register_widget($widget_class);
1105
-        // add to array of registered widgets
1106
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1107
-    }
1108
-
1109
-
1110
-    /**
1111
-     *        _register_modules
1112
-     *
1113
-     * @access private
1114
-     * @return array
1115
-     */
1116
-    private function _register_modules()
1117
-    {
1118
-        // grab list of installed modules
1119
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1120
-        // filter list of modules to register
1121
-        $modules_to_register = apply_filters(
1122
-            'FHEE__EE_Config__register_modules__modules_to_register',
1123
-            $modules_to_register
1124
-        );
1125
-        if (! empty($modules_to_register)) {
1126
-            // loop through folders
1127
-            foreach ($modules_to_register as $module_path) {
1128
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1129
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1130
-                    && $module_path !== EE_MODULES . 'gateways'
1131
-                ) {
1132
-                    // add to list of installed modules
1133
-                    EE_Config::register_module($module_path);
1134
-                }
1135
-            }
1136
-        }
1137
-        // filter list of installed modules
1138
-        return apply_filters(
1139
-            'FHEE__EE_Config___register_modules__installed_modules',
1140
-            EE_Registry::instance()->modules
1141
-        );
1142
-    }
1143
-
1144
-
1145
-    /**
1146
-     *    register_module - makes core aware of this module
1147
-     *
1148
-     * @access    public
1149
-     * @param    string $module_path - full path up to and including module folder
1150
-     * @return    bool
1151
-     */
1152
-    public static function register_module($module_path = null)
1153
-    {
1154
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1155
-        $module_ext = '.module.php';
1156
-        // make all separators match
1157
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1158
-        // does the file path INCLUDE the actual file name as part of the path ?
1159
-        if (strpos($module_path, $module_ext) !== false) {
1160
-            // grab and shortcode file name from directory name and break apart at dots
1161
-            $module_file = explode('.', basename($module_path));
1162
-            // now we need to rebuild the shortcode path
1163
-            $module_path = explode('/', $module_path);
1164
-            // remove last segment
1165
-            array_pop($module_path);
1166
-            // glue it back together
1167
-            $module_path = implode('/', $module_path) . '/';
1168
-            // take first segment from file name pieces and sanitize it
1169
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1170
-            // ensure class prefix is added
1171
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1172
-        } else {
1173
-            // we need to generate the filename based off of the folder name
1174
-            // grab and sanitize module name
1175
-            $module = strtolower(basename($module_path));
1176
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1177
-            // like trailingslashit()
1178
-            $module_path = rtrim($module_path, '/') . '/';
1179
-            // create classname from module directory name
1180
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1181
-            // add class prefix
1182
-            $module_class = 'EED_' . $module;
1183
-        }
1184
-        // does the module exist ?
1185
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1186
-            $msg = sprintf(
1187
-                __(
1188
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1189
-                    'event_espresso'
1190
-                ),
1191
-                $module
1192
-            );
1193
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1194
-            return false;
1195
-        }
1196
-        // load the module class file
1197
-        require_once($module_path . $module_class . $module_ext);
1198
-        // verify that class exists
1199
-        if (! class_exists($module_class)) {
1200
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1201
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1202
-            return false;
1203
-        }
1204
-        // add to array of registered modules
1205
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1206
-        do_action(
1207
-            'AHEE__EE_Config__register_module__complete',
1208
-            $module_class,
1209
-            EE_Registry::instance()->modules->{$module_class}
1210
-        );
1211
-        return true;
1212
-    }
1213
-
1214
-
1215
-    /**
1216
-     *    _initialize_modules
1217
-     *    allow modules to set hooks for the rest of the system
1218
-     *
1219
-     * @access private
1220
-     * @return void
1221
-     */
1222
-    private function _initialize_modules()
1223
-    {
1224
-        // cycle thru shortcode folders
1225
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1226
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1227
-            // which set hooks ?
1228
-            if (is_admin()) {
1229
-                // fire immediately
1230
-                call_user_func(array($module_class, 'set_hooks_admin'));
1231
-            } else {
1232
-                // delay until other systems are online
1233
-                add_action(
1234
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1235
-                    array($module_class, 'set_hooks')
1236
-                );
1237
-            }
1238
-        }
1239
-    }
1240
-
1241
-
1242
-    /**
1243
-     *    register_route - adds module method routes to route_map
1244
-     *
1245
-     * @access    public
1246
-     * @param    string $route       - "pretty" public alias for module method
1247
-     * @param    string $module      - module name (classname without EED_ prefix)
1248
-     * @param    string $method_name - the actual module method to be routed to
1249
-     * @param    string $key         - url param key indicating a route is being called
1250
-     * @return    bool
1251
-     */
1252
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1253
-    {
1254
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1255
-        $module = str_replace('EED_', '', $module);
1256
-        $module_class = 'EED_' . $module;
1257
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1258
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1259
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1260
-            return false;
1261
-        }
1262
-        if (empty($route)) {
1263
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1264
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1265
-            return false;
1266
-        }
1267
-        if (! method_exists('EED_' . $module, $method_name)) {
1268
-            $msg = sprintf(
1269
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1270
-                $route
1271
-            );
1272
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1273
-            return false;
1274
-        }
1275
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1276
-        return true;
1277
-    }
1278
-
1279
-
1280
-    /**
1281
-     *    get_route - get module method route
1282
-     *
1283
-     * @access    public
1284
-     * @param    string $route - "pretty" public alias for module method
1285
-     * @param    string $key   - url param key indicating a route is being called
1286
-     * @return    string
1287
-     */
1288
-    public static function get_route($route = null, $key = 'ee')
1289
-    {
1290
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1291
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1292
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1293
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1294
-        }
1295
-        return null;
1296
-    }
1297
-
1298
-
1299
-    /**
1300
-     *    get_routes - get ALL module method routes
1301
-     *
1302
-     * @access    public
1303
-     * @return    array
1304
-     */
1305
-    public static function get_routes()
1306
-    {
1307
-        return EE_Config::$_module_route_map;
1308
-    }
1309
-
1310
-
1311
-    /**
1312
-     *    register_forward - allows modules to forward request to another module for further processing
1313
-     *
1314
-     * @access    public
1315
-     * @param    string       $route   - "pretty" public alias for module method
1316
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1317
-     *                                 class, allows different forwards to be served based on status
1318
-     * @param    array|string $forward - function name or array( class, method )
1319
-     * @param    string       $key     - url param key indicating a route is being called
1320
-     * @return    bool
1321
-     */
1322
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1323
-    {
1324
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1325
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1326
-            $msg = sprintf(
1327
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1328
-                $route
1329
-            );
1330
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1331
-            return false;
1332
-        }
1333
-        if (empty($forward)) {
1334
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1335
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1336
-            return false;
1337
-        }
1338
-        if (is_array($forward)) {
1339
-            if (! isset($forward[1])) {
1340
-                $msg = sprintf(
1341
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1342
-                    $route
1343
-                );
1344
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1345
-                return false;
1346
-            }
1347
-            if (! method_exists($forward[0], $forward[1])) {
1348
-                $msg = sprintf(
1349
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1350
-                    $forward[1],
1351
-                    $route
1352
-                );
1353
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1354
-                return false;
1355
-            }
1356
-        } elseif (! function_exists($forward)) {
1357
-            $msg = sprintf(
1358
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1359
-                $forward,
1360
-                $route
1361
-            );
1362
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1363
-            return false;
1364
-        }
1365
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1366
-        return true;
1367
-    }
1368
-
1369
-
1370
-    /**
1371
-     *    get_forward - get forwarding route
1372
-     *
1373
-     * @access    public
1374
-     * @param    string  $route  - "pretty" public alias for module method
1375
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1376
-     *                           allows different forwards to be served based on status
1377
-     * @param    string  $key    - url param key indicating a route is being called
1378
-     * @return    string
1379
-     */
1380
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1381
-    {
1382
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1383
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1384
-            return apply_filters(
1385
-                'FHEE__EE_Config__get_forward',
1386
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1387
-                $route,
1388
-                $status
1389
-            );
1390
-        }
1391
-        return null;
1392
-    }
1393
-
1394
-
1395
-    /**
1396
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1397
-     *    results
1398
-     *
1399
-     * @access    public
1400
-     * @param    string  $route  - "pretty" public alias for module method
1401
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1402
-     *                           allows different views to be served based on status
1403
-     * @param    string  $view
1404
-     * @param    string  $key    - url param key indicating a route is being called
1405
-     * @return    bool
1406
-     */
1407
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1408
-    {
1409
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1410
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1411
-            $msg = sprintf(
1412
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1413
-                $route
1414
-            );
1415
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1416
-            return false;
1417
-        }
1418
-        if (! is_readable($view)) {
1419
-            $msg = sprintf(
1420
-                __(
1421
-                    'The %s view file could not be found or is not readable due to file permissions.',
1422
-                    'event_espresso'
1423
-                ),
1424
-                $view
1425
-            );
1426
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1427
-            return false;
1428
-        }
1429
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1430
-        return true;
1431
-    }
1432
-
1433
-
1434
-    /**
1435
-     *    get_view - get view for route and status
1436
-     *
1437
-     * @access    public
1438
-     * @param    string  $route  - "pretty" public alias for module method
1439
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1440
-     *                           allows different views to be served based on status
1441
-     * @param    string  $key    - url param key indicating a route is being called
1442
-     * @return    string
1443
-     */
1444
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1445
-    {
1446
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1447
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1448
-            return apply_filters(
1449
-                'FHEE__EE_Config__get_view',
1450
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1451
-                $route,
1452
-                $status
1453
-            );
1454
-        }
1455
-        return null;
1456
-    }
1457
-
1458
-
1459
-    public function update_addon_option_names()
1460
-    {
1461
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1462
-    }
1463
-
1464
-
1465
-    public function shutdown()
1466
-    {
1467
-        $this->update_addon_option_names();
1468
-    }
1469
-
1470
-
1471
-    /**
1472
-     * @return LegacyShortcodesManager
1473
-     */
1474
-    public static function getLegacyShortcodesManager()
1475
-    {
1476
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477
-            EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1478
-                LegacyShortcodesManager::class
1479
-            );
1480
-        }
1481
-        return EE_Config::instance()->legacy_shortcodes_manager;
1482
-    }
1483
-
1484
-
1485
-    /**
1486
-     * register_shortcode - makes core aware of this shortcode
1487
-     *
1488
-     * @deprecated 4.9.26
1489
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1490
-     * @return    bool
1491
-     */
1492
-    public static function register_shortcode($shortcode_path = null)
1493
-    {
1494
-        EE_Error::doing_it_wrong(
1495
-            __METHOD__,
1496
-            __(
1497
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1498
-                'event_espresso'
1499
-            ),
1500
-            '4.9.26'
1501
-        );
1502
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1503
-    }
1504
-}
1505
-
1506
-/**
1507
- * Base class used for config classes. These classes should generally not have
1508
- * magic functions in use, except we'll allow them to magically set and get stuff...
1509
- * basically, they should just be well-defined stdClasses
1510
- */
1511
-class EE_Config_Base
1512
-{
1513
-
1514
-    /**
1515
-     * Utility function for escaping the value of a property and returning.
1516
-     *
1517
-     * @param string $property property name (checks to see if exists).
1518
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1519
-     * @throws \EE_Error
1520
-     */
1521
-    public function get_pretty($property)
1522
-    {
1523
-        if (! property_exists($this, $property)) {
1524
-            throw new EE_Error(
1525
-                sprintf(
1526
-                    __(
1527
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1528
-                        'event_espresso'
1529
-                    ),
1530
-                    get_class($this),
1531
-                    $property
1532
-                )
1533
-            );
1534
-        }
1535
-        // just handling escaping of strings for now.
1536
-        if (is_string($this->{$property})) {
1537
-            return stripslashes($this->{$property});
1538
-        }
1539
-        return $this->{$property};
1540
-    }
1541
-
1542
-
1543
-    public function populate()
1544
-    {
1545
-        // grab defaults via a new instance of this class.
1546
-        $class_name = get_class($this);
1547
-        $defaults = new $class_name;
1548
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1549
-        // default from our $defaults object.
1550
-        foreach (get_object_vars($defaults) as $property => $value) {
1551
-            if ($this->{$property} === null) {
1552
-                $this->{$property} = $value;
1553
-            }
1554
-        }
1555
-        // cleanup
1556
-        unset($defaults);
1557
-    }
1558
-
1559
-
1560
-    /**
1561
-     *        __isset
1562
-     *
1563
-     * @param $a
1564
-     * @return bool
1565
-     */
1566
-    public function __isset($a)
1567
-    {
1568
-        return false;
1569
-    }
1570
-
1571
-
1572
-    /**
1573
-     *        __unset
1574
-     *
1575
-     * @param $a
1576
-     * @return bool
1577
-     */
1578
-    public function __unset($a)
1579
-    {
1580
-        return false;
1581
-    }
1582
-
1583
-
1584
-    /**
1585
-     *        __clone
1586
-     */
1587
-    public function __clone()
1588
-    {
1589
-    }
1590
-
1591
-
1592
-    /**
1593
-     *        __wakeup
1594
-     */
1595
-    public function __wakeup()
1596
-    {
1597
-    }
1598
-
1599
-
1600
-    /**
1601
-     *        __destruct
1602
-     */
1603
-    public function __destruct()
1604
-    {
1605
-    }
1606
-}
1607
-
1608
-/**
1609
- * Class for defining what's in the EE_Config relating to registration settings
1610
- */
1611
-class EE_Core_Config extends EE_Config_Base
1612
-{
1613
-
1614
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1615
-
1616
-
1617
-    public $current_blog_id;
1618
-
1619
-    public $ee_ueip_optin;
1620
-
1621
-    public $ee_ueip_has_notified;
1622
-
1623
-    /**
1624
-     * Not to be confused with the 4 critical page variables (See
1625
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1626
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1627
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1628
-     *
1629
-     * @var array
1630
-     */
1631
-    public $post_shortcodes;
1632
-
1633
-    public $module_route_map;
1634
-
1635
-    public $module_forward_map;
1636
-
1637
-    public $module_view_map;
1638
-
1639
-    /**
1640
-     * The next 4 vars are the IDs of critical EE pages.
1641
-     *
1642
-     * @var int
1643
-     */
1644
-    public $reg_page_id;
1645
-
1646
-    public $txn_page_id;
1647
-
1648
-    public $thank_you_page_id;
1649
-
1650
-    public $cancel_page_id;
1651
-
1652
-    /**
1653
-     * The next 4 vars are the URLs of critical EE pages.
1654
-     *
1655
-     * @var int
1656
-     */
1657
-    public $reg_page_url;
1658
-
1659
-    public $txn_page_url;
1660
-
1661
-    public $thank_you_page_url;
1662
-
1663
-    public $cancel_page_url;
1664
-
1665
-    /**
1666
-     * The next vars relate to the custom slugs for EE CPT routes
1667
-     */
1668
-    public $event_cpt_slug;
1669
-
1670
-    /**
1671
-     * This caches the _ee_ueip_option in case this config is reset in the same
1672
-     * request across blog switches in a multisite context.
1673
-     * Avoids extra queries to the db for this option.
1674
-     *
1675
-     * @var bool
1676
-     */
1677
-    public static $ee_ueip_option;
1678
-
1679
-
1680
-    /**
1681
-     *    class constructor
1682
-     *
1683
-     * @access    public
1684
-     */
1685
-    public function __construct()
1686
-    {
1687
-        // set default organization settings
1688
-        $this->current_blog_id = get_current_blog_id();
1689
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1690
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1691
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1692
-        $this->post_shortcodes = array();
1693
-        $this->module_route_map = array();
1694
-        $this->module_forward_map = array();
1695
-        $this->module_view_map = array();
1696
-        // critical EE page IDs
1697
-        $this->reg_page_id = 0;
1698
-        $this->txn_page_id = 0;
1699
-        $this->thank_you_page_id = 0;
1700
-        $this->cancel_page_id = 0;
1701
-        // critical EE page URLs
1702
-        $this->reg_page_url = '';
1703
-        $this->txn_page_url = '';
1704
-        $this->thank_you_page_url = '';
1705
-        $this->cancel_page_url = '';
1706
-        // cpt slugs
1707
-        $this->event_cpt_slug = __('events', 'event_espresso');
1708
-        // ueip constant check
1709
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1710
-            $this->ee_ueip_optin = false;
1711
-            $this->ee_ueip_has_notified = true;
1712
-        }
1713
-    }
1714
-
1715
-
1716
-    /**
1717
-     * @return array
1718
-     */
1719
-    public function get_critical_pages_array()
1720
-    {
1721
-        return array(
1722
-            $this->reg_page_id,
1723
-            $this->txn_page_id,
1724
-            $this->thank_you_page_id,
1725
-            $this->cancel_page_id,
1726
-        );
1727
-    }
1728
-
1729
-
1730
-    /**
1731
-     * @return array
1732
-     */
1733
-    public function get_critical_pages_shortcodes_array()
1734
-    {
1735
-        return array(
1736
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1737
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1738
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1739
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1740
-        );
1741
-    }
1742
-
1743
-
1744
-    /**
1745
-     *  gets/returns URL for EE reg_page
1746
-     *
1747
-     * @access    public
1748
-     * @return    string
1749
-     */
1750
-    public function reg_page_url()
1751
-    {
1752
-        if (! $this->reg_page_url) {
1753
-            $this->reg_page_url = add_query_arg(
1754
-                array('uts' => time()),
1755
-                get_permalink($this->reg_page_id)
1756
-            ) . '#checkout';
1757
-        }
1758
-        return $this->reg_page_url;
1759
-    }
1760
-
1761
-
1762
-    /**
1763
-     *  gets/returns URL for EE txn_page
1764
-     *
1765
-     * @param array $query_args like what gets passed to
1766
-     *                          add_query_arg() as the first argument
1767
-     * @access    public
1768
-     * @return    string
1769
-     */
1770
-    public function txn_page_url($query_args = array())
1771
-    {
1772
-        if (! $this->txn_page_url) {
1773
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1774
-        }
1775
-        if ($query_args) {
1776
-            return add_query_arg($query_args, $this->txn_page_url);
1777
-        } else {
1778
-            return $this->txn_page_url;
1779
-        }
1780
-    }
1781
-
1782
-
1783
-    /**
1784
-     *  gets/returns URL for EE thank_you_page
1785
-     *
1786
-     * @param array $query_args like what gets passed to
1787
-     *                          add_query_arg() as the first argument
1788
-     * @access    public
1789
-     * @return    string
1790
-     */
1791
-    public function thank_you_page_url($query_args = array())
1792
-    {
1793
-        if (! $this->thank_you_page_url) {
1794
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795
-        }
1796
-        if ($query_args) {
1797
-            return add_query_arg($query_args, $this->thank_you_page_url);
1798
-        } else {
1799
-            return $this->thank_you_page_url;
1800
-        }
1801
-    }
1802
-
1803
-
1804
-    /**
1805
-     *  gets/returns URL for EE cancel_page
1806
-     *
1807
-     * @access    public
1808
-     * @return    string
1809
-     */
1810
-    public function cancel_page_url()
1811
-    {
1812
-        if (! $this->cancel_page_url) {
1813
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1814
-        }
1815
-        return $this->cancel_page_url;
1816
-    }
1817
-
1818
-
1819
-    /**
1820
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1821
-     *
1822
-     * @since 4.7.5
1823
-     */
1824
-    protected function _reset_urls()
1825
-    {
1826
-        $this->reg_page_url = '';
1827
-        $this->txn_page_url = '';
1828
-        $this->cancel_page_url = '';
1829
-        $this->thank_you_page_url = '';
1830
-    }
1831
-
1832
-
1833
-    /**
1834
-     * Used to return what the optin value is set for the EE User Experience Program.
1835
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1836
-     * on the main site only.
1837
-     *
1838
-     * @return bool
1839
-     */
1840
-    protected function _get_main_ee_ueip_optin()
1841
-    {
1842
-        // if this is the main site then we can just bypass our direct query.
1843
-        if (is_main_site()) {
1844
-            return get_option(self::OPTION_NAME_UXIP, false);
1845
-        }
1846
-        // is this already cached for this request?  If so use it.
1847
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1848
-            return EE_Core_Config::$ee_ueip_option;
1849
-        }
1850
-        global $wpdb;
1851
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1852
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853
-        $option = self::OPTION_NAME_UXIP;
1854
-        // set correct table for query
1855
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1856
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860
-        // for the purpose of caching.
1861
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1862
-        if (false !== $pre) {
1863
-            EE_Core_Config::$ee_ueip_option = $pre;
1864
-            return EE_Core_Config::$ee_ueip_option;
1865
-        }
1866
-        $row = $wpdb->get_row(
1867
-            $wpdb->prepare(
1868
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1869
-                $option
1870
-            )
1871
-        );
1872
-        if (is_object($row)) {
1873
-            $value = $row->option_value;
1874
-        } else { // option does not exist so use default.
1875
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1876
-            return EE_Core_Config::$ee_ueip_option;
1877
-        }
1878
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1879
-        return EE_Core_Config::$ee_ueip_option;
1880
-    }
1881
-
1882
-
1883
-    /**
1884
-     * Utility function for escaping the value of a property and returning.
1885
-     *
1886
-     * @param string $property property name (checks to see if exists).
1887
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1888
-     * @throws \EE_Error
1889
-     */
1890
-    public function get_pretty($property)
1891
-    {
1892
-        if ($property === self::OPTION_NAME_UXIP) {
1893
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1894
-        }
1895
-        return parent::get_pretty($property);
1896
-    }
1897
-
1898
-
1899
-    /**
1900
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1901
-     * on the object.
1902
-     *
1903
-     * @return array
1904
-     */
1905
-    public function __sleep()
1906
-    {
1907
-        // reset all url properties
1908
-        $this->_reset_urls();
1909
-        // return what to save to db
1910
-        return array_keys(get_object_vars($this));
1911
-    }
1912
-}
1913
-
1914
-/**
1915
- * Config class for storing info on the Organization
1916
- */
1917
-class EE_Organization_Config extends EE_Config_Base
1918
-{
1919
-
1920
-    /**
1921
-     * @var string $name
1922
-     * eg EE4.1
1923
-     */
1924
-    public $name;
1925
-
1926
-    /**
1927
-     * @var string $address_1
1928
-     * eg 123 Onna Road
1929
-     */
1930
-    public $address_1 = '';
1931
-
1932
-    /**
1933
-     * @var string $address_2
1934
-     * eg PO Box 123
1935
-     */
1936
-    public $address_2 = '';
1937
-
1938
-    /**
1939
-     * @var string $city
1940
-     * eg Inna City
1941
-     */
1942
-    public $city = '';
1943
-
1944
-    /**
1945
-     * @var int $STA_ID
1946
-     * eg 4
1947
-     */
1948
-    public $STA_ID = 0;
1949
-
1950
-    /**
1951
-     * @var string $CNT_ISO
1952
-     * eg US
1953
-     */
1954
-    public $CNT_ISO = '';
1955
-
1956
-    /**
1957
-     * @var string $zip
1958
-     * eg 12345  or V1A 2B3
1959
-     */
1960
-    public $zip = '';
1961
-
1962
-    /**
1963
-     * @var string $email
1964
-     * eg [email protected]
1965
-     */
1966
-    public $email;
1967
-
1968
-    /**
1969
-     * @var string $phone
1970
-     * eg. 111-111-1111
1971
-     */
1972
-    public $phone = '';
1973
-
1974
-    /**
1975
-     * @var string $vat
1976
-     * VAT/Tax Number
1977
-     */
1978
-    public $vat = '';
1979
-
1980
-    /**
1981
-     * @var string $logo_url
1982
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1983
-     */
1984
-    public $logo_url = '';
1985
-
1986
-    /**
1987
-     * The below are all various properties for holding links to organization social network profiles
1988
-     *
1989
-     * @var string
1990
-     */
1991
-    /**
1992
-     * facebook (facebook.com/profile.name)
1993
-     *
1994
-     * @var string
1995
-     */
1996
-    public $facebook = '';
1997
-
1998
-    /**
1999
-     * twitter (twitter.com/twitter_handle)
2000
-     *
2001
-     * @var string
2002
-     */
2003
-    public $twitter = '';
2004
-
2005
-    /**
2006
-     * linkedin (linkedin.com/in/profile_name)
2007
-     *
2008
-     * @var string
2009
-     */
2010
-    public $linkedin = '';
2011
-
2012
-    /**
2013
-     * pinterest (www.pinterest.com/profile_name)
2014
-     *
2015
-     * @var string
2016
-     */
2017
-    public $pinterest = '';
2018
-
2019
-    /**
2020
-     * google+ (google.com/+profileName)
2021
-     *
2022
-     * @var string
2023
-     */
2024
-    public $google = '';
2025
-
2026
-    /**
2027
-     * instagram (instagram.com/handle)
2028
-     *
2029
-     * @var string
2030
-     */
2031
-    public $instagram = '';
2032
-
2033
-
2034
-    /**
2035
-     *    class constructor
2036
-     *
2037
-     * @access    public
2038
-     */
2039
-    public function __construct()
2040
-    {
2041
-        // set default organization settings
2042
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2043
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2044
-        $this->email = get_bloginfo('admin_email');
2045
-    }
2046
-}
2047
-
2048
-/**
2049
- * Class for defining what's in the EE_Config relating to currency
2050
- */
2051
-class EE_Currency_Config extends EE_Config_Base
2052
-{
2053
-
2054
-    /**
2055
-     * @var string $code
2056
-     * eg 'US'
2057
-     */
2058
-    public $code;
2059
-
2060
-    /**
2061
-     * @var string $name
2062
-     * eg 'Dollar'
2063
-     */
2064
-    public $name;
2065
-
2066
-    /**
2067
-     * plural name
2068
-     *
2069
-     * @var string $plural
2070
-     * eg 'Dollars'
2071
-     */
2072
-    public $plural;
2073
-
2074
-    /**
2075
-     * currency sign
2076
-     *
2077
-     * @var string $sign
2078
-     * eg '$'
2079
-     */
2080
-    public $sign;
2081
-
2082
-    /**
2083
-     * Whether the currency sign should come before the number or not
2084
-     *
2085
-     * @var boolean $sign_b4
2086
-     */
2087
-    public $sign_b4;
2088
-
2089
-    /**
2090
-     * How many digits should come after the decimal place
2091
-     *
2092
-     * @var int $dec_plc
2093
-     */
2094
-    public $dec_plc;
2095
-
2096
-    /**
2097
-     * Symbol to use for decimal mark
2098
-     *
2099
-     * @var string $dec_mrk
2100
-     * eg '.'
2101
-     */
2102
-    public $dec_mrk;
2103
-
2104
-    /**
2105
-     * Symbol to use for thousands
2106
-     *
2107
-     * @var string $thsnds
2108
-     * eg ','
2109
-     */
2110
-    public $thsnds;
2111
-
2112
-
2113
-    /**
2114
-     *    class constructor
2115
-     *
2116
-     * @access    public
2117
-     * @param string $CNT_ISO
2118
-     * @throws \EE_Error
2119
-     */
2120
-    public function __construct($CNT_ISO = '')
2121
-    {
2122
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2123
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2124
-        // get country code from organization settings or use default
2125
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2126
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2127
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2128
-            : '';
2129
-        // but override if requested
2130
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2131
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2132
-        if (! empty($CNT_ISO)
2133
-            && EE_Maintenance_Mode::instance()->models_can_query()
2134
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2135
-        ) {
2136
-            // retrieve the country settings from the db, just in case they have been customized
2137
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2138
-            if ($country instanceof EE_Country) {
2139
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2140
-                $this->name = $country->currency_name_single();    // Dollar
2141
-                $this->plural = $country->currency_name_plural();    // Dollars
2142
-                $this->sign = $country->currency_sign();            // currency sign: $
2143
-                $this->sign_b4 = $country->currency_sign_before(
2144
-                );        // currency sign before or after: $TRUE  or  FALSE$
2145
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2146
-                $this->dec_mrk = $country->currency_decimal_mark(
2147
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2148
-                $this->thsnds = $country->currency_thousands_separator(
2149
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2150
-            }
2151
-        }
2152
-        // fallback to hardcoded defaults, in case the above failed
2153
-        if (empty($this->code)) {
2154
-            // set default currency settings
2155
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2156
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2157
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2158
-            $this->sign = '$';    // currency sign: $
2159
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2160
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2161
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2162
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2163
-        }
2164
-    }
2165
-}
2166
-
2167
-/**
2168
- * Class for defining what's in the EE_Config relating to registration settings
2169
- */
2170
-class EE_Registration_Config extends EE_Config_Base
2171
-{
2172
-
2173
-    /**
2174
-     * Default registration status
2175
-     *
2176
-     * @var string $default_STS_ID
2177
-     * eg 'RPP'
2178
-     */
2179
-    public $default_STS_ID;
2180
-
2181
-    /**
2182
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2183
-     * registrations)
2184
-     *
2185
-     * @var int
2186
-     */
2187
-    public $default_maximum_number_of_tickets;
2188
-
2189
-    /**
2190
-     * level of validation to apply to email addresses
2191
-     *
2192
-     * @var string $email_validation_level
2193
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2194
-     */
2195
-    public $email_validation_level;
2196
-
2197
-    /**
2198
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2199
-     *
2200
-     * @var boolean $show_pending_payment_options
2201
-     */
2202
-    public $show_pending_payment_options;
2203
-
2204
-    /**
2205
-     * Whether to skip the registration confirmation page
2206
-     *
2207
-     * @var boolean $skip_reg_confirmation
2208
-     */
2209
-    public $skip_reg_confirmation;
2210
-
2211
-    /**
2212
-     * an array of SPCO reg steps where:
2213
-     *        the keys denotes the reg step order
2214
-     *        each element consists of an array with the following elements:
2215
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2216
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2217
-     *            "slug" => the URL param used to trigger the reg step
2218
-     *
2219
-     * @var array $reg_steps
2220
-     */
2221
-    public $reg_steps;
2222
-
2223
-    /**
2224
-     * Whether registration confirmation should be the last page of SPCO
2225
-     *
2226
-     * @var boolean $reg_confirmation_last
2227
-     */
2228
-    public $reg_confirmation_last;
2229
-
2230
-    /**
2231
-     * Whether or not to enable the EE Bot Trap
2232
-     *
2233
-     * @var boolean $use_bot_trap
2234
-     */
2235
-    public $use_bot_trap;
2236
-
2237
-    /**
2238
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2239
-     *
2240
-     * @var boolean $use_encryption
2241
-     */
2242
-    public $use_encryption;
2243
-
2244
-    /**
2245
-     * Whether or not to use ReCaptcha
2246
-     *
2247
-     * @var boolean $use_captcha
2248
-     */
2249
-    public $use_captcha;
2250
-
2251
-    /**
2252
-     * ReCaptcha Theme
2253
-     *
2254
-     * @var string $recaptcha_theme
2255
-     *    options: 'dark', 'light', 'invisible'
2256
-     */
2257
-    public $recaptcha_theme;
2258
-
2259
-    /**
2260
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2261
-     *
2262
-     * @var string $recaptcha_badge
2263
-     *    options: 'bottomright', 'bottomleft', 'inline'
2264
-     */
2265
-    public $recaptcha_badge;
18
+	const OPTION_NAME = 'ee_config';
19
+
20
+	const LOG_NAME = 'ee_config_log';
21
+
22
+	const LOG_LENGTH = 100;
23
+
24
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
25
+
26
+	/**
27
+	 *    instance of the EE_Config object
28
+	 *
29
+	 * @var    EE_Config $_instance
30
+	 * @access    private
31
+	 */
32
+	private static $_instance;
33
+
34
+	/**
35
+	 * @var boolean $_logging_enabled
36
+	 */
37
+	private static $_logging_enabled = false;
38
+
39
+	/**
40
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
41
+	 */
42
+	private $legacy_shortcodes_manager;
43
+
44
+	/**
45
+	 * An StdClass whose property names are addon slugs,
46
+	 * and values are their config classes
47
+	 *
48
+	 * @var StdClass
49
+	 */
50
+	public $addons;
51
+
52
+	/**
53
+	 * @var EE_Admin_Config
54
+	 */
55
+	public $admin;
56
+
57
+	/**
58
+	 * @var EE_Core_Config
59
+	 */
60
+	public $core;
61
+
62
+	/**
63
+	 * @var EE_Currency_Config
64
+	 */
65
+	public $currency;
66
+
67
+	/**
68
+	 * @var EE_Organization_Config
69
+	 */
70
+	public $organization;
71
+
72
+	/**
73
+	 * @var EE_Registration_Config
74
+	 */
75
+	public $registration;
76
+
77
+	/**
78
+	 * @var EE_Template_Config
79
+	 */
80
+	public $template_settings;
81
+
82
+	/**
83
+	 * Holds EE environment values.
84
+	 *
85
+	 * @var EE_Environment_Config
86
+	 */
87
+	public $environment;
88
+
89
+	/**
90
+	 * settings pertaining to Google maps
91
+	 *
92
+	 * @var EE_Map_Config
93
+	 */
94
+	public $map_settings;
95
+
96
+	/**
97
+	 * settings pertaining to Taxes
98
+	 *
99
+	 * @var EE_Tax_Config
100
+	 */
101
+	public $tax_settings;
102
+
103
+	/**
104
+	 * Settings pertaining to global messages settings.
105
+	 *
106
+	 * @var EE_Messages_Config
107
+	 */
108
+	public $messages;
109
+
110
+	/**
111
+	 * @deprecated
112
+	 * @var EE_Gateway_Config
113
+	 */
114
+	public $gateway;
115
+
116
+	/**
117
+	 * @var    array $_addon_option_names
118
+	 * @access    private
119
+	 */
120
+	private $_addon_option_names = array();
121
+
122
+	/**
123
+	 * @var    array $_module_route_map
124
+	 * @access    private
125
+	 */
126
+	private static $_module_route_map = array();
127
+
128
+	/**
129
+	 * @var    array $_module_forward_map
130
+	 * @access    private
131
+	 */
132
+	private static $_module_forward_map = array();
133
+
134
+	/**
135
+	 * @var    array $_module_view_map
136
+	 * @access    private
137
+	 */
138
+	private static $_module_view_map = array();
139
+
140
+
141
+	/**
142
+	 * @singleton method used to instantiate class object
143
+	 * @access    public
144
+	 * @return EE_Config instance
145
+	 */
146
+	public static function instance()
147
+	{
148
+		// check if class object is instantiated, and instantiated properly
149
+		if (! self::$_instance instanceof EE_Config) {
150
+			self::$_instance = new self();
151
+		}
152
+		return self::$_instance;
153
+	}
154
+
155
+
156
+	/**
157
+	 * Resets the config
158
+	 *
159
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
160
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
161
+	 *                               reflect its state in the database
162
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
163
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
164
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
165
+	 *                               site was put into maintenance mode)
166
+	 * @return EE_Config
167
+	 */
168
+	public static function reset($hard_reset = false, $reinstantiate = true)
169
+	{
170
+		if (self::$_instance instanceof EE_Config) {
171
+			if ($hard_reset) {
172
+				self::$_instance->legacy_shortcodes_manager = null;
173
+				self::$_instance->_addon_option_names = array();
174
+				self::$_instance->_initialize_config();
175
+				self::$_instance->update_espresso_config();
176
+			}
177
+			self::$_instance->update_addon_option_names();
178
+		}
179
+		self::$_instance = null;
180
+		// we don't need to reset the static properties imo because those should
181
+		// only change when a module is added or removed. Currently we don't
182
+		// support removing a module during a request when it previously existed
183
+		if ($reinstantiate) {
184
+			return self::instance();
185
+		} else {
186
+			return null;
187
+		}
188
+	}
189
+
190
+
191
+	/**
192
+	 *    class constructor
193
+	 *
194
+	 * @access    private
195
+	 */
196
+	private function __construct()
197
+	{
198
+		do_action('AHEE__EE_Config__construct__begin', $this);
199
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
200
+		// setup empty config classes
201
+		$this->_initialize_config();
202
+		// load existing EE site settings
203
+		$this->_load_core_config();
204
+		// confirm everything loaded correctly and set filtered defaults if not
205
+		$this->_verify_config();
206
+		//  register shortcodes and modules
207
+		add_action(
208
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
209
+			array($this, 'register_shortcodes_and_modules'),
210
+			999
211
+		);
212
+		//  initialize shortcodes and modules
213
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
214
+		// register widgets
215
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
216
+		// shutdown
217
+		add_action('shutdown', array($this, 'shutdown'), 10);
218
+		// construct__end hook
219
+		do_action('AHEE__EE_Config__construct__end', $this);
220
+		// hardcoded hack
221
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
222
+	}
223
+
224
+
225
+	/**
226
+	 * @return boolean
227
+	 */
228
+	public static function logging_enabled()
229
+	{
230
+		return self::$_logging_enabled;
231
+	}
232
+
233
+
234
+	/**
235
+	 * use to get the current theme if needed from static context
236
+	 *
237
+	 * @return string current theme set.
238
+	 */
239
+	public static function get_current_theme()
240
+	{
241
+		return isset(self::$_instance->template_settings->current_espresso_theme)
242
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
243
+	}
244
+
245
+
246
+	/**
247
+	 *        _initialize_config
248
+	 *
249
+	 * @access private
250
+	 * @return void
251
+	 */
252
+	private function _initialize_config()
253
+	{
254
+		EE_Config::trim_log();
255
+		// set defaults
256
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
257
+		$this->addons = new stdClass();
258
+		// set _module_route_map
259
+		EE_Config::$_module_route_map = array();
260
+		// set _module_forward_map
261
+		EE_Config::$_module_forward_map = array();
262
+		// set _module_view_map
263
+		EE_Config::$_module_view_map = array();
264
+	}
265
+
266
+
267
+	/**
268
+	 *        load core plugin configuration
269
+	 *
270
+	 * @access private
271
+	 * @return void
272
+	 */
273
+	private function _load_core_config()
274
+	{
275
+		// load_core_config__start hook
276
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
277
+		$espresso_config = $this->get_espresso_config();
278
+		foreach ($espresso_config as $config => $settings) {
279
+			// load_core_config__start hook
280
+			$settings = apply_filters(
281
+				'FHEE__EE_Config___load_core_config__config_settings',
282
+				$settings,
283
+				$config,
284
+				$this
285
+			);
286
+			if (is_object($settings) && property_exists($this, $config)) {
287
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
288
+				// call configs populate method to ensure any defaults are set for empty values.
289
+				if (method_exists($settings, 'populate')) {
290
+					$this->{$config}->populate();
291
+				}
292
+				if (method_exists($settings, 'do_hooks')) {
293
+					$this->{$config}->do_hooks();
294
+				}
295
+			}
296
+		}
297
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
298
+			$this->update_espresso_config();
299
+		}
300
+		// load_core_config__end hook
301
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
302
+	}
303
+
304
+
305
+	/**
306
+	 *    _verify_config
307
+	 *
308
+	 * @access    protected
309
+	 * @return    void
310
+	 */
311
+	protected function _verify_config()
312
+	{
313
+		$this->core = $this->core instanceof EE_Core_Config
314
+			? $this->core
315
+			: new EE_Core_Config();
316
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
317
+		$this->organization = $this->organization instanceof EE_Organization_Config
318
+			? $this->organization
319
+			: new EE_Organization_Config();
320
+		$this->organization = apply_filters(
321
+			'FHEE__EE_Config___initialize_config__organization',
322
+			$this->organization
323
+		);
324
+		$this->currency = $this->currency instanceof EE_Currency_Config
325
+			? $this->currency
326
+			: new EE_Currency_Config();
327
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
328
+		$this->registration = $this->registration instanceof EE_Registration_Config
329
+			? $this->registration
330
+			: new EE_Registration_Config();
331
+		$this->registration = apply_filters(
332
+			'FHEE__EE_Config___initialize_config__registration',
333
+			$this->registration
334
+		);
335
+		$this->admin = $this->admin instanceof EE_Admin_Config
336
+			? $this->admin
337
+			: new EE_Admin_Config();
338
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
339
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
340
+			? $this->template_settings
341
+			: new EE_Template_Config();
342
+		$this->template_settings = apply_filters(
343
+			'FHEE__EE_Config___initialize_config__template_settings',
344
+			$this->template_settings
345
+		);
346
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
347
+			? $this->map_settings
348
+			: new EE_Map_Config();
349
+		$this->map_settings = apply_filters(
350
+			'FHEE__EE_Config___initialize_config__map_settings',
351
+			$this->map_settings
352
+		);
353
+		$this->environment = $this->environment instanceof EE_Environment_Config
354
+			? $this->environment
355
+			: new EE_Environment_Config();
356
+		$this->environment = apply_filters(
357
+			'FHEE__EE_Config___initialize_config__environment',
358
+			$this->environment
359
+		);
360
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
361
+			? $this->tax_settings
362
+			: new EE_Tax_Config();
363
+		$this->tax_settings = apply_filters(
364
+			'FHEE__EE_Config___initialize_config__tax_settings',
365
+			$this->tax_settings
366
+		);
367
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
368
+		$this->messages = $this->messages instanceof EE_Messages_Config
369
+			? $this->messages
370
+			: new EE_Messages_Config();
371
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
372
+			? $this->gateway
373
+			: new EE_Gateway_Config();
374
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
375
+		$this->legacy_shortcodes_manager = null;
376
+	}
377
+
378
+
379
+	/**
380
+	 *    get_espresso_config
381
+	 *
382
+	 * @access    public
383
+	 * @return    array of espresso config stuff
384
+	 */
385
+	public function get_espresso_config()
386
+	{
387
+		// grab espresso configuration
388
+		return apply_filters(
389
+			'FHEE__EE_Config__get_espresso_config__CFG',
390
+			get_option(EE_Config::OPTION_NAME, array())
391
+		);
392
+	}
393
+
394
+
395
+	/**
396
+	 *    double_check_config_comparison
397
+	 *
398
+	 * @access    public
399
+	 * @param string $option
400
+	 * @param        $old_value
401
+	 * @param        $value
402
+	 */
403
+	public function double_check_config_comparison($option = '', $old_value, $value)
404
+	{
405
+		// make sure we're checking the ee config
406
+		if ($option === EE_Config::OPTION_NAME) {
407
+			// run a loose comparison of the old value against the new value for type and properties,
408
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
409
+			if ($value != $old_value) {
410
+				// if they are NOT the same, then remove the hook,
411
+				// which means the subsequent update results will be based solely on the update query results
412
+				// the reason we do this is because, as stated above,
413
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
414
+				// this happens PRIOR to serialization and any subsequent update.
415
+				// If values are found to match their previous old value,
416
+				// then WP bails before performing any update.
417
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
418
+				// it just pulled from the db, with the one being passed to it (which will not match).
419
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
420
+				// MySQL MAY ALSO NOT perform the update because
421
+				// the string it sees in the db looks the same as the new one it has been passed!!!
422
+				// This results in the query returning an "affected rows" value of ZERO,
423
+				// which gets returned immediately by WP update_option and looks like an error.
424
+				remove_action('update_option', array($this, 'check_config_updated'));
425
+			}
426
+		}
427
+	}
428
+
429
+
430
+	/**
431
+	 *    update_espresso_config
432
+	 *
433
+	 * @access   public
434
+	 */
435
+	protected function _reset_espresso_addon_config()
436
+	{
437
+		$this->_addon_option_names = array();
438
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
439
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
440
+			if ($addon_config_obj instanceof EE_Config_Base) {
441
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
442
+			}
443
+			$this->addons->{$addon_name} = null;
444
+		}
445
+	}
446
+
447
+
448
+	/**
449
+	 *    update_espresso_config
450
+	 *
451
+	 * @access   public
452
+	 * @param   bool $add_success
453
+	 * @param   bool $add_error
454
+	 * @return   bool
455
+	 */
456
+	public function update_espresso_config($add_success = false, $add_error = true)
457
+	{
458
+		// don't allow config updates during WP heartbeats
459
+		/** @var RequestInterface $request */
460
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
461
+		if ($request->isWordPressHeartbeat()) {
462
+			return false;
463
+		}
464
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
465
+		// $clone = clone( self::$_instance );
466
+		// self::$_instance = NULL;
467
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
468
+		$this->_reset_espresso_addon_config();
469
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
470
+		// but BEFORE the actual update occurs
471
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
472
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
473
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
474
+		$this->legacy_shortcodes_manager = null;
475
+		// now update "ee_config"
476
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
477
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
478
+		EE_Config::log(EE_Config::OPTION_NAME);
479
+		// if not saved... check if the hook we just added still exists;
480
+		// if it does, it means one of two things:
481
+		// that update_option bailed at the($value === $old_value) conditional,
482
+		// or...
483
+		// the db update query returned 0 rows affected
484
+		// (probably because the data  value was the same from it's perspective)
485
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
486
+		// but just means no update occurred, so don't display an error to the user.
487
+		// BUT... if update_option returns FALSE, AND the hook is missing,
488
+		// then it means that something truly went wrong
489
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
490
+		// remove our action since we don't want it in the system anymore
491
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
492
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
493
+		// self::$_instance = $clone;
494
+		// unset( $clone );
495
+		// if config remains the same or was updated successfully
496
+		if ($saved) {
497
+			if ($add_success) {
498
+				EE_Error::add_success(
499
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
500
+					__FILE__,
501
+					__FUNCTION__,
502
+					__LINE__
503
+				);
504
+			}
505
+			return true;
506
+		} else {
507
+			if ($add_error) {
508
+				EE_Error::add_error(
509
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
510
+					__FILE__,
511
+					__FUNCTION__,
512
+					__LINE__
513
+				);
514
+			}
515
+			return false;
516
+		}
517
+	}
518
+
519
+
520
+	/**
521
+	 *    _verify_config_params
522
+	 *
523
+	 * @access    private
524
+	 * @param    string         $section
525
+	 * @param    string         $name
526
+	 * @param    string         $config_class
527
+	 * @param    EE_Config_Base $config_obj
528
+	 * @param    array          $tests_to_run
529
+	 * @param    bool           $display_errors
530
+	 * @return    bool    TRUE on success, FALSE on fail
531
+	 */
532
+	private function _verify_config_params(
533
+		$section = '',
534
+		$name = '',
535
+		$config_class = '',
536
+		$config_obj = null,
537
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
538
+		$display_errors = true
539
+	) {
540
+		try {
541
+			foreach ($tests_to_run as $test) {
542
+				switch ($test) {
543
+					// TEST #1 : check that section was set
544
+					case 1:
545
+						if (empty($section)) {
546
+							if ($display_errors) {
547
+								throw new EE_Error(
548
+									sprintf(
549
+										__(
550
+											'No configuration section has been provided while attempting to save "%s".',
551
+											'event_espresso'
552
+										),
553
+										$config_class
554
+									)
555
+								);
556
+							}
557
+							return false;
558
+						}
559
+						break;
560
+					// TEST #2 : check that settings section exists
561
+					case 2:
562
+						if (! isset($this->{$section})) {
563
+							if ($display_errors) {
564
+								throw new EE_Error(
565
+									sprintf(
566
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
567
+										$section
568
+									)
569
+								);
570
+							}
571
+							return false;
572
+						}
573
+						break;
574
+					// TEST #3 : check that section is the proper format
575
+					case 3:
576
+						if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
577
+						) {
578
+							if ($display_errors) {
579
+								throw new EE_Error(
580
+									sprintf(
581
+										__(
582
+											'The "%s" configuration settings have not been formatted correctly.',
583
+											'event_espresso'
584
+										),
585
+										$section
586
+									)
587
+								);
588
+							}
589
+							return false;
590
+						}
591
+						break;
592
+					// TEST #4 : check that config section name has been set
593
+					case 4:
594
+						if (empty($name)) {
595
+							if ($display_errors) {
596
+								throw new EE_Error(
597
+									__(
598
+										'No name has been provided for the specific configuration section.',
599
+										'event_espresso'
600
+									)
601
+								);
602
+							}
603
+							return false;
604
+						}
605
+						break;
606
+					// TEST #5 : check that a config class name has been set
607
+					case 5:
608
+						if (empty($config_class)) {
609
+							if ($display_errors) {
610
+								throw new EE_Error(
611
+									__(
612
+										'No class name has been provided for the specific configuration section.',
613
+										'event_espresso'
614
+									)
615
+								);
616
+							}
617
+							return false;
618
+						}
619
+						break;
620
+					// TEST #6 : verify config class is accessible
621
+					case 6:
622
+						if (! class_exists($config_class)) {
623
+							if ($display_errors) {
624
+								throw new EE_Error(
625
+									sprintf(
626
+										__(
627
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
628
+											'event_espresso'
629
+										),
630
+										$config_class
631
+									)
632
+								);
633
+							}
634
+							return false;
635
+						}
636
+						break;
637
+					// TEST #7 : check that config has even been set
638
+					case 7:
639
+						if (! isset($this->{$section}->{$name})) {
640
+							if ($display_errors) {
641
+								throw new EE_Error(
642
+									sprintf(
643
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
644
+										$section,
645
+										$name
646
+									)
647
+								);
648
+							}
649
+							return false;
650
+						} else {
651
+							// and make sure it's not serialized
652
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
653
+						}
654
+						break;
655
+					// TEST #8 : check that config is the requested type
656
+					case 8:
657
+						if (! $this->{$section}->{$name} instanceof $config_class) {
658
+							if ($display_errors) {
659
+								throw new EE_Error(
660
+									sprintf(
661
+										__(
662
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
663
+											'event_espresso'
664
+										),
665
+										$section,
666
+										$name,
667
+										$config_class
668
+									)
669
+								);
670
+							}
671
+							return false;
672
+						}
673
+						break;
674
+					// TEST #9 : verify config object
675
+					case 9:
676
+						if (! $config_obj instanceof EE_Config_Base) {
677
+							if ($display_errors) {
678
+								throw new EE_Error(
679
+									sprintf(
680
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
681
+										print_r($config_obj, true)
682
+									)
683
+								);
684
+							}
685
+							return false;
686
+						}
687
+						break;
688
+				}
689
+			}
690
+		} catch (EE_Error $e) {
691
+			$e->get_error();
692
+		}
693
+		// you have successfully run the gauntlet
694
+		return true;
695
+	}
696
+
697
+
698
+	/**
699
+	 *    _generate_config_option_name
700
+	 *
701
+	 * @access        protected
702
+	 * @param        string $section
703
+	 * @param        string $name
704
+	 * @return        string
705
+	 */
706
+	private function _generate_config_option_name($section = '', $name = '')
707
+	{
708
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
709
+	}
710
+
711
+
712
+	/**
713
+	 *    _set_config_class
714
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
715
+	 *
716
+	 * @access    private
717
+	 * @param    string $config_class
718
+	 * @param    string $name
719
+	 * @return    string
720
+	 */
721
+	private function _set_config_class($config_class = '', $name = '')
722
+	{
723
+		return ! empty($config_class)
724
+			? $config_class
725
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
726
+	}
727
+
728
+
729
+	/**
730
+	 *    set_config
731
+	 *
732
+	 * @access    protected
733
+	 * @param    string         $section
734
+	 * @param    string         $name
735
+	 * @param    string         $config_class
736
+	 * @param    EE_Config_Base $config_obj
737
+	 * @return    EE_Config_Base
738
+	 */
739
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
740
+	{
741
+		// ensure config class is set to something
742
+		$config_class = $this->_set_config_class($config_class, $name);
743
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
744
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
745
+			return null;
746
+		}
747
+		$config_option_name = $this->_generate_config_option_name($section, $name);
748
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
749
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
750
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
751
+			$this->update_addon_option_names();
752
+		}
753
+		// verify the incoming config object but suppress errors
754
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
755
+			$config_obj = new $config_class();
756
+		}
757
+		if (get_option($config_option_name)) {
758
+			EE_Config::log($config_option_name);
759
+			update_option($config_option_name, $config_obj);
760
+			$this->{$section}->{$name} = $config_obj;
761
+			return $this->{$section}->{$name};
762
+		} else {
763
+			// create a wp-option for this config
764
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
765
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
766
+				return $this->{$section}->{$name};
767
+			} else {
768
+				EE_Error::add_error(
769
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
770
+					__FILE__,
771
+					__FUNCTION__,
772
+					__LINE__
773
+				);
774
+				return null;
775
+			}
776
+		}
777
+	}
778
+
779
+
780
+	/**
781
+	 *    update_config
782
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
783
+	 *
784
+	 * @access    public
785
+	 * @param    string                $section
786
+	 * @param    string                $name
787
+	 * @param    EE_Config_Base|string $config_obj
788
+	 * @param    bool                  $throw_errors
789
+	 * @return    bool
790
+	 */
791
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
792
+	{
793
+		// don't allow config updates during WP heartbeats
794
+		/** @var RequestInterface $request */
795
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
796
+		if ($request->isWordPressHeartbeat()) {
797
+			return false;
798
+		}
799
+		$config_obj = maybe_unserialize($config_obj);
800
+		// get class name of the incoming object
801
+		$config_class = get_class($config_obj);
802
+		// run tests 1-5 and 9 to verify config
803
+		if (! $this->_verify_config_params(
804
+			$section,
805
+			$name,
806
+			$config_class,
807
+			$config_obj,
808
+			array(1, 2, 3, 4, 7, 9)
809
+		)
810
+		) {
811
+			return false;
812
+		}
813
+		$config_option_name = $this->_generate_config_option_name($section, $name);
814
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
815
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
816
+			// save new config to db
817
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
818
+				return true;
819
+			}
820
+		} else {
821
+			// first check if the record already exists
822
+			$existing_config = get_option($config_option_name);
823
+			$config_obj = serialize($config_obj);
824
+			// just return if db record is already up to date (NOT type safe comparison)
825
+			if ($existing_config == $config_obj) {
826
+				$this->{$section}->{$name} = $config_obj;
827
+				return true;
828
+			} elseif (update_option($config_option_name, $config_obj)) {
829
+				EE_Config::log($config_option_name);
830
+				// update wp-option for this config class
831
+				$this->{$section}->{$name} = $config_obj;
832
+				return true;
833
+			} elseif ($throw_errors) {
834
+				EE_Error::add_error(
835
+					sprintf(
836
+						__(
837
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
838
+							'event_espresso'
839
+						),
840
+						$config_class,
841
+						'EE_Config->' . $section . '->' . $name
842
+					),
843
+					__FILE__,
844
+					__FUNCTION__,
845
+					__LINE__
846
+				);
847
+			}
848
+		}
849
+		return false;
850
+	}
851
+
852
+
853
+	/**
854
+	 *    get_config
855
+	 *
856
+	 * @access    public
857
+	 * @param    string $section
858
+	 * @param    string $name
859
+	 * @param    string $config_class
860
+	 * @return    mixed EE_Config_Base | NULL
861
+	 */
862
+	public function get_config($section = '', $name = '', $config_class = '')
863
+	{
864
+		// ensure config class is set to something
865
+		$config_class = $this->_set_config_class($config_class, $name);
866
+		// run tests 1-4, 6 and 7 to verify that all params have been set
867
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
868
+			return null;
869
+		}
870
+		// now test if the requested config object exists, but suppress errors
871
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
872
+			// config already exists, so pass it back
873
+			return $this->{$section}->{$name};
874
+		}
875
+		// load config option from db if it exists
876
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
877
+		// verify the newly retrieved config object, but suppress errors
878
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
879
+			// config is good, so set it and pass it back
880
+			$this->{$section}->{$name} = $config_obj;
881
+			return $this->{$section}->{$name};
882
+		}
883
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
884
+		$config_obj = $this->set_config($section, $name, $config_class);
885
+		// verify the newly created config object
886
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
887
+			return $this->{$section}->{$name};
888
+		} else {
889
+			EE_Error::add_error(
890
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
891
+				__FILE__,
892
+				__FUNCTION__,
893
+				__LINE__
894
+			);
895
+		}
896
+		return null;
897
+	}
898
+
899
+
900
+	/**
901
+	 *    get_config_option
902
+	 *
903
+	 * @access    public
904
+	 * @param    string $config_option_name
905
+	 * @return    mixed EE_Config_Base | FALSE
906
+	 */
907
+	public function get_config_option($config_option_name = '')
908
+	{
909
+		// retrieve the wp-option for this config class.
910
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
911
+		if (empty($config_option)) {
912
+			EE_Config::log($config_option_name . '-NOT-FOUND');
913
+		}
914
+		return $config_option;
915
+	}
916
+
917
+
918
+	/**
919
+	 * log
920
+	 *
921
+	 * @param string $config_option_name
922
+	 */
923
+	public static function log($config_option_name = '')
924
+	{
925
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
926
+			$config_log = get_option(EE_Config::LOG_NAME, array());
927
+			// copy incoming $_REQUEST and sanitize it so we can save it
928
+			$_request = $_REQUEST;
929
+			array_walk_recursive($_request, 'sanitize_text_field');
930
+			$config_log[ (string) microtime(true) ] = array(
931
+				'config_name' => $config_option_name,
932
+				'request'     => $_request,
933
+			);
934
+			update_option(EE_Config::LOG_NAME, $config_log);
935
+		}
936
+	}
937
+
938
+
939
+	/**
940
+	 * trim_log
941
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
942
+	 */
943
+	public static function trim_log()
944
+	{
945
+		if (! EE_Config::logging_enabled()) {
946
+			return;
947
+		}
948
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
949
+		$log_length = count($config_log);
950
+		if ($log_length > EE_Config::LOG_LENGTH) {
951
+			ksort($config_log);
952
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
953
+			update_option(EE_Config::LOG_NAME, $config_log);
954
+		}
955
+	}
956
+
957
+
958
+	/**
959
+	 *    get_page_for_posts
960
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
961
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
962
+	 *
963
+	 * @access    public
964
+	 * @return    string
965
+	 */
966
+	public static function get_page_for_posts()
967
+	{
968
+		$page_for_posts = get_option('page_for_posts');
969
+		if (! $page_for_posts) {
970
+			return 'posts';
971
+		}
972
+		/** @type WPDB $wpdb */
973
+		global $wpdb;
974
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
975
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
976
+	}
977
+
978
+
979
+	/**
980
+	 *    register_shortcodes_and_modules.
981
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
982
+	 *    In fact, this is where we give modules a chance to let core know they exist
983
+	 *    so they can help trigger maintenance mode if it's needed
984
+	 *
985
+	 * @access    public
986
+	 * @return    void
987
+	 */
988
+	public function register_shortcodes_and_modules()
989
+	{
990
+		// allow modules to set hooks for the rest of the system
991
+		EE_Registry::instance()->modules = $this->_register_modules();
992
+	}
993
+
994
+
995
+	/**
996
+	 *    initialize_shortcodes_and_modules
997
+	 *    meaning they can start adding their hooks to get stuff done
998
+	 *
999
+	 * @access    public
1000
+	 * @return    void
1001
+	 */
1002
+	public function initialize_shortcodes_and_modules()
1003
+	{
1004
+		// allow modules to set hooks for the rest of the system
1005
+		$this->_initialize_modules();
1006
+	}
1007
+
1008
+
1009
+	/**
1010
+	 *    widgets_init
1011
+	 *
1012
+	 * @access private
1013
+	 * @return void
1014
+	 */
1015
+	public function widgets_init()
1016
+	{
1017
+		// only init widgets on admin pages when not in complete maintenance, and
1018
+		// on frontend when not in any maintenance mode
1019
+		if (! EE_Maintenance_Mode::instance()->level()
1020
+			|| (
1021
+				is_admin()
1022
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1023
+			)
1024
+		) {
1025
+			// grab list of installed widgets
1026
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1027
+			// filter list of modules to register
1028
+			$widgets_to_register = apply_filters(
1029
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1030
+				$widgets_to_register
1031
+			);
1032
+			if (! empty($widgets_to_register)) {
1033
+				// cycle thru widget folders
1034
+				foreach ($widgets_to_register as $widget_path) {
1035
+					// add to list of installed widget modules
1036
+					EE_Config::register_ee_widget($widget_path);
1037
+				}
1038
+			}
1039
+			// filter list of installed modules
1040
+			EE_Registry::instance()->widgets = apply_filters(
1041
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1042
+				EE_Registry::instance()->widgets
1043
+			);
1044
+		}
1045
+	}
1046
+
1047
+
1048
+	/**
1049
+	 *    register_ee_widget - makes core aware of this widget
1050
+	 *
1051
+	 * @access    public
1052
+	 * @param    string $widget_path - full path up to and including widget folder
1053
+	 * @return    void
1054
+	 */
1055
+	public static function register_ee_widget($widget_path = null)
1056
+	{
1057
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1058
+		$widget_ext = '.widget.php';
1059
+		// make all separators match
1060
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1061
+		// does the file path INCLUDE the actual file name as part of the path ?
1062
+		if (strpos($widget_path, $widget_ext) !== false) {
1063
+			// grab and shortcode file name from directory name and break apart at dots
1064
+			$file_name = explode('.', basename($widget_path));
1065
+			// take first segment from file name pieces and remove class prefix if it exists
1066
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1067
+			// sanitize shortcode directory name
1068
+			$widget = sanitize_key($widget);
1069
+			// now we need to rebuild the shortcode path
1070
+			$widget_path = explode('/', $widget_path);
1071
+			// remove last segment
1072
+			array_pop($widget_path);
1073
+			// glue it back together
1074
+			$widget_path = implode(DS, $widget_path);
1075
+		} else {
1076
+			// grab and sanitize widget directory name
1077
+			$widget = sanitize_key(basename($widget_path));
1078
+		}
1079
+		// create classname from widget directory name
1080
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1081
+		// add class prefix
1082
+		$widget_class = 'EEW_' . $widget;
1083
+		// does the widget exist ?
1084
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1085
+			$msg = sprintf(
1086
+				__(
1087
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1088
+					'event_espresso'
1089
+				),
1090
+				$widget_class,
1091
+				$widget_path . '/' . $widget_class . $widget_ext
1092
+			);
1093
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1094
+			return;
1095
+		}
1096
+		// load the widget class file
1097
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1098
+		// verify that class exists
1099
+		if (! class_exists($widget_class)) {
1100
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1101
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1102
+			return;
1103
+		}
1104
+		register_widget($widget_class);
1105
+		// add to array of registered widgets
1106
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1107
+	}
1108
+
1109
+
1110
+	/**
1111
+	 *        _register_modules
1112
+	 *
1113
+	 * @access private
1114
+	 * @return array
1115
+	 */
1116
+	private function _register_modules()
1117
+	{
1118
+		// grab list of installed modules
1119
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1120
+		// filter list of modules to register
1121
+		$modules_to_register = apply_filters(
1122
+			'FHEE__EE_Config__register_modules__modules_to_register',
1123
+			$modules_to_register
1124
+		);
1125
+		if (! empty($modules_to_register)) {
1126
+			// loop through folders
1127
+			foreach ($modules_to_register as $module_path) {
1128
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1129
+				if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1130
+					&& $module_path !== EE_MODULES . 'gateways'
1131
+				) {
1132
+					// add to list of installed modules
1133
+					EE_Config::register_module($module_path);
1134
+				}
1135
+			}
1136
+		}
1137
+		// filter list of installed modules
1138
+		return apply_filters(
1139
+			'FHEE__EE_Config___register_modules__installed_modules',
1140
+			EE_Registry::instance()->modules
1141
+		);
1142
+	}
1143
+
1144
+
1145
+	/**
1146
+	 *    register_module - makes core aware of this module
1147
+	 *
1148
+	 * @access    public
1149
+	 * @param    string $module_path - full path up to and including module folder
1150
+	 * @return    bool
1151
+	 */
1152
+	public static function register_module($module_path = null)
1153
+	{
1154
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1155
+		$module_ext = '.module.php';
1156
+		// make all separators match
1157
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1158
+		// does the file path INCLUDE the actual file name as part of the path ?
1159
+		if (strpos($module_path, $module_ext) !== false) {
1160
+			// grab and shortcode file name from directory name and break apart at dots
1161
+			$module_file = explode('.', basename($module_path));
1162
+			// now we need to rebuild the shortcode path
1163
+			$module_path = explode('/', $module_path);
1164
+			// remove last segment
1165
+			array_pop($module_path);
1166
+			// glue it back together
1167
+			$module_path = implode('/', $module_path) . '/';
1168
+			// take first segment from file name pieces and sanitize it
1169
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1170
+			// ensure class prefix is added
1171
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1172
+		} else {
1173
+			// we need to generate the filename based off of the folder name
1174
+			// grab and sanitize module name
1175
+			$module = strtolower(basename($module_path));
1176
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1177
+			// like trailingslashit()
1178
+			$module_path = rtrim($module_path, '/') . '/';
1179
+			// create classname from module directory name
1180
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1181
+			// add class prefix
1182
+			$module_class = 'EED_' . $module;
1183
+		}
1184
+		// does the module exist ?
1185
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1186
+			$msg = sprintf(
1187
+				__(
1188
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1189
+					'event_espresso'
1190
+				),
1191
+				$module
1192
+			);
1193
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1194
+			return false;
1195
+		}
1196
+		// load the module class file
1197
+		require_once($module_path . $module_class . $module_ext);
1198
+		// verify that class exists
1199
+		if (! class_exists($module_class)) {
1200
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1201
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1202
+			return false;
1203
+		}
1204
+		// add to array of registered modules
1205
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1206
+		do_action(
1207
+			'AHEE__EE_Config__register_module__complete',
1208
+			$module_class,
1209
+			EE_Registry::instance()->modules->{$module_class}
1210
+		);
1211
+		return true;
1212
+	}
1213
+
1214
+
1215
+	/**
1216
+	 *    _initialize_modules
1217
+	 *    allow modules to set hooks for the rest of the system
1218
+	 *
1219
+	 * @access private
1220
+	 * @return void
1221
+	 */
1222
+	private function _initialize_modules()
1223
+	{
1224
+		// cycle thru shortcode folders
1225
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1226
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1227
+			// which set hooks ?
1228
+			if (is_admin()) {
1229
+				// fire immediately
1230
+				call_user_func(array($module_class, 'set_hooks_admin'));
1231
+			} else {
1232
+				// delay until other systems are online
1233
+				add_action(
1234
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1235
+					array($module_class, 'set_hooks')
1236
+				);
1237
+			}
1238
+		}
1239
+	}
1240
+
1241
+
1242
+	/**
1243
+	 *    register_route - adds module method routes to route_map
1244
+	 *
1245
+	 * @access    public
1246
+	 * @param    string $route       - "pretty" public alias for module method
1247
+	 * @param    string $module      - module name (classname without EED_ prefix)
1248
+	 * @param    string $method_name - the actual module method to be routed to
1249
+	 * @param    string $key         - url param key indicating a route is being called
1250
+	 * @return    bool
1251
+	 */
1252
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1253
+	{
1254
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1255
+		$module = str_replace('EED_', '', $module);
1256
+		$module_class = 'EED_' . $module;
1257
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1258
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1259
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1260
+			return false;
1261
+		}
1262
+		if (empty($route)) {
1263
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1264
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1265
+			return false;
1266
+		}
1267
+		if (! method_exists('EED_' . $module, $method_name)) {
1268
+			$msg = sprintf(
1269
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1270
+				$route
1271
+			);
1272
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1273
+			return false;
1274
+		}
1275
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1276
+		return true;
1277
+	}
1278
+
1279
+
1280
+	/**
1281
+	 *    get_route - get module method route
1282
+	 *
1283
+	 * @access    public
1284
+	 * @param    string $route - "pretty" public alias for module method
1285
+	 * @param    string $key   - url param key indicating a route is being called
1286
+	 * @return    string
1287
+	 */
1288
+	public static function get_route($route = null, $key = 'ee')
1289
+	{
1290
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1291
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1292
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1293
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1294
+		}
1295
+		return null;
1296
+	}
1297
+
1298
+
1299
+	/**
1300
+	 *    get_routes - get ALL module method routes
1301
+	 *
1302
+	 * @access    public
1303
+	 * @return    array
1304
+	 */
1305
+	public static function get_routes()
1306
+	{
1307
+		return EE_Config::$_module_route_map;
1308
+	}
1309
+
1310
+
1311
+	/**
1312
+	 *    register_forward - allows modules to forward request to another module for further processing
1313
+	 *
1314
+	 * @access    public
1315
+	 * @param    string       $route   - "pretty" public alias for module method
1316
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1317
+	 *                                 class, allows different forwards to be served based on status
1318
+	 * @param    array|string $forward - function name or array( class, method )
1319
+	 * @param    string       $key     - url param key indicating a route is being called
1320
+	 * @return    bool
1321
+	 */
1322
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1323
+	{
1324
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1325
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1326
+			$msg = sprintf(
1327
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1328
+				$route
1329
+			);
1330
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1331
+			return false;
1332
+		}
1333
+		if (empty($forward)) {
1334
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1335
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1336
+			return false;
1337
+		}
1338
+		if (is_array($forward)) {
1339
+			if (! isset($forward[1])) {
1340
+				$msg = sprintf(
1341
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1342
+					$route
1343
+				);
1344
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1345
+				return false;
1346
+			}
1347
+			if (! method_exists($forward[0], $forward[1])) {
1348
+				$msg = sprintf(
1349
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1350
+					$forward[1],
1351
+					$route
1352
+				);
1353
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1354
+				return false;
1355
+			}
1356
+		} elseif (! function_exists($forward)) {
1357
+			$msg = sprintf(
1358
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1359
+				$forward,
1360
+				$route
1361
+			);
1362
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1363
+			return false;
1364
+		}
1365
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1366
+		return true;
1367
+	}
1368
+
1369
+
1370
+	/**
1371
+	 *    get_forward - get forwarding route
1372
+	 *
1373
+	 * @access    public
1374
+	 * @param    string  $route  - "pretty" public alias for module method
1375
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1376
+	 *                           allows different forwards to be served based on status
1377
+	 * @param    string  $key    - url param key indicating a route is being called
1378
+	 * @return    string
1379
+	 */
1380
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1381
+	{
1382
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1383
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1384
+			return apply_filters(
1385
+				'FHEE__EE_Config__get_forward',
1386
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1387
+				$route,
1388
+				$status
1389
+			);
1390
+		}
1391
+		return null;
1392
+	}
1393
+
1394
+
1395
+	/**
1396
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1397
+	 *    results
1398
+	 *
1399
+	 * @access    public
1400
+	 * @param    string  $route  - "pretty" public alias for module method
1401
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1402
+	 *                           allows different views to be served based on status
1403
+	 * @param    string  $view
1404
+	 * @param    string  $key    - url param key indicating a route is being called
1405
+	 * @return    bool
1406
+	 */
1407
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1408
+	{
1409
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1410
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1411
+			$msg = sprintf(
1412
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1413
+				$route
1414
+			);
1415
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1416
+			return false;
1417
+		}
1418
+		if (! is_readable($view)) {
1419
+			$msg = sprintf(
1420
+				__(
1421
+					'The %s view file could not be found or is not readable due to file permissions.',
1422
+					'event_espresso'
1423
+				),
1424
+				$view
1425
+			);
1426
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1427
+			return false;
1428
+		}
1429
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1430
+		return true;
1431
+	}
1432
+
1433
+
1434
+	/**
1435
+	 *    get_view - get view for route and status
1436
+	 *
1437
+	 * @access    public
1438
+	 * @param    string  $route  - "pretty" public alias for module method
1439
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1440
+	 *                           allows different views to be served based on status
1441
+	 * @param    string  $key    - url param key indicating a route is being called
1442
+	 * @return    string
1443
+	 */
1444
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1445
+	{
1446
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1447
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1448
+			return apply_filters(
1449
+				'FHEE__EE_Config__get_view',
1450
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1451
+				$route,
1452
+				$status
1453
+			);
1454
+		}
1455
+		return null;
1456
+	}
1457
+
1458
+
1459
+	public function update_addon_option_names()
1460
+	{
1461
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1462
+	}
1463
+
1464
+
1465
+	public function shutdown()
1466
+	{
1467
+		$this->update_addon_option_names();
1468
+	}
1469
+
1470
+
1471
+	/**
1472
+	 * @return LegacyShortcodesManager
1473
+	 */
1474
+	public static function getLegacyShortcodesManager()
1475
+	{
1476
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477
+			EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1478
+				LegacyShortcodesManager::class
1479
+			);
1480
+		}
1481
+		return EE_Config::instance()->legacy_shortcodes_manager;
1482
+	}
1483
+
1484
+
1485
+	/**
1486
+	 * register_shortcode - makes core aware of this shortcode
1487
+	 *
1488
+	 * @deprecated 4.9.26
1489
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1490
+	 * @return    bool
1491
+	 */
1492
+	public static function register_shortcode($shortcode_path = null)
1493
+	{
1494
+		EE_Error::doing_it_wrong(
1495
+			__METHOD__,
1496
+			__(
1497
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1498
+				'event_espresso'
1499
+			),
1500
+			'4.9.26'
1501
+		);
1502
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1503
+	}
1504
+}
2266 1505
 
2267
-    /**
2268
-     * ReCaptcha Type
2269
-     *
2270
-     * @var string $recaptcha_type
2271
-     *    options: 'audio', 'image'
2272
-     */
2273
-    public $recaptcha_type;
1506
+/**
1507
+ * Base class used for config classes. These classes should generally not have
1508
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1509
+ * basically, they should just be well-defined stdClasses
1510
+ */
1511
+class EE_Config_Base
1512
+{
2274 1513
 
2275
-    /**
2276
-     * ReCaptcha language
2277
-     *
2278
-     * @var string $recaptcha_language
2279
-     * eg 'en'
2280
-     */
2281
-    public $recaptcha_language;
1514
+	/**
1515
+	 * Utility function for escaping the value of a property and returning.
1516
+	 *
1517
+	 * @param string $property property name (checks to see if exists).
1518
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1519
+	 * @throws \EE_Error
1520
+	 */
1521
+	public function get_pretty($property)
1522
+	{
1523
+		if (! property_exists($this, $property)) {
1524
+			throw new EE_Error(
1525
+				sprintf(
1526
+					__(
1527
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1528
+						'event_espresso'
1529
+					),
1530
+					get_class($this),
1531
+					$property
1532
+				)
1533
+			);
1534
+		}
1535
+		// just handling escaping of strings for now.
1536
+		if (is_string($this->{$property})) {
1537
+			return stripslashes($this->{$property});
1538
+		}
1539
+		return $this->{$property};
1540
+	}
1541
+
1542
+
1543
+	public function populate()
1544
+	{
1545
+		// grab defaults via a new instance of this class.
1546
+		$class_name = get_class($this);
1547
+		$defaults = new $class_name;
1548
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1549
+		// default from our $defaults object.
1550
+		foreach (get_object_vars($defaults) as $property => $value) {
1551
+			if ($this->{$property} === null) {
1552
+				$this->{$property} = $value;
1553
+			}
1554
+		}
1555
+		// cleanup
1556
+		unset($defaults);
1557
+	}
1558
+
1559
+
1560
+	/**
1561
+	 *        __isset
1562
+	 *
1563
+	 * @param $a
1564
+	 * @return bool
1565
+	 */
1566
+	public function __isset($a)
1567
+	{
1568
+		return false;
1569
+	}
1570
+
1571
+
1572
+	/**
1573
+	 *        __unset
1574
+	 *
1575
+	 * @param $a
1576
+	 * @return bool
1577
+	 */
1578
+	public function __unset($a)
1579
+	{
1580
+		return false;
1581
+	}
1582
+
1583
+
1584
+	/**
1585
+	 *        __clone
1586
+	 */
1587
+	public function __clone()
1588
+	{
1589
+	}
1590
+
1591
+
1592
+	/**
1593
+	 *        __wakeup
1594
+	 */
1595
+	public function __wakeup()
1596
+	{
1597
+	}
1598
+
1599
+
1600
+	/**
1601
+	 *        __destruct
1602
+	 */
1603
+	public function __destruct()
1604
+	{
1605
+	}
1606
+}
2282 1607
 
2283
-    /**
2284
-     * ReCaptcha public key
2285
-     *
2286
-     * @var string $recaptcha_publickey
2287
-     */
2288
-    public $recaptcha_publickey;
1608
+/**
1609
+ * Class for defining what's in the EE_Config relating to registration settings
1610
+ */
1611
+class EE_Core_Config extends EE_Config_Base
1612
+{
2289 1613
 
2290
-    /**
2291
-     * ReCaptcha private key
2292
-     *
2293
-     * @var string $recaptcha_privatekey
2294
-     */
2295
-    public $recaptcha_privatekey;
1614
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1615
+
1616
+
1617
+	public $current_blog_id;
1618
+
1619
+	public $ee_ueip_optin;
1620
+
1621
+	public $ee_ueip_has_notified;
1622
+
1623
+	/**
1624
+	 * Not to be confused with the 4 critical page variables (See
1625
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1626
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1627
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1628
+	 *
1629
+	 * @var array
1630
+	 */
1631
+	public $post_shortcodes;
1632
+
1633
+	public $module_route_map;
1634
+
1635
+	public $module_forward_map;
1636
+
1637
+	public $module_view_map;
1638
+
1639
+	/**
1640
+	 * The next 4 vars are the IDs of critical EE pages.
1641
+	 *
1642
+	 * @var int
1643
+	 */
1644
+	public $reg_page_id;
1645
+
1646
+	public $txn_page_id;
1647
+
1648
+	public $thank_you_page_id;
1649
+
1650
+	public $cancel_page_id;
1651
+
1652
+	/**
1653
+	 * The next 4 vars are the URLs of critical EE pages.
1654
+	 *
1655
+	 * @var int
1656
+	 */
1657
+	public $reg_page_url;
1658
+
1659
+	public $txn_page_url;
1660
+
1661
+	public $thank_you_page_url;
1662
+
1663
+	public $cancel_page_url;
1664
+
1665
+	/**
1666
+	 * The next vars relate to the custom slugs for EE CPT routes
1667
+	 */
1668
+	public $event_cpt_slug;
1669
+
1670
+	/**
1671
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1672
+	 * request across blog switches in a multisite context.
1673
+	 * Avoids extra queries to the db for this option.
1674
+	 *
1675
+	 * @var bool
1676
+	 */
1677
+	public static $ee_ueip_option;
1678
+
1679
+
1680
+	/**
1681
+	 *    class constructor
1682
+	 *
1683
+	 * @access    public
1684
+	 */
1685
+	public function __construct()
1686
+	{
1687
+		// set default organization settings
1688
+		$this->current_blog_id = get_current_blog_id();
1689
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1690
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1691
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1692
+		$this->post_shortcodes = array();
1693
+		$this->module_route_map = array();
1694
+		$this->module_forward_map = array();
1695
+		$this->module_view_map = array();
1696
+		// critical EE page IDs
1697
+		$this->reg_page_id = 0;
1698
+		$this->txn_page_id = 0;
1699
+		$this->thank_you_page_id = 0;
1700
+		$this->cancel_page_id = 0;
1701
+		// critical EE page URLs
1702
+		$this->reg_page_url = '';
1703
+		$this->txn_page_url = '';
1704
+		$this->thank_you_page_url = '';
1705
+		$this->cancel_page_url = '';
1706
+		// cpt slugs
1707
+		$this->event_cpt_slug = __('events', 'event_espresso');
1708
+		// ueip constant check
1709
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1710
+			$this->ee_ueip_optin = false;
1711
+			$this->ee_ueip_has_notified = true;
1712
+		}
1713
+	}
1714
+
1715
+
1716
+	/**
1717
+	 * @return array
1718
+	 */
1719
+	public function get_critical_pages_array()
1720
+	{
1721
+		return array(
1722
+			$this->reg_page_id,
1723
+			$this->txn_page_id,
1724
+			$this->thank_you_page_id,
1725
+			$this->cancel_page_id,
1726
+		);
1727
+	}
1728
+
1729
+
1730
+	/**
1731
+	 * @return array
1732
+	 */
1733
+	public function get_critical_pages_shortcodes_array()
1734
+	{
1735
+		return array(
1736
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1737
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1738
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1739
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1740
+		);
1741
+	}
1742
+
1743
+
1744
+	/**
1745
+	 *  gets/returns URL for EE reg_page
1746
+	 *
1747
+	 * @access    public
1748
+	 * @return    string
1749
+	 */
1750
+	public function reg_page_url()
1751
+	{
1752
+		if (! $this->reg_page_url) {
1753
+			$this->reg_page_url = add_query_arg(
1754
+				array('uts' => time()),
1755
+				get_permalink($this->reg_page_id)
1756
+			) . '#checkout';
1757
+		}
1758
+		return $this->reg_page_url;
1759
+	}
1760
+
1761
+
1762
+	/**
1763
+	 *  gets/returns URL for EE txn_page
1764
+	 *
1765
+	 * @param array $query_args like what gets passed to
1766
+	 *                          add_query_arg() as the first argument
1767
+	 * @access    public
1768
+	 * @return    string
1769
+	 */
1770
+	public function txn_page_url($query_args = array())
1771
+	{
1772
+		if (! $this->txn_page_url) {
1773
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1774
+		}
1775
+		if ($query_args) {
1776
+			return add_query_arg($query_args, $this->txn_page_url);
1777
+		} else {
1778
+			return $this->txn_page_url;
1779
+		}
1780
+	}
1781
+
1782
+
1783
+	/**
1784
+	 *  gets/returns URL for EE thank_you_page
1785
+	 *
1786
+	 * @param array $query_args like what gets passed to
1787
+	 *                          add_query_arg() as the first argument
1788
+	 * @access    public
1789
+	 * @return    string
1790
+	 */
1791
+	public function thank_you_page_url($query_args = array())
1792
+	{
1793
+		if (! $this->thank_you_page_url) {
1794
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795
+		}
1796
+		if ($query_args) {
1797
+			return add_query_arg($query_args, $this->thank_you_page_url);
1798
+		} else {
1799
+			return $this->thank_you_page_url;
1800
+		}
1801
+	}
1802
+
1803
+
1804
+	/**
1805
+	 *  gets/returns URL for EE cancel_page
1806
+	 *
1807
+	 * @access    public
1808
+	 * @return    string
1809
+	 */
1810
+	public function cancel_page_url()
1811
+	{
1812
+		if (! $this->cancel_page_url) {
1813
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1814
+		}
1815
+		return $this->cancel_page_url;
1816
+	}
1817
+
1818
+
1819
+	/**
1820
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1821
+	 *
1822
+	 * @since 4.7.5
1823
+	 */
1824
+	protected function _reset_urls()
1825
+	{
1826
+		$this->reg_page_url = '';
1827
+		$this->txn_page_url = '';
1828
+		$this->cancel_page_url = '';
1829
+		$this->thank_you_page_url = '';
1830
+	}
1831
+
1832
+
1833
+	/**
1834
+	 * Used to return what the optin value is set for the EE User Experience Program.
1835
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1836
+	 * on the main site only.
1837
+	 *
1838
+	 * @return bool
1839
+	 */
1840
+	protected function _get_main_ee_ueip_optin()
1841
+	{
1842
+		// if this is the main site then we can just bypass our direct query.
1843
+		if (is_main_site()) {
1844
+			return get_option(self::OPTION_NAME_UXIP, false);
1845
+		}
1846
+		// is this already cached for this request?  If so use it.
1847
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1848
+			return EE_Core_Config::$ee_ueip_option;
1849
+		}
1850
+		global $wpdb;
1851
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1852
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853
+		$option = self::OPTION_NAME_UXIP;
1854
+		// set correct table for query
1855
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1856
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860
+		// for the purpose of caching.
1861
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1862
+		if (false !== $pre) {
1863
+			EE_Core_Config::$ee_ueip_option = $pre;
1864
+			return EE_Core_Config::$ee_ueip_option;
1865
+		}
1866
+		$row = $wpdb->get_row(
1867
+			$wpdb->prepare(
1868
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1869
+				$option
1870
+			)
1871
+		);
1872
+		if (is_object($row)) {
1873
+			$value = $row->option_value;
1874
+		} else { // option does not exist so use default.
1875
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1876
+			return EE_Core_Config::$ee_ueip_option;
1877
+		}
1878
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1879
+		return EE_Core_Config::$ee_ueip_option;
1880
+	}
1881
+
1882
+
1883
+	/**
1884
+	 * Utility function for escaping the value of a property and returning.
1885
+	 *
1886
+	 * @param string $property property name (checks to see if exists).
1887
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1888
+	 * @throws \EE_Error
1889
+	 */
1890
+	public function get_pretty($property)
1891
+	{
1892
+		if ($property === self::OPTION_NAME_UXIP) {
1893
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1894
+		}
1895
+		return parent::get_pretty($property);
1896
+	}
1897
+
1898
+
1899
+	/**
1900
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1901
+	 * on the object.
1902
+	 *
1903
+	 * @return array
1904
+	 */
1905
+	public function __sleep()
1906
+	{
1907
+		// reset all url properties
1908
+		$this->_reset_urls();
1909
+		// return what to save to db
1910
+		return array_keys(get_object_vars($this));
1911
+	}
1912
+}
2296 1913
 
2297
-    /**
2298
-     * array of form names protected by ReCaptcha
2299
-     *
2300
-     * @var array $recaptcha_protected_forms
2301
-     */
2302
-    public $recaptcha_protected_forms;
1914
+/**
1915
+ * Config class for storing info on the Organization
1916
+ */
1917
+class EE_Organization_Config extends EE_Config_Base
1918
+{
2303 1919
 
2304
-    /**
2305
-     * ReCaptcha width
2306
-     *
2307
-     * @var int $recaptcha_width
2308
-     * @deprecated
2309
-     */
2310
-    public $recaptcha_width;
1920
+	/**
1921
+	 * @var string $name
1922
+	 * eg EE4.1
1923
+	 */
1924
+	public $name;
1925
+
1926
+	/**
1927
+	 * @var string $address_1
1928
+	 * eg 123 Onna Road
1929
+	 */
1930
+	public $address_1 = '';
1931
+
1932
+	/**
1933
+	 * @var string $address_2
1934
+	 * eg PO Box 123
1935
+	 */
1936
+	public $address_2 = '';
1937
+
1938
+	/**
1939
+	 * @var string $city
1940
+	 * eg Inna City
1941
+	 */
1942
+	public $city = '';
1943
+
1944
+	/**
1945
+	 * @var int $STA_ID
1946
+	 * eg 4
1947
+	 */
1948
+	public $STA_ID = 0;
1949
+
1950
+	/**
1951
+	 * @var string $CNT_ISO
1952
+	 * eg US
1953
+	 */
1954
+	public $CNT_ISO = '';
1955
+
1956
+	/**
1957
+	 * @var string $zip
1958
+	 * eg 12345  or V1A 2B3
1959
+	 */
1960
+	public $zip = '';
1961
+
1962
+	/**
1963
+	 * @var string $email
1964
+	 * eg [email protected]
1965
+	 */
1966
+	public $email;
1967
+
1968
+	/**
1969
+	 * @var string $phone
1970
+	 * eg. 111-111-1111
1971
+	 */
1972
+	public $phone = '';
1973
+
1974
+	/**
1975
+	 * @var string $vat
1976
+	 * VAT/Tax Number
1977
+	 */
1978
+	public $vat = '';
1979
+
1980
+	/**
1981
+	 * @var string $logo_url
1982
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1983
+	 */
1984
+	public $logo_url = '';
1985
+
1986
+	/**
1987
+	 * The below are all various properties for holding links to organization social network profiles
1988
+	 *
1989
+	 * @var string
1990
+	 */
1991
+	/**
1992
+	 * facebook (facebook.com/profile.name)
1993
+	 *
1994
+	 * @var string
1995
+	 */
1996
+	public $facebook = '';
1997
+
1998
+	/**
1999
+	 * twitter (twitter.com/twitter_handle)
2000
+	 *
2001
+	 * @var string
2002
+	 */
2003
+	public $twitter = '';
2004
+
2005
+	/**
2006
+	 * linkedin (linkedin.com/in/profile_name)
2007
+	 *
2008
+	 * @var string
2009
+	 */
2010
+	public $linkedin = '';
2011
+
2012
+	/**
2013
+	 * pinterest (www.pinterest.com/profile_name)
2014
+	 *
2015
+	 * @var string
2016
+	 */
2017
+	public $pinterest = '';
2018
+
2019
+	/**
2020
+	 * google+ (google.com/+profileName)
2021
+	 *
2022
+	 * @var string
2023
+	 */
2024
+	public $google = '';
2025
+
2026
+	/**
2027
+	 * instagram (instagram.com/handle)
2028
+	 *
2029
+	 * @var string
2030
+	 */
2031
+	public $instagram = '';
2032
+
2033
+
2034
+	/**
2035
+	 *    class constructor
2036
+	 *
2037
+	 * @access    public
2038
+	 */
2039
+	public function __construct()
2040
+	{
2041
+		// set default organization settings
2042
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2043
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2044
+		$this->email = get_bloginfo('admin_email');
2045
+	}
2046
+}
2311 2047
 
2312
-    /**
2313
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2314
-     *
2315
-     * @var boolean $track_invalid_checkout_access
2316
-     */
2317
-    protected $track_invalid_checkout_access = true;
2048
+/**
2049
+ * Class for defining what's in the EE_Config relating to currency
2050
+ */
2051
+class EE_Currency_Config extends EE_Config_Base
2052
+{
2318 2053
 
2319
-    /**
2320
-     * Whether or not to show the privacy policy consent checkbox
2321
-     *
2322
-     * @var bool
2323
-     */
2324
-    public $consent_checkbox_enabled;
2054
+	/**
2055
+	 * @var string $code
2056
+	 * eg 'US'
2057
+	 */
2058
+	public $code;
2059
+
2060
+	/**
2061
+	 * @var string $name
2062
+	 * eg 'Dollar'
2063
+	 */
2064
+	public $name;
2065
+
2066
+	/**
2067
+	 * plural name
2068
+	 *
2069
+	 * @var string $plural
2070
+	 * eg 'Dollars'
2071
+	 */
2072
+	public $plural;
2073
+
2074
+	/**
2075
+	 * currency sign
2076
+	 *
2077
+	 * @var string $sign
2078
+	 * eg '$'
2079
+	 */
2080
+	public $sign;
2081
+
2082
+	/**
2083
+	 * Whether the currency sign should come before the number or not
2084
+	 *
2085
+	 * @var boolean $sign_b4
2086
+	 */
2087
+	public $sign_b4;
2088
+
2089
+	/**
2090
+	 * How many digits should come after the decimal place
2091
+	 *
2092
+	 * @var int $dec_plc
2093
+	 */
2094
+	public $dec_plc;
2095
+
2096
+	/**
2097
+	 * Symbol to use for decimal mark
2098
+	 *
2099
+	 * @var string $dec_mrk
2100
+	 * eg '.'
2101
+	 */
2102
+	public $dec_mrk;
2103
+
2104
+	/**
2105
+	 * Symbol to use for thousands
2106
+	 *
2107
+	 * @var string $thsnds
2108
+	 * eg ','
2109
+	 */
2110
+	public $thsnds;
2111
+
2112
+
2113
+	/**
2114
+	 *    class constructor
2115
+	 *
2116
+	 * @access    public
2117
+	 * @param string $CNT_ISO
2118
+	 * @throws \EE_Error
2119
+	 */
2120
+	public function __construct($CNT_ISO = '')
2121
+	{
2122
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2123
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2124
+		// get country code from organization settings or use default
2125
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2126
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2127
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2128
+			: '';
2129
+		// but override if requested
2130
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2131
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2132
+		if (! empty($CNT_ISO)
2133
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2134
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2135
+		) {
2136
+			// retrieve the country settings from the db, just in case they have been customized
2137
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2138
+			if ($country instanceof EE_Country) {
2139
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2140
+				$this->name = $country->currency_name_single();    // Dollar
2141
+				$this->plural = $country->currency_name_plural();    // Dollars
2142
+				$this->sign = $country->currency_sign();            // currency sign: $
2143
+				$this->sign_b4 = $country->currency_sign_before(
2144
+				);        // currency sign before or after: $TRUE  or  FALSE$
2145
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2146
+				$this->dec_mrk = $country->currency_decimal_mark(
2147
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2148
+				$this->thsnds = $country->currency_thousands_separator(
2149
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2150
+			}
2151
+		}
2152
+		// fallback to hardcoded defaults, in case the above failed
2153
+		if (empty($this->code)) {
2154
+			// set default currency settings
2155
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2156
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2157
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2158
+			$this->sign = '$';    // currency sign: $
2159
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2160
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2161
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2162
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2163
+		}
2164
+	}
2165
+}
2325 2166
 
2326
-    /**
2327
-     * Label text to show on the checkbox
2328
-     *
2329
-     * @var string
2330
-     */
2331
-    public $consent_checkbox_label_text;
2167
+/**
2168
+ * Class for defining what's in the EE_Config relating to registration settings
2169
+ */
2170
+class EE_Registration_Config extends EE_Config_Base
2171
+{
2332 2172
 
2333
-    /*
2173
+	/**
2174
+	 * Default registration status
2175
+	 *
2176
+	 * @var string $default_STS_ID
2177
+	 * eg 'RPP'
2178
+	 */
2179
+	public $default_STS_ID;
2180
+
2181
+	/**
2182
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2183
+	 * registrations)
2184
+	 *
2185
+	 * @var int
2186
+	 */
2187
+	public $default_maximum_number_of_tickets;
2188
+
2189
+	/**
2190
+	 * level of validation to apply to email addresses
2191
+	 *
2192
+	 * @var string $email_validation_level
2193
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2194
+	 */
2195
+	public $email_validation_level;
2196
+
2197
+	/**
2198
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2199
+	 *
2200
+	 * @var boolean $show_pending_payment_options
2201
+	 */
2202
+	public $show_pending_payment_options;
2203
+
2204
+	/**
2205
+	 * Whether to skip the registration confirmation page
2206
+	 *
2207
+	 * @var boolean $skip_reg_confirmation
2208
+	 */
2209
+	public $skip_reg_confirmation;
2210
+
2211
+	/**
2212
+	 * an array of SPCO reg steps where:
2213
+	 *        the keys denotes the reg step order
2214
+	 *        each element consists of an array with the following elements:
2215
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2216
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2217
+	 *            "slug" => the URL param used to trigger the reg step
2218
+	 *
2219
+	 * @var array $reg_steps
2220
+	 */
2221
+	public $reg_steps;
2222
+
2223
+	/**
2224
+	 * Whether registration confirmation should be the last page of SPCO
2225
+	 *
2226
+	 * @var boolean $reg_confirmation_last
2227
+	 */
2228
+	public $reg_confirmation_last;
2229
+
2230
+	/**
2231
+	 * Whether or not to enable the EE Bot Trap
2232
+	 *
2233
+	 * @var boolean $use_bot_trap
2234
+	 */
2235
+	public $use_bot_trap;
2236
+
2237
+	/**
2238
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2239
+	 *
2240
+	 * @var boolean $use_encryption
2241
+	 */
2242
+	public $use_encryption;
2243
+
2244
+	/**
2245
+	 * Whether or not to use ReCaptcha
2246
+	 *
2247
+	 * @var boolean $use_captcha
2248
+	 */
2249
+	public $use_captcha;
2250
+
2251
+	/**
2252
+	 * ReCaptcha Theme
2253
+	 *
2254
+	 * @var string $recaptcha_theme
2255
+	 *    options: 'dark', 'light', 'invisible'
2256
+	 */
2257
+	public $recaptcha_theme;
2258
+
2259
+	/**
2260
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2261
+	 *
2262
+	 * @var string $recaptcha_badge
2263
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2264
+	 */
2265
+	public $recaptcha_badge;
2266
+
2267
+	/**
2268
+	 * ReCaptcha Type
2269
+	 *
2270
+	 * @var string $recaptcha_type
2271
+	 *    options: 'audio', 'image'
2272
+	 */
2273
+	public $recaptcha_type;
2274
+
2275
+	/**
2276
+	 * ReCaptcha language
2277
+	 *
2278
+	 * @var string $recaptcha_language
2279
+	 * eg 'en'
2280
+	 */
2281
+	public $recaptcha_language;
2282
+
2283
+	/**
2284
+	 * ReCaptcha public key
2285
+	 *
2286
+	 * @var string $recaptcha_publickey
2287
+	 */
2288
+	public $recaptcha_publickey;
2289
+
2290
+	/**
2291
+	 * ReCaptcha private key
2292
+	 *
2293
+	 * @var string $recaptcha_privatekey
2294
+	 */
2295
+	public $recaptcha_privatekey;
2296
+
2297
+	/**
2298
+	 * array of form names protected by ReCaptcha
2299
+	 *
2300
+	 * @var array $recaptcha_protected_forms
2301
+	 */
2302
+	public $recaptcha_protected_forms;
2303
+
2304
+	/**
2305
+	 * ReCaptcha width
2306
+	 *
2307
+	 * @var int $recaptcha_width
2308
+	 * @deprecated
2309
+	 */
2310
+	public $recaptcha_width;
2311
+
2312
+	/**
2313
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2314
+	 *
2315
+	 * @var boolean $track_invalid_checkout_access
2316
+	 */
2317
+	protected $track_invalid_checkout_access = true;
2318
+
2319
+	/**
2320
+	 * Whether or not to show the privacy policy consent checkbox
2321
+	 *
2322
+	 * @var bool
2323
+	 */
2324
+	public $consent_checkbox_enabled;
2325
+
2326
+	/**
2327
+	 * Label text to show on the checkbox
2328
+	 *
2329
+	 * @var string
2330
+	 */
2331
+	public $consent_checkbox_label_text;
2332
+
2333
+	/*
2334 2334
      * String describing how long to keep payment logs. Passed into DateTime constructor
2335 2335
      * @var string
2336 2336
      */
2337
-    public $gateway_log_lifespan = '1 week';
2338
-
2339
-    /**
2340
-     * Enable copy attendee info at form
2341
-     *
2342
-     * @var boolean $enable_copy_attendee
2343
-     */
2344
-    protected $copy_attendee_info = true;
2345
-
2346
-
2347
-    /**
2348
-     *    class constructor
2349
-     *
2350
-     * @access    public
2351
-     */
2352
-    public function __construct()
2353
-    {
2354
-        // set default registration settings
2355
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2356
-        $this->email_validation_level = 'wp_default';
2357
-        $this->show_pending_payment_options = true;
2358
-        $this->skip_reg_confirmation = true;
2359
-        $this->reg_steps = array();
2360
-        $this->reg_confirmation_last = false;
2361
-        $this->use_bot_trap = true;
2362
-        $this->use_encryption = true;
2363
-        $this->use_captcha = false;
2364
-        $this->recaptcha_theme = 'light';
2365
-        $this->recaptcha_badge = 'bottomleft';
2366
-        $this->recaptcha_type = 'image';
2367
-        $this->recaptcha_language = 'en';
2368
-        $this->recaptcha_publickey = null;
2369
-        $this->recaptcha_privatekey = null;
2370
-        $this->recaptcha_protected_forms = array();
2371
-        $this->recaptcha_width = 500;
2372
-        $this->default_maximum_number_of_tickets = 10;
2373
-        $this->consent_checkbox_enabled = false;
2374
-        $this->consent_checkbox_label_text = '';
2375
-        $this->gateway_log_lifespan = '7 days';
2376
-        $this->copy_attendee_info = true;
2377
-    }
2378
-
2379
-
2380
-    /**
2381
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2382
-     *
2383
-     * @since 4.8.8.rc.019
2384
-     */
2385
-    public function do_hooks()
2386
-    {
2387
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2388
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2389
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2390
-    }
2391
-
2392
-
2393
-    /**
2394
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2395
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2396
-     */
2397
-    public function set_default_reg_status_on_EEM_Event()
2398
-    {
2399
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2400
-    }
2401
-
2402
-
2403
-    /**
2404
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2405
-     * for Events matches the config setting for default_maximum_number_of_tickets
2406
-     */
2407
-    public function set_default_max_ticket_on_EEM_Event()
2408
-    {
2409
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2410
-    }
2411
-
2412
-
2413
-    /**
2414
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2415
-     * constructed because that happens before we can get the privacy policy page's permalink.
2416
-     *
2417
-     * @throws InvalidArgumentException
2418
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2419
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2420
-     */
2421
-    public function setDefaultCheckboxLabelText()
2422
-    {
2423
-        if ($this->getConsentCheckboxLabelText() === null
2424
-            || $this->getConsentCheckboxLabelText() === '') {
2425
-            $opening_a_tag = '';
2426
-            $closing_a_tag = '';
2427
-            if (function_exists('get_privacy_policy_url')) {
2428
-                $privacy_page_url = get_privacy_policy_url();
2429
-                if (! empty($privacy_page_url)) {
2430
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2431
-                    $closing_a_tag = '</a>';
2432
-                }
2433
-            }
2434
-            $loader = LoaderFactory::getLoader();
2435
-            $org_config = $loader->getShared('EE_Organization_Config');
2436
-            /**
2437
-             * @var $org_config EE_Organization_Config
2438
-             */
2439
-
2440
-            $this->setConsentCheckboxLabelText(
2441
-                sprintf(
2442
-                    esc_html__(
2443
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2444
-                        'event_espresso'
2445
-                    ),
2446
-                    $org_config->name,
2447
-                    $opening_a_tag,
2448
-                    $closing_a_tag
2449
-                )
2450
-            );
2451
-        }
2452
-    }
2453
-
2454
-
2455
-    /**
2456
-     * @return boolean
2457
-     */
2458
-    public function track_invalid_checkout_access()
2459
-    {
2460
-        return $this->track_invalid_checkout_access;
2461
-    }
2462
-
2463
-
2464
-    /**
2465
-     * @param boolean $track_invalid_checkout_access
2466
-     */
2467
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
-    {
2469
-        $this->track_invalid_checkout_access = filter_var(
2470
-            $track_invalid_checkout_access,
2471
-            FILTER_VALIDATE_BOOLEAN
2472
-        );
2473
-    }
2474
-
2475
-    /**
2476
-     * @return boolean
2477
-     */
2478
-    public function copyAttendeeInfo()
2479
-    {
2480
-        return $this->copy_attendee_info;
2481
-    }
2482
-
2483
-
2484
-    /**
2485
-     * @param boolean $copy_attendee_info
2486
-     */
2487
-    public function setCopyAttendeeInfo($copy_attendee_info)
2488
-    {
2489
-        $this->copy_attendee_info = filter_var(
2490
-            $copy_attendee_info,
2491
-            FILTER_VALIDATE_BOOLEAN
2492
-        );
2493
-    }
2494
-
2495
-
2496
-    /**
2497
-     * Gets the options to make availalbe for the gateway log lifespan
2498
-     * @return array
2499
-     */
2500
-    public function gatewayLogLifespanOptions()
2501
-    {
2502
-        return (array) apply_filters(
2503
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2504
-            array(
2505
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2506
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2507
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2508
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2509
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2510
-            )
2511
-        );
2512
-    }
2513
-
2514
-
2515
-    /**
2516
-     * @return bool
2517
-     */
2518
-    public function isConsentCheckboxEnabled()
2519
-    {
2520
-        return $this->consent_checkbox_enabled;
2521
-    }
2522
-
2523
-
2524
-    /**
2525
-     * @param bool $consent_checkbox_enabled
2526
-     */
2527
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2528
-    {
2529
-        $this->consent_checkbox_enabled = filter_var(
2530
-            $consent_checkbox_enabled,
2531
-            FILTER_VALIDATE_BOOLEAN
2532
-        );
2533
-    }
2534
-
2535
-
2536
-    /**
2537
-     * @return string
2538
-     */
2539
-    public function getConsentCheckboxLabelText()
2540
-    {
2541
-        return $this->consent_checkbox_label_text;
2542
-    }
2543
-
2544
-
2545
-    /**
2546
-     * @param string $consent_checkbox_label_text
2547
-     */
2548
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2549
-    {
2550
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2551
-    }
2337
+	public $gateway_log_lifespan = '1 week';
2338
+
2339
+	/**
2340
+	 * Enable copy attendee info at form
2341
+	 *
2342
+	 * @var boolean $enable_copy_attendee
2343
+	 */
2344
+	protected $copy_attendee_info = true;
2345
+
2346
+
2347
+	/**
2348
+	 *    class constructor
2349
+	 *
2350
+	 * @access    public
2351
+	 */
2352
+	public function __construct()
2353
+	{
2354
+		// set default registration settings
2355
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2356
+		$this->email_validation_level = 'wp_default';
2357
+		$this->show_pending_payment_options = true;
2358
+		$this->skip_reg_confirmation = true;
2359
+		$this->reg_steps = array();
2360
+		$this->reg_confirmation_last = false;
2361
+		$this->use_bot_trap = true;
2362
+		$this->use_encryption = true;
2363
+		$this->use_captcha = false;
2364
+		$this->recaptcha_theme = 'light';
2365
+		$this->recaptcha_badge = 'bottomleft';
2366
+		$this->recaptcha_type = 'image';
2367
+		$this->recaptcha_language = 'en';
2368
+		$this->recaptcha_publickey = null;
2369
+		$this->recaptcha_privatekey = null;
2370
+		$this->recaptcha_protected_forms = array();
2371
+		$this->recaptcha_width = 500;
2372
+		$this->default_maximum_number_of_tickets = 10;
2373
+		$this->consent_checkbox_enabled = false;
2374
+		$this->consent_checkbox_label_text = '';
2375
+		$this->gateway_log_lifespan = '7 days';
2376
+		$this->copy_attendee_info = true;
2377
+	}
2378
+
2379
+
2380
+	/**
2381
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2382
+	 *
2383
+	 * @since 4.8.8.rc.019
2384
+	 */
2385
+	public function do_hooks()
2386
+	{
2387
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2388
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2389
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2390
+	}
2391
+
2392
+
2393
+	/**
2394
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2395
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2396
+	 */
2397
+	public function set_default_reg_status_on_EEM_Event()
2398
+	{
2399
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2400
+	}
2401
+
2402
+
2403
+	/**
2404
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2405
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2406
+	 */
2407
+	public function set_default_max_ticket_on_EEM_Event()
2408
+	{
2409
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2410
+	}
2411
+
2412
+
2413
+	/**
2414
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2415
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2416
+	 *
2417
+	 * @throws InvalidArgumentException
2418
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2419
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2420
+	 */
2421
+	public function setDefaultCheckboxLabelText()
2422
+	{
2423
+		if ($this->getConsentCheckboxLabelText() === null
2424
+			|| $this->getConsentCheckboxLabelText() === '') {
2425
+			$opening_a_tag = '';
2426
+			$closing_a_tag = '';
2427
+			if (function_exists('get_privacy_policy_url')) {
2428
+				$privacy_page_url = get_privacy_policy_url();
2429
+				if (! empty($privacy_page_url)) {
2430
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2431
+					$closing_a_tag = '</a>';
2432
+				}
2433
+			}
2434
+			$loader = LoaderFactory::getLoader();
2435
+			$org_config = $loader->getShared('EE_Organization_Config');
2436
+			/**
2437
+			 * @var $org_config EE_Organization_Config
2438
+			 */
2439
+
2440
+			$this->setConsentCheckboxLabelText(
2441
+				sprintf(
2442
+					esc_html__(
2443
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2444
+						'event_espresso'
2445
+					),
2446
+					$org_config->name,
2447
+					$opening_a_tag,
2448
+					$closing_a_tag
2449
+				)
2450
+			);
2451
+		}
2452
+	}
2453
+
2454
+
2455
+	/**
2456
+	 * @return boolean
2457
+	 */
2458
+	public function track_invalid_checkout_access()
2459
+	{
2460
+		return $this->track_invalid_checkout_access;
2461
+	}
2462
+
2463
+
2464
+	/**
2465
+	 * @param boolean $track_invalid_checkout_access
2466
+	 */
2467
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
+	{
2469
+		$this->track_invalid_checkout_access = filter_var(
2470
+			$track_invalid_checkout_access,
2471
+			FILTER_VALIDATE_BOOLEAN
2472
+		);
2473
+	}
2474
+
2475
+	/**
2476
+	 * @return boolean
2477
+	 */
2478
+	public function copyAttendeeInfo()
2479
+	{
2480
+		return $this->copy_attendee_info;
2481
+	}
2482
+
2483
+
2484
+	/**
2485
+	 * @param boolean $copy_attendee_info
2486
+	 */
2487
+	public function setCopyAttendeeInfo($copy_attendee_info)
2488
+	{
2489
+		$this->copy_attendee_info = filter_var(
2490
+			$copy_attendee_info,
2491
+			FILTER_VALIDATE_BOOLEAN
2492
+		);
2493
+	}
2494
+
2495
+
2496
+	/**
2497
+	 * Gets the options to make availalbe for the gateway log lifespan
2498
+	 * @return array
2499
+	 */
2500
+	public function gatewayLogLifespanOptions()
2501
+	{
2502
+		return (array) apply_filters(
2503
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2504
+			array(
2505
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2506
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2507
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2508
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2509
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2510
+			)
2511
+		);
2512
+	}
2513
+
2514
+
2515
+	/**
2516
+	 * @return bool
2517
+	 */
2518
+	public function isConsentCheckboxEnabled()
2519
+	{
2520
+		return $this->consent_checkbox_enabled;
2521
+	}
2522
+
2523
+
2524
+	/**
2525
+	 * @param bool $consent_checkbox_enabled
2526
+	 */
2527
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2528
+	{
2529
+		$this->consent_checkbox_enabled = filter_var(
2530
+			$consent_checkbox_enabled,
2531
+			FILTER_VALIDATE_BOOLEAN
2532
+		);
2533
+	}
2534
+
2535
+
2536
+	/**
2537
+	 * @return string
2538
+	 */
2539
+	public function getConsentCheckboxLabelText()
2540
+	{
2541
+		return $this->consent_checkbox_label_text;
2542
+	}
2543
+
2544
+
2545
+	/**
2546
+	 * @param string $consent_checkbox_label_text
2547
+	 */
2548
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2549
+	{
2550
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2551
+	}
2552 2552
 }
2553 2553
 
2554 2554
 /**
@@ -2557,151 +2557,151 @@  discard block
 block discarded – undo
2557 2557
 class EE_Admin_Config extends EE_Config_Base
2558 2558
 {
2559 2559
 
2560
-    /**
2561
-     * @var boolean $use_personnel_manager
2562
-     */
2563
-    public $use_personnel_manager;
2564
-
2565
-    /**
2566
-     * @var boolean $use_dashboard_widget
2567
-     */
2568
-    public $use_dashboard_widget;
2569
-
2570
-    /**
2571
-     * @var int $events_in_dashboard
2572
-     */
2573
-    public $events_in_dashboard;
2574
-
2575
-    /**
2576
-     * @var boolean $use_event_timezones
2577
-     */
2578
-    public $use_event_timezones;
2579
-
2580
-    /**
2581
-     * @var string $log_file_name
2582
-     */
2583
-    public $log_file_name;
2584
-
2585
-    /**
2586
-     * @var string $debug_file_name
2587
-     */
2588
-    public $debug_file_name;
2589
-
2590
-    /**
2591
-     * @var boolean $use_remote_logging
2592
-     */
2593
-    public $use_remote_logging;
2594
-
2595
-    /**
2596
-     * @var string $remote_logging_url
2597
-     */
2598
-    public $remote_logging_url;
2599
-
2600
-    /**
2601
-     * @var boolean $show_reg_footer
2602
-     */
2603
-    public $show_reg_footer;
2604
-
2605
-    /**
2606
-     * @var string $affiliate_id
2607
-     */
2608
-    public $affiliate_id;
2609
-
2610
-    /**
2611
-     * help tours on or off (global setting)
2612
-     *
2613
-     * @var boolean
2614
-     */
2615
-    public $help_tour_activation;
2616
-
2617
-    /**
2618
-     * adds extra layer of encoding to session data to prevent serialization errors
2619
-     * but is incompatible with some server configuration errors
2620
-     * if you get "500 internal server errors" during registration, try turning this on
2621
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2622
-     *
2623
-     * @var boolean $encode_session_data
2624
-     */
2625
-    private $encode_session_data = false;
2626
-
2627
-
2628
-    /**
2629
-     *    class constructor
2630
-     *
2631
-     * @access    public
2632
-     */
2633
-    public function __construct()
2634
-    {
2635
-        // set default general admin settings
2636
-        $this->use_personnel_manager = true;
2637
-        $this->use_dashboard_widget = true;
2638
-        $this->events_in_dashboard = 30;
2639
-        $this->use_event_timezones = false;
2640
-        $this->use_remote_logging = false;
2641
-        $this->remote_logging_url = null;
2642
-        $this->show_reg_footer = apply_filters(
2643
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2644
-            false
2645
-        );
2646
-        $this->affiliate_id = 'default';
2647
-        $this->help_tour_activation = false;
2648
-        $this->encode_session_data = false;
2649
-    }
2650
-
2651
-
2652
-    /**
2653
-     * @param bool $reset
2654
-     * @return string
2655
-     */
2656
-    public function log_file_name($reset = false)
2657
-    {
2658
-        if (empty($this->log_file_name) || $reset) {
2659
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2660
-            EE_Config::instance()->update_espresso_config(false, false);
2661
-        }
2662
-        return $this->log_file_name;
2663
-    }
2664
-
2665
-
2666
-    /**
2667
-     * @param bool $reset
2668
-     * @return string
2669
-     */
2670
-    public function debug_file_name($reset = false)
2671
-    {
2672
-        if (empty($this->debug_file_name) || $reset) {
2673
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2674
-            EE_Config::instance()->update_espresso_config(false, false);
2675
-        }
2676
-        return $this->debug_file_name;
2677
-    }
2678
-
2679
-
2680
-    /**
2681
-     * @return string
2682
-     */
2683
-    public function affiliate_id()
2684
-    {
2685
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2686
-    }
2687
-
2688
-
2689
-    /**
2690
-     * @return boolean
2691
-     */
2692
-    public function encode_session_data()
2693
-    {
2694
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2695
-    }
2696
-
2697
-
2698
-    /**
2699
-     * @param boolean $encode_session_data
2700
-     */
2701
-    public function set_encode_session_data($encode_session_data)
2702
-    {
2703
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2704
-    }
2560
+	/**
2561
+	 * @var boolean $use_personnel_manager
2562
+	 */
2563
+	public $use_personnel_manager;
2564
+
2565
+	/**
2566
+	 * @var boolean $use_dashboard_widget
2567
+	 */
2568
+	public $use_dashboard_widget;
2569
+
2570
+	/**
2571
+	 * @var int $events_in_dashboard
2572
+	 */
2573
+	public $events_in_dashboard;
2574
+
2575
+	/**
2576
+	 * @var boolean $use_event_timezones
2577
+	 */
2578
+	public $use_event_timezones;
2579
+
2580
+	/**
2581
+	 * @var string $log_file_name
2582
+	 */
2583
+	public $log_file_name;
2584
+
2585
+	/**
2586
+	 * @var string $debug_file_name
2587
+	 */
2588
+	public $debug_file_name;
2589
+
2590
+	/**
2591
+	 * @var boolean $use_remote_logging
2592
+	 */
2593
+	public $use_remote_logging;
2594
+
2595
+	/**
2596
+	 * @var string $remote_logging_url
2597
+	 */
2598
+	public $remote_logging_url;
2599
+
2600
+	/**
2601
+	 * @var boolean $show_reg_footer
2602
+	 */
2603
+	public $show_reg_footer;
2604
+
2605
+	/**
2606
+	 * @var string $affiliate_id
2607
+	 */
2608
+	public $affiliate_id;
2609
+
2610
+	/**
2611
+	 * help tours on or off (global setting)
2612
+	 *
2613
+	 * @var boolean
2614
+	 */
2615
+	public $help_tour_activation;
2616
+
2617
+	/**
2618
+	 * adds extra layer of encoding to session data to prevent serialization errors
2619
+	 * but is incompatible with some server configuration errors
2620
+	 * if you get "500 internal server errors" during registration, try turning this on
2621
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2622
+	 *
2623
+	 * @var boolean $encode_session_data
2624
+	 */
2625
+	private $encode_session_data = false;
2626
+
2627
+
2628
+	/**
2629
+	 *    class constructor
2630
+	 *
2631
+	 * @access    public
2632
+	 */
2633
+	public function __construct()
2634
+	{
2635
+		// set default general admin settings
2636
+		$this->use_personnel_manager = true;
2637
+		$this->use_dashboard_widget = true;
2638
+		$this->events_in_dashboard = 30;
2639
+		$this->use_event_timezones = false;
2640
+		$this->use_remote_logging = false;
2641
+		$this->remote_logging_url = null;
2642
+		$this->show_reg_footer = apply_filters(
2643
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2644
+			false
2645
+		);
2646
+		$this->affiliate_id = 'default';
2647
+		$this->help_tour_activation = false;
2648
+		$this->encode_session_data = false;
2649
+	}
2650
+
2651
+
2652
+	/**
2653
+	 * @param bool $reset
2654
+	 * @return string
2655
+	 */
2656
+	public function log_file_name($reset = false)
2657
+	{
2658
+		if (empty($this->log_file_name) || $reset) {
2659
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2660
+			EE_Config::instance()->update_espresso_config(false, false);
2661
+		}
2662
+		return $this->log_file_name;
2663
+	}
2664
+
2665
+
2666
+	/**
2667
+	 * @param bool $reset
2668
+	 * @return string
2669
+	 */
2670
+	public function debug_file_name($reset = false)
2671
+	{
2672
+		if (empty($this->debug_file_name) || $reset) {
2673
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2674
+			EE_Config::instance()->update_espresso_config(false, false);
2675
+		}
2676
+		return $this->debug_file_name;
2677
+	}
2678
+
2679
+
2680
+	/**
2681
+	 * @return string
2682
+	 */
2683
+	public function affiliate_id()
2684
+	{
2685
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2686
+	}
2687
+
2688
+
2689
+	/**
2690
+	 * @return boolean
2691
+	 */
2692
+	public function encode_session_data()
2693
+	{
2694
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2695
+	}
2696
+
2697
+
2698
+	/**
2699
+	 * @param boolean $encode_session_data
2700
+	 */
2701
+	public function set_encode_session_data($encode_session_data)
2702
+	{
2703
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2704
+	}
2705 2705
 }
2706 2706
 
2707 2707
 /**
@@ -2710,70 +2710,70 @@  discard block
 block discarded – undo
2710 2710
 class EE_Template_Config extends EE_Config_Base
2711 2711
 {
2712 2712
 
2713
-    /**
2714
-     * @var boolean $enable_default_style
2715
-     */
2716
-    public $enable_default_style;
2717
-
2718
-    /**
2719
-     * @var string $custom_style_sheet
2720
-     */
2721
-    public $custom_style_sheet;
2722
-
2723
-    /**
2724
-     * @var boolean $display_address_in_regform
2725
-     */
2726
-    public $display_address_in_regform;
2727
-
2728
-    /**
2729
-     * @var int $display_description_on_multi_reg_page
2730
-     */
2731
-    public $display_description_on_multi_reg_page;
2732
-
2733
-    /**
2734
-     * @var boolean $use_custom_templates
2735
-     */
2736
-    public $use_custom_templates;
2737
-
2738
-    /**
2739
-     * @var string $current_espresso_theme
2740
-     */
2741
-    public $current_espresso_theme;
2742
-
2743
-    /**
2744
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2745
-     */
2746
-    public $EED_Ticket_Selector;
2747
-
2748
-    /**
2749
-     * @var EE_Event_Single_Config $EED_Event_Single
2750
-     */
2751
-    public $EED_Event_Single;
2752
-
2753
-    /**
2754
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2755
-     */
2756
-    public $EED_Events_Archive;
2757
-
2758
-
2759
-    /**
2760
-     *    class constructor
2761
-     *
2762
-     * @access    public
2763
-     */
2764
-    public function __construct()
2765
-    {
2766
-        // set default template settings
2767
-        $this->enable_default_style = true;
2768
-        $this->custom_style_sheet = null;
2769
-        $this->display_address_in_regform = true;
2770
-        $this->display_description_on_multi_reg_page = false;
2771
-        $this->use_custom_templates = false;
2772
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2773
-        $this->EED_Event_Single = null;
2774
-        $this->EED_Events_Archive = null;
2775
-        $this->EED_Ticket_Selector = null;
2776
-    }
2713
+	/**
2714
+	 * @var boolean $enable_default_style
2715
+	 */
2716
+	public $enable_default_style;
2717
+
2718
+	/**
2719
+	 * @var string $custom_style_sheet
2720
+	 */
2721
+	public $custom_style_sheet;
2722
+
2723
+	/**
2724
+	 * @var boolean $display_address_in_regform
2725
+	 */
2726
+	public $display_address_in_regform;
2727
+
2728
+	/**
2729
+	 * @var int $display_description_on_multi_reg_page
2730
+	 */
2731
+	public $display_description_on_multi_reg_page;
2732
+
2733
+	/**
2734
+	 * @var boolean $use_custom_templates
2735
+	 */
2736
+	public $use_custom_templates;
2737
+
2738
+	/**
2739
+	 * @var string $current_espresso_theme
2740
+	 */
2741
+	public $current_espresso_theme;
2742
+
2743
+	/**
2744
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2745
+	 */
2746
+	public $EED_Ticket_Selector;
2747
+
2748
+	/**
2749
+	 * @var EE_Event_Single_Config $EED_Event_Single
2750
+	 */
2751
+	public $EED_Event_Single;
2752
+
2753
+	/**
2754
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2755
+	 */
2756
+	public $EED_Events_Archive;
2757
+
2758
+
2759
+	/**
2760
+	 *    class constructor
2761
+	 *
2762
+	 * @access    public
2763
+	 */
2764
+	public function __construct()
2765
+	{
2766
+		// set default template settings
2767
+		$this->enable_default_style = true;
2768
+		$this->custom_style_sheet = null;
2769
+		$this->display_address_in_regform = true;
2770
+		$this->display_description_on_multi_reg_page = false;
2771
+		$this->use_custom_templates = false;
2772
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2773
+		$this->EED_Event_Single = null;
2774
+		$this->EED_Events_Archive = null;
2775
+		$this->EED_Ticket_Selector = null;
2776
+	}
2777 2777
 }
2778 2778
 
2779 2779
 /**
@@ -2782,114 +2782,114 @@  discard block
 block discarded – undo
2782 2782
 class EE_Map_Config extends EE_Config_Base
2783 2783
 {
2784 2784
 
2785
-    /**
2786
-     * @var boolean $use_google_maps
2787
-     */
2788
-    public $use_google_maps;
2789
-
2790
-    /**
2791
-     * @var string $api_key
2792
-     */
2793
-    public $google_map_api_key;
2794
-
2795
-    /**
2796
-     * @var int $event_details_map_width
2797
-     */
2798
-    public $event_details_map_width;
2799
-
2800
-    /**
2801
-     * @var int $event_details_map_height
2802
-     */
2803
-    public $event_details_map_height;
2804
-
2805
-    /**
2806
-     * @var int $event_details_map_zoom
2807
-     */
2808
-    public $event_details_map_zoom;
2809
-
2810
-    /**
2811
-     * @var boolean $event_details_display_nav
2812
-     */
2813
-    public $event_details_display_nav;
2814
-
2815
-    /**
2816
-     * @var boolean $event_details_nav_size
2817
-     */
2818
-    public $event_details_nav_size;
2819
-
2820
-    /**
2821
-     * @var string $event_details_control_type
2822
-     */
2823
-    public $event_details_control_type;
2824
-
2825
-    /**
2826
-     * @var string $event_details_map_align
2827
-     */
2828
-    public $event_details_map_align;
2829
-
2830
-    /**
2831
-     * @var int $event_list_map_width
2832
-     */
2833
-    public $event_list_map_width;
2834
-
2835
-    /**
2836
-     * @var int $event_list_map_height
2837
-     */
2838
-    public $event_list_map_height;
2839
-
2840
-    /**
2841
-     * @var int $event_list_map_zoom
2842
-     */
2843
-    public $event_list_map_zoom;
2844
-
2845
-    /**
2846
-     * @var boolean $event_list_display_nav
2847
-     */
2848
-    public $event_list_display_nav;
2849
-
2850
-    /**
2851
-     * @var boolean $event_list_nav_size
2852
-     */
2853
-    public $event_list_nav_size;
2854
-
2855
-    /**
2856
-     * @var string $event_list_control_type
2857
-     */
2858
-    public $event_list_control_type;
2859
-
2860
-    /**
2861
-     * @var string $event_list_map_align
2862
-     */
2863
-    public $event_list_map_align;
2864
-
2865
-
2866
-    /**
2867
-     *    class constructor
2868
-     *
2869
-     * @access    public
2870
-     */
2871
-    public function __construct()
2872
-    {
2873
-        // set default map settings
2874
-        $this->use_google_maps = true;
2875
-        $this->google_map_api_key = '';
2876
-        // for event details pages (reg page)
2877
-        $this->event_details_map_width = 585;            // ee_map_width_single
2878
-        $this->event_details_map_height = 362;            // ee_map_height_single
2879
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2880
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2881
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2882
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2883
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2884
-        // for event list pages
2885
-        $this->event_list_map_width = 300;            // ee_map_width
2886
-        $this->event_list_map_height = 185;        // ee_map_height
2887
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2888
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2889
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2890
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2891
-        $this->event_list_map_align = 'center';            // ee_map_align
2892
-    }
2785
+	/**
2786
+	 * @var boolean $use_google_maps
2787
+	 */
2788
+	public $use_google_maps;
2789
+
2790
+	/**
2791
+	 * @var string $api_key
2792
+	 */
2793
+	public $google_map_api_key;
2794
+
2795
+	/**
2796
+	 * @var int $event_details_map_width
2797
+	 */
2798
+	public $event_details_map_width;
2799
+
2800
+	/**
2801
+	 * @var int $event_details_map_height
2802
+	 */
2803
+	public $event_details_map_height;
2804
+
2805
+	/**
2806
+	 * @var int $event_details_map_zoom
2807
+	 */
2808
+	public $event_details_map_zoom;
2809
+
2810
+	/**
2811
+	 * @var boolean $event_details_display_nav
2812
+	 */
2813
+	public $event_details_display_nav;
2814
+
2815
+	/**
2816
+	 * @var boolean $event_details_nav_size
2817
+	 */
2818
+	public $event_details_nav_size;
2819
+
2820
+	/**
2821
+	 * @var string $event_details_control_type
2822
+	 */
2823
+	public $event_details_control_type;
2824
+
2825
+	/**
2826
+	 * @var string $event_details_map_align
2827
+	 */
2828
+	public $event_details_map_align;
2829
+
2830
+	/**
2831
+	 * @var int $event_list_map_width
2832
+	 */
2833
+	public $event_list_map_width;
2834
+
2835
+	/**
2836
+	 * @var int $event_list_map_height
2837
+	 */
2838
+	public $event_list_map_height;
2839
+
2840
+	/**
2841
+	 * @var int $event_list_map_zoom
2842
+	 */
2843
+	public $event_list_map_zoom;
2844
+
2845
+	/**
2846
+	 * @var boolean $event_list_display_nav
2847
+	 */
2848
+	public $event_list_display_nav;
2849
+
2850
+	/**
2851
+	 * @var boolean $event_list_nav_size
2852
+	 */
2853
+	public $event_list_nav_size;
2854
+
2855
+	/**
2856
+	 * @var string $event_list_control_type
2857
+	 */
2858
+	public $event_list_control_type;
2859
+
2860
+	/**
2861
+	 * @var string $event_list_map_align
2862
+	 */
2863
+	public $event_list_map_align;
2864
+
2865
+
2866
+	/**
2867
+	 *    class constructor
2868
+	 *
2869
+	 * @access    public
2870
+	 */
2871
+	public function __construct()
2872
+	{
2873
+		// set default map settings
2874
+		$this->use_google_maps = true;
2875
+		$this->google_map_api_key = '';
2876
+		// for event details pages (reg page)
2877
+		$this->event_details_map_width = 585;            // ee_map_width_single
2878
+		$this->event_details_map_height = 362;            // ee_map_height_single
2879
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2880
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2881
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2882
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2883
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2884
+		// for event list pages
2885
+		$this->event_list_map_width = 300;            // ee_map_width
2886
+		$this->event_list_map_height = 185;        // ee_map_height
2887
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2888
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2889
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2890
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2891
+		$this->event_list_map_align = 'center';            // ee_map_align
2892
+	}
2893 2893
 }
2894 2894
 
2895 2895
 /**
@@ -2898,46 +2898,46 @@  discard block
 block discarded – undo
2898 2898
 class EE_Events_Archive_Config extends EE_Config_Base
2899 2899
 {
2900 2900
 
2901
-    public $display_status_banner;
2901
+	public $display_status_banner;
2902 2902
 
2903
-    public $display_description;
2903
+	public $display_description;
2904 2904
 
2905
-    public $display_ticket_selector;
2905
+	public $display_ticket_selector;
2906 2906
 
2907
-    public $display_datetimes;
2907
+	public $display_datetimes;
2908 2908
 
2909
-    public $display_venue;
2909
+	public $display_venue;
2910 2910
 
2911
-    public $display_expired_events;
2911
+	public $display_expired_events;
2912 2912
 
2913
-    public $use_sortable_display_order;
2913
+	public $use_sortable_display_order;
2914 2914
 
2915
-    public $display_order_tickets;
2915
+	public $display_order_tickets;
2916 2916
 
2917
-    public $display_order_datetimes;
2917
+	public $display_order_datetimes;
2918 2918
 
2919
-    public $display_order_event;
2919
+	public $display_order_event;
2920 2920
 
2921
-    public $display_order_venue;
2921
+	public $display_order_venue;
2922 2922
 
2923 2923
 
2924
-    /**
2925
-     *    class constructor
2926
-     */
2927
-    public function __construct()
2928
-    {
2929
-        $this->display_status_banner = 0;
2930
-        $this->display_description = 1;
2931
-        $this->display_ticket_selector = 0;
2932
-        $this->display_datetimes = 1;
2933
-        $this->display_venue = 0;
2934
-        $this->display_expired_events = 0;
2935
-        $this->use_sortable_display_order = false;
2936
-        $this->display_order_tickets = 100;
2937
-        $this->display_order_datetimes = 110;
2938
-        $this->display_order_event = 120;
2939
-        $this->display_order_venue = 130;
2940
-    }
2924
+	/**
2925
+	 *    class constructor
2926
+	 */
2927
+	public function __construct()
2928
+	{
2929
+		$this->display_status_banner = 0;
2930
+		$this->display_description = 1;
2931
+		$this->display_ticket_selector = 0;
2932
+		$this->display_datetimes = 1;
2933
+		$this->display_venue = 0;
2934
+		$this->display_expired_events = 0;
2935
+		$this->use_sortable_display_order = false;
2936
+		$this->display_order_tickets = 100;
2937
+		$this->display_order_datetimes = 110;
2938
+		$this->display_order_event = 120;
2939
+		$this->display_order_venue = 130;
2940
+	}
2941 2941
 }
2942 2942
 
2943 2943
 /**
@@ -2946,34 +2946,34 @@  discard block
 block discarded – undo
2946 2946
 class EE_Event_Single_Config extends EE_Config_Base
2947 2947
 {
2948 2948
 
2949
-    public $display_status_banner_single;
2949
+	public $display_status_banner_single;
2950 2950
 
2951
-    public $display_venue;
2951
+	public $display_venue;
2952 2952
 
2953
-    public $use_sortable_display_order;
2953
+	public $use_sortable_display_order;
2954 2954
 
2955
-    public $display_order_tickets;
2955
+	public $display_order_tickets;
2956 2956
 
2957
-    public $display_order_datetimes;
2957
+	public $display_order_datetimes;
2958 2958
 
2959
-    public $display_order_event;
2959
+	public $display_order_event;
2960 2960
 
2961
-    public $display_order_venue;
2961
+	public $display_order_venue;
2962 2962
 
2963 2963
 
2964
-    /**
2965
-     *    class constructor
2966
-     */
2967
-    public function __construct()
2968
-    {
2969
-        $this->display_status_banner_single = 0;
2970
-        $this->display_venue = 1;
2971
-        $this->use_sortable_display_order = false;
2972
-        $this->display_order_tickets = 100;
2973
-        $this->display_order_datetimes = 110;
2974
-        $this->display_order_event = 120;
2975
-        $this->display_order_venue = 130;
2976
-    }
2964
+	/**
2965
+	 *    class constructor
2966
+	 */
2967
+	public function __construct()
2968
+	{
2969
+		$this->display_status_banner_single = 0;
2970
+		$this->display_venue = 1;
2971
+		$this->use_sortable_display_order = false;
2972
+		$this->display_order_tickets = 100;
2973
+		$this->display_order_datetimes = 110;
2974
+		$this->display_order_event = 120;
2975
+		$this->display_order_venue = 130;
2976
+	}
2977 2977
 }
2978 2978
 
2979 2979
 /**
@@ -2982,172 +2982,172 @@  discard block
 block discarded – undo
2982 2982
 class EE_Ticket_Selector_Config extends EE_Config_Base
2983 2983
 {
2984 2984
 
2985
-    /**
2986
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2987
-     */
2988
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2989
-
2990
-    /**
2991
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2992
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2993
-     */
2994
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2995
-
2996
-    /**
2997
-     * @var boolean $show_ticket_sale_columns
2998
-     */
2999
-    public $show_ticket_sale_columns;
3000
-
3001
-    /**
3002
-     * @var boolean $show_ticket_details
3003
-     */
3004
-    public $show_ticket_details;
3005
-
3006
-    /**
3007
-     * @var boolean $show_expired_tickets
3008
-     */
3009
-    public $show_expired_tickets;
3010
-
3011
-    /**
3012
-     * whether or not to display a dropdown box populated with event datetimes
3013
-     * that toggles which tickets are displayed for a ticket selector.
3014
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3015
-     *
3016
-     * @var string $show_datetime_selector
3017
-     */
3018
-    private $show_datetime_selector = 'no_datetime_selector';
3019
-
3020
-    /**
3021
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3022
-     *
3023
-     * @var int $datetime_selector_threshold
3024
-     */
3025
-    private $datetime_selector_threshold = 3;
3026
-
3027
-    /**
3028
-     * determines the maximum number of "checked" dates in the date and time filter
3029
-     *
3030
-     * @var int $datetime_selector_checked
3031
-     */
3032
-    private $datetime_selector_max_checked = 10;
3033
-
3034
-
3035
-    /**
3036
-     *    class constructor
3037
-     */
3038
-    public function __construct()
3039
-    {
3040
-        $this->show_ticket_sale_columns = true;
3041
-        $this->show_ticket_details = true;
3042
-        $this->show_expired_tickets = true;
3043
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3044
-        $this->datetime_selector_threshold = 3;
3045
-        $this->datetime_selector_max_checked = 10;
3046
-    }
3047
-
3048
-
3049
-    /**
3050
-     * returns true if a datetime selector should be displayed
3051
-     *
3052
-     * @param array $datetimes
3053
-     * @return bool
3054
-     */
3055
-    public function showDatetimeSelector(array $datetimes)
3056
-    {
3057
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3058
-        return ! (
3059
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3060
-            || (
3061
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3062
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3063
-            )
3064
-        );
3065
-    }
3066
-
3067
-
3068
-    /**
3069
-     * @return string
3070
-     */
3071
-    public function getShowDatetimeSelector()
3072
-    {
3073
-        return $this->show_datetime_selector;
3074
-    }
3075
-
3076
-
3077
-    /**
3078
-     * @param bool $keys_only
3079
-     * @return array
3080
-     */
3081
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3082
-    {
3083
-        return $keys_only
3084
-            ? array(
3085
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3086
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3087
-            )
3088
-            : array(
3089
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3090
-                    'Do not show date & time filter',
3091
-                    'event_espresso'
3092
-                ),
3093
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3094
-                    'Maybe show date & time filter',
3095
-                    'event_espresso'
3096
-                ),
3097
-            );
3098
-    }
3099
-
3100
-
3101
-    /**
3102
-     * @param string $show_datetime_selector
3103
-     */
3104
-    public function setShowDatetimeSelector($show_datetime_selector)
3105
-    {
3106
-        $this->show_datetime_selector = in_array(
3107
-            $show_datetime_selector,
3108
-            $this->getShowDatetimeSelectorOptions(),
3109
-            true
3110
-        )
3111
-            ? $show_datetime_selector
3112
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3113
-    }
3114
-
3115
-
3116
-    /**
3117
-     * @return int
3118
-     */
3119
-    public function getDatetimeSelectorThreshold()
3120
-    {
3121
-        return $this->datetime_selector_threshold;
3122
-    }
3123
-
3124
-
3125
-    /**
3126
-     * @param int $datetime_selector_threshold
3127
-     */
3128
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3129
-    {
3130
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3131
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3132
-    }
3133
-
3134
-
3135
-    /**
3136
-     * @return int
3137
-     */
3138
-    public function getDatetimeSelectorMaxChecked()
3139
-    {
3140
-        return $this->datetime_selector_max_checked;
3141
-    }
3142
-
3143
-
3144
-    /**
3145
-     * @param int $datetime_selector_max_checked
3146
-     */
3147
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3148
-    {
3149
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3150
-    }
2985
+	/**
2986
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2987
+	 */
2988
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2989
+
2990
+	/**
2991
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2992
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2993
+	 */
2994
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2995
+
2996
+	/**
2997
+	 * @var boolean $show_ticket_sale_columns
2998
+	 */
2999
+	public $show_ticket_sale_columns;
3000
+
3001
+	/**
3002
+	 * @var boolean $show_ticket_details
3003
+	 */
3004
+	public $show_ticket_details;
3005
+
3006
+	/**
3007
+	 * @var boolean $show_expired_tickets
3008
+	 */
3009
+	public $show_expired_tickets;
3010
+
3011
+	/**
3012
+	 * whether or not to display a dropdown box populated with event datetimes
3013
+	 * that toggles which tickets are displayed for a ticket selector.
3014
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3015
+	 *
3016
+	 * @var string $show_datetime_selector
3017
+	 */
3018
+	private $show_datetime_selector = 'no_datetime_selector';
3019
+
3020
+	/**
3021
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3022
+	 *
3023
+	 * @var int $datetime_selector_threshold
3024
+	 */
3025
+	private $datetime_selector_threshold = 3;
3026
+
3027
+	/**
3028
+	 * determines the maximum number of "checked" dates in the date and time filter
3029
+	 *
3030
+	 * @var int $datetime_selector_checked
3031
+	 */
3032
+	private $datetime_selector_max_checked = 10;
3033
+
3034
+
3035
+	/**
3036
+	 *    class constructor
3037
+	 */
3038
+	public function __construct()
3039
+	{
3040
+		$this->show_ticket_sale_columns = true;
3041
+		$this->show_ticket_details = true;
3042
+		$this->show_expired_tickets = true;
3043
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3044
+		$this->datetime_selector_threshold = 3;
3045
+		$this->datetime_selector_max_checked = 10;
3046
+	}
3047
+
3048
+
3049
+	/**
3050
+	 * returns true if a datetime selector should be displayed
3051
+	 *
3052
+	 * @param array $datetimes
3053
+	 * @return bool
3054
+	 */
3055
+	public function showDatetimeSelector(array $datetimes)
3056
+	{
3057
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3058
+		return ! (
3059
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3060
+			|| (
3061
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3062
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3063
+			)
3064
+		);
3065
+	}
3066
+
3067
+
3068
+	/**
3069
+	 * @return string
3070
+	 */
3071
+	public function getShowDatetimeSelector()
3072
+	{
3073
+		return $this->show_datetime_selector;
3074
+	}
3075
+
3076
+
3077
+	/**
3078
+	 * @param bool $keys_only
3079
+	 * @return array
3080
+	 */
3081
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3082
+	{
3083
+		return $keys_only
3084
+			? array(
3085
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3086
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3087
+			)
3088
+			: array(
3089
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3090
+					'Do not show date & time filter',
3091
+					'event_espresso'
3092
+				),
3093
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3094
+					'Maybe show date & time filter',
3095
+					'event_espresso'
3096
+				),
3097
+			);
3098
+	}
3099
+
3100
+
3101
+	/**
3102
+	 * @param string $show_datetime_selector
3103
+	 */
3104
+	public function setShowDatetimeSelector($show_datetime_selector)
3105
+	{
3106
+		$this->show_datetime_selector = in_array(
3107
+			$show_datetime_selector,
3108
+			$this->getShowDatetimeSelectorOptions(),
3109
+			true
3110
+		)
3111
+			? $show_datetime_selector
3112
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3113
+	}
3114
+
3115
+
3116
+	/**
3117
+	 * @return int
3118
+	 */
3119
+	public function getDatetimeSelectorThreshold()
3120
+	{
3121
+		return $this->datetime_selector_threshold;
3122
+	}
3123
+
3124
+
3125
+	/**
3126
+	 * @param int $datetime_selector_threshold
3127
+	 */
3128
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3129
+	{
3130
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3131
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3132
+	}
3133
+
3134
+
3135
+	/**
3136
+	 * @return int
3137
+	 */
3138
+	public function getDatetimeSelectorMaxChecked()
3139
+	{
3140
+		return $this->datetime_selector_max_checked;
3141
+	}
3142
+
3143
+
3144
+	/**
3145
+	 * @param int $datetime_selector_max_checked
3146
+	 */
3147
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3148
+	{
3149
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3150
+	}
3151 3151
 }
3152 3152
 
3153 3153
 /**
@@ -3160,86 +3160,86 @@  discard block
 block discarded – undo
3160 3160
 class EE_Environment_Config extends EE_Config_Base
3161 3161
 {
3162 3162
 
3163
-    /**
3164
-     * Hold any php environment variables that we want to track.
3165
-     *
3166
-     * @var stdClass;
3167
-     */
3168
-    public $php;
3169
-
3170
-
3171
-    /**
3172
-     *    constructor
3173
-     */
3174
-    public function __construct()
3175
-    {
3176
-        $this->php = new stdClass();
3177
-        $this->_set_php_values();
3178
-    }
3179
-
3180
-
3181
-    /**
3182
-     * This sets the php environment variables.
3183
-     *
3184
-     * @since 4.4.0
3185
-     * @return void
3186
-     */
3187
-    protected function _set_php_values()
3188
-    {
3189
-        $this->php->max_input_vars = ini_get('max_input_vars');
3190
-        $this->php->version = phpversion();
3191
-    }
3192
-
3193
-
3194
-    /**
3195
-     * helper method for determining whether input_count is
3196
-     * reaching the potential maximum the server can handle
3197
-     * according to max_input_vars
3198
-     *
3199
-     * @param int   $input_count the count of input vars.
3200
-     * @return array {
3201
-     *                           An array that represents whether available space and if no available space the error
3202
-     *                           message.
3203
-     * @type bool   $has_space   whether more inputs can be added.
3204
-     * @type string $msg         Any message to be displayed.
3205
-     *                           }
3206
-     */
3207
-    public function max_input_vars_limit_check($input_count = 0)
3208
-    {
3209
-        if (! empty($this->php->max_input_vars)
3210
-            && ($input_count >= $this->php->max_input_vars)
3211
-        ) {
3212
-            // check the server setting because the config value could be stale
3213
-            $max_input_vars = ini_get('max_input_vars');
3214
-            if ($input_count >= $max_input_vars) {
3215
-                return sprintf(
3216
-                    esc_html__(
3217
-                        'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3218
-                        'event_espresso'
3219
-                    ),
3220
-                    '<br>',
3221
-                    $input_count,
3222
-                    $max_input_vars
3223
-                );
3224
-            } else {
3225
-                return '';
3226
-            }
3227
-        } else {
3228
-            return '';
3229
-        }
3230
-    }
3231
-
3232
-
3233
-    /**
3234
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3235
-     *
3236
-     * @since 4.4.1
3237
-     * @return void
3238
-     */
3239
-    public function recheck_values()
3240
-    {
3241
-        $this->_set_php_values();
3242
-    }
3163
+	/**
3164
+	 * Hold any php environment variables that we want to track.
3165
+	 *
3166
+	 * @var stdClass;
3167
+	 */
3168
+	public $php;
3169
+
3170
+
3171
+	/**
3172
+	 *    constructor
3173
+	 */
3174
+	public function __construct()
3175
+	{
3176
+		$this->php = new stdClass();
3177
+		$this->_set_php_values();
3178
+	}
3179
+
3180
+
3181
+	/**
3182
+	 * This sets the php environment variables.
3183
+	 *
3184
+	 * @since 4.4.0
3185
+	 * @return void
3186
+	 */
3187
+	protected function _set_php_values()
3188
+	{
3189
+		$this->php->max_input_vars = ini_get('max_input_vars');
3190
+		$this->php->version = phpversion();
3191
+	}
3192
+
3193
+
3194
+	/**
3195
+	 * helper method for determining whether input_count is
3196
+	 * reaching the potential maximum the server can handle
3197
+	 * according to max_input_vars
3198
+	 *
3199
+	 * @param int   $input_count the count of input vars.
3200
+	 * @return array {
3201
+	 *                           An array that represents whether available space and if no available space the error
3202
+	 *                           message.
3203
+	 * @type bool   $has_space   whether more inputs can be added.
3204
+	 * @type string $msg         Any message to be displayed.
3205
+	 *                           }
3206
+	 */
3207
+	public function max_input_vars_limit_check($input_count = 0)
3208
+	{
3209
+		if (! empty($this->php->max_input_vars)
3210
+			&& ($input_count >= $this->php->max_input_vars)
3211
+		) {
3212
+			// check the server setting because the config value could be stale
3213
+			$max_input_vars = ini_get('max_input_vars');
3214
+			if ($input_count >= $max_input_vars) {
3215
+				return sprintf(
3216
+					esc_html__(
3217
+						'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3218
+						'event_espresso'
3219
+					),
3220
+					'<br>',
3221
+					$input_count,
3222
+					$max_input_vars
3223
+				);
3224
+			} else {
3225
+				return '';
3226
+			}
3227
+		} else {
3228
+			return '';
3229
+		}
3230
+	}
3231
+
3232
+
3233
+	/**
3234
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3235
+	 *
3236
+	 * @since 4.4.1
3237
+	 * @return void
3238
+	 */
3239
+	public function recheck_values()
3240
+	{
3241
+		$this->_set_php_values();
3242
+	}
3243 3243
 }
3244 3244
 
3245 3245
 /**
@@ -3252,21 +3252,21 @@  discard block
 block discarded – undo
3252 3252
 class EE_Tax_Config extends EE_Config_Base
3253 3253
 {
3254 3254
 
3255
-    /*
3255
+	/*
3256 3256
      * flag to indicate whether or not to display ticket prices with the taxes included
3257 3257
      *
3258 3258
      * @var boolean $prices_displayed_including_taxes
3259 3259
      */
3260
-    public $prices_displayed_including_taxes;
3260
+	public $prices_displayed_including_taxes;
3261 3261
 
3262 3262
 
3263
-    /**
3264
-     *    class constructor
3265
-     */
3266
-    public function __construct()
3267
-    {
3268
-        $this->prices_displayed_including_taxes = true;
3269
-    }
3263
+	/**
3264
+	 *    class constructor
3265
+	 */
3266
+	public function __construct()
3267
+	{
3268
+		$this->prices_displayed_including_taxes = true;
3269
+	}
3270 3270
 }
3271 3271
 
3272 3272
 /**
@@ -3280,19 +3280,19 @@  discard block
 block discarded – undo
3280 3280
 class EE_Messages_Config extends EE_Config_Base
3281 3281
 {
3282 3282
 
3283
-    /**
3284
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3285
-     * A value of 0 represents never deleting.  Default is 0.
3286
-     *
3287
-     * @var integer
3288
-     */
3289
-    public $delete_threshold;
3283
+	/**
3284
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3285
+	 * A value of 0 represents never deleting.  Default is 0.
3286
+	 *
3287
+	 * @var integer
3288
+	 */
3289
+	public $delete_threshold;
3290 3290
 
3291 3291
 
3292
-    public function __construct()
3293
-    {
3294
-        $this->delete_threshold = 0;
3295
-    }
3292
+	public function __construct()
3293
+	{
3294
+		$this->delete_threshold = 0;
3295
+	}
3296 3296
 }
3297 3297
 
3298 3298
 /**
@@ -3303,31 +3303,31 @@  discard block
 block discarded – undo
3303 3303
 class EE_Gateway_Config extends EE_Config_Base
3304 3304
 {
3305 3305
 
3306
-    /**
3307
-     * Array with keys that are payment gateways slugs, and values are arrays
3308
-     * with any config info the gateway wants to store
3309
-     *
3310
-     * @var array
3311
-     */
3312
-    public $payment_settings;
3313
-
3314
-    /**
3315
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3316
-     * the gateway is stored in the uploads directory
3317
-     *
3318
-     * @var array
3319
-     */
3320
-    public $active_gateways;
3321
-
3322
-
3323
-    /**
3324
-     *    class constructor
3325
-     *
3326
-     * @deprecated
3327
-     */
3328
-    public function __construct()
3329
-    {
3330
-        $this->payment_settings = array();
3331
-        $this->active_gateways = array('Invoice' => false);
3332
-    }
3306
+	/**
3307
+	 * Array with keys that are payment gateways slugs, and values are arrays
3308
+	 * with any config info the gateway wants to store
3309
+	 *
3310
+	 * @var array
3311
+	 */
3312
+	public $payment_settings;
3313
+
3314
+	/**
3315
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3316
+	 * the gateway is stored in the uploads directory
3317
+	 *
3318
+	 * @var array
3319
+	 */
3320
+	public $active_gateways;
3321
+
3322
+
3323
+	/**
3324
+	 *    class constructor
3325
+	 *
3326
+	 * @deprecated
3327
+	 */
3328
+	public function __construct()
3329
+	{
3330
+		$this->payment_settings = array();
3331
+		$this->active_gateways = array('Invoice' => false);
3332
+	}
3333 3333
 }
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     public static function instance()
147 147
     {
148 148
         // check if class object is instantiated, and instantiated properly
149
-        if (! self::$_instance instanceof EE_Config) {
149
+        if ( ! self::$_instance instanceof EE_Config) {
150 150
             self::$_instance = new self();
151 151
         }
152 152
         return self::$_instance;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                 $this
285 285
             );
286 286
             if (is_object($settings) && property_exists($this, $config)) {
287
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
288 288
                 // call configs populate method to ensure any defaults are set for empty values.
289 289
                 if (method_exists($settings, 'populate')) {
290 290
                     $this->{$config}->populate();
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
                         break;
560 560
                     // TEST #2 : check that settings section exists
561 561
                     case 2:
562
-                        if (! isset($this->{$section})) {
562
+                        if ( ! isset($this->{$section})) {
563 563
                             if ($display_errors) {
564 564
                                 throw new EE_Error(
565 565
                                     sprintf(
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
                         break;
574 574
                     // TEST #3 : check that section is the proper format
575 575
                     case 3:
576
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
576
+                        if ( ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
577 577
                         ) {
578 578
                             if ($display_errors) {
579 579
                                 throw new EE_Error(
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
                         break;
620 620
                     // TEST #6 : verify config class is accessible
621 621
                     case 6:
622
-                        if (! class_exists($config_class)) {
622
+                        if ( ! class_exists($config_class)) {
623 623
                             if ($display_errors) {
624 624
                                 throw new EE_Error(
625 625
                                     sprintf(
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
                         break;
637 637
                     // TEST #7 : check that config has even been set
638 638
                     case 7:
639
-                        if (! isset($this->{$section}->{$name})) {
639
+                        if ( ! isset($this->{$section}->{$name})) {
640 640
                             if ($display_errors) {
641 641
                                 throw new EE_Error(
642 642
                                     sprintf(
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
                         break;
655 655
                     // TEST #8 : check that config is the requested type
656 656
                     case 8:
657
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
657
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
658 658
                             if ($display_errors) {
659 659
                                 throw new EE_Error(
660 660
                                     sprintf(
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                         break;
674 674
                     // TEST #9 : verify config object
675 675
                     case 9:
676
-                        if (! $config_obj instanceof EE_Config_Base) {
676
+                        if ( ! $config_obj instanceof EE_Config_Base) {
677 677
                             if ($display_errors) {
678 678
                                 throw new EE_Error(
679 679
                                     sprintf(
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
      */
706 706
     private function _generate_config_option_name($section = '', $name = '')
707 707
     {
708
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
708
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
709 709
     }
710 710
 
711 711
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     {
723 723
         return ! empty($config_class)
724 724
             ? $config_class
725
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
725
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
726 726
     }
727 727
 
728 728
 
@@ -741,17 +741,17 @@  discard block
 block discarded – undo
741 741
         // ensure config class is set to something
742 742
         $config_class = $this->_set_config_class($config_class, $name);
743 743
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
744
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
744
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
745 745
             return null;
746 746
         }
747 747
         $config_option_name = $this->_generate_config_option_name($section, $name);
748 748
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
749
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
750
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
749
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
750
+            $this->_addon_option_names[$config_option_name] = $config_class;
751 751
             $this->update_addon_option_names();
752 752
         }
753 753
         // verify the incoming config object but suppress errors
754
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
754
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
755 755
             $config_obj = new $config_class();
756 756
         }
757 757
         if (get_option($config_option_name)) {
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
         // get class name of the incoming object
801 801
         $config_class = get_class($config_obj);
802 802
         // run tests 1-5 and 9 to verify config
803
-        if (! $this->_verify_config_params(
803
+        if ( ! $this->_verify_config_params(
804 804
             $section,
805 805
             $name,
806 806
             $config_class,
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
         }
813 813
         $config_option_name = $this->_generate_config_option_name($section, $name);
814 814
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
815
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
815
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
816 816
             // save new config to db
817 817
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
818 818
                 return true;
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
                             'event_espresso'
839 839
                         ),
840 840
                         $config_class,
841
-                        'EE_Config->' . $section . '->' . $name
841
+                        'EE_Config->'.$section.'->'.$name
842 842
                     ),
843 843
                     __FILE__,
844 844
                     __FUNCTION__,
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
         // ensure config class is set to something
865 865
         $config_class = $this->_set_config_class($config_class, $name);
866 866
         // run tests 1-4, 6 and 7 to verify that all params have been set
867
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
867
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
868 868
             return null;
869 869
         }
870 870
         // now test if the requested config object exists, but suppress errors
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
         // retrieve the wp-option for this config class.
910 910
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
911 911
         if (empty($config_option)) {
912
-            EE_Config::log($config_option_name . '-NOT-FOUND');
912
+            EE_Config::log($config_option_name.'-NOT-FOUND');
913 913
         }
914 914
         return $config_option;
915 915
     }
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
             // copy incoming $_REQUEST and sanitize it so we can save it
928 928
             $_request = $_REQUEST;
929 929
             array_walk_recursive($_request, 'sanitize_text_field');
930
-            $config_log[ (string) microtime(true) ] = array(
930
+            $config_log[(string) microtime(true)] = array(
931 931
                 'config_name' => $config_option_name,
932 932
                 'request'     => $_request,
933 933
             );
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
      */
943 943
     public static function trim_log()
944 944
     {
945
-        if (! EE_Config::logging_enabled()) {
945
+        if ( ! EE_Config::logging_enabled()) {
946 946
             return;
947 947
         }
948 948
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
     public static function get_page_for_posts()
967 967
     {
968 968
         $page_for_posts = get_option('page_for_posts');
969
-        if (! $page_for_posts) {
969
+        if ( ! $page_for_posts) {
970 970
             return 'posts';
971 971
         }
972 972
         /** @type WPDB $wpdb */
@@ -1016,20 +1016,20 @@  discard block
 block discarded – undo
1016 1016
     {
1017 1017
         // only init widgets on admin pages when not in complete maintenance, and
1018 1018
         // on frontend when not in any maintenance mode
1019
-        if (! EE_Maintenance_Mode::instance()->level()
1019
+        if ( ! EE_Maintenance_Mode::instance()->level()
1020 1020
             || (
1021 1021
                 is_admin()
1022 1022
                 && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1023 1023
             )
1024 1024
         ) {
1025 1025
             // grab list of installed widgets
1026
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1026
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1027 1027
             // filter list of modules to register
1028 1028
             $widgets_to_register = apply_filters(
1029 1029
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1030 1030
                 $widgets_to_register
1031 1031
             );
1032
-            if (! empty($widgets_to_register)) {
1032
+            if ( ! empty($widgets_to_register)) {
1033 1033
                 // cycle thru widget folders
1034 1034
                 foreach ($widgets_to_register as $widget_path) {
1035 1035
                     // add to list of installed widget modules
@@ -1079,31 +1079,31 @@  discard block
 block discarded – undo
1079 1079
         // create classname from widget directory name
1080 1080
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1081 1081
         // add class prefix
1082
-        $widget_class = 'EEW_' . $widget;
1082
+        $widget_class = 'EEW_'.$widget;
1083 1083
         // does the widget exist ?
1084
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1084
+        if ( ! is_readable($widget_path.'/'.$widget_class.$widget_ext)) {
1085 1085
             $msg = sprintf(
1086 1086
                 __(
1087 1087
                     'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1088 1088
                     'event_espresso'
1089 1089
                 ),
1090 1090
                 $widget_class,
1091
-                $widget_path . '/' . $widget_class . $widget_ext
1091
+                $widget_path.'/'.$widget_class.$widget_ext
1092 1092
             );
1093
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1093
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1094 1094
             return;
1095 1095
         }
1096 1096
         // load the widget class file
1097
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1097
+        require_once($widget_path.'/'.$widget_class.$widget_ext);
1098 1098
         // verify that class exists
1099
-        if (! class_exists($widget_class)) {
1099
+        if ( ! class_exists($widget_class)) {
1100 1100
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1101
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1101
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1102 1102
             return;
1103 1103
         }
1104 1104
         register_widget($widget_class);
1105 1105
         // add to array of registered widgets
1106
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1106
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.'/'.$widget_class.$widget_ext;
1107 1107
     }
1108 1108
 
1109 1109
 
@@ -1116,18 +1116,18 @@  discard block
 block discarded – undo
1116 1116
     private function _register_modules()
1117 1117
     {
1118 1118
         // grab list of installed modules
1119
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1119
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1120 1120
         // filter list of modules to register
1121 1121
         $modules_to_register = apply_filters(
1122 1122
             'FHEE__EE_Config__register_modules__modules_to_register',
1123 1123
             $modules_to_register
1124 1124
         );
1125
-        if (! empty($modules_to_register)) {
1125
+        if ( ! empty($modules_to_register)) {
1126 1126
             // loop through folders
1127 1127
             foreach ($modules_to_register as $module_path) {
1128 1128
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1129
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1130
-                    && $module_path !== EE_MODULES . 'gateways'
1129
+                if ($module_path !== EE_MODULES.'zzz-copy-this-module-template'
1130
+                    && $module_path !== EE_MODULES.'gateways'
1131 1131
                 ) {
1132 1132
                     // add to list of installed modules
1133 1133
                     EE_Config::register_module($module_path);
@@ -1164,25 +1164,25 @@  discard block
 block discarded – undo
1164 1164
             // remove last segment
1165 1165
             array_pop($module_path);
1166 1166
             // glue it back together
1167
-            $module_path = implode('/', $module_path) . '/';
1167
+            $module_path = implode('/', $module_path).'/';
1168 1168
             // take first segment from file name pieces and sanitize it
1169 1169
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1170 1170
             // ensure class prefix is added
1171
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1171
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1172 1172
         } else {
1173 1173
             // we need to generate the filename based off of the folder name
1174 1174
             // grab and sanitize module name
1175 1175
             $module = strtolower(basename($module_path));
1176 1176
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1177 1177
             // like trailingslashit()
1178
-            $module_path = rtrim($module_path, '/') . '/';
1178
+            $module_path = rtrim($module_path, '/').'/';
1179 1179
             // create classname from module directory name
1180 1180
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1181 1181
             // add class prefix
1182
-            $module_class = 'EED_' . $module;
1182
+            $module_class = 'EED_'.$module;
1183 1183
         }
1184 1184
         // does the module exist ?
1185
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1185
+        if ( ! is_readable($module_path.'/'.$module_class.$module_ext)) {
1186 1186
             $msg = sprintf(
1187 1187
                 __(
1188 1188
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1190,19 +1190,19 @@  discard block
 block discarded – undo
1190 1190
                 ),
1191 1191
                 $module
1192 1192
             );
1193
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1193
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1194 1194
             return false;
1195 1195
         }
1196 1196
         // load the module class file
1197
-        require_once($module_path . $module_class . $module_ext);
1197
+        require_once($module_path.$module_class.$module_ext);
1198 1198
         // verify that class exists
1199
-        if (! class_exists($module_class)) {
1199
+        if ( ! class_exists($module_class)) {
1200 1200
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1201
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1201
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1202 1202
             return false;
1203 1203
         }
1204 1204
         // add to array of registered modules
1205
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1205
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1206 1206
         do_action(
1207 1207
             'AHEE__EE_Config__register_module__complete',
1208 1208
             $module_class,
@@ -1253,26 +1253,26 @@  discard block
 block discarded – undo
1253 1253
     {
1254 1254
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1255 1255
         $module = str_replace('EED_', '', $module);
1256
-        $module_class = 'EED_' . $module;
1257
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1256
+        $module_class = 'EED_'.$module;
1257
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1258 1258
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1259
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1260 1260
             return false;
1261 1261
         }
1262 1262
         if (empty($route)) {
1263 1263
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1264
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1265 1265
             return false;
1266 1266
         }
1267
-        if (! method_exists('EED_' . $module, $method_name)) {
1267
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1268 1268
             $msg = sprintf(
1269 1269
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1270 1270
                 $route
1271 1271
             );
1272
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1273 1273
             return false;
1274 1274
         }
1275
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1275
+        EE_Config::$_module_route_map[(string) $key][(string) $route] = array('EED_'.$module, $method_name);
1276 1276
         return true;
1277 1277
     }
1278 1278
 
@@ -1289,8 +1289,8 @@  discard block
 block discarded – undo
1289 1289
     {
1290 1290
         do_action('AHEE__EE_Config__get_route__begin', $route);
1291 1291
         $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1292
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1293
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1292
+        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1293
+            return EE_Config::$_module_route_map[$key][$route];
1294 1294
         }
1295 1295
         return null;
1296 1296
     }
@@ -1322,47 +1322,47 @@  discard block
 block discarded – undo
1322 1322
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1323 1323
     {
1324 1324
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1325
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1325
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1326 1326
             $msg = sprintf(
1327 1327
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1328 1328
                 $route
1329 1329
             );
1330
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1331 1331
             return false;
1332 1332
         }
1333 1333
         if (empty($forward)) {
1334 1334
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1335
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1335
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1336 1336
             return false;
1337 1337
         }
1338 1338
         if (is_array($forward)) {
1339
-            if (! isset($forward[1])) {
1339
+            if ( ! isset($forward[1])) {
1340 1340
                 $msg = sprintf(
1341 1341
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1342 1342
                     $route
1343 1343
                 );
1344
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1344
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1345 1345
                 return false;
1346 1346
             }
1347
-            if (! method_exists($forward[0], $forward[1])) {
1347
+            if ( ! method_exists($forward[0], $forward[1])) {
1348 1348
                 $msg = sprintf(
1349 1349
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1350 1350
                     $forward[1],
1351 1351
                     $route
1352 1352
                 );
1353
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1354 1354
                 return false;
1355 1355
             }
1356
-        } elseif (! function_exists($forward)) {
1356
+        } elseif ( ! function_exists($forward)) {
1357 1357
             $msg = sprintf(
1358 1358
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1359 1359
                 $forward,
1360 1360
                 $route
1361 1361
             );
1362
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1362
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1363 1363
             return false;
1364 1364
         }
1365
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1365
+        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1366 1366
         return true;
1367 1367
     }
1368 1368
 
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
     public static function get_forward($route = null, $status = 0, $key = 'ee')
1381 1381
     {
1382 1382
         do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1383
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1383
+        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1384 1384
             return apply_filters(
1385 1385
                 'FHEE__EE_Config__get_forward',
1386
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1386
+                EE_Config::$_module_forward_map[$key][$route][$status],
1387 1387
                 $route,
1388 1388
                 $status
1389 1389
             );
@@ -1407,15 +1407,15 @@  discard block
 block discarded – undo
1407 1407
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1408 1408
     {
1409 1409
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1410
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1410
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1411 1411
             $msg = sprintf(
1412 1412
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1413 1413
                 $route
1414 1414
             );
1415
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1415
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1416 1416
             return false;
1417 1417
         }
1418
-        if (! is_readable($view)) {
1418
+        if ( ! is_readable($view)) {
1419 1419
             $msg = sprintf(
1420 1420
                 __(
1421 1421
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1423,10 +1423,10 @@  discard block
 block discarded – undo
1423 1423
                 ),
1424 1424
                 $view
1425 1425
             );
1426
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1427 1427
             return false;
1428 1428
         }
1429
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1429
+        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1430 1430
         return true;
1431 1431
     }
1432 1432
 
@@ -1444,10 +1444,10 @@  discard block
 block discarded – undo
1444 1444
     public static function get_view($route = null, $status = 0, $key = 'ee')
1445 1445
     {
1446 1446
         do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1447
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1447
+        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1448 1448
             return apply_filters(
1449 1449
                 'FHEE__EE_Config__get_view',
1450
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1450
+                EE_Config::$_module_view_map[$key][$route][$status],
1451 1451
                 $route,
1452 1452
                 $status
1453 1453
             );
@@ -1473,7 +1473,7 @@  discard block
 block discarded – undo
1473 1473
      */
1474 1474
     public static function getLegacyShortcodesManager()
1475 1475
     {
1476
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1476
+        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477 1477
             EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1478 1478
                 LegacyShortcodesManager::class
1479 1479
             );
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
      */
1521 1521
     public function get_pretty($property)
1522 1522
     {
1523
-        if (! property_exists($this, $property)) {
1523
+        if ( ! property_exists($this, $property)) {
1524 1524
             throw new EE_Error(
1525 1525
                 sprintf(
1526 1526
                     __(
@@ -1749,11 +1749,11 @@  discard block
 block discarded – undo
1749 1749
      */
1750 1750
     public function reg_page_url()
1751 1751
     {
1752
-        if (! $this->reg_page_url) {
1752
+        if ( ! $this->reg_page_url) {
1753 1753
             $this->reg_page_url = add_query_arg(
1754 1754
                 array('uts' => time()),
1755 1755
                 get_permalink($this->reg_page_id)
1756
-            ) . '#checkout';
1756
+            ).'#checkout';
1757 1757
         }
1758 1758
         return $this->reg_page_url;
1759 1759
     }
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
      */
1770 1770
     public function txn_page_url($query_args = array())
1771 1771
     {
1772
-        if (! $this->txn_page_url) {
1772
+        if ( ! $this->txn_page_url) {
1773 1773
             $this->txn_page_url = get_permalink($this->txn_page_id);
1774 1774
         }
1775 1775
         if ($query_args) {
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
      */
1791 1791
     public function thank_you_page_url($query_args = array())
1792 1792
     {
1793
-        if (! $this->thank_you_page_url) {
1793
+        if ( ! $this->thank_you_page_url) {
1794 1794
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795 1795
         }
1796 1796
         if ($query_args) {
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
      */
1810 1810
     public function cancel_page_url()
1811 1811
     {
1812
-        if (! $this->cancel_page_url) {
1812
+        if ( ! $this->cancel_page_url) {
1813 1813
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1814 1814
         }
1815 1815
         return $this->cancel_page_url;
@@ -1852,13 +1852,13 @@  discard block
 block discarded – undo
1852 1852
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853 1853
         $option = self::OPTION_NAME_UXIP;
1854 1854
         // set correct table for query
1855
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1855
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1856 1856
         // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857 1857
         // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858 1858
         // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859 1859
         // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860 1860
         // for the purpose of caching.
1861
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1861
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1862 1862
         if (false !== $pre) {
1863 1863
             EE_Core_Config::$ee_ueip_option = $pre;
1864 1864
             return EE_Core_Config::$ee_ueip_option;
@@ -1872,10 +1872,10 @@  discard block
 block discarded – undo
1872 1872
         if (is_object($row)) {
1873 1873
             $value = $row->option_value;
1874 1874
         } else { // option does not exist so use default.
1875
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1875
+            EE_Core_Config::$ee_ueip_option = apply_filters('default_option_'.$option, false, $option);
1876 1876
             return EE_Core_Config::$ee_ueip_option;
1877 1877
         }
1878
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1878
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1879 1879
         return EE_Core_Config::$ee_ueip_option;
1880 1880
     }
1881 1881
 
@@ -2129,37 +2129,37 @@  discard block
 block discarded – undo
2129 2129
         // but override if requested
2130 2130
         $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2131 2131
         // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2132
-        if (! empty($CNT_ISO)
2132
+        if ( ! empty($CNT_ISO)
2133 2133
             && EE_Maintenance_Mode::instance()->models_can_query()
2134 2134
             && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2135 2135
         ) {
2136 2136
             // retrieve the country settings from the db, just in case they have been customized
2137 2137
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2138 2138
             if ($country instanceof EE_Country) {
2139
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2140
-                $this->name = $country->currency_name_single();    // Dollar
2141
-                $this->plural = $country->currency_name_plural();    // Dollars
2142
-                $this->sign = $country->currency_sign();            // currency sign: $
2139
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2140
+                $this->name = $country->currency_name_single(); // Dollar
2141
+                $this->plural = $country->currency_name_plural(); // Dollars
2142
+                $this->sign = $country->currency_sign(); // currency sign: $
2143 2143
                 $this->sign_b4 = $country->currency_sign_before(
2144
-                );        // currency sign before or after: $TRUE  or  FALSE$
2145
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2144
+                ); // currency sign before or after: $TRUE  or  FALSE$
2145
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2146 2146
                 $this->dec_mrk = $country->currency_decimal_mark(
2147
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2147
+                ); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2148 2148
                 $this->thsnds = $country->currency_thousands_separator(
2149
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2149
+                ); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2150 2150
             }
2151 2151
         }
2152 2152
         // fallback to hardcoded defaults, in case the above failed
2153 2153
         if (empty($this->code)) {
2154 2154
             // set default currency settings
2155
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2156
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2157
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2158
-            $this->sign = '$';    // currency sign: $
2159
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2160
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2161
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2162
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2155
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2156
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2157
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2158
+            $this->sign = '$'; // currency sign: $
2159
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2160
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2161
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2162
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2163 2163
         }
2164 2164
     }
2165 2165
 }
@@ -2426,8 +2426,8 @@  discard block
 block discarded – undo
2426 2426
             $closing_a_tag = '';
2427 2427
             if (function_exists('get_privacy_policy_url')) {
2428 2428
                 $privacy_page_url = get_privacy_policy_url();
2429
-                if (! empty($privacy_page_url)) {
2430
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2429
+                if ( ! empty($privacy_page_url)) {
2430
+                    $opening_a_tag = '<a href="'.$privacy_page_url.'" target="_blank">';
2431 2431
                     $closing_a_tag = '</a>';
2432 2432
                 }
2433 2433
             }
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
     public function log_file_name($reset = false)
2657 2657
     {
2658 2658
         if (empty($this->log_file_name) || $reset) {
2659
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2659
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2660 2660
             EE_Config::instance()->update_espresso_config(false, false);
2661 2661
         }
2662 2662
         return $this->log_file_name;
@@ -2670,7 +2670,7 @@  discard block
 block discarded – undo
2670 2670
     public function debug_file_name($reset = false)
2671 2671
     {
2672 2672
         if (empty($this->debug_file_name) || $reset) {
2673
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2673
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2674 2674
             EE_Config::instance()->update_espresso_config(false, false);
2675 2675
         }
2676 2676
         return $this->debug_file_name;
@@ -2874,21 +2874,21 @@  discard block
 block discarded – undo
2874 2874
         $this->use_google_maps = true;
2875 2875
         $this->google_map_api_key = '';
2876 2876
         // for event details pages (reg page)
2877
-        $this->event_details_map_width = 585;            // ee_map_width_single
2878
-        $this->event_details_map_height = 362;            // ee_map_height_single
2879
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2880
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2881
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2882
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2883
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2877
+        $this->event_details_map_width = 585; // ee_map_width_single
2878
+        $this->event_details_map_height = 362; // ee_map_height_single
2879
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2880
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2881
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2882
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2883
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2884 2884
         // for event list pages
2885
-        $this->event_list_map_width = 300;            // ee_map_width
2886
-        $this->event_list_map_height = 185;        // ee_map_height
2887
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2888
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2889
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2890
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2891
-        $this->event_list_map_align = 'center';            // ee_map_align
2885
+        $this->event_list_map_width = 300; // ee_map_width
2886
+        $this->event_list_map_height = 185; // ee_map_height
2887
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2888
+        $this->event_list_display_nav = false; // ee_map_nav_display
2889
+        $this->event_list_nav_size = true; // ee_map_nav_size
2890
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2891
+        $this->event_list_map_align = 'center'; // ee_map_align
2892 2892
     }
2893 2893
 }
2894 2894
 
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
      */
3207 3207
     public function max_input_vars_limit_check($input_count = 0)
3208 3208
     {
3209
-        if (! empty($this->php->max_input_vars)
3209
+        if ( ! empty($this->php->max_input_vars)
3210 3210
             && ($input_count >= $this->php->max_input_vars)
3211 3211
         ) {
3212 3212
             // check the server setting because the config value could be stale
Please login to merge, or discard this patch.
core/helpers/EEH_Form_Fields.helper.php 2 patches
Indentation   +1465 added lines, -1465 removed lines patch added patch discarded remove patch
@@ -32,1038 +32,1038 @@  discard block
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     *  Generates HTML for the forms used on admin pages
37
-     *
38
-     *
39
-     *  @static
40
-     *  @access public
41
-     *  @param  array $input_vars - array of input field details
42
-     *  format:
43
-     *  $template_form_fields['field-id'] = array(
44
-     *      'name' => 'name_attribute',
45
-     *      'label' => __('Field Label', 'event_espresso'), //or false
46
-     *      'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden', 'checkbox', 'wp_editor'
47
-     *      'type' => 'int', //what "type" the value is (i.e. string, int etc)
48
-     *      'required' => false, //boolean for whether the field is required
49
-     *      'validation' => true, //boolean, whether to validate the field (todo)
50
-     *      'value' => 'some_value_for_field', //what value is used for field
51
-     *      'format' => '%d', //what format the value is (%d, %f, or %s)
52
-     *      'db-col' => 'column_in_db' //used to indicate which column the field corresponds with in the db
53
-     *      'options' => optiona, optionb || array('value' => 'label', '') //if the input type is "select", this allows you to set the args for the different <option> tags.
54
-     *      'tabindex' => 1 //this allows you to set the tabindex for the field.
55
-     *      'append_content' => '' //this allows you to send in html content to append to the field.
56
-     *  )
57
-     *  @param  array $id - used for defining unique identifiers for the form.
58
-     *  @return string
59
-     *  @todo: at some point we can break this down into other static methods to abstract it a bit better.
60
-     */
61
-    public static function get_form_fields($input_vars = array(), $id = false)
62
-    {
35
+	/**
36
+	 *  Generates HTML for the forms used on admin pages
37
+	 *
38
+	 *
39
+	 *  @static
40
+	 *  @access public
41
+	 *  @param  array $input_vars - array of input field details
42
+	 *  format:
43
+	 *  $template_form_fields['field-id'] = array(
44
+	 *      'name' => 'name_attribute',
45
+	 *      'label' => __('Field Label', 'event_espresso'), //or false
46
+	 *      'input' => 'hidden', //field input type can be 'text', 'select', 'textarea', 'hidden', 'checkbox', 'wp_editor'
47
+	 *      'type' => 'int', //what "type" the value is (i.e. string, int etc)
48
+	 *      'required' => false, //boolean for whether the field is required
49
+	 *      'validation' => true, //boolean, whether to validate the field (todo)
50
+	 *      'value' => 'some_value_for_field', //what value is used for field
51
+	 *      'format' => '%d', //what format the value is (%d, %f, or %s)
52
+	 *      'db-col' => 'column_in_db' //used to indicate which column the field corresponds with in the db
53
+	 *      'options' => optiona, optionb || array('value' => 'label', '') //if the input type is "select", this allows you to set the args for the different <option> tags.
54
+	 *      'tabindex' => 1 //this allows you to set the tabindex for the field.
55
+	 *      'append_content' => '' //this allows you to send in html content to append to the field.
56
+	 *  )
57
+	 *  @param  array $id - used for defining unique identifiers for the form.
58
+	 *  @return string
59
+	 *  @todo: at some point we can break this down into other static methods to abstract it a bit better.
60
+	 */
61
+	public static function get_form_fields($input_vars = array(), $id = false)
62
+	{
63 63
         
64
-        if (empty($input_vars)) {
65
-            EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
66
-            return false;
67
-        }
68
-
69
-        // if you don't behave - this is what you're gonna get !!!
70
-        $close = true;
71
-        $output = '<ul>'; // this is for using built-in wp styles... watch carefully...
72
-
73
-        // cycle thru inputs
74
-        foreach ($input_vars as $input_key => $input_value) {
75
-            $defaults = array(
76
-                'name' => $input_key,
77
-                'label' => __('No label', 'event_espresso'),
78
-                'input' => 'hidden',
79
-                'type' => 'int',
80
-                'required' => false,
81
-                'validation' => true,
82
-                'value' => 'some_value_for_field',
83
-                'format' => '%d',
84
-                'db-col' => 'column_in_db',
85
-                'options' => array(),
86
-                'tabindex' => '',
87
-                'append_content' => ''
88
-                );
89
-
90
-            $input_value = wp_parse_args($input_value, $defaults);
91
-
92
-            // required fields get a *
93
-            $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': ';
94
-            // and the css class "required"
95
-            $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : '';
96
-            $styles = $input_value['required'] ? 'required ' . $css_class : $css_class;
97
-
98
-            $field_id = ($id) ? $id . '-' . $input_key : $input_key;
99
-            $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : '';
100
-
101
-            // rows or cols?
102
-            $rows = isset($input_value['rows']) ? $input_value['rows'] : '10';
103
-            $cols = isset($input_value['cols']) ? $input_value['cols'] : '80';
104
-
105
-            // any content?
106
-            $append_content = $input_value['append_content'];
107
-
108
-            $output .= (!$close) ? '<ul>' : '';
109
-            $output .= '<li>';
110
-
111
-            // what type of input are we dealing with ?
112
-            switch ($input_value['input']) {
113
-                // text inputs
114
-                case 'text':
115
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
116
-                    $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . esc_textarea($input_value['value']) . '" name="' . $input_value['name'] . '"' . $tabindex . '>';
117
-                    break;
118
-
119
-                // dropdowns
120
-                case 'select':
121
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
122
-                    $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>';
123
-
124
-                    if (is_array($input_value['options'])) {
125
-                        $options = $input_value['options'];
126
-                    } else {
127
-                        $options = explode(',', $input_value['options']);
128
-                    }
129
-
130
-                    foreach ($options as $key => $value) {
131
-                        $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : '';
132
-                        // $key = str_replace( ' ', '_', sanitize_key( $value ));
133
-                        $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>';
134
-                    }
135
-                    $output .= "\n\t\t\t" . '</select>';
136
-
137
-                    break;
138
-
139
-                case 'textarea':
140
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
141
-                    $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . esc_textarea($input_value['value']) . '</textarea>';
142
-                    break;
143
-
144
-                case 'hidden':
145
-                    $close = false;
146
-                    $output .= "</li></ul>";
147
-                    $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">';
148
-                    break;
149
-
150
-                case 'checkbox':
151
-                    $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : '';
152
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
153
-                    $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />';
154
-                    break;
155
-
156
-                case 'wp_editor':
157
-                    $close = false;
158
-                    $editor_settings = array(
159
-                        'textarea_name' => $input_value['name'],
160
-                        'textarea_rows' => $rows,
161
-                        'editor_class' => $styles,
162
-                        'tabindex' => $input_value['tabindex']
163
-                    );
164
-                    $output .= '</li>';
165
-                    $output .= '</ul>';
166
-                    $output .= '<h4>' . $input_value['label'] . '</h4>';
167
-                    if ($append_content) {
168
-                        $output .= $append_content;
169
-                    }
170
-                    ob_start();
171
-                    wp_editor($input_value['value'], $field_id, $editor_settings);
172
-                    $editor = ob_get_contents();
173
-                    ob_end_clean();
174
-                    $output .= $editor;
175
-                    break;
176
-            }
177
-            if ($append_content && $input_value['input'] !== 'wp_editor') {
178
-                $output .= $append_content;
179
-            }
180
-                $output .= ($close) ? '</li>' : '';
181
-        } // end foreach( $input_vars as $input_key => $input_value )
182
-        $output .= ($close) ? '</ul>' : '';
183
-
184
-        return $output;
185
-    }
186
-
187
-    /**
188
-     * form_fields_array
189
-     * This utility function assembles form fields from a given structured array with field information.
190
-     * //TODO: This is an alternate generator that we may want to use instead.
191
-     *
192
-     * @param  array $fields structured array of fields to assemble in the following format:
193
-     * [field_name] => array(
194
-     *      ['label'] => 'label for field',
195
-     *      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select type of field you can indicated the labels for each option via this index
196
-     *      ['extra_desc'] => 'extra description for the field', //optional
197
-     *      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults to text
198
-     *      ['value'] => 'value that goes in the field', //(if multi then this is an array of values and the 'default' paramater will be used for what is selected)
199
-     *      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
200
-     *      ['class'] => 'name-of-class(es)-for-input',
201
-     *      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi select type of field you can indicate the css class for each option via this index.
202
-     *      ['id'] => 'css-id-for-input') //defaults to 'field_name'
203
-     *      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields generated are going to be used in a loop and you want to make sure that the field identifiers are unique from each other.
204
-     *      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types such as textarea to indicate cols/rows.
205
-     *      ['tabindex'] => '' //this allows you to set the tabindex for the field.
206
-     *      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally contain an array of arguments for the editor setup.
207
-     *
208
-     * @return array         an array of inputs for form indexed by field name, and in the following structure:
209
-     *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
210
-     */
211
-    public static function get_form_fields_array($fields)
212
-    {
213
-
214
-        $form_fields = array();
215
-        $fields = (array) $fields;
216
-
217
-        foreach ($fields as $field_name => $field_atts) {
218
-            // defaults:
219
-            $defaults = array(
220
-                'label' => '',
221
-                'labels' => '',
222
-                'extra_desc' => '',
223
-                'type' => 'text',
224
-                'value' => '',
225
-                'default' => '',
226
-                'class' => '',
227
-                'classes' => '',
228
-                'id' => $field_name,
229
-                'unique_id' => '',
230
-                'dimensions' => array('10', '5'),
231
-                'tabindex' => '',
232
-                'wpeditor_args' => array()
233
-                );
234
-            // merge defaults with passed arguments
235
-            $_fields = wp_parse_args($field_atts, $defaults);
236
-            extract($_fields);
237
-            // generate label
238
-            $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>';
239
-            // generate field name
240
-            $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
241
-
242
-            // tabindex
243
-            $tabindex_str = !empty($tabindex) ? ' tabindex="' . $tabindex . '"' : '';
244
-
245
-            // we determine what we're building based on the type
246
-            switch ($type) {
247
-                case 'textarea':
248
-                        $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>';
249
-                        $fld .= $extra_desc;
250
-                    break;
251
-
252
-                case 'checkbox':
253
-                        $c_input = '';
254
-                    if (is_array($value)) {
255
-                        foreach ($value as $key => $val) {
256
-                            $c_id = $field_name . '_' . $value;
257
-                            $c_class = isset($classes[ $key ]) ? ' class="' . $classes[ $key ] . '" ' : '';
258
-                            $c_label = isset($labels[ $key ]) ? '<label for="' . $c_id . '">' . $labels[ $key ] . '</label>' : '';
259
-                            $checked = !empty($default) && $default == $val ? ' checked="checked" ' : '';
260
-                            $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label;
261
-                        }
262
-                        $fld = $c_input;
263
-                    } else {
264
-                        $checked = !empty($default) && $default == $val ? 'checked="checked" ' : '';
265
-                        $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n";
266
-                    }
267
-                    break;
268
-
269
-                case 'radio':
270
-                        $c_input = '';
271
-                    if (is_array($value)) {
272
-                        foreach ($value as $key => $val) {
273
-                            $c_id = $field_name . '_' . $value;
274
-                            $c_class = isset($classes[ $key ]) ? 'class="' . $classes[ $key ] . '" ' : '';
275
-                            $c_label = isset($labels[ $key ]) ? '<label for="' . $c_id . '">' . $labels[ $key ] . '</label>' : '';
276
-                            $checked = !empty($default) && $default == $val ? ' checked="checked" ' : '';
277
-                            $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label;
278
-                        }
279
-                        $fld = $c_input;
280
-                    } else {
281
-                        $checked = !empty($default) && $default == $val ? 'checked="checked" ' : '';
282
-                        $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n";
283
-                    }
284
-                    break;
285
-
286
-                case 'hidden':
287
-                        $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n";
288
-                    break;
289
-
290
-                case 'select':
291
-                        $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n";
292
-                    foreach ($value as $key => $val) {
293
-                        $checked = !empty($default) && $default == $val ? ' selected="selected"' : '';
294
-                        $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[ $key ] . '</option>' . "\n";
295
-                    }
296
-                        $fld .= '</select>';
297
-                    break;
298
-
299
-                case 'wp_editor':
300
-                        $editor_settings = array(
301
-                            'textarea_name' => $f_name,
302
-                            'textarea_rows' => $dimensions[1],
303
-                            'editor_class' => $class,
304
-                            'tabindex' => $tabindex
305
-                            );
306
-                        $editor_settings = array_merge($wpeditor_args, $editor_settings);
307
-                        ob_start();
308
-                        wp_editor($value, $id, $editor_settings);
309
-                        $editor = ob_get_contents();
310
-                        ob_end_clean();
311
-                        $fld = $editor;
312
-                    break;
313
-
314
-                default: // 'text fields'
315
-                        $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n";
316
-                        $fld .= $extra_desc;
317
-            }
318
-
319
-            $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld );
320
-        }
321
-
322
-        return $form_fields;
323
-    }
324
-
325
-
326
-
327
-
328
-
329
-
330
-    /**
331
-     * espresso admin page select_input
332
-     * Turns an array into a select fields
333
-     *
334
-     * @static
335
-     * @access public
336
-     * @param  string  $name       field name
337
-     * @param  array  $values     option values, numbered array starting at 0, where each value is an array with a key 'text' (meaning text to display' and 'id' (meaning the internal value)
338
-     * eg: array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or as an array of key-value pairs, where the key is to be used for the
339
-     * select input's name, and the value will be the text shown to the user.  Optionally you can also include an additional key of "class" which will add a specific class to the option for that value.
340
-     * @param  string  $default    default value
341
-     * @param  string  $parameters extra paramaters
342
-     * @param  string  $class      css class
343
-     * @param  boolean $autosize   whether to autosize the select or not
344
-     * @return string              html string for the select input
345
-     */
346
-    public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
347
-    {
348
-        // if $values was submitted in the wrong format, convert it over
349
-        if (!empty($values) && (!array_key_exists(0, $values) || !is_array($values[0]))) {
350
-            $converted_values=array();
351
-            foreach ($values as $id => $text) {
352
-                $converted_values[]=array('id'=>$id,'text'=>$text);
353
-            }
354
-            $values=$converted_values;
355
-        }
356
-
357
-        $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"';
358
-        // Debug
359
-        // EEH_Debug_Tools::printr( $values, '$values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
360
-        if (EEH_Formatter::ee_tep_not_null($parameters)) {
361
-            $field .= ' ' . $parameters;
362
-        }
363
-        if ($autosize) {
364
-            $size = 'med';
365
-            for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
366
-                if ($values[ $ii ]['text']) {
367
-                    if (strlen($values[ $ii ]['text']) > 5) {
368
-                        $size = 'wide';
369
-                    }
370
-                }
371
-            }
372
-        } else {
373
-            $size = '';
374
-        }
375
-
376
-        $field .= ' class="' . $class . ' ' . $size . '">';
377
-
378
-        if (empty($default) && isset($GLOBALS[ $name ])) {
379
-            $default = stripslashes($GLOBALS[ $name ]);
380
-        }
381
-
382
-
383
-        for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
384
-            $field .= '<option value="' . $values[ $i ]['id'] . '"';
385
-            if ($default == $values[ $i ]['id']) {
386
-                $field .= ' selected = "selected"';
387
-            }
388
-            if (isset($values[ $i ]['class'])) {
389
-                $field .= ' class="' . $values[ $i ]['class'] . '"';
390
-            }
391
-            $field .= '>' . $values[ $i ]['text'] . '</option>';
392
-        }
393
-        $field .= '</select>';
394
-
395
-        return $field;
396
-    }
397
-
398
-
399
-
400
-
401
-
402
-
403
-    /**
404
-     * generate_question_groups_html
405
-     *
406
-     * @param string $question_groups
407
-     * @return string HTML
408
-     */
409
-    public static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset')
410
-    {
411
-
412
-        $html = '';
413
-        $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
414
-        $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
415
-
416
-        if (! empty($question_groups)) {
417
-            // EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
418
-            // loop thru question groups
419
-            foreach ($question_groups as $QSG) {
420
-                // check that questions exist
421
-                if (! empty($QSG['QSG_questions'])) {
422
-                    // use fieldsets
423
-                    $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">';
424
-                    // group_name
425
-                    $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer($QSG['QSG_name']) . '</h5>' : '';
426
-                    // group_desc
427
-                    $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer($QSG['QSG_desc']) . '</div>' : '';
428
-
429
-                    $html .= $before_question_group_questions;
430
-                    // loop thru questions
431
-                    foreach ($QSG['QSG_questions'] as $question) {
64
+		if (empty($input_vars)) {
65
+			EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
66
+			return false;
67
+		}
68
+
69
+		// if you don't behave - this is what you're gonna get !!!
70
+		$close = true;
71
+		$output = '<ul>'; // this is for using built-in wp styles... watch carefully...
72
+
73
+		// cycle thru inputs
74
+		foreach ($input_vars as $input_key => $input_value) {
75
+			$defaults = array(
76
+				'name' => $input_key,
77
+				'label' => __('No label', 'event_espresso'),
78
+				'input' => 'hidden',
79
+				'type' => 'int',
80
+				'required' => false,
81
+				'validation' => true,
82
+				'value' => 'some_value_for_field',
83
+				'format' => '%d',
84
+				'db-col' => 'column_in_db',
85
+				'options' => array(),
86
+				'tabindex' => '',
87
+				'append_content' => ''
88
+				);
89
+
90
+			$input_value = wp_parse_args($input_value, $defaults);
91
+
92
+			// required fields get a *
93
+			$required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': ';
94
+			// and the css class "required"
95
+			$css_class = isset($input_value['css_class']) ? $input_value['css_class'] : '';
96
+			$styles = $input_value['required'] ? 'required ' . $css_class : $css_class;
97
+
98
+			$field_id = ($id) ? $id . '-' . $input_key : $input_key;
99
+			$tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : '';
100
+
101
+			// rows or cols?
102
+			$rows = isset($input_value['rows']) ? $input_value['rows'] : '10';
103
+			$cols = isset($input_value['cols']) ? $input_value['cols'] : '80';
104
+
105
+			// any content?
106
+			$append_content = $input_value['append_content'];
107
+
108
+			$output .= (!$close) ? '<ul>' : '';
109
+			$output .= '<li>';
110
+
111
+			// what type of input are we dealing with ?
112
+			switch ($input_value['input']) {
113
+				// text inputs
114
+				case 'text':
115
+					$output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
116
+					$output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . esc_textarea($input_value['value']) . '" name="' . $input_value['name'] . '"' . $tabindex . '>';
117
+					break;
118
+
119
+				// dropdowns
120
+				case 'select':
121
+					$output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
122
+					$output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>';
123
+
124
+					if (is_array($input_value['options'])) {
125
+						$options = $input_value['options'];
126
+					} else {
127
+						$options = explode(',', $input_value['options']);
128
+					}
129
+
130
+					foreach ($options as $key => $value) {
131
+						$selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : '';
132
+						// $key = str_replace( ' ', '_', sanitize_key( $value ));
133
+						$output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>';
134
+					}
135
+					$output .= "\n\t\t\t" . '</select>';
136
+
137
+					break;
138
+
139
+				case 'textarea':
140
+					$output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
141
+					$output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . esc_textarea($input_value['value']) . '</textarea>';
142
+					break;
143
+
144
+				case 'hidden':
145
+					$close = false;
146
+					$output .= "</li></ul>";
147
+					$output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">';
148
+					break;
149
+
150
+				case 'checkbox':
151
+					$checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : '';
152
+					$output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
153
+					$output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />';
154
+					break;
155
+
156
+				case 'wp_editor':
157
+					$close = false;
158
+					$editor_settings = array(
159
+						'textarea_name' => $input_value['name'],
160
+						'textarea_rows' => $rows,
161
+						'editor_class' => $styles,
162
+						'tabindex' => $input_value['tabindex']
163
+					);
164
+					$output .= '</li>';
165
+					$output .= '</ul>';
166
+					$output .= '<h4>' . $input_value['label'] . '</h4>';
167
+					if ($append_content) {
168
+						$output .= $append_content;
169
+					}
170
+					ob_start();
171
+					wp_editor($input_value['value'], $field_id, $editor_settings);
172
+					$editor = ob_get_contents();
173
+					ob_end_clean();
174
+					$output .= $editor;
175
+					break;
176
+			}
177
+			if ($append_content && $input_value['input'] !== 'wp_editor') {
178
+				$output .= $append_content;
179
+			}
180
+				$output .= ($close) ? '</li>' : '';
181
+		} // end foreach( $input_vars as $input_key => $input_value )
182
+		$output .= ($close) ? '</ul>' : '';
183
+
184
+		return $output;
185
+	}
186
+
187
+	/**
188
+	 * form_fields_array
189
+	 * This utility function assembles form fields from a given structured array with field information.
190
+	 * //TODO: This is an alternate generator that we may want to use instead.
191
+	 *
192
+	 * @param  array $fields structured array of fields to assemble in the following format:
193
+	 * [field_name] => array(
194
+	 *      ['label'] => 'label for field',
195
+	 *      ['labels'] => array('label_1', 'label_2'); //optional - if the field type is a multi select type of field you can indicated the labels for each option via this index
196
+	 *      ['extra_desc'] => 'extra description for the field', //optional
197
+	 *      ['type'] => 'textarea'|'text'|'wp_editor'|'checkbox'|'radio'|'hidden'|'select', //defaults to text
198
+	 *      ['value'] => 'value that goes in the field', //(if multi then this is an array of values and the 'default' paramater will be used for what is selected)
199
+	 *      ['default'] => 'default if the field type is multi (i.e. select or radios or checkboxes)',
200
+	 *      ['class'] => 'name-of-class(es)-for-input',
201
+	 *      ['classes'] => array('class_1', 'class_2'); //optional - if the field type is a multi select type of field you can indicate the css class for each option via this index.
202
+	 *      ['id'] => 'css-id-for-input') //defaults to 'field_name'
203
+	 *      ['unique_id'] => 1 //defaults to empty string.  This is useful for when the fields generated are going to be used in a loop and you want to make sure that the field identifiers are unique from each other.
204
+	 *      ['dimensions'] => array(100,300), //defaults to empty array.  This is used by field types such as textarea to indicate cols/rows.
205
+	 *      ['tabindex'] => '' //this allows you to set the tabindex for the field.
206
+	 *      ['wpeditor_args'] => array() //if the type of field is wpeditor then this can optionally contain an array of arguments for the editor setup.
207
+	 *
208
+	 * @return array         an array of inputs for form indexed by field name, and in the following structure:
209
+	 *     [field_name] => array( 'label' => '{label_html}', 'field' => '{input_html}'
210
+	 */
211
+	public static function get_form_fields_array($fields)
212
+	{
213
+
214
+		$form_fields = array();
215
+		$fields = (array) $fields;
216
+
217
+		foreach ($fields as $field_name => $field_atts) {
218
+			// defaults:
219
+			$defaults = array(
220
+				'label' => '',
221
+				'labels' => '',
222
+				'extra_desc' => '',
223
+				'type' => 'text',
224
+				'value' => '',
225
+				'default' => '',
226
+				'class' => '',
227
+				'classes' => '',
228
+				'id' => $field_name,
229
+				'unique_id' => '',
230
+				'dimensions' => array('10', '5'),
231
+				'tabindex' => '',
232
+				'wpeditor_args' => array()
233
+				);
234
+			// merge defaults with passed arguments
235
+			$_fields = wp_parse_args($field_atts, $defaults);
236
+			extract($_fields);
237
+			// generate label
238
+			$label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>';
239
+			// generate field name
240
+			$f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
241
+
242
+			// tabindex
243
+			$tabindex_str = !empty($tabindex) ? ' tabindex="' . $tabindex . '"' : '';
244
+
245
+			// we determine what we're building based on the type
246
+			switch ($type) {
247
+				case 'textarea':
248
+						$fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>';
249
+						$fld .= $extra_desc;
250
+					break;
251
+
252
+				case 'checkbox':
253
+						$c_input = '';
254
+					if (is_array($value)) {
255
+						foreach ($value as $key => $val) {
256
+							$c_id = $field_name . '_' . $value;
257
+							$c_class = isset($classes[ $key ]) ? ' class="' . $classes[ $key ] . '" ' : '';
258
+							$c_label = isset($labels[ $key ]) ? '<label for="' . $c_id . '">' . $labels[ $key ] . '</label>' : '';
259
+							$checked = !empty($default) && $default == $val ? ' checked="checked" ' : '';
260
+							$c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label;
261
+						}
262
+						$fld = $c_input;
263
+					} else {
264
+						$checked = !empty($default) && $default == $val ? 'checked="checked" ' : '';
265
+						$fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n";
266
+					}
267
+					break;
268
+
269
+				case 'radio':
270
+						$c_input = '';
271
+					if (is_array($value)) {
272
+						foreach ($value as $key => $val) {
273
+							$c_id = $field_name . '_' . $value;
274
+							$c_class = isset($classes[ $key ]) ? 'class="' . $classes[ $key ] . '" ' : '';
275
+							$c_label = isset($labels[ $key ]) ? '<label for="' . $c_id . '">' . $labels[ $key ] . '</label>' : '';
276
+							$checked = !empty($default) && $default == $val ? ' checked="checked" ' : '';
277
+							$c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label;
278
+						}
279
+						$fld = $c_input;
280
+					} else {
281
+						$checked = !empty($default) && $default == $val ? 'checked="checked" ' : '';
282
+						$fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n";
283
+					}
284
+					break;
285
+
286
+				case 'hidden':
287
+						$fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n";
288
+					break;
289
+
290
+				case 'select':
291
+						$fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n";
292
+					foreach ($value as $key => $val) {
293
+						$checked = !empty($default) && $default == $val ? ' selected="selected"' : '';
294
+						$fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[ $key ] . '</option>' . "\n";
295
+					}
296
+						$fld .= '</select>';
297
+					break;
298
+
299
+				case 'wp_editor':
300
+						$editor_settings = array(
301
+							'textarea_name' => $f_name,
302
+							'textarea_rows' => $dimensions[1],
303
+							'editor_class' => $class,
304
+							'tabindex' => $tabindex
305
+							);
306
+						$editor_settings = array_merge($wpeditor_args, $editor_settings);
307
+						ob_start();
308
+						wp_editor($value, $id, $editor_settings);
309
+						$editor = ob_get_contents();
310
+						ob_end_clean();
311
+						$fld = $editor;
312
+					break;
313
+
314
+				default: // 'text fields'
315
+						$fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n";
316
+						$fld .= $extra_desc;
317
+			}
318
+
319
+			$form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld );
320
+		}
321
+
322
+		return $form_fields;
323
+	}
324
+
325
+
326
+
327
+
328
+
329
+
330
+	/**
331
+	 * espresso admin page select_input
332
+	 * Turns an array into a select fields
333
+	 *
334
+	 * @static
335
+	 * @access public
336
+	 * @param  string  $name       field name
337
+	 * @param  array  $values     option values, numbered array starting at 0, where each value is an array with a key 'text' (meaning text to display' and 'id' (meaning the internal value)
338
+	 * eg: array(1=>array('text'=>'Monday','id'=>1),2=>array('text'=>'Tuesday','id'=>2)...). or as an array of key-value pairs, where the key is to be used for the
339
+	 * select input's name, and the value will be the text shown to the user.  Optionally you can also include an additional key of "class" which will add a specific class to the option for that value.
340
+	 * @param  string  $default    default value
341
+	 * @param  string  $parameters extra paramaters
342
+	 * @param  string  $class      css class
343
+	 * @param  boolean $autosize   whether to autosize the select or not
344
+	 * @return string              html string for the select input
345
+	 */
346
+	public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
347
+	{
348
+		// if $values was submitted in the wrong format, convert it over
349
+		if (!empty($values) && (!array_key_exists(0, $values) || !is_array($values[0]))) {
350
+			$converted_values=array();
351
+			foreach ($values as $id => $text) {
352
+				$converted_values[]=array('id'=>$id,'text'=>$text);
353
+			}
354
+			$values=$converted_values;
355
+		}
356
+
357
+		$field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"';
358
+		// Debug
359
+		// EEH_Debug_Tools::printr( $values, '$values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
360
+		if (EEH_Formatter::ee_tep_not_null($parameters)) {
361
+			$field .= ' ' . $parameters;
362
+		}
363
+		if ($autosize) {
364
+			$size = 'med';
365
+			for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
366
+				if ($values[ $ii ]['text']) {
367
+					if (strlen($values[ $ii ]['text']) > 5) {
368
+						$size = 'wide';
369
+					}
370
+				}
371
+			}
372
+		} else {
373
+			$size = '';
374
+		}
375
+
376
+		$field .= ' class="' . $class . ' ' . $size . '">';
377
+
378
+		if (empty($default) && isset($GLOBALS[ $name ])) {
379
+			$default = stripslashes($GLOBALS[ $name ]);
380
+		}
381
+
382
+
383
+		for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
384
+			$field .= '<option value="' . $values[ $i ]['id'] . '"';
385
+			if ($default == $values[ $i ]['id']) {
386
+				$field .= ' selected = "selected"';
387
+			}
388
+			if (isset($values[ $i ]['class'])) {
389
+				$field .= ' class="' . $values[ $i ]['class'] . '"';
390
+			}
391
+			$field .= '>' . $values[ $i ]['text'] . '</option>';
392
+		}
393
+		$field .= '</select>';
394
+
395
+		return $field;
396
+	}
397
+
398
+
399
+
400
+
401
+
402
+
403
+	/**
404
+	 * generate_question_groups_html
405
+	 *
406
+	 * @param string $question_groups
407
+	 * @return string HTML
408
+	 */
409
+	public static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset')
410
+	{
411
+
412
+		$html = '';
413
+		$before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
414
+		$after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
415
+
416
+		if (! empty($question_groups)) {
417
+			// EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
418
+			// loop thru question groups
419
+			foreach ($question_groups as $QSG) {
420
+				// check that questions exist
421
+				if (! empty($QSG['QSG_questions'])) {
422
+					// use fieldsets
423
+					$html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">';
424
+					// group_name
425
+					$html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer($QSG['QSG_name']) . '</h5>' : '';
426
+					// group_desc
427
+					$html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer($QSG['QSG_desc']) . '</div>' : '';
428
+
429
+					$html .= $before_question_group_questions;
430
+					// loop thru questions
431
+					foreach ($QSG['QSG_questions'] as $question) {
432 432
 //                      EEH_Debug_Tools::printr( $question, '$question  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
433
-                        $QFI = new EE_Question_Form_Input(
434
-                            $question['qst_obj'],
435
-                            $question['ans_obj'],
436
-                            $question
437
-                        );
438
-                        $html .= self::generate_form_input($QFI);
439
-                    }
440
-                    $html .= $after_question_group_questions;
441
-                    $html .= "\n\t" . '</' . $group_wrapper . '>';
442
-                }
443
-            }
444
-        }
445
-
446
-        return $html;
447
-    }
448
-
449
-
450
-
451
-    /**
452
-     * generate_question_groups_html
453
-     *
454
-     * @param array         $question_groups
455
-     * @param array        $q_meta
456
-     * @param bool         $from_admin
457
-     * @param string       $group_wrapper
458
-     * @return string HTML
459
-     */
460
-    public static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = false, $group_wrapper = 'fieldset')
461
-    {
462
-
463
-        $html = '';
464
-        $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
465
-        $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
466
-
467
-        $default_q_meta = array(
468
-                'att_nmbr' => 1,
469
-                'ticket_id' => '',
470
-                'input_name' => '',
471
-                'input_id' => '',
472
-                'input_class' => ''
473
-        );
474
-        $q_meta = array_merge($default_q_meta, $q_meta);
475
-        // EEH_Debug_Tools::printr( $q_meta, '$q_meta  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
476
-
477
-        if (! empty($question_groups)) {
433
+						$QFI = new EE_Question_Form_Input(
434
+							$question['qst_obj'],
435
+							$question['ans_obj'],
436
+							$question
437
+						);
438
+						$html .= self::generate_form_input($QFI);
439
+					}
440
+					$html .= $after_question_group_questions;
441
+					$html .= "\n\t" . '</' . $group_wrapper . '>';
442
+				}
443
+			}
444
+		}
445
+
446
+		return $html;
447
+	}
448
+
449
+
450
+
451
+	/**
452
+	 * generate_question_groups_html
453
+	 *
454
+	 * @param array         $question_groups
455
+	 * @param array        $q_meta
456
+	 * @param bool         $from_admin
457
+	 * @param string       $group_wrapper
458
+	 * @return string HTML
459
+	 */
460
+	public static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = false, $group_wrapper = 'fieldset')
461
+	{
462
+
463
+		$html = '';
464
+		$before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
465
+		$after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
466
+
467
+		$default_q_meta = array(
468
+				'att_nmbr' => 1,
469
+				'ticket_id' => '',
470
+				'input_name' => '',
471
+				'input_id' => '',
472
+				'input_class' => ''
473
+		);
474
+		$q_meta = array_merge($default_q_meta, $q_meta);
475
+		// EEH_Debug_Tools::printr( $q_meta, '$q_meta  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
476
+
477
+		if (! empty($question_groups)) {
478 478
 //          EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
479
-            // loop thru question groups
480
-            foreach ($question_groups as $QSG) {
481
-                if ($QSG instanceof EE_Question_Group) {
482
-                    // check that questions exist
483
-
484
-                    $where = array( 'QST_deleted' => 0 );
485
-                    if (! $from_admin) {
486
-                        $where['QST_admin_only'] = 0;
487
-                    }
488
-                    $questions = $QSG->questions(array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' )));
489
-                    if (! empty($questions)) {
490
-                        // use fieldsets
491
-                        $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get('QSG_identifier') . '">';
492
-                        // group_name
493
-                        if ($QSG->show_group_name()) {
494
-                            $html .=  "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty('QSG_name') . '</h5>';
495
-                        }
496
-                        // group_desc
497
-                        if ($QSG->show_group_desc()) {
498
-                            $html .=  '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty('QSG_desc') . '</div>';
499
-                        }
500
-
501
-                        $html .= $before_question_group_questions;
502
-                        // loop thru questions
503
-                        foreach ($questions as $QST) {
504
-                            $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
505
-
506
-                            $answer = null;
507
-
508
-                            if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
509
-                                // check for answer in $_GET in case we are reprocessing a form after an error
510
-                                if (isset($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ])) {
511
-                                    $answer = is_array($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ]) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ]);
512
-                                }
513
-                            } elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
514
-                                // attendee data from the session
515
-                                $answer = isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
516
-                            }
517
-
518
-
519
-
520
-                            $QFI = new EE_Question_Form_Input(
521
-                                $QST,
522
-                                EE_Answer::new_instance(array(
523
-                                            'ANS_ID'=> 0,
524
-                                            'QST_ID'=> 0,
525
-                                            'REG_ID'=> 0,
526
-                                            'ANS_value'=> $answer
527
-                                    )),
528
-                                $q_meta
529
-                            );
530
-                            // EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
531
-                            $html .= self::generate_form_input($QFI);
532
-                        }
533
-                        $html .= $after_question_group_questions;
534
-                        $html .= "\n\t" . '</' . $group_wrapper . '>';
535
-                    }
536
-                }
537
-            }
538
-        }
539
-        return $html;
540
-    }
541
-
542
-
543
-
544
-
545
-
546
-
547
-    /**
548
-     * generate_form_input
549
-     *
550
-     * @param EE_Question_Form_Input $QFI
551
-     * @return string HTML
552
-     */
553
-    public static function generate_form_input(EE_Question_Form_Input $QFI)
554
-    {
555
-        if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
556
-            return '';
557
-        }
558
-        /** @var RequestInterface $request */
559
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
560
-
561
-        $QFI = self::_load_system_dropdowns($QFI);
562
-        $QFI = self::_load_specialized_dropdowns($QFI);
563
-
564
-        // we also need to verify
565
-
566
-        $display_text = $QFI->get('QST_display_text');
567
-        $input_name = $QFI->get('QST_input_name');
568
-        $answer = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
569
-        $input_id = $QFI->get('QST_input_id');
570
-        $input_class = $QFI->get('QST_input_class');
479
+			// loop thru question groups
480
+			foreach ($question_groups as $QSG) {
481
+				if ($QSG instanceof EE_Question_Group) {
482
+					// check that questions exist
483
+
484
+					$where = array( 'QST_deleted' => 0 );
485
+					if (! $from_admin) {
486
+						$where['QST_admin_only'] = 0;
487
+					}
488
+					$questions = $QSG->questions(array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' )));
489
+					if (! empty($questions)) {
490
+						// use fieldsets
491
+						$html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get('QSG_identifier') . '">';
492
+						// group_name
493
+						if ($QSG->show_group_name()) {
494
+							$html .=  "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty('QSG_name') . '</h5>';
495
+						}
496
+						// group_desc
497
+						if ($QSG->show_group_desc()) {
498
+							$html .=  '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty('QSG_desc') . '</div>';
499
+						}
500
+
501
+						$html .= $before_question_group_questions;
502
+						// loop thru questions
503
+						foreach ($questions as $QST) {
504
+							$qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID();
505
+
506
+							$answer = null;
507
+
508
+							if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
509
+								// check for answer in $_GET in case we are reprocessing a form after an error
510
+								if (isset($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ])) {
511
+									$answer = is_array($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ]) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ]);
512
+								}
513
+							} elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
514
+								// attendee data from the session
515
+								$answer = isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
516
+							}
517
+
518
+
519
+
520
+							$QFI = new EE_Question_Form_Input(
521
+								$QST,
522
+								EE_Answer::new_instance(array(
523
+											'ANS_ID'=> 0,
524
+											'QST_ID'=> 0,
525
+											'REG_ID'=> 0,
526
+											'ANS_value'=> $answer
527
+									)),
528
+								$q_meta
529
+							);
530
+							// EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
531
+							$html .= self::generate_form_input($QFI);
532
+						}
533
+						$html .= $after_question_group_questions;
534
+						$html .= "\n\t" . '</' . $group_wrapper . '>';
535
+					}
536
+				}
537
+			}
538
+		}
539
+		return $html;
540
+	}
541
+
542
+
543
+
544
+
545
+
546
+
547
+	/**
548
+	 * generate_form_input
549
+	 *
550
+	 * @param EE_Question_Form_Input $QFI
551
+	 * @return string HTML
552
+	 */
553
+	public static function generate_form_input(EE_Question_Form_Input $QFI)
554
+	{
555
+		if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) {
556
+			return '';
557
+		}
558
+		/** @var RequestInterface $request */
559
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
560
+
561
+		$QFI = self::_load_system_dropdowns($QFI);
562
+		$QFI = self::_load_specialized_dropdowns($QFI);
563
+
564
+		// we also need to verify
565
+
566
+		$display_text = $QFI->get('QST_display_text');
567
+		$input_name = $QFI->get('QST_input_name');
568
+		$answer = $request->getRequestParam($input_name, $QFI->get('ANS_value'));
569
+		$input_id = $QFI->get('QST_input_id');
570
+		$input_class = $QFI->get('QST_input_class');
571 571
 //      $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : '';
572
-        $disabled = $QFI->get('QST_disabled');
573
-        $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
574
-        $QST_required = $QFI->get('QST_required');
575
-        $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array();
576
-        $use_html_entities = $QFI->get_meta('htmlentities');
577
-        $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso');
578
-        $required_text = $QST_required
579
-            ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer($required_text, $use_html_entities) . '</div>'
580
-            : '';
581
-        $label_class = 'espresso-form-input-lbl';
582
-        $QST_options = $QFI->options(true, $answer);
583
-        $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array();
584
-        $system_ID = $QFI->get('QST_system');
585
-        $label_b4 = $QFI->get_meta('label_b4');
586
-        $use_desc_4_label = $QFI->get_meta('use_desc_4_label');
587
-
588
-
589
-        switch ($QFI->get('QST_type')) {
590
-            case 'TEXTAREA':
591
-                return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities);
592
-                break;
593
-
594
-            case 'DROPDOWN':
595
-                return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, true);
596
-                break;
597
-
598
-
599
-            case 'RADIO_BTN':
600
-                return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label);
601
-                break;
602
-
603
-            case 'CHECKBOX':
604
-                return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities);
605
-                break;
606
-
607
-            case 'DATE':
608
-                return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities);
609
-                break;
610
-
611
-            case 'TEXT':
612
-            default:
613
-                return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities);
614
-                break;
615
-        }
616
-    }
617
-
618
-
619
-
620
-
621
-
622
-
623
-    /**
624
-     * generates HTML for a form text input
625
-     *
626
-     * @param string $question  label content
627
-     * @param string $answer        form input value attribute
628
-     * @param string $name          form input name attribute
629
-     * @param string $id                form input css id attribute
630
-     * @param string $class             form input css class attribute
631
-     * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
632
-     * @param string $label_class   css class attribute for the label
633
-     * @param string $disabled      disabled="disabled" or null
634
-     * @return string HTML
635
-     */
636
-    public static function text($question = false, $answer = null, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
637
-    {
638
-        // need these
639
-        if (! $question || ! $name) {
640
-            return null;
641
-        }
642
-        // prep the answer
643
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
644
-        // prep the required array
645
-        $required = self::prep_required($required);
646
-        // set disabled tag
647
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
648
-        // ya gots ta have style man!!!
649
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
650
-        $class = empty($class) ? $txt_class : $class;
651
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
652
-        $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
653
-
654
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
655
-        // filter label but ensure required text comes before it
656
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
657
-
658
-        $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  title="' . esc_attr($required['msg']) . '" ' . $disabled .' ' . $extra . '/>';
659
-
660
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
661
-        return  $label_html . $input_html;
662
-    }
663
-
664
-
665
-
666
-
667
-
668
-    /**
669
-     * generates HTML for a form textarea
670
-     *
671
-     * @param string $question      label content
672
-     * @param string $answer        form input value attribute
673
-     * @param string $name          form input name attribute
674
-     * @param string $id                form input css id attribute
675
-     * @param string $class             form input css class attribute
676
-     * @param array $dimensions array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
677
-     * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
678
-     * @param string $label_class   css class attribute for the label
679
-     * @param string $disabled      disabled="disabled" or null
680
-     * @return string HTML
681
-     */
682
-    public static function textarea($question = false, $answer = null, $name = false, $id = '', $class = '', $dimensions = false, $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
683
-    {
684
-        // need these
685
-        if (! $question || ! $name) {
686
-            return null;
687
-        }
688
-        // prep the answer
689
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
690
-        // prep the required array
691
-        $required = self::prep_required($required);
692
-        // make sure $dimensions is an array
693
-        $dimensions = is_array($dimensions) ? $dimensions : array();
694
-        // and set some defaults
695
-        $dimensions = array_merge(array( 'rows' => 3, 'cols' => 40 ), $dimensions);
696
-        // set disabled tag
697
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
698
-        // ya gots ta have style man!!!
699
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
700
-        $class = empty($class) ? $txt_class : $class;
701
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
702
-        $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
703
-
704
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
705
-        // filter label but ensure required text comes before it
706
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
707
-
708
-        $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>';
709
-
710
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
711
-        return  $label_html . $input_html;
712
-    }
713
-
714
-
715
-
716
-
717
-
718
-
719
-    /**
720
-     * generates HTML for a form select input
721
-     *
722
-     * @param string $question      label content
723
-     * @param string $answer        form input value attribute
724
-     * @param array $options            array of answer options where array key = option value and array value = option display text
725
-     * @param string $name          form input name attribute
726
-     * @param string $id                form input css id attribute
727
-     * @param string $class             form input css class attribute
728
-     * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
729
-     * @param string $label_class   css class attribute for the label
730
-     * @param string $disabled      disabled="disabled" or null
731
-     * @return string HTML
732
-     */
733
-    public static function select($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true, $add_please_select_option = false)
734
-    {
735
-
736
-        // need these
737
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
738
-            return null;
739
-        }
740
-        // prep the answer
741
-        $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities);
742
-        // prep the required array
743
-        $required = self::prep_required($required);
744
-        // set disabled tag
745
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
746
-        // ya gots ta have style man!!!
747
-        $txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
748
-        $class = empty($class) ? $txt_class : $class;
749
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
750
-        $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
751
-
752
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
753
-        // filter label but ensure required text comes before it
754
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
755
-
756
-        $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
757
-        // recursively count array elements, to determine total number of options
758
-        $only_option = count($options, 1) == 1 ? true : false;
759
-        if (! $only_option) {
760
-            // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
761
-            $selected = $answer === null ? ' selected="selected"' : '';
762
-            $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : '';
763
-        }
764
-        foreach ($options as $key => $value) {
765
-            // if value is an array, then create option groups, else create regular ol' options
766
-            $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities);
767
-        }
768
-
769
-        $input_html .= "\n\t\t\t" . '</select>';
770
-
771
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID);
772
-
773
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
774
-        return  $label_html . $input_html;
775
-    }
776
-
777
-
778
-
779
-    /**
780
-     *  _generate_select_option_group
781
-     *
782
-     *  if  $value for a select box is an array, then the key will be used as the optgroup label
783
-     *  and the value array will be looped thru and the elements sent to _generate_select_option
784
-     *
785
-     * @param mixed $opt_group
786
-     * @param mixed $QSOs
787
-     * @param mixed $answer
788
-     * @param boolean $use_html_entities
789
-     * @return string
790
-     */
791
-    private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
792
-    {
793
-        $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
794
-        foreach ($QSOs as $QSO) {
795
-            $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
796
-        }
797
-        $html .= "\n\t\t\t\t" . '</optgroup>';
798
-        return $html;
799
-    }
800
-
801
-
802
-
803
-    /**
804
-     *  _generate_select_option
805
-     * @param mixed $key
806
-     * @param mixed $value
807
-     * @param mixed $answer
808
-     * @param int $only_option
809
-     * @param boolean $use_html_entities
810
-     * @return string
811
-     */
812
-    private static function _generate_select_option($key, $value, $answer, $only_option = false, $use_html_entities = true)
813
-    {
814
-        $key = self::prep_answer($key, $use_html_entities);
815
-        $value = self::prep_answer($value, $use_html_entities);
816
-        $value = ! empty($value) ? $value : $key;
817
-        $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : '';
818
-        return "\n\t\t\t\t" . '<option value="' . self::prep_option_value($key) . '"' . $selected . '> ' . $value . '&nbsp;&nbsp;&nbsp;</option>';
819
-    }
820
-
821
-
822
-
823
-    /**
824
-     * generates HTML for form radio button inputs
825
-     *
826
-     * @param bool|string $question    label content
827
-     * @param string      $answer      form input value attribute
828
-     * @param array|bool  $options     array of answer options where array key = option value and array value = option display text
829
-     * @param bool|string $name        form input name attribute
830
-     * @param string      $id          form input css id attribute
831
-     * @param string      $class       form input css class attribute
832
-     * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
833
-     * @param string      $required_text
834
-     * @param string      $label_class css class attribute for the label
835
-     * @param bool|string $disabled    disabled="disabled" or null
836
-     * @param bool        $system_ID
837
-     * @param bool        $use_html_entities
838
-     * @param bool        $label_b4
839
-     * @param bool        $use_desc_4_label
840
-     * @return string HTML
841
-     */
842
-    public static function radio($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true, $label_b4 = false, $use_desc_4_label = false)
843
-    {
844
-        // need these
845
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
846
-            return null;
847
-        }
848
-        // prep the answer
849
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
850
-        // prep the required array
851
-        $required = self::prep_required($required);
852
-        // set disabled tag
853
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
854
-        // ya gots ta have style man!!!
855
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
856
-        $class = ! empty($class) ? $class : 'espresso-radio-btn-inp';
857
-        $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
858
-
859
-        $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label> ';
860
-        // filter label but ensure required text comes before it
861
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
862
-
863
-        $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
864
-
865
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
866
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
867
-
868
-        foreach ($options as $OPT) {
869
-            if ($OPT instanceof EE_Question_Option) {
870
-                $value = self::prep_option_value($OPT->value());
871
-                $label = $use_desc_4_label ? $OPT->desc() : $OPT->value();
872
-                $size = $use_desc_4_label ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc()) : self::get_label_size_class($OPT->value());
873
-                $desc = $OPT->desc();// no self::prep_answer
874
-                $answer = is_numeric($value) && empty($answer) ? 0 : $answer;
875
-                $checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
876
-                $opt = '-' . sanitize_key($value);
877
-
878
-                $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
879
-                $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
880
-                $input_html .= $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
881
-                $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
882
-                $input_html .= ! $label_b4  ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : '';
883
-                $input_html .= "\n\t\t\t\t\t" . '</label>';
884
-                $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
885
-                $input_html .= "\n\t\t\t\t" . '</li>';
886
-            }
887
-        }
888
-
889
-        $input_html .= "\n\t\t\t" . '</ul>';
890
-
891
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
892
-        return  $label_html . $input_html;
893
-    }
894
-
895
-
896
-
897
-
898
-
899
-
900
-    /**
901
-     * generates HTML for form checkbox inputs
902
-     *
903
-     * @param string $question      label content
904
-     * @param string $answer        form input value attribute
905
-     * @param array $options            array of options where array key = option value and array value = option display text
906
-     * @param string $name          form input name attribute
907
-     * @param string $id                form input css id attribute
908
-     * @param string $class             form input css class attribute
909
-     * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
910
-     * @param string $label_class   css class attribute for the label
911
-     * @param string $disabled      disabled="disabled" or null
912
-     * @return string HTML
913
-     */
914
-    public static function checkbox($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $label_b4 = false, $system_ID = false, $use_html_entities = true)
915
-    {
916
-        // need these
917
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
918
-            return null;
919
-        }
920
-        $answer = maybe_unserialize($answer);
921
-
922
-        // prep the answer(s)
923
-        $answer = is_array($answer) ? $answer : array( sanitize_key($answer) => $answer );
924
-
925
-        foreach ($answer as $key => $value) {
926
-            $key = self::prep_option_value($key);
927
-            $answer[ $key ] = self::prep_answer($value, $use_html_entities);
928
-        }
929
-
930
-        // prep the required array
931
-        $required = self::prep_required($required);
932
-        // set disabled tag
933
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
934
-        // ya gots ta have style man!!!
935
-        $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
936
-        $class = empty($class) ? 'espresso-radio-btn-inp' : $class;
937
-        $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
938
-
939
-        $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label> ';
940
-        // filter label but ensure required text comes before it
941
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
942
-
943
-        $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
944
-
945
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
946
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
947
-
948
-        foreach ($options as $OPT) {
949
-            $value = $OPT->value();// self::prep_option_value( $OPT->value() );
950
-            $size = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
951
-            $text = self::prep_answer($OPT->value());
952
-            $desc = $OPT->desc() ;
953
-            $opt = '-' . sanitize_key($value);
954
-
955
-            $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
956
-
957
-            $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
958
-            $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
959
-            $input_html .= $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
960
-            $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
961
-            $input_html .= ! $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
962
-            $input_html .= "\n\t\t\t\t\t" . '</label>';
963
-            if (! empty($desc) && $desc != $text) {
964
-                $input_html .= "\n\t\t\t\t\t" . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>';
965
-            }
966
-            $input_html .= "\n\t\t\t\t" . '</li>';
967
-        }
968
-
969
-        $input_html .= "\n\t\t\t" . '</ul>';
970
-
971
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
972
-        return  $label_html . $input_html;
973
-    }
974
-
975
-
976
-
977
-
978
-
979
-
980
-    /**
981
-     * generates HTML for a form datepicker input
982
-     *
983
-     * @param string $question  label content
984
-     * @param string $answer        form input value attribute
985
-     * @param string $name          form input name attribute
986
-     * @param string $id                form input css id attribute
987
-     * @param string $class             form input css class attribute
988
-     * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
989
-     * @param string $label_class   css class attribute for the label
990
-     * @param string $disabled      disabled="disabled" or null
991
-     * @return string HTML
992
-     */
993
-    public static function datepicker($question = false, $answer = null, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
994
-    {
995
-        // need these
996
-        if (! $question || ! $name) {
997
-            return null;
998
-        }
999
-        // prep the answer
1000
-        $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1001
-        // prep the required array
1002
-        $required = self::prep_required($required);
1003
-        // set disabled tag
1004
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
1005
-        // ya gots ta have style man!!!
1006
-        $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1007
-        $class = empty($class) ? $txt_class : $class;
1008
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1009
-        $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1010
-
1011
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
1012
-        // filter label but ensure required text comes before it
1013
-        $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1014
-
1015
-        $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1016
-
1017
-        // enqueue scripts
1018
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1019
-        wp_enqueue_style('espresso-ui-theme');
1020
-        wp_enqueue_script('jquery-ui-datepicker');
1021
-
1022
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1023
-        return  $label_html . $input_html;
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *  remove_label_keep_required_msg
1030
-     *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1031
-     *  @access public
1032
-     *  @return     string
1033
-     */
1034
-    public static function remove_label_keep_required_msg($label_html, $required_text)
1035
-    {
1036
-        return $required_text;
1037
-    }
1038
-
1039
-
1040
-
1041
-
1042
-
1043
-    /**
1044
-     * Simply return sthe HTML for a hidden input of the given name and value.
1045
-     * @param string $name
1046
-     * @param string $value
1047
-     * @return string HTML
1048
-     */
1049
-    public static function hidden_input($name, $value, $id = '')
1050
-    {
1051
-        $id = ! empty($id) ? $id : $name;
1052
-        return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' .  $value . '"/>';
1053
-    }
1054
-
1055
-
1056
-
1057
-
1058
-
1059
-    /**
1060
-     * prep_question
1061
-     * @param string $question
1062
-     * @return string
1063
-     */
1064
-    public static function prep_question($question)
1065
-    {
1066
-        return $question;
572
+		$disabled = $QFI->get('QST_disabled');
573
+		$required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
574
+		$QST_required = $QFI->get('QST_required');
575
+		$required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array();
576
+		$use_html_entities = $QFI->get_meta('htmlentities');
577
+		$required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso');
578
+		$required_text = $QST_required
579
+			? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer($required_text, $use_html_entities) . '</div>'
580
+			: '';
581
+		$label_class = 'espresso-form-input-lbl';
582
+		$QST_options = $QFI->options(true, $answer);
583
+		$options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array();
584
+		$system_ID = $QFI->get('QST_system');
585
+		$label_b4 = $QFI->get_meta('label_b4');
586
+		$use_desc_4_label = $QFI->get_meta('use_desc_4_label');
587
+
588
+
589
+		switch ($QFI->get('QST_type')) {
590
+			case 'TEXTAREA':
591
+				return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities);
592
+				break;
593
+
594
+			case 'DROPDOWN':
595
+				return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, true);
596
+				break;
597
+
598
+
599
+			case 'RADIO_BTN':
600
+				return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label);
601
+				break;
602
+
603
+			case 'CHECKBOX':
604
+				return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities);
605
+				break;
606
+
607
+			case 'DATE':
608
+				return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities);
609
+				break;
610
+
611
+			case 'TEXT':
612
+			default:
613
+				return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities);
614
+				break;
615
+		}
616
+	}
617
+
618
+
619
+
620
+
621
+
622
+
623
+	/**
624
+	 * generates HTML for a form text input
625
+	 *
626
+	 * @param string $question  label content
627
+	 * @param string $answer        form input value attribute
628
+	 * @param string $name          form input name attribute
629
+	 * @param string $id                form input css id attribute
630
+	 * @param string $class             form input css class attribute
631
+	 * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
632
+	 * @param string $label_class   css class attribute for the label
633
+	 * @param string $disabled      disabled="disabled" or null
634
+	 * @return string HTML
635
+	 */
636
+	public static function text($question = false, $answer = null, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
637
+	{
638
+		// need these
639
+		if (! $question || ! $name) {
640
+			return null;
641
+		}
642
+		// prep the answer
643
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
644
+		// prep the required array
645
+		$required = self::prep_required($required);
646
+		// set disabled tag
647
+		$disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
648
+		// ya gots ta have style man!!!
649
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
650
+		$class = empty($class) ? $txt_class : $class;
651
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
652
+		$extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
653
+
654
+		$label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
655
+		// filter label but ensure required text comes before it
656
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
657
+
658
+		$input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  title="' . esc_attr($required['msg']) . '" ' . $disabled .' ' . $extra . '/>';
659
+
660
+		$input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
661
+		return  $label_html . $input_html;
662
+	}
663
+
664
+
665
+
666
+
667
+
668
+	/**
669
+	 * generates HTML for a form textarea
670
+	 *
671
+	 * @param string $question      label content
672
+	 * @param string $answer        form input value attribute
673
+	 * @param string $name          form input name attribute
674
+	 * @param string $id                form input css id attribute
675
+	 * @param string $class             form input css class attribute
676
+	 * @param array $dimensions array of form input rows and cols attributes : array( 'rows' => 3, 'cols' => 40 )
677
+	 * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
678
+	 * @param string $label_class   css class attribute for the label
679
+	 * @param string $disabled      disabled="disabled" or null
680
+	 * @return string HTML
681
+	 */
682
+	public static function textarea($question = false, $answer = null, $name = false, $id = '', $class = '', $dimensions = false, $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
683
+	{
684
+		// need these
685
+		if (! $question || ! $name) {
686
+			return null;
687
+		}
688
+		// prep the answer
689
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
690
+		// prep the required array
691
+		$required = self::prep_required($required);
692
+		// make sure $dimensions is an array
693
+		$dimensions = is_array($dimensions) ? $dimensions : array();
694
+		// and set some defaults
695
+		$dimensions = array_merge(array( 'rows' => 3, 'cols' => 40 ), $dimensions);
696
+		// set disabled tag
697
+		$disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
698
+		// ya gots ta have style man!!!
699
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
700
+		$class = empty($class) ? $txt_class : $class;
701
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
702
+		$extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
703
+
704
+		$label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
705
+		// filter label but ensure required text comes before it
706
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
707
+
708
+		$input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>';
709
+
710
+		$input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
711
+		return  $label_html . $input_html;
712
+	}
713
+
714
+
715
+
716
+
717
+
718
+
719
+	/**
720
+	 * generates HTML for a form select input
721
+	 *
722
+	 * @param string $question      label content
723
+	 * @param string $answer        form input value attribute
724
+	 * @param array $options            array of answer options where array key = option value and array value = option display text
725
+	 * @param string $name          form input name attribute
726
+	 * @param string $id                form input css id attribute
727
+	 * @param string $class             form input css class attribute
728
+	 * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
729
+	 * @param string $label_class   css class attribute for the label
730
+	 * @param string $disabled      disabled="disabled" or null
731
+	 * @return string HTML
732
+	 */
733
+	public static function select($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true, $add_please_select_option = false)
734
+	{
735
+
736
+		// need these
737
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
738
+			return null;
739
+		}
740
+		// prep the answer
741
+		$answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities);
742
+		// prep the required array
743
+		$required = self::prep_required($required);
744
+		// set disabled tag
745
+		$disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
746
+		// ya gots ta have style man!!!
747
+		$txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
748
+		$class = empty($class) ? $txt_class : $class;
749
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
750
+		$extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
751
+
752
+		$label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
753
+		// filter label but ensure required text comes before it
754
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
755
+
756
+		$input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
757
+		// recursively count array elements, to determine total number of options
758
+		$only_option = count($options, 1) == 1 ? true : false;
759
+		if (! $only_option) {
760
+			// if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
761
+			$selected = $answer === null ? ' selected="selected"' : '';
762
+			$input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : '';
763
+		}
764
+		foreach ($options as $key => $value) {
765
+			// if value is an array, then create option groups, else create regular ol' options
766
+			$input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities);
767
+		}
768
+
769
+		$input_html .= "\n\t\t\t" . '</select>';
770
+
771
+		$input_html =  apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID);
772
+
773
+		$input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
774
+		return  $label_html . $input_html;
775
+	}
776
+
777
+
778
+
779
+	/**
780
+	 *  _generate_select_option_group
781
+	 *
782
+	 *  if  $value for a select box is an array, then the key will be used as the optgroup label
783
+	 *  and the value array will be looped thru and the elements sent to _generate_select_option
784
+	 *
785
+	 * @param mixed $opt_group
786
+	 * @param mixed $QSOs
787
+	 * @param mixed $answer
788
+	 * @param boolean $use_html_entities
789
+	 * @return string
790
+	 */
791
+	private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
792
+	{
793
+		$html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
794
+		foreach ($QSOs as $QSO) {
795
+			$html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
796
+		}
797
+		$html .= "\n\t\t\t\t" . '</optgroup>';
798
+		return $html;
799
+	}
800
+
801
+
802
+
803
+	/**
804
+	 *  _generate_select_option
805
+	 * @param mixed $key
806
+	 * @param mixed $value
807
+	 * @param mixed $answer
808
+	 * @param int $only_option
809
+	 * @param boolean $use_html_entities
810
+	 * @return string
811
+	 */
812
+	private static function _generate_select_option($key, $value, $answer, $only_option = false, $use_html_entities = true)
813
+	{
814
+		$key = self::prep_answer($key, $use_html_entities);
815
+		$value = self::prep_answer($value, $use_html_entities);
816
+		$value = ! empty($value) ? $value : $key;
817
+		$selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : '';
818
+		return "\n\t\t\t\t" . '<option value="' . self::prep_option_value($key) . '"' . $selected . '> ' . $value . '&nbsp;&nbsp;&nbsp;</option>';
819
+	}
820
+
821
+
822
+
823
+	/**
824
+	 * generates HTML for form radio button inputs
825
+	 *
826
+	 * @param bool|string $question    label content
827
+	 * @param string      $answer      form input value attribute
828
+	 * @param array|bool  $options     array of answer options where array key = option value and array value = option display text
829
+	 * @param bool|string $name        form input name attribute
830
+	 * @param string      $id          form input css id attribute
831
+	 * @param string      $class       form input css class attribute
832
+	 * @param array|bool  $required    'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
833
+	 * @param string      $required_text
834
+	 * @param string      $label_class css class attribute for the label
835
+	 * @param bool|string $disabled    disabled="disabled" or null
836
+	 * @param bool        $system_ID
837
+	 * @param bool        $use_html_entities
838
+	 * @param bool        $label_b4
839
+	 * @param bool        $use_desc_4_label
840
+	 * @return string HTML
841
+	 */
842
+	public static function radio($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true, $label_b4 = false, $use_desc_4_label = false)
843
+	{
844
+		// need these
845
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
846
+			return null;
847
+		}
848
+		// prep the answer
849
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
850
+		// prep the required array
851
+		$required = self::prep_required($required);
852
+		// set disabled tag
853
+		$disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
854
+		// ya gots ta have style man!!!
855
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
856
+		$class = ! empty($class) ? $class : 'espresso-radio-btn-inp';
857
+		$extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
858
+
859
+		$label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label> ';
860
+		// filter label but ensure required text comes before it
861
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
862
+
863
+		$input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
864
+
865
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
866
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
867
+
868
+		foreach ($options as $OPT) {
869
+			if ($OPT instanceof EE_Question_Option) {
870
+				$value = self::prep_option_value($OPT->value());
871
+				$label = $use_desc_4_label ? $OPT->desc() : $OPT->value();
872
+				$size = $use_desc_4_label ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc()) : self::get_label_size_class($OPT->value());
873
+				$desc = $OPT->desc();// no self::prep_answer
874
+				$answer = is_numeric($value) && empty($answer) ? 0 : $answer;
875
+				$checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
876
+				$opt = '-' . sanitize_key($value);
877
+
878
+				$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
879
+				$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
880
+				$input_html .= $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
881
+				$input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
882
+				$input_html .= ! $label_b4  ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : '';
883
+				$input_html .= "\n\t\t\t\t\t" . '</label>';
884
+				$input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
885
+				$input_html .= "\n\t\t\t\t" . '</li>';
886
+			}
887
+		}
888
+
889
+		$input_html .= "\n\t\t\t" . '</ul>';
890
+
891
+		$input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
892
+		return  $label_html . $input_html;
893
+	}
894
+
895
+
896
+
897
+
898
+
899
+
900
+	/**
901
+	 * generates HTML for form checkbox inputs
902
+	 *
903
+	 * @param string $question      label content
904
+	 * @param string $answer        form input value attribute
905
+	 * @param array $options            array of options where array key = option value and array value = option display text
906
+	 * @param string $name          form input name attribute
907
+	 * @param string $id                form input css id attribute
908
+	 * @param string $class             form input css class attribute
909
+	 * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
910
+	 * @param string $label_class   css class attribute for the label
911
+	 * @param string $disabled      disabled="disabled" or null
912
+	 * @return string HTML
913
+	 */
914
+	public static function checkbox($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $label_b4 = false, $system_ID = false, $use_html_entities = true)
915
+	{
916
+		// need these
917
+		if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
918
+			return null;
919
+		}
920
+		$answer = maybe_unserialize($answer);
921
+
922
+		// prep the answer(s)
923
+		$answer = is_array($answer) ? $answer : array( sanitize_key($answer) => $answer );
924
+
925
+		foreach ($answer as $key => $value) {
926
+			$key = self::prep_option_value($key);
927
+			$answer[ $key ] = self::prep_answer($value, $use_html_entities);
928
+		}
929
+
930
+		// prep the required array
931
+		$required = self::prep_required($required);
932
+		// set disabled tag
933
+		$disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
934
+		// ya gots ta have style man!!!
935
+		$radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
936
+		$class = empty($class) ? 'espresso-radio-btn-inp' : $class;
937
+		$extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
938
+
939
+		$label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label> ';
940
+		// filter label but ensure required text comes before it
941
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
942
+
943
+		$input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
944
+
945
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
946
+		$class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
947
+
948
+		foreach ($options as $OPT) {
949
+			$value = $OPT->value();// self::prep_option_value( $OPT->value() );
950
+			$size = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
951
+			$text = self::prep_answer($OPT->value());
952
+			$desc = $OPT->desc() ;
953
+			$opt = '-' . sanitize_key($value);
954
+
955
+			$checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
956
+
957
+			$input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
958
+			$input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
959
+			$input_html .= $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
960
+			$input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
961
+			$input_html .= ! $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
962
+			$input_html .= "\n\t\t\t\t\t" . '</label>';
963
+			if (! empty($desc) && $desc != $text) {
964
+				$input_html .= "\n\t\t\t\t\t" . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>';
965
+			}
966
+			$input_html .= "\n\t\t\t\t" . '</li>';
967
+		}
968
+
969
+		$input_html .= "\n\t\t\t" . '</ul>';
970
+
971
+		$input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
972
+		return  $label_html . $input_html;
973
+	}
974
+
975
+
976
+
977
+
978
+
979
+
980
+	/**
981
+	 * generates HTML for a form datepicker input
982
+	 *
983
+	 * @param string $question  label content
984
+	 * @param string $answer        form input value attribute
985
+	 * @param string $name          form input name attribute
986
+	 * @param string $id                form input css id attribute
987
+	 * @param string $class             form input css class attribute
988
+	 * @param array $required       'label', 'class', and 'msg' - array of values for required "label" content, css required 'class', and required 'msg' attribute
989
+	 * @param string $label_class   css class attribute for the label
990
+	 * @param string $disabled      disabled="disabled" or null
991
+	 * @return string HTML
992
+	 */
993
+	public static function datepicker($question = false, $answer = null, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
994
+	{
995
+		// need these
996
+		if (! $question || ! $name) {
997
+			return null;
998
+		}
999
+		// prep the answer
1000
+		$answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities);
1001
+		// prep the required array
1002
+		$required = self::prep_required($required);
1003
+		// set disabled tag
1004
+		$disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
1005
+		// ya gots ta have style man!!!
1006
+		$txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1007
+		$class = empty($class) ? $txt_class : $class;
1008
+		$class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1009
+		$extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1010
+
1011
+		$label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
1012
+		// filter label but ensure required text comes before it
1013
+		$label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1014
+
1015
+		$input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1016
+
1017
+		// enqueue scripts
1018
+		wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1019
+		wp_enqueue_style('espresso-ui-theme');
1020
+		wp_enqueue_script('jquery-ui-datepicker');
1021
+
1022
+		$input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1023
+		return  $label_html . $input_html;
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *  remove_label_keep_required_msg
1030
+	 *  this will strip out a form input's label HTML while keeping the required text HTML that MUST be before the label
1031
+	 *  @access public
1032
+	 *  @return     string
1033
+	 */
1034
+	public static function remove_label_keep_required_msg($label_html, $required_text)
1035
+	{
1036
+		return $required_text;
1037
+	}
1038
+
1039
+
1040
+
1041
+
1042
+
1043
+	/**
1044
+	 * Simply return sthe HTML for a hidden input of the given name and value.
1045
+	 * @param string $name
1046
+	 * @param string $value
1047
+	 * @return string HTML
1048
+	 */
1049
+	public static function hidden_input($name, $value, $id = '')
1050
+	{
1051
+		$id = ! empty($id) ? $id : $name;
1052
+		return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' .  $value . '"/>';
1053
+	}
1054
+
1055
+
1056
+
1057
+
1058
+
1059
+	/**
1060
+	 * prep_question
1061
+	 * @param string $question
1062
+	 * @return string
1063
+	 */
1064
+	public static function prep_question($question)
1065
+	{
1066
+		return $question;
1067 1067
 //      $link = '';
1068 1068
 //      // does this label have a help link attached ?
1069 1069
 //      if ( strpos( $question, '<a ' ) !== FALSE ) {
@@ -1075,447 +1075,447 @@  discard block
 block discarded – undo
1075 1075
 //          $link = '<a ' . $link;
1076 1076
 //      }
1077 1077
 //      return htmlspecialchars( trim( stripslashes( str_replace( '&#039;', "'", $question ))), ENT_QUOTES, 'UTF-8' ) . ' ' . $link;
1078
-    }
1079
-
1080
-
1081
-
1082
-
1083
-    /**
1084
-     *  prep_answer
1085
-     * @param mixed $answer
1086
-     * @return string
1087
-     */
1088
-    public static function prep_answer($answer, $use_html_entities = true)
1089
-    {
1090
-        // make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired, we want "0".
1091
-        if (is_bool($answer)) {
1092
-            $answer = $answer ? 1 : 0;
1093
-        }
1094
-        $answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1095
-        return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1096
-    }
1097
-
1098
-
1099
-
1100
-    /**
1101
-     *  prep_answer_options
1102
-     *  @param array $QSOs  array of EE_Question_Option objects
1103
-     *  @return array
1104
-     */
1105
-    public static function prep_answer_options($QSOs = array())
1106
-    {
1107
-        $prepped_answer_options = array();
1108
-        if (is_array($QSOs) && ! empty($QSOs)) {
1109
-            foreach ($QSOs as $key => $QSO) {
1110
-                if (! $QSO instanceof EE_Question_Option) {
1111
-                    $QSO = EE_Question_Option::new_instance(array(
1112
-                        'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key,
1113
-                        'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO
1114
-                    ));
1115
-                }
1116
-                if ($QSO->opt_group()) {
1117
-                    $prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1118
-                } else {
1119
-                    $prepped_answer_options[] = $QSO;
1120
-                }
1121
-            }
1122
-        }
1078
+	}
1079
+
1080
+
1081
+
1082
+
1083
+	/**
1084
+	 *  prep_answer
1085
+	 * @param mixed $answer
1086
+	 * @return string
1087
+	 */
1088
+	public static function prep_answer($answer, $use_html_entities = true)
1089
+	{
1090
+		// make sure we convert bools first.  Otherwise (bool) false becomes an empty string which is NOT desired, we want "0".
1091
+		if (is_bool($answer)) {
1092
+			$answer = $answer ? 1 : 0;
1093
+		}
1094
+		$answer = trim(stripslashes(str_replace('&#039;', "'", $answer)));
1095
+		return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer;
1096
+	}
1097
+
1098
+
1099
+
1100
+	/**
1101
+	 *  prep_answer_options
1102
+	 *  @param array $QSOs  array of EE_Question_Option objects
1103
+	 *  @return array
1104
+	 */
1105
+	public static function prep_answer_options($QSOs = array())
1106
+	{
1107
+		$prepped_answer_options = array();
1108
+		if (is_array($QSOs) && ! empty($QSOs)) {
1109
+			foreach ($QSOs as $key => $QSO) {
1110
+				if (! $QSO instanceof EE_Question_Option) {
1111
+					$QSO = EE_Question_Option::new_instance(array(
1112
+						'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key,
1113
+						'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO
1114
+					));
1115
+				}
1116
+				if ($QSO->opt_group()) {
1117
+					$prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1118
+				} else {
1119
+					$prepped_answer_options[] = $QSO;
1120
+				}
1121
+			}
1122
+		}
1123 1123
 //      d( $prepped_answer_options );
1124
-        return $prepped_answer_options;
1125
-    }
1126
-
1127
-
1128
-    /**
1129
-     *  prep_option_value
1130
-     * @param string $option_value
1131
-     * @return string
1132
-     */
1133
-    public static function prep_option_value($option_value)
1134
-    {
1135
-        return esc_attr(trim(stripslashes($option_value)));
1136
-    }
1137
-
1138
-
1139
-
1140
-
1141
-    /**
1142
-     *  prep_required
1143
-     * @param string|array  $required
1144
-     * @return array
1145
-     */
1146
-    public static function prep_required($required = array())
1147
-    {
1148
-        // make sure required is an array
1149
-        $required = is_array($required) ? $required : array();
1150
-        // and set some defaults
1151
-        $required = array_merge(array( 'label' => '', 'class' => '', 'msg' => '' ), $required);
1152
-        return $required;
1153
-    }
1154
-
1155
-
1156
-
1157
-    /**
1158
-     *  get_label_size_class
1159
-     * @param string    $value
1160
-     * @return string
1161
-     */
1162
-    public static function get_label_size_class($value = false)
1163
-    {
1164
-        if ($value === false || $value == '') {
1165
-            return ' class="medium-lbl"';
1166
-        }
1167
-            // determine length of option value
1168
-            $val_size = strlen($value);
1169
-        switch ($val_size) {
1170
-            case $val_size < 3:
1171
-                $size =  ' class="nano-lbl"';
1172
-                break;
1173
-            case $val_size < 6:
1174
-                $size =  ' class="micro-lbl"';
1175
-                break;
1176
-            case $val_size < 12:
1177
-                $size =  ' class="tiny-lbl"';
1178
-                break;
1179
-            case $val_size < 25:
1180
-                $size =  ' class="small-lbl"';
1181
-                break;
1182
-            case $val_size > 100:
1183
-                $size =  ' class="big-lbl"';
1184
-                break;
1185
-            default:
1186
-                $size =  ' class="medium-lbl"';
1187
-                break;
1188
-        }
1189
-        return $size;
1190
-    }
1191
-
1192
-
1193
-
1194
-
1195
-    /**
1196
-     *  _load_system_dropdowns
1197
-     * @param array     $QFI
1198
-     * @return array
1199
-     */
1200
-    private static function _load_system_dropdowns($QFI)
1201
-    {
1202
-        $QST_system = $QFI->get('QST_system');
1203
-        switch ($QST_system) {
1204
-            case 'state':
1205
-                $QFI = self::generate_state_dropdown($QFI);
1206
-                break;
1207
-            case 'country':
1208
-                $QFI = self::generate_country_dropdown($QFI);
1209
-                break;
1210
-            case 'admin-state':
1211
-                $QFI = self::generate_state_dropdown($QFI, true);
1212
-                break;
1213
-            case 'admin-country':
1214
-                $QFI = self::generate_country_dropdown($QFI, true);
1215
-                break;
1216
-        }
1217
-        return $QFI;
1218
-    }
1219
-
1220
-
1221
-
1222
-    /**
1223
-     * This preps dropdowns that are specialized.
1224
-     *
1225
-     * @since  4.6.0
1226
-     *
1227
-     * @param EE_Question_Form_Input $QFI
1228
-     *
1229
-     * @return EE_Question_Form_Input
1230
-     */
1231
-    protected static function _load_specialized_dropdowns($QFI)
1232
-    {
1233
-        switch ($QFI->get('QST_type')) {
1234
-            case 'STATE':
1235
-                $QFI = self::generate_state_dropdown($QFI);
1236
-                break;
1237
-            case 'COUNTRY':
1238
-                $QFI = self::generate_country_dropdown($QFI);
1239
-                break;
1240
-        }
1241
-        return $QFI;
1242
-    }
1243
-
1244
-
1245
-
1246
-    /**
1247
-     *    generate_state_dropdown
1248
-     * @param array $QST
1249
-     * @param bool  $get_all
1250
-     * @return array
1251
-     */
1252
-    public static function generate_state_dropdown($QST, $get_all = false)
1253
-    {
1254
-        $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries();
1255
-        if ($states && count($states) != count($QST->options())) {
1256
-            $QST->set('QST_type', 'DROPDOWN');
1257
-            // if multiple countries, we'll create option groups within the dropdown
1258
-            foreach ($states as $state) {
1259
-                if ($state instanceof EE_State) {
1260
-                    $QSO = EE_Question_Option::new_instance(array (
1261
-                        'QSO_value' => $state->ID(),
1262
-                        'QSO_desc' => $state->name(),
1263
-                        'QST_ID' => $QST->get('QST_ID'),
1264
-                        'QSO_deleted' => false
1265
-                    ));
1266
-                    // set option group
1267
-                    $QSO->set_opt_group($state->country()->name());
1268
-                    // add option to question
1269
-                    $QST->add_temp_option($QSO);
1270
-                }
1271
-            }
1272
-        }
1273
-        return $QST;
1274
-    }
1275
-
1276
-
1277
-
1278
-    /**
1279
-     *    generate_country_dropdown
1280
-     * @param      $QST
1281
-     * @param bool $get_all
1282
-     * @internal param array $question
1283
-     * @return array
1284
-     */
1285
-    public static function generate_country_dropdown($QST, $get_all = false)
1286
-    {
1287
-        $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries();
1288
-        if ($countries && count($countries) != count($QST->options())) {
1289
-            $QST->set('QST_type', 'DROPDOWN');
1290
-            // now add countries
1291
-            foreach ($countries as $country) {
1292
-                if ($country instanceof EE_Country) {
1293
-                    $QSO = EE_Question_Option::new_instance(array (
1294
-                        'QSO_value' => $country->ID(),
1295
-                        'QSO_desc' => $country->name(),
1296
-                        'QST_ID' => $QST->get('QST_ID'),
1297
-                        'QSO_deleted' => false
1298
-                    ));
1299
-                    $QST->add_temp_option($QSO);
1300
-                }
1301
-            }
1302
-        }
1303
-        return $QST;
1304
-    }
1305
-
1306
-
1307
-
1308
-
1309
-
1310
-    /**
1311
-     *  generates options for a month dropdown selector with numbers from 01 to 12
1312
-     *  @return array()
1313
-     */
1314
-    public static function two_digit_months_dropdown_options()
1315
-    {
1316
-        $options = array();
1317
-        for ($x = 1; $x <= 12; $x++) {
1318
-            $mm = str_pad($x, 2, '0', STR_PAD_LEFT);
1319
-            $options[ (string) $mm ] = (string) $mm;
1320
-        }
1321
-        return EEH_Form_Fields::prep_answer_options($options);
1322
-    }
1323
-
1324
-
1325
-
1326
-
1327
-
1328
-    /**
1329
-     *  generates a year dropdown selector with numbers for the next ten years
1330
-     *  @return object
1331
-     */
1332
-    public static function next_decade_two_digit_year_dropdown_options()
1333
-    {
1334
-        $options = array();
1335
-        $current_year = date('y');
1336
-        $next_decade = $current_year + 10;
1337
-        for ($x = $current_year; $x <= $next_decade; $x++) {
1338
-            $yy = str_pad($x, 2, '0', STR_PAD_LEFT);
1339
-            $options[ (string) $yy ] = (string) $yy;
1340
-        }
1341
-        return EEH_Form_Fields::prep_answer_options($options);
1342
-    }
1343
-
1344
-
1345
-
1346
-
1347
-
1348
-    /**
1349
-     * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for list table filter.
1350
-     * @param  string  $cur_date     any currently selected date can be entered here.
1351
-     * @param  string  $status       Registration status
1352
-     * @param  integer $evt_category Event Category ID if the Event Category filter is selected
1353
-     * @return string                html
1354
-     */
1355
-    public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1356
-    {
1357
-        $_where = array();
1358
-        if (!empty($status)) {
1359
-            $_where['STS_ID'] = $status;
1360
-        }
1361
-
1362
-        if ($evt_category > 0) {
1363
-            $_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1364
-        }
1365
-
1366
-        $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1367
-
1368
-        // setup vals for select input helper
1369
-        $options = array(
1370
-            0 => array(
1371
-                'text' => __('Select a Month/Year', 'event_espresso'),
1372
-                'id' => ''
1373
-                )
1374
-            );
1375
-
1376
-        foreach ($regdtts as $regdtt) {
1377
-            $date = $regdtt->reg_month. ' ' . $regdtt->reg_year;
1378
-            $options[] = array(
1379
-                'text' => $date,
1380
-                'id' => $date
1381
-                );
1382
-        }
1383
-
1384
-        return self::select_input('month_range', $options, $cur_date, '', 'wide');
1385
-    }
1386
-
1387
-
1388
-
1389
-    /**
1390
-     * generates a month/year dropdown selector for all events matching the given criteria
1391
-     * Typically used for list table filter
1392
-     * @param  string $cur_date          any currently selected date can be entered here.
1393
-     * @param  string $status            "view" (i.e. all, today, month, draft)
1394
-     * @param  int    $evt_category      category event belongs to
1395
-     * @param  string $evt_active_status "upcoming", "expired", "active", or "inactive"
1396
-     * @return string                    html
1397
-     */
1398
-    public static function generate_event_months_dropdown($cur_date = '', $status = null, $evt_category = null, $evt_active_status = null)
1399
-    {
1400
-        // determine what post_status our condition will have for the query.
1401
-        // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1402
-        switch ($status) {
1403
-            case 'month':
1404
-            case 'today':
1405
-            case null:
1406
-            case 'all':
1407
-                $where['Event.status'] = array( 'NOT IN', array('trash') );
1408
-                break;
1409
-
1410
-            case 'draft':
1411
-                $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') );
1412
-
1413
-            default:
1414
-                $where['Event.status'] = $status;
1415
-        }
1416
-
1417
-        // phpcs:enable
1418
-
1419
-        // categories?
1420
-
1124
+		return $prepped_answer_options;
1125
+	}
1126
+
1127
+
1128
+	/**
1129
+	 *  prep_option_value
1130
+	 * @param string $option_value
1131
+	 * @return string
1132
+	 */
1133
+	public static function prep_option_value($option_value)
1134
+	{
1135
+		return esc_attr(trim(stripslashes($option_value)));
1136
+	}
1137
+
1138
+
1139
+
1140
+
1141
+	/**
1142
+	 *  prep_required
1143
+	 * @param string|array  $required
1144
+	 * @return array
1145
+	 */
1146
+	public static function prep_required($required = array())
1147
+	{
1148
+		// make sure required is an array
1149
+		$required = is_array($required) ? $required : array();
1150
+		// and set some defaults
1151
+		$required = array_merge(array( 'label' => '', 'class' => '', 'msg' => '' ), $required);
1152
+		return $required;
1153
+	}
1154
+
1155
+
1156
+
1157
+	/**
1158
+	 *  get_label_size_class
1159
+	 * @param string    $value
1160
+	 * @return string
1161
+	 */
1162
+	public static function get_label_size_class($value = false)
1163
+	{
1164
+		if ($value === false || $value == '') {
1165
+			return ' class="medium-lbl"';
1166
+		}
1167
+			// determine length of option value
1168
+			$val_size = strlen($value);
1169
+		switch ($val_size) {
1170
+			case $val_size < 3:
1171
+				$size =  ' class="nano-lbl"';
1172
+				break;
1173
+			case $val_size < 6:
1174
+				$size =  ' class="micro-lbl"';
1175
+				break;
1176
+			case $val_size < 12:
1177
+				$size =  ' class="tiny-lbl"';
1178
+				break;
1179
+			case $val_size < 25:
1180
+				$size =  ' class="small-lbl"';
1181
+				break;
1182
+			case $val_size > 100:
1183
+				$size =  ' class="big-lbl"';
1184
+				break;
1185
+			default:
1186
+				$size =  ' class="medium-lbl"';
1187
+				break;
1188
+		}
1189
+		return $size;
1190
+	}
1191
+
1192
+
1193
+
1194
+
1195
+	/**
1196
+	 *  _load_system_dropdowns
1197
+	 * @param array     $QFI
1198
+	 * @return array
1199
+	 */
1200
+	private static function _load_system_dropdowns($QFI)
1201
+	{
1202
+		$QST_system = $QFI->get('QST_system');
1203
+		switch ($QST_system) {
1204
+			case 'state':
1205
+				$QFI = self::generate_state_dropdown($QFI);
1206
+				break;
1207
+			case 'country':
1208
+				$QFI = self::generate_country_dropdown($QFI);
1209
+				break;
1210
+			case 'admin-state':
1211
+				$QFI = self::generate_state_dropdown($QFI, true);
1212
+				break;
1213
+			case 'admin-country':
1214
+				$QFI = self::generate_country_dropdown($QFI, true);
1215
+				break;
1216
+		}
1217
+		return $QFI;
1218
+	}
1219
+
1220
+
1221
+
1222
+	/**
1223
+	 * This preps dropdowns that are specialized.
1224
+	 *
1225
+	 * @since  4.6.0
1226
+	 *
1227
+	 * @param EE_Question_Form_Input $QFI
1228
+	 *
1229
+	 * @return EE_Question_Form_Input
1230
+	 */
1231
+	protected static function _load_specialized_dropdowns($QFI)
1232
+	{
1233
+		switch ($QFI->get('QST_type')) {
1234
+			case 'STATE':
1235
+				$QFI = self::generate_state_dropdown($QFI);
1236
+				break;
1237
+			case 'COUNTRY':
1238
+				$QFI = self::generate_country_dropdown($QFI);
1239
+				break;
1240
+		}
1241
+		return $QFI;
1242
+	}
1243
+
1244
+
1245
+
1246
+	/**
1247
+	 *    generate_state_dropdown
1248
+	 * @param array $QST
1249
+	 * @param bool  $get_all
1250
+	 * @return array
1251
+	 */
1252
+	public static function generate_state_dropdown($QST, $get_all = false)
1253
+	{
1254
+		$states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries();
1255
+		if ($states && count($states) != count($QST->options())) {
1256
+			$QST->set('QST_type', 'DROPDOWN');
1257
+			// if multiple countries, we'll create option groups within the dropdown
1258
+			foreach ($states as $state) {
1259
+				if ($state instanceof EE_State) {
1260
+					$QSO = EE_Question_Option::new_instance(array (
1261
+						'QSO_value' => $state->ID(),
1262
+						'QSO_desc' => $state->name(),
1263
+						'QST_ID' => $QST->get('QST_ID'),
1264
+						'QSO_deleted' => false
1265
+					));
1266
+					// set option group
1267
+					$QSO->set_opt_group($state->country()->name());
1268
+					// add option to question
1269
+					$QST->add_temp_option($QSO);
1270
+				}
1271
+			}
1272
+		}
1273
+		return $QST;
1274
+	}
1275
+
1276
+
1277
+
1278
+	/**
1279
+	 *    generate_country_dropdown
1280
+	 * @param      $QST
1281
+	 * @param bool $get_all
1282
+	 * @internal param array $question
1283
+	 * @return array
1284
+	 */
1285
+	public static function generate_country_dropdown($QST, $get_all = false)
1286
+	{
1287
+		$countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries();
1288
+		if ($countries && count($countries) != count($QST->options())) {
1289
+			$QST->set('QST_type', 'DROPDOWN');
1290
+			// now add countries
1291
+			foreach ($countries as $country) {
1292
+				if ($country instanceof EE_Country) {
1293
+					$QSO = EE_Question_Option::new_instance(array (
1294
+						'QSO_value' => $country->ID(),
1295
+						'QSO_desc' => $country->name(),
1296
+						'QST_ID' => $QST->get('QST_ID'),
1297
+						'QSO_deleted' => false
1298
+					));
1299
+					$QST->add_temp_option($QSO);
1300
+				}
1301
+			}
1302
+		}
1303
+		return $QST;
1304
+	}
1305
+
1306
+
1307
+
1308
+
1309
+
1310
+	/**
1311
+	 *  generates options for a month dropdown selector with numbers from 01 to 12
1312
+	 *  @return array()
1313
+	 */
1314
+	public static function two_digit_months_dropdown_options()
1315
+	{
1316
+		$options = array();
1317
+		for ($x = 1; $x <= 12; $x++) {
1318
+			$mm = str_pad($x, 2, '0', STR_PAD_LEFT);
1319
+			$options[ (string) $mm ] = (string) $mm;
1320
+		}
1321
+		return EEH_Form_Fields::prep_answer_options($options);
1322
+	}
1323
+
1324
+
1325
+
1326
+
1327
+
1328
+	/**
1329
+	 *  generates a year dropdown selector with numbers for the next ten years
1330
+	 *  @return object
1331
+	 */
1332
+	public static function next_decade_two_digit_year_dropdown_options()
1333
+	{
1334
+		$options = array();
1335
+		$current_year = date('y');
1336
+		$next_decade = $current_year + 10;
1337
+		for ($x = $current_year; $x <= $next_decade; $x++) {
1338
+			$yy = str_pad($x, 2, '0', STR_PAD_LEFT);
1339
+			$options[ (string) $yy ] = (string) $yy;
1340
+		}
1341
+		return EEH_Form_Fields::prep_answer_options($options);
1342
+	}
1343
+
1344
+
1345
+
1346
+
1347
+
1348
+	/**
1349
+	 * generates a month/year dropdown selector for all registrations matching the given criteria.  Typically used for list table filter.
1350
+	 * @param  string  $cur_date     any currently selected date can be entered here.
1351
+	 * @param  string  $status       Registration status
1352
+	 * @param  integer $evt_category Event Category ID if the Event Category filter is selected
1353
+	 * @return string                html
1354
+	 */
1355
+	public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1356
+	{
1357
+		$_where = array();
1358
+		if (!empty($status)) {
1359
+			$_where['STS_ID'] = $status;
1360
+		}
1361
+
1362
+		if ($evt_category > 0) {
1363
+			$_where['Event.Term_Taxonomy.term_id'] = $evt_category;
1364
+		}
1365
+
1366
+		$regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where);
1367
+
1368
+		// setup vals for select input helper
1369
+		$options = array(
1370
+			0 => array(
1371
+				'text' => __('Select a Month/Year', 'event_espresso'),
1372
+				'id' => ''
1373
+				)
1374
+			);
1375
+
1376
+		foreach ($regdtts as $regdtt) {
1377
+			$date = $regdtt->reg_month. ' ' . $regdtt->reg_year;
1378
+			$options[] = array(
1379
+				'text' => $date,
1380
+				'id' => $date
1381
+				);
1382
+		}
1383
+
1384
+		return self::select_input('month_range', $options, $cur_date, '', 'wide');
1385
+	}
1386
+
1387
+
1388
+
1389
+	/**
1390
+	 * generates a month/year dropdown selector for all events matching the given criteria
1391
+	 * Typically used for list table filter
1392
+	 * @param  string $cur_date          any currently selected date can be entered here.
1393
+	 * @param  string $status            "view" (i.e. all, today, month, draft)
1394
+	 * @param  int    $evt_category      category event belongs to
1395
+	 * @param  string $evt_active_status "upcoming", "expired", "active", or "inactive"
1396
+	 * @return string                    html
1397
+	 */
1398
+	public static function generate_event_months_dropdown($cur_date = '', $status = null, $evt_category = null, $evt_active_status = null)
1399
+	{
1400
+		// determine what post_status our condition will have for the query.
1401
+		// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
1402
+		switch ($status) {
1403
+			case 'month':
1404
+			case 'today':
1405
+			case null:
1406
+			case 'all':
1407
+				$where['Event.status'] = array( 'NOT IN', array('trash') );
1408
+				break;
1409
+
1410
+			case 'draft':
1411
+				$where['Event.status'] = array( 'IN', array('draft', 'auto-draft') );
1412
+
1413
+			default:
1414
+				$where['Event.status'] = $status;
1415
+		}
1416
+
1417
+		// phpcs:enable
1418
+
1419
+		// categories?
1420
+
1421 1421
 
1422
-        if (!empty($evt_category)) {
1423
-            $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1424
-            $where['Event.Term_Taxonomy.term_id'] = $evt_category;
1425
-        }
1422
+		if (!empty($evt_category)) {
1423
+			$where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1424
+			$where['Event.Term_Taxonomy.term_id'] = $evt_category;
1425
+		}
1426 1426
 
1427 1427
 
1428 1428
 //      $where['DTT_is_primary'] = 1;
1429 1429
 
1430
-        $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status);
1431
-
1432
-        // let's setup vals for select input helper
1433
-        $options = array(
1434
-            0 => array(
1435
-                'text' => __('Select a Month/Year', 'event_espresso'),
1436
-                'id' => ""
1437
-                )
1438
-            );
1439
-
1440
-
1441
-
1442
-        // translate month and date
1443
-        global $wp_locale;
1444
-
1445
-        foreach ($DTTS as $DTT) {
1446
-            $localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1447
-            $id = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1448
-            $options[] = array(
1449
-                'text' => $localized_date,
1450
-                'id' => $id
1451
-                );
1452
-        }
1453
-
1454
-
1455
-        return self::select_input('month_range', $options, $cur_date, '', 'wide');
1456
-    }
1457
-
1458
-
1459
-
1460
-    /**
1461
-     * generates the dropdown selector for event categories
1462
-     * typically used as a filter on list tables.
1463
-     * @param  integer $current_cat currently selected category
1464
-     * @return string               html for dropdown
1465
-     */
1466
-    public static function generate_event_category_dropdown($current_cat = -1)
1467
-    {
1468
-        $categories = EEM_Term::instance()->get_all_ee_categories(true);
1469
-        $options = array(
1470
-            '0' => array(
1471
-                'text' => __('All Categories', 'event_espresso'),
1472
-                'id' => -1
1473
-                )
1474
-            );
1475
-
1476
-        // setup categories for dropdown
1477
-        foreach ($categories as $category) {
1478
-            $options[] = array(
1479
-                'text' => $category->get('name'),
1480
-                'id' => $category->ID()
1481
-                );
1482
-        }
1483
-
1484
-        return self::select_input('EVT_CAT', $options, $current_cat);
1485
-    }
1486
-
1487
-
1488
-
1489
-    /**
1490
-     *    generate a submit button with or without it's own microform
1491
-     *    this is the only way to create buttons that are compatible across all themes
1492
-     *
1493
-     * @access    public
1494
-     * @param    string   $url              - the form action
1495
-     * @param    string   $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm" for the form
1496
-     * @param    string   $class            - css classes (separated by spaces if more than one)
1497
-     * @param    string   $text             - what appears on the button
1498
-     * @param    string   $nonce_action     - if using nonces
1499
-     * @param    bool|string $input_only       - whether to print form header and footer. TRUE returns the input without the form
1500
-     * @param    string   $extra_attributes - any extra attributes that need to be attached to the form input
1501
-     * @return    void
1502
-     */
1503
-    public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = false, $extra_attributes = '')
1504
-    {
1505
-        $btn = '';
1506
-        if (empty($url) || empty($ID)) {
1507
-            return $btn;
1508
-        }
1509
-        $text = ! empty($text) ? $text : __('Submit', 'event_espresso');
1510
-        $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
1511
-        if (! $input_only) {
1512
-            $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
1513
-            $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false) : '';
1514
-            $btn_frm .= $btn;
1515
-            $btn_frm .= '</form>';
1516
-            $btn = $btn_frm;
1517
-            unset($btn_frm);
1518
-        }
1519
-        return $btn;
1520
-    }
1430
+		$DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status);
1431
+
1432
+		// let's setup vals for select input helper
1433
+		$options = array(
1434
+			0 => array(
1435
+				'text' => __('Select a Month/Year', 'event_espresso'),
1436
+				'id' => ""
1437
+				)
1438
+			);
1439
+
1440
+
1441
+
1442
+		// translate month and date
1443
+		global $wp_locale;
1444
+
1445
+		foreach ($DTTS as $DTT) {
1446
+			$localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1447
+			$id = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1448
+			$options[] = array(
1449
+				'text' => $localized_date,
1450
+				'id' => $id
1451
+				);
1452
+		}
1453
+
1454
+
1455
+		return self::select_input('month_range', $options, $cur_date, '', 'wide');
1456
+	}
1457
+
1458
+
1459
+
1460
+	/**
1461
+	 * generates the dropdown selector for event categories
1462
+	 * typically used as a filter on list tables.
1463
+	 * @param  integer $current_cat currently selected category
1464
+	 * @return string               html for dropdown
1465
+	 */
1466
+	public static function generate_event_category_dropdown($current_cat = -1)
1467
+	{
1468
+		$categories = EEM_Term::instance()->get_all_ee_categories(true);
1469
+		$options = array(
1470
+			'0' => array(
1471
+				'text' => __('All Categories', 'event_espresso'),
1472
+				'id' => -1
1473
+				)
1474
+			);
1475
+
1476
+		// setup categories for dropdown
1477
+		foreach ($categories as $category) {
1478
+			$options[] = array(
1479
+				'text' => $category->get('name'),
1480
+				'id' => $category->ID()
1481
+				);
1482
+		}
1483
+
1484
+		return self::select_input('EVT_CAT', $options, $current_cat);
1485
+	}
1486
+
1487
+
1488
+
1489
+	/**
1490
+	 *    generate a submit button with or without it's own microform
1491
+	 *    this is the only way to create buttons that are compatible across all themes
1492
+	 *
1493
+	 * @access    public
1494
+	 * @param    string   $url              - the form action
1495
+	 * @param    string   $ID               - some kind of unique ID, appended with "-sbmt" for the input and "-frm" for the form
1496
+	 * @param    string   $class            - css classes (separated by spaces if more than one)
1497
+	 * @param    string   $text             - what appears on the button
1498
+	 * @param    string   $nonce_action     - if using nonces
1499
+	 * @param    bool|string $input_only       - whether to print form header and footer. TRUE returns the input without the form
1500
+	 * @param    string   $extra_attributes - any extra attributes that need to be attached to the form input
1501
+	 * @return    void
1502
+	 */
1503
+	public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = false, $extra_attributes = '')
1504
+	{
1505
+		$btn = '';
1506
+		if (empty($url) || empty($ID)) {
1507
+			return $btn;
1508
+		}
1509
+		$text = ! empty($text) ? $text : __('Submit', 'event_espresso');
1510
+		$btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
1511
+		if (! $input_only) {
1512
+			$btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
1513
+			$btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false) : '';
1514
+			$btn_frm .= $btn;
1515
+			$btn_frm .= '</form>';
1516
+			$btn = $btn_frm;
1517
+			unset($btn_frm);
1518
+		}
1519
+		return $btn;
1520
+	}
1521 1521
 }
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
             $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': ';
94 94
             // and the css class "required"
95 95
             $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : '';
96
-            $styles = $input_value['required'] ? 'required ' . $css_class : $css_class;
96
+            $styles = $input_value['required'] ? 'required '.$css_class : $css_class;
97 97
 
98
-            $field_id = ($id) ? $id . '-' . $input_key : $input_key;
99
-            $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : '';
98
+            $field_id = ($id) ? $id.'-'.$input_key : $input_key;
99
+            $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : '';
100 100
 
101 101
             // rows or cols?
102 102
             $rows = isset($input_value['rows']) ? $input_value['rows'] : '10';
@@ -105,21 +105,21 @@  discard block
 block discarded – undo
105 105
             // any content?
106 106
             $append_content = $input_value['append_content'];
107 107
 
108
-            $output .= (!$close) ? '<ul>' : '';
108
+            $output .= ( ! $close) ? '<ul>' : '';
109 109
             $output .= '<li>';
110 110
 
111 111
             // what type of input are we dealing with ?
112 112
             switch ($input_value['input']) {
113 113
                 // text inputs
114 114
                 case 'text':
115
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
116
-                    $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . esc_textarea($input_value['value']) . '" name="' . $input_value['name'] . '"' . $tabindex . '>';
115
+                    $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>';
116
+                    $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.esc_textarea($input_value['value']).'" name="'.$input_value['name'].'"'.$tabindex.'>';
117 117
                     break;
118 118
 
119 119
                 // dropdowns
120 120
                 case 'select':
121
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
122
-                    $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>';
121
+                    $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>';
122
+                    $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>';
123 123
 
124 124
                     if (is_array($input_value['options'])) {
125 125
                         $options = $input_value['options'];
@@ -130,27 +130,27 @@  discard block
 block discarded – undo
130 130
                     foreach ($options as $key => $value) {
131 131
                         $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : '';
132 132
                         // $key = str_replace( ' ', '_', sanitize_key( $value ));
133
-                        $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>';
133
+                        $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>';
134 134
                     }
135
-                    $output .= "\n\t\t\t" . '</select>';
135
+                    $output .= "\n\t\t\t".'</select>';
136 136
 
137 137
                     break;
138 138
 
139 139
                 case 'textarea':
140
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
141
-                    $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . esc_textarea($input_value['value']) . '</textarea>';
140
+                    $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>';
141
+                    $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.esc_textarea($input_value['value']).'</textarea>';
142 142
                     break;
143 143
 
144 144
                 case 'hidden':
145 145
                     $close = false;
146 146
                     $output .= "</li></ul>";
147
-                    $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">';
147
+                    $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">';
148 148
                     break;
149 149
 
150 150
                 case 'checkbox':
151
-                    $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : '';
152
-                    $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>';
153
-                    $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />';
151
+                    $checked = ($input_value['value'] == 1) ? 'checked="checked"' : '';
152
+                    $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>';
153
+                    $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />';
154 154
                     break;
155 155
 
156 156
                 case 'wp_editor':
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
                     );
164 164
                     $output .= '</li>';
165 165
                     $output .= '</ul>';
166
-                    $output .= '<h4>' . $input_value['label'] . '</h4>';
166
+                    $output .= '<h4>'.$input_value['label'].'</h4>';
167 167
                     if ($append_content) {
168 168
                         $output .= $append_content;
169 169
                     }
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
             $_fields = wp_parse_args($field_atts, $defaults);
236 236
             extract($_fields);
237 237
             // generate label
238
-            $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>';
238
+            $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>';
239 239
             // generate field name
240
-            $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name;
240
+            $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name;
241 241
 
242 242
             // tabindex
243
-            $tabindex_str = !empty($tabindex) ? ' tabindex="' . $tabindex . '"' : '';
243
+            $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : '';
244 244
 
245 245
             // we determine what we're building based on the type
246 246
             switch ($type) {
247 247
                 case 'textarea':
248
-                        $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>';
248
+                        $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>';
249 249
                         $fld .= $extra_desc;
250 250
                     break;
251 251
 
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
                         $c_input = '';
254 254
                     if (is_array($value)) {
255 255
                         foreach ($value as $key => $val) {
256
-                            $c_id = $field_name . '_' . $value;
257
-                            $c_class = isset($classes[ $key ]) ? ' class="' . $classes[ $key ] . '" ' : '';
258
-                            $c_label = isset($labels[ $key ]) ? '<label for="' . $c_id . '">' . $labels[ $key ] . '</label>' : '';
259
-                            $checked = !empty($default) && $default == $val ? ' checked="checked" ' : '';
260
-                            $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label;
256
+                            $c_id = $field_name.'_'.$value;
257
+                            $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : '';
258
+                            $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : '';
259
+                            $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : '';
260
+                            $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label;
261 261
                         }
262 262
                         $fld = $c_input;
263 263
                     } else {
264
-                        $checked = !empty($default) && $default == $val ? 'checked="checked" ' : '';
265
-                        $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n";
264
+                        $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : '';
265
+                        $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n";
266 266
                     }
267 267
                     break;
268 268
 
@@ -270,28 +270,28 @@  discard block
 block discarded – undo
270 270
                         $c_input = '';
271 271
                     if (is_array($value)) {
272 272
                         foreach ($value as $key => $val) {
273
-                            $c_id = $field_name . '_' . $value;
274
-                            $c_class = isset($classes[ $key ]) ? 'class="' . $classes[ $key ] . '" ' : '';
275
-                            $c_label = isset($labels[ $key ]) ? '<label for="' . $c_id . '">' . $labels[ $key ] . '</label>' : '';
276
-                            $checked = !empty($default) && $default == $val ? ' checked="checked" ' : '';
277
-                            $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label;
273
+                            $c_id = $field_name.'_'.$value;
274
+                            $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : '';
275
+                            $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : '';
276
+                            $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : '';
277
+                            $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label;
278 278
                         }
279 279
                         $fld = $c_input;
280 280
                     } else {
281
-                        $checked = !empty($default) && $default == $val ? 'checked="checked" ' : '';
282
-                        $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n";
281
+                        $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : '';
282
+                        $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n";
283 283
                     }
284 284
                     break;
285 285
 
286 286
                 case 'hidden':
287
-                        $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n";
287
+                        $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n";
288 288
                     break;
289 289
 
290 290
                 case 'select':
291
-                        $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n";
291
+                        $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n";
292 292
                     foreach ($value as $key => $val) {
293
-                        $checked = !empty($default) && $default == $val ? ' selected="selected"' : '';
294
-                        $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[ $key ] . '</option>' . "\n";
293
+                        $checked = ! empty($default) && $default == $val ? ' selected="selected"' : '';
294
+                        $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n";
295 295
                     }
296 296
                         $fld .= '</select>';
297 297
                     break;
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
                     break;
313 313
 
314 314
                 default: // 'text fields'
315
-                        $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n";
315
+                        $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n";
316 316
                         $fld .= $extra_desc;
317 317
             }
318 318
 
319
-            $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld );
319
+            $form_fields[$field_name] = array('label' => $label, 'field' => $fld);
320 320
         }
321 321
 
322 322
         return $form_fields;
@@ -346,25 +346,25 @@  discard block
 block discarded – undo
346 346
     public static function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true)
347 347
     {
348 348
         // if $values was submitted in the wrong format, convert it over
349
-        if (!empty($values) && (!array_key_exists(0, $values) || !is_array($values[0]))) {
350
-            $converted_values=array();
349
+        if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) {
350
+            $converted_values = array();
351 351
             foreach ($values as $id => $text) {
352
-                $converted_values[]=array('id'=>$id,'text'=>$text);
352
+                $converted_values[] = array('id'=>$id, 'text'=>$text);
353 353
             }
354
-            $values=$converted_values;
354
+            $values = $converted_values;
355 355
         }
356 356
 
357
-        $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"';
357
+        $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"';
358 358
         // Debug
359 359
         // EEH_Debug_Tools::printr( $values, '$values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
360 360
         if (EEH_Formatter::ee_tep_not_null($parameters)) {
361
-            $field .= ' ' . $parameters;
361
+            $field .= ' '.$parameters;
362 362
         }
363 363
         if ($autosize) {
364 364
             $size = 'med';
365 365
             for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) {
366
-                if ($values[ $ii ]['text']) {
367
-                    if (strlen($values[ $ii ]['text']) > 5) {
366
+                if ($values[$ii]['text']) {
367
+                    if (strlen($values[$ii]['text']) > 5) {
368 368
                         $size = 'wide';
369 369
                     }
370 370
                 }
@@ -373,22 +373,22 @@  discard block
 block discarded – undo
373 373
             $size = '';
374 374
         }
375 375
 
376
-        $field .= ' class="' . $class . ' ' . $size . '">';
376
+        $field .= ' class="'.$class.' '.$size.'">';
377 377
 
378
-        if (empty($default) && isset($GLOBALS[ $name ])) {
379
-            $default = stripslashes($GLOBALS[ $name ]);
378
+        if (empty($default) && isset($GLOBALS[$name])) {
379
+            $default = stripslashes($GLOBALS[$name]);
380 380
         }
381 381
 
382 382
 
383 383
         for ($i = 0, $n = sizeof($values); $i < $n; $i++) {
384
-            $field .= '<option value="' . $values[ $i ]['id'] . '"';
385
-            if ($default == $values[ $i ]['id']) {
384
+            $field .= '<option value="'.$values[$i]['id'].'"';
385
+            if ($default == $values[$i]['id']) {
386 386
                 $field .= ' selected = "selected"';
387 387
             }
388
-            if (isset($values[ $i ]['class'])) {
389
-                $field .= ' class="' . $values[ $i ]['class'] . '"';
388
+            if (isset($values[$i]['class'])) {
389
+                $field .= ' class="'.$values[$i]['class'].'"';
390 390
             }
391
-            $field .= '>' . $values[ $i ]['text'] . '</option>';
391
+            $field .= '>'.$values[$i]['text'].'</option>';
392 392
         }
393 393
         $field .= '</select>';
394 394
 
@@ -413,18 +413,18 @@  discard block
 block discarded – undo
413 413
         $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '');
414 414
         $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '');
415 415
 
416
-        if (! empty($question_groups)) {
416
+        if ( ! empty($question_groups)) {
417 417
             // EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
418 418
             // loop thru question groups
419 419
             foreach ($question_groups as $QSG) {
420 420
                 // check that questions exist
421
-                if (! empty($QSG['QSG_questions'])) {
421
+                if ( ! empty($QSG['QSG_questions'])) {
422 422
                     // use fieldsets
423
-                    $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">';
423
+                    $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">';
424 424
                     // group_name
425
-                    $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer($QSG['QSG_name']) . '</h5>' : '';
425
+                    $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : '';
426 426
                     // group_desc
427
-                    $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer($QSG['QSG_desc']) . '</div>' : '';
427
+                    $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : '';
428 428
 
429 429
                     $html .= $before_question_group_questions;
430 430
                     // loop thru questions
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
                         $html .= self::generate_form_input($QFI);
439 439
                     }
440 440
                     $html .= $after_question_group_questions;
441
-                    $html .= "\n\t" . '</' . $group_wrapper . '>';
441
+                    $html .= "\n\t".'</'.$group_wrapper.'>';
442 442
                 }
443 443
             }
444 444
         }
@@ -474,28 +474,28 @@  discard block
 block discarded – undo
474 474
         $q_meta = array_merge($default_q_meta, $q_meta);
475 475
         // EEH_Debug_Tools::printr( $q_meta, '$q_meta  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
476 476
 
477
-        if (! empty($question_groups)) {
477
+        if ( ! empty($question_groups)) {
478 478
 //          EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
479 479
             // loop thru question groups
480 480
             foreach ($question_groups as $QSG) {
481 481
                 if ($QSG instanceof EE_Question_Group) {
482 482
                     // check that questions exist
483 483
 
484
-                    $where = array( 'QST_deleted' => 0 );
485
-                    if (! $from_admin) {
484
+                    $where = array('QST_deleted' => 0);
485
+                    if ( ! $from_admin) {
486 486
                         $where['QST_admin_only'] = 0;
487 487
                     }
488
-                    $questions = $QSG->questions(array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' )));
489
-                    if (! empty($questions)) {
488
+                    $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC')));
489
+                    if ( ! empty($questions)) {
490 490
                         // use fieldsets
491
-                        $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get('QSG_identifier') . '">';
491
+                        $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">';
492 492
                         // group_name
493 493
                         if ($QSG->show_group_name()) {
494
-                            $html .=  "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty('QSG_name') . '</h5>';
494
+                            $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>';
495 495
                         }
496 496
                         // group_desc
497 497
                         if ($QSG->show_group_desc()) {
498
-                            $html .=  '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty('QSG_desc') . '</div>';
498
+                            $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>';
499 499
                         }
500 500
 
501 501
                         $html .= $before_question_group_questions;
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 
508 508
                             if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) {
509 509
                                 // check for answer in $_GET in case we are reprocessing a form after an error
510
-                                if (isset($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ])) {
511
-                                    $answer = is_array($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ]) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field($_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ]);
510
+                                if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) {
511
+                                    $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]);
512 512
                                 }
513 513
                             } elseif (isset($q_meta['attendee']) && $q_meta['attendee']) {
514 514
                                 // attendee data from the session
515
-                                $answer = isset($q_meta['attendee'][ $qstn_id ]) ? $q_meta['attendee'][ $qstn_id ] : null;
515
+                                $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : null;
516 516
                             }
517 517
 
518 518
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
                             $html .= self::generate_form_input($QFI);
532 532
                         }
533 533
                         $html .= $after_question_group_questions;
534
-                        $html .= "\n\t" . '</' . $group_wrapper . '>';
534
+                        $html .= "\n\t".'</'.$group_wrapper.'>';
535 535
                     }
536 536
                 }
537 537
             }
@@ -572,11 +572,11 @@  discard block
 block discarded – undo
572 572
         $disabled = $QFI->get('QST_disabled');
573 573
         $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>');
574 574
         $QST_required = $QFI->get('QST_required');
575
-        $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array();
575
+        $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array();
576 576
         $use_html_entities = $QFI->get_meta('htmlentities');
577 577
         $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso');
578 578
         $required_text = $QST_required
579
-            ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer($required_text, $use_html_entities) . '</div>'
579
+            ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>'
580 580
             : '';
581 581
         $label_class = 'espresso-form-input-lbl';
582 582
         $QST_options = $QFI->options(true, $answer);
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
     public static function text($question = false, $answer = null, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
637 637
     {
638 638
         // need these
639
-        if (! $question || ! $name) {
639
+        if ( ! $question || ! $name) {
640 640
             return null;
641 641
         }
642 642
         // prep the answer
@@ -644,21 +644,21 @@  discard block
 block discarded – undo
644 644
         // prep the required array
645 645
         $required = self::prep_required($required);
646 646
         // set disabled tag
647
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
647
+        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
648 648
         // ya gots ta have style man!!!
649 649
         $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp';
650 650
         $class = empty($class) ? $txt_class : $class;
651
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
651
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
652 652
         $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
653 653
 
654
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
654
+        $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>';
655 655
         // filter label but ensure required text comes before it
656 656
         $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
657 657
 
658
-        $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr($answer) . '"  title="' . esc_attr($required['msg']) . '" ' . $disabled .' ' . $extra . '/>';
658
+        $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'"  title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>';
659 659
 
660
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
661
-        return  $label_html . $input_html;
660
+        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
661
+        return  $label_html.$input_html;
662 662
     }
663 663
 
664 664
 
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     public static function textarea($question = false, $answer = null, $name = false, $id = '', $class = '', $dimensions = false, $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
683 683
     {
684 684
         // need these
685
-        if (! $question || ! $name) {
685
+        if ( ! $question || ! $name) {
686 686
             return null;
687 687
         }
688 688
         // prep the answer
@@ -692,23 +692,23 @@  discard block
 block discarded – undo
692 692
         // make sure $dimensions is an array
693 693
         $dimensions = is_array($dimensions) ? $dimensions : array();
694 694
         // and set some defaults
695
-        $dimensions = array_merge(array( 'rows' => 3, 'cols' => 40 ), $dimensions);
695
+        $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions);
696 696
         // set disabled tag
697
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
697
+        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
698 698
         // ya gots ta have style man!!!
699 699
         $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp';
700 700
         $class = empty($class) ? $txt_class : $class;
701
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
701
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
702 702
         $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
703 703
 
704
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
704
+        $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>';
705 705
         // filter label but ensure required text comes before it
706 706
         $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
707 707
 
708
-        $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '"  title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>';
708
+        $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'"  title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>';
709 709
 
710
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
711
-        return  $label_html . $input_html;
710
+        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
711
+        return  $label_html.$input_html;
712 712
     }
713 713
 
714 714
 
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
     {
735 735
 
736 736
         // need these
737
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
737
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
738 738
             return null;
739 739
         }
740 740
         // prep the answer
@@ -742,36 +742,36 @@  discard block
 block discarded – undo
742 742
         // prep the required array
743 743
         $required = self::prep_required($required);
744 744
         // set disabled tag
745
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
745
+        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
746 746
         // ya gots ta have style man!!!
747 747
         $txt_class = is_admin() ? 'wide' : 'espresso-select-inp';
748 748
         $class = empty($class) ? $txt_class : $class;
749
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
749
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
750 750
         $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
751 751
 
752
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
752
+        $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>';
753 753
         // filter label but ensure required text comes before it
754 754
         $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
755 755
 
756
-        $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr($required['msg']) . '"' . $disabled . ' ' . $extra . '>';
756
+        $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>';
757 757
         // recursively count array elements, to determine total number of options
758 758
         $only_option = count($options, 1) == 1 ? true : false;
759
-        if (! $only_option) {
759
+        if ( ! $only_option) {
760 760
             // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected
761 761
             $selected = $answer === null ? ' selected="selected"' : '';
762
-            $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : '';
762
+            $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : '';
763 763
         }
764 764
         foreach ($options as $key => $value) {
765 765
             // if value is an array, then create option groups, else create regular ol' options
766 766
             $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities);
767 767
         }
768 768
 
769
-        $input_html .= "\n\t\t\t" . '</select>';
769
+        $input_html .= "\n\t\t\t".'</select>';
770 770
 
771
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID);
771
+        $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID);
772 772
 
773
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
774
-        return  $label_html . $input_html;
773
+        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
774
+        return  $label_html.$input_html;
775 775
     }
776 776
 
777 777
 
@@ -790,11 +790,11 @@  discard block
 block discarded – undo
790 790
      */
791 791
     private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true)
792 792
     {
793
-        $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value($opt_group) . '">';
793
+        $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">';
794 794
         foreach ($QSOs as $QSO) {
795 795
             $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities);
796 796
         }
797
-        $html .= "\n\t\t\t\t" . '</optgroup>';
797
+        $html .= "\n\t\t\t\t".'</optgroup>';
798 798
         return $html;
799 799
     }
800 800
 
@@ -814,8 +814,8 @@  discard block
 block discarded – undo
814 814
         $key = self::prep_answer($key, $use_html_entities);
815 815
         $value = self::prep_answer($value, $use_html_entities);
816 816
         $value = ! empty($value) ? $value : $key;
817
-        $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : '';
818
-        return "\n\t\t\t\t" . '<option value="' . self::prep_option_value($key) . '"' . $selected . '> ' . $value . '&nbsp;&nbsp;&nbsp;</option>';
817
+        $selected = ($answer == $key || $only_option) ? ' selected="selected"' : '';
818
+        return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.'&nbsp;&nbsp;&nbsp;</option>';
819 819
     }
820 820
 
821 821
 
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
     public static function radio($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true, $label_b4 = false, $use_desc_4_label = false)
843 843
     {
844 844
         // need these
845
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
845
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
846 846
             return null;
847 847
         }
848 848
         // prep the answer
@@ -850,46 +850,46 @@  discard block
 block discarded – undo
850 850
         // prep the required array
851 851
         $required = self::prep_required($required);
852 852
         // set disabled tag
853
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
853
+        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
854 854
         // ya gots ta have style man!!!
855 855
         $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
856 856
         $class = ! empty($class) ? $class : 'espresso-radio-btn-inp';
857 857
         $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
858 858
 
859
-        $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label> ';
859
+        $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> ';
860 860
         // filter label but ensure required text comes before it
861 861
         $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
862 862
 
863
-        $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">';
863
+        $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">';
864 864
 
865
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
866
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
865
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
866
+        $class .= ! empty($required['class']) ? ' '.$required['class'] : '';
867 867
 
868 868
         foreach ($options as $OPT) {
869 869
             if ($OPT instanceof EE_Question_Option) {
870 870
                 $value = self::prep_option_value($OPT->value());
871 871
                 $label = $use_desc_4_label ? $OPT->desc() : $OPT->value();
872
-                $size = $use_desc_4_label ? self::get_label_size_class($OPT->value() . ' ' . $OPT->desc()) : self::get_label_size_class($OPT->value());
873
-                $desc = $OPT->desc();// no self::prep_answer
872
+                $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value());
873
+                $desc = $OPT->desc(); // no self::prep_answer
874 874
                 $answer = is_numeric($value) && empty($answer) ? 0 : $answer;
875 875
                 $checked = (string) $value == (string) $answer ? ' checked="checked"' : '';
876
-                $opt = '-' . sanitize_key($value);
877
-
878
-                $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
879
-                $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">';
880
-                $input_html .= $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : '';
881
-                $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
882
-                $input_html .= ! $label_b4  ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : '';
883
-                $input_html .= "\n\t\t\t\t\t" . '</label>';
884
-                $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>';
885
-                $input_html .= "\n\t\t\t\t" . '</li>';
876
+                $opt = '-'.sanitize_key($value);
877
+
878
+                $input_html .= "\n\t\t\t\t".'<li'.$size.'>';
879
+                $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">';
880
+                $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : '';
881
+                $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>';
882
+                $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : '';
883
+                $input_html .= "\n\t\t\t\t\t".'</label>';
884
+                $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>';
885
+                $input_html .= "\n\t\t\t\t".'</li>';
886 886
             }
887 887
         }
888 888
 
889
-        $input_html .= "\n\t\t\t" . '</ul>';
889
+        $input_html .= "\n\t\t\t".'</ul>';
890 890
 
891
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
892
-        return  $label_html . $input_html;
891
+        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
892
+        return  $label_html.$input_html;
893 893
     }
894 894
 
895 895
 
@@ -914,62 +914,62 @@  discard block
 block discarded – undo
914 914
     public static function checkbox($question = false, $answer = null, $options = false, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $label_b4 = false, $system_ID = false, $use_html_entities = true)
915 915
     {
916 916
         // need these
917
-        if (! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
917
+        if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) {
918 918
             return null;
919 919
         }
920 920
         $answer = maybe_unserialize($answer);
921 921
 
922 922
         // prep the answer(s)
923
-        $answer = is_array($answer) ? $answer : array( sanitize_key($answer) => $answer );
923
+        $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer);
924 924
 
925 925
         foreach ($answer as $key => $value) {
926 926
             $key = self::prep_option_value($key);
927
-            $answer[ $key ] = self::prep_answer($value, $use_html_entities);
927
+            $answer[$key] = self::prep_answer($value, $use_html_entities);
928 928
         }
929 929
 
930 930
         // prep the required array
931 931
         $required = self::prep_required($required);
932 932
         // set disabled tag
933
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
933
+        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
934 934
         // ya gots ta have style man!!!
935 935
         $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class;
936 936
         $class = empty($class) ? 'espresso-radio-btn-inp' : $class;
937 937
         $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
938 938
 
939
-        $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label> ';
939
+        $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> ';
940 940
         // filter label but ensure required text comes before it
941 941
         $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
942 942
 
943
-        $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">';
943
+        $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">';
944 944
 
945
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
946
-        $class .= ! empty($required['class']) ? ' ' . $required['class'] : '';
945
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
946
+        $class .= ! empty($required['class']) ? ' '.$required['class'] : '';
947 947
 
948 948
         foreach ($options as $OPT) {
949
-            $value = $OPT->value();// self::prep_option_value( $OPT->value() );
950
-            $size = self::get_label_size_class($OPT->value() . ' ' . $OPT->desc());
949
+            $value = $OPT->value(); // self::prep_option_value( $OPT->value() );
950
+            $size = self::get_label_size_class($OPT->value().' '.$OPT->desc());
951 951
             $text = self::prep_answer($OPT->value());
952
-            $desc = $OPT->desc() ;
953
-            $opt = '-' . sanitize_key($value);
952
+            $desc = $OPT->desc();
953
+            $opt = '-'.sanitize_key($value);
954 954
 
955 955
             $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : '';
956 956
 
957
-            $input_html .= "\n\t\t\t\t" . '<li' . $size . '>';
958
-            $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">';
959
-            $input_html .= $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
960
-            $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr($required['msg']) . '" ' . $disabled . $checked . ' ' . $extra . '/>';
961
-            $input_html .= ! $label_b4  ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : '';
962
-            $input_html .= "\n\t\t\t\t\t" . '</label>';
963
-            if (! empty($desc) && $desc != $text) {
964
-                $input_html .= "\n\t\t\t\t\t" . ' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>';
957
+            $input_html .= "\n\t\t\t\t".'<li'.$size.'>';
958
+            $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">';
959
+            $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : '';
960
+            $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>';
961
+            $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : '';
962
+            $input_html .= "\n\t\t\t\t\t".'</label>';
963
+            if ( ! empty($desc) && $desc != $text) {
964
+                $input_html .= "\n\t\t\t\t\t".' &nbsp; <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>';
965 965
             }
966
-            $input_html .= "\n\t\t\t\t" . '</li>';
966
+            $input_html .= "\n\t\t\t\t".'</li>';
967 967
         }
968 968
 
969
-        $input_html .= "\n\t\t\t" . '</ul>';
969
+        $input_html .= "\n\t\t\t".'</ul>';
970 970
 
971
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
972
-        return  $label_html . $input_html;
971
+        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
972
+        return  $label_html.$input_html;
973 973
     }
974 974
 
975 975
 
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
     public static function datepicker($question = false, $answer = null, $name = false, $id = '', $class = '', $required = false, $required_text = '', $label_class = '', $disabled = false, $system_ID = false, $use_html_entities = true)
994 994
     {
995 995
         // need these
996
-        if (! $question || ! $name) {
996
+        if ( ! $question || ! $name) {
997 997
             return null;
998 998
         }
999 999
         // prep the answer
@@ -1001,26 +1001,26 @@  discard block
 block discarded – undo
1001 1001
         // prep the required array
1002 1002
         $required = self::prep_required($required);
1003 1003
         // set disabled tag
1004
-        $disabled = $answer === null || ! $disabled  ? '' : ' disabled="disabled"';
1004
+        $disabled = $answer === null || ! $disabled ? '' : ' disabled="disabled"';
1005 1005
         // ya gots ta have style man!!!
1006 1006
         $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp';
1007 1007
         $class = empty($class) ? $txt_class : $class;
1008
-        $class .= ! empty($system_ID) ? ' ' . $system_ID : '';
1008
+        $class .= ! empty($system_ID) ? ' '.$system_ID : '';
1009 1009
         $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', '');
1010 1010
 
1011
-        $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question($question) . $required['label'] . '</label><br/>';
1011
+        $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>';
1012 1012
         // filter label but ensure required text comes before it
1013 1013
         $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text);
1014 1014
 
1015
-        $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '"  title="' . esc_attr($required['msg']) . '" ' . $disabled . ' ' . $extra . '/>';
1015
+        $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'"  title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>';
1016 1016
 
1017 1017
         // enqueue scripts
1018
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1018
+        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1019 1019
         wp_enqueue_style('espresso-ui-theme');
1020 1020
         wp_enqueue_script('jquery-ui-datepicker');
1021 1021
 
1022
-        $input_html =  apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1023
-        return  $label_html . $input_html;
1022
+        $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id);
1023
+        return  $label_html.$input_html;
1024 1024
     }
1025 1025
 
1026 1026
 
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
     public static function hidden_input($name, $value, $id = '')
1050 1050
     {
1051 1051
         $id = ! empty($id) ? $id : $name;
1052
-        return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' .  $value . '"/>';
1052
+        return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>';
1053 1053
     }
1054 1054
 
1055 1055
 
@@ -1107,14 +1107,14 @@  discard block
 block discarded – undo
1107 1107
         $prepped_answer_options = array();
1108 1108
         if (is_array($QSOs) && ! empty($QSOs)) {
1109 1109
             foreach ($QSOs as $key => $QSO) {
1110
-                if (! $QSO instanceof EE_Question_Option) {
1110
+                if ( ! $QSO instanceof EE_Question_Option) {
1111 1111
                     $QSO = EE_Question_Option::new_instance(array(
1112 1112
                         'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key,
1113 1113
                         'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO
1114 1114
                     ));
1115 1115
                 }
1116 1116
                 if ($QSO->opt_group()) {
1117
-                    $prepped_answer_options[ $QSO->opt_group() ][] = $QSO;
1117
+                    $prepped_answer_options[$QSO->opt_group()][] = $QSO;
1118 1118
                 } else {
1119 1119
                     $prepped_answer_options[] = $QSO;
1120 1120
                 }
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
         // make sure required is an array
1149 1149
         $required = is_array($required) ? $required : array();
1150 1150
         // and set some defaults
1151
-        $required = array_merge(array( 'label' => '', 'class' => '', 'msg' => '' ), $required);
1151
+        $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required);
1152 1152
         return $required;
1153 1153
     }
1154 1154
 
@@ -1168,22 +1168,22 @@  discard block
 block discarded – undo
1168 1168
             $val_size = strlen($value);
1169 1169
         switch ($val_size) {
1170 1170
             case $val_size < 3:
1171
-                $size =  ' class="nano-lbl"';
1171
+                $size = ' class="nano-lbl"';
1172 1172
                 break;
1173 1173
             case $val_size < 6:
1174
-                $size =  ' class="micro-lbl"';
1174
+                $size = ' class="micro-lbl"';
1175 1175
                 break;
1176 1176
             case $val_size < 12:
1177
-                $size =  ' class="tiny-lbl"';
1177
+                $size = ' class="tiny-lbl"';
1178 1178
                 break;
1179 1179
             case $val_size < 25:
1180
-                $size =  ' class="small-lbl"';
1180
+                $size = ' class="small-lbl"';
1181 1181
                 break;
1182 1182
             case $val_size > 100:
1183
-                $size =  ' class="big-lbl"';
1183
+                $size = ' class="big-lbl"';
1184 1184
                 break;
1185 1185
             default:
1186
-                $size =  ' class="medium-lbl"';
1186
+                $size = ' class="medium-lbl"';
1187 1187
                 break;
1188 1188
         }
1189 1189
         return $size;
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
             // if multiple countries, we'll create option groups within the dropdown
1258 1258
             foreach ($states as $state) {
1259 1259
                 if ($state instanceof EE_State) {
1260
-                    $QSO = EE_Question_Option::new_instance(array (
1260
+                    $QSO = EE_Question_Option::new_instance(array(
1261 1261
                         'QSO_value' => $state->ID(),
1262 1262
                         'QSO_desc' => $state->name(),
1263 1263
                         'QST_ID' => $QST->get('QST_ID'),
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
             // now add countries
1291 1291
             foreach ($countries as $country) {
1292 1292
                 if ($country instanceof EE_Country) {
1293
-                    $QSO = EE_Question_Option::new_instance(array (
1293
+                    $QSO = EE_Question_Option::new_instance(array(
1294 1294
                         'QSO_value' => $country->ID(),
1295 1295
                         'QSO_desc' => $country->name(),
1296 1296
                         'QST_ID' => $QST->get('QST_ID'),
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
         $options = array();
1317 1317
         for ($x = 1; $x <= 12; $x++) {
1318 1318
             $mm = str_pad($x, 2, '0', STR_PAD_LEFT);
1319
-            $options[ (string) $mm ] = (string) $mm;
1319
+            $options[(string) $mm] = (string) $mm;
1320 1320
         }
1321 1321
         return EEH_Form_Fields::prep_answer_options($options);
1322 1322
     }
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
         $next_decade = $current_year + 10;
1337 1337
         for ($x = $current_year; $x <= $next_decade; $x++) {
1338 1338
             $yy = str_pad($x, 2, '0', STR_PAD_LEFT);
1339
-            $options[ (string) $yy ] = (string) $yy;
1339
+            $options[(string) $yy] = (string) $yy;
1340 1340
         }
1341 1341
         return EEH_Form_Fields::prep_answer_options($options);
1342 1342
     }
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
     public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0)
1356 1356
     {
1357 1357
         $_where = array();
1358
-        if (!empty($status)) {
1358
+        if ( ! empty($status)) {
1359 1359
             $_where['STS_ID'] = $status;
1360 1360
         }
1361 1361
 
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
             );
1375 1375
 
1376 1376
         foreach ($regdtts as $regdtt) {
1377
-            $date = $regdtt->reg_month. ' ' . $regdtt->reg_year;
1377
+            $date = $regdtt->reg_month.' '.$regdtt->reg_year;
1378 1378
             $options[] = array(
1379 1379
                 'text' => $date,
1380 1380
                 'id' => $date
@@ -1404,11 +1404,11 @@  discard block
 block discarded – undo
1404 1404
             case 'today':
1405 1405
             case null:
1406 1406
             case 'all':
1407
-                $where['Event.status'] = array( 'NOT IN', array('trash') );
1407
+                $where['Event.status'] = array('NOT IN', array('trash'));
1408 1408
                 break;
1409 1409
 
1410 1410
             case 'draft':
1411
-                $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') );
1411
+                $where['Event.status'] = array('IN', array('draft', 'auto-draft'));
1412 1412
 
1413 1413
             default:
1414 1414
                 $where['Event.status'] = $status;
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
         // categories?
1420 1420
 
1421 1421
 
1422
-        if (!empty($evt_category)) {
1422
+        if ( ! empty($evt_category)) {
1423 1423
             $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1424 1424
             $where['Event.Term_Taxonomy.term_id'] = $evt_category;
1425 1425
         }
@@ -1443,8 +1443,8 @@  discard block
 block discarded – undo
1443 1443
         global $wp_locale;
1444 1444
 
1445 1445
         foreach ($DTTS as $DTT) {
1446
-            $localized_date = $wp_locale->get_month($DTT->dtt_month_num) . ' ' . $DTT->dtt_year;
1447
-            $id = $DTT->dtt_month . ' ' . $DTT->dtt_year;
1446
+            $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year;
1447
+            $id = $DTT->dtt_month.' '.$DTT->dtt_year;
1448 1448
             $options[] = array(
1449 1449
                 'text' => $localized_date,
1450 1450
                 'id' => $id
@@ -1507,10 +1507,10 @@  discard block
 block discarded – undo
1507 1507
             return $btn;
1508 1508
         }
1509 1509
         $text = ! empty($text) ? $text : __('Submit', 'event_espresso');
1510
-        $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>';
1511
-        if (! $input_only) {
1512
-            $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">';
1513
-            $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action . '_nonce', true, false) : '';
1510
+        $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>';
1511
+        if ( ! $input_only) {
1512
+            $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">';
1513
+            $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', true, false) : '';
1514 1514
             $btn_frm .= $btn;
1515 1515
             $btn_frm .= '</form>';
1516 1516
             $btn = $btn_frm;
Please login to merge, or discard this patch.
core/helpers/EEH_Debug_Tools.helper.php 2 patches
Indentation   +679 added lines, -679 removed lines patch added patch discarded remove patch
@@ -15,670 +15,670 @@  discard block
 block discarded – undo
15 15
 class EEH_Debug_Tools
16 16
 {
17 17
 
18
-    /**
19
-     *    instance of the EEH_Autoloader object
20
-     *
21
-     * @var    $_instance
22
-     * @access    private
23
-     */
24
-    private static $_instance;
25
-
26
-    /**
27
-     * @var array
28
-     */
29
-    protected $_memory_usage_points = array();
30
-
31
-
32
-
33
-    /**
34
-     * @singleton method used to instantiate class object
35
-     * @access    public
36
-     * @return EEH_Debug_Tools
37
-     */
38
-    public static function instance()
39
-    {
40
-        // check if class object is instantiated, and instantiated properly
41
-        if (! self::$_instance instanceof EEH_Debug_Tools) {
42
-            self::$_instance = new self();
43
-        }
44
-        return self::$_instance;
45
-    }
46
-
47
-
48
-
49
-    /**
50
-     * private class constructor
51
-     */
52
-    private function __construct()
53
-    {
54
-        // load Kint PHP debugging library
55
-        if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests/kint/Kint.class.php')) {
56
-            // despite EE4 having a check for an existing copy of the Kint debugging class,
57
-            // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
58
-            // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
59
-            // so we've moved it to our test folder so that it is not included with production releases
60
-            // plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
61
-            require_once(EE_PLUGIN_DIR_PATH . 'tests/kint/Kint.class.php');
62
-        }
63
-        // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
64
-        // add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
65
-        // }
66
-        $plugin = basename(EE_PLUGIN_DIR_PATH);
67
-        add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
68
-        add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
69
-        add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
70
-    }
71
-
72
-
73
-
74
-    /**
75
-     *    show_db_name
76
-     *
77
-     * @return void
78
-     */
79
-    public static function show_db_name()
80
-    {
81
-        if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
82
-            echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
83
-                 . DB_NAME
84
-                 . '</p>';
85
-        }
86
-        if (EE_DEBUG) {
87
-            Benchmark::displayResults();
88
-        }
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     *    dump EE_Session object at bottom of page after everything else has happened
95
-     *
96
-     * @return void
97
-     */
98
-    public function espresso_session_footer_dump()
99
-    {
100
-        if ((defined('WP_DEBUG') && WP_DEBUG)
101
-            && ! defined('DOING_AJAX')
102
-            && class_exists('Kint')
103
-            && function_exists('wp_get_current_user')
104
-            && current_user_can('update_core')
105
-            && class_exists('EE_Registry')
106
-        ) {
107
-            Kint::dump(EE_Registry::instance()->SSN->id());
108
-            Kint::dump(EE_Registry::instance()->SSN);
109
-            //          Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
110
-            $this->espresso_list_hooked_functions();
111
-            Benchmark::displayResults();
112
-        }
113
-    }
114
-
115
-
116
-
117
-    /**
118
-     *    List All Hooked Functions
119
-     *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
120
-     *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
121
-     *
122
-     * @param string $tag
123
-     * @return void
124
-     */
125
-    public function espresso_list_hooked_functions($tag = '')
126
-    {
127
-        global $wp_filter;
128
-        echo '<br/><br/><br/><h3>Hooked Functions</h3>';
129
-        if ($tag) {
130
-            $hook[ $tag ] = $wp_filter[ $tag ];
131
-            if (! is_array($hook[ $tag ])) {
132
-                trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
133
-                return;
134
-            }
135
-            echo '<h5>For Tag: ' . $tag . '</h5>';
136
-        } else {
137
-            $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
138
-            ksort($hook);
139
-        }
140
-        foreach ($hook as $tag_name => $priorities) {
141
-            echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
142
-            ksort($priorities);
143
-            foreach ($priorities as $priority => $function) {
144
-                echo $priority;
145
-                foreach ($function as $name => $properties) {
146
-                    echo "\t$name<br />";
147
-                }
148
-            }
149
-        }
150
-    }
151
-
152
-
153
-
154
-    /**
155
-     *    registered_filter_callbacks
156
-     *
157
-     * @param string $hook_name
158
-     * @return array
159
-     */
160
-    public static function registered_filter_callbacks($hook_name = '')
161
-    {
162
-        $filters = array();
163
-        global $wp_filter;
164
-        if (isset($wp_filter[ $hook_name ])) {
165
-            $filters[ $hook_name ] = array();
166
-            foreach ($wp_filter[ $hook_name ] as $priority => $callbacks) {
167
-                $filters[ $hook_name ][ $priority ] = array();
168
-                foreach ($callbacks as $callback) {
169
-                    $filters[ $hook_name ][ $priority ][] = $callback['function'];
170
-                }
171
-            }
172
-        }
173
-        return $filters;
174
-    }
175
-
176
-
177
-
178
-    /**
179
-     *    captures plugin activation errors for debugging
180
-     *
181
-     * @return void
182
-     * @throws EE_Error
183
-     */
184
-    public static function ee_plugin_activation_errors()
185
-    {
186
-        if (WP_DEBUG) {
187
-            $activation_errors = ob_get_contents();
188
-            if (! empty($activation_errors)) {
189
-                $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
190
-            }
191
-            espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
192
-            if (class_exists('EEH_File')) {
193
-                try {
194
-                    EEH_File::ensure_file_exists_and_is_writable(
195
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html'
196
-                    );
197
-                    EEH_File::write_to_file(
198
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html',
199
-                        $activation_errors
200
-                    );
201
-                } catch (EE_Error $e) {
202
-                    EE_Error::add_error(
203
-                        sprintf(
204
-                            __(
205
-                                'The Event Espresso activation errors file could not be setup because: %s',
206
-                                'event_espresso'
207
-                            ),
208
-                            $e->getMessage()
209
-                        ),
210
-                        __FILE__,
211
-                        __FUNCTION__,
212
-                        __LINE__
213
-                    );
214
-                }
215
-            } else {
216
-                // old school attempt
217
-                file_put_contents(
218
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html',
219
-                    $activation_errors
220
-                );
221
-            }
222
-            $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
223
-            update_option('ee_plugin_activation_errors', $activation_errors);
224
-        }
225
-    }
226
-
227
-
228
-
229
-    /**
230
-     * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
231
-     * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
232
-     * or we want to make sure they use something the right way.
233
-     *
234
-     * @access public
235
-     * @param string $function      The function that was called
236
-     * @param string $message       A message explaining what has been done incorrectly
237
-     * @param string $version       The version of Event Espresso where the error was added
238
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
239
-     *                              for a deprecated function. This allows deprecation to occur during one version,
240
-     *                              but not have any notices appear until a later version. This allows developers
241
-     *                              extra time to update their code before notices appear.
242
-     * @param int    $error_type
243
-     * @uses   trigger_error()
244
-     */
245
-    public function doing_it_wrong(
246
-        $function,
247
-        $message,
248
-        $version,
249
-        $applies_when = '',
250
-        $error_type = null
251
-    ) {
252
-        $applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
253
-        $error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
254
-        // because we swapped the parameter order around for the last two params,
255
-        // let's verify that some third party isn't still passing an error type value for the third param
256
-        if (is_int($applies_when)) {
257
-            $error_type = $applies_when;
258
-            $applies_when = espresso_version();
259
-        }
260
-        // if not displaying notices yet, then just leave
261
-        if (version_compare(espresso_version(), $applies_when, '<')) {
262
-            return;
263
-        }
264
-        do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
265
-        $version = $version === null
266
-            ? ''
267
-            : sprintf(
268
-                __('(This message was added in version %s of Event Espresso)', 'event_espresso'),
269
-                $version
270
-            );
271
-        $error_message = sprintf(
272
-            esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
273
-            $function,
274
-            '<strong>',
275
-            '</strong>',
276
-            $message,
277
-            $version
278
-        );
279
-        // don't trigger error if doing ajax,
280
-        // instead we'll add a transient EE_Error notice that in theory should show on the next request.
281
-        if (defined('DOING_AJAX') && DOING_AJAX) {
282
-            $error_message .= ' ' . esc_html__(
283
-                'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
284
-                'event_espresso'
285
-            );
286
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
287
-            $error_message .= '<ul><li>';
288
-            $error_message .= implode('</li><li>', $request->requestParams());
289
-            $error_message .= '</ul>';
290
-            EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
291
-            // now we set this on the transient so it shows up on the next request.
292
-            EE_Error::get_notices(false, true);
293
-        } else {
294
-            trigger_error($error_message, $error_type);
295
-        }
296
-    }
297
-
298
-
299
-
300
-
301
-    /**
302
-     * Logger helpers
303
-     */
304
-    /**
305
-     * debug
306
-     *
307
-     * @param string $class
308
-     * @param string $func
309
-     * @param string $line
310
-     * @param array  $info
311
-     * @param bool   $display_request
312
-     * @param string $debug_index
313
-     * @param string $debug_key
314
-     * @throws EE_Error
315
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
316
-     */
317
-    public static function log(
318
-        $class = '',
319
-        $func = '',
320
-        $line = '',
321
-        $info = array(),
322
-        $display_request = false,
323
-        $debug_index = '',
324
-        $debug_key = 'EE_DEBUG_SPCO'
325
-    ) {
326
-        if (WP_DEBUG) {
327
-            $debug_key = $debug_key . '_' . EE_Session::instance()->id();
328
-            $debug_data = get_option($debug_key, array());
329
-            $default_data = array(
330
-                $class => $func . '() : ' . $line,
331
-            );
332
-            // don't serialize objects
333
-            $info = self::strip_objects($info);
334
-            $index = ! empty($debug_index) ? $debug_index : 0;
335
-            if (! isset($debug_data[ $index ])) {
336
-                $debug_data[ $index ] = array();
337
-            }
338
-            $debug_data[ $index ][ microtime() ] = array_merge($default_data, $info);
339
-            update_option($debug_key, $debug_data);
340
-        }
341
-    }
342
-
343
-
344
-
345
-    /**
346
-     * strip_objects
347
-     *
348
-     * @param array $info
349
-     * @return array
350
-     */
351
-    public static function strip_objects($info = array())
352
-    {
353
-        foreach ($info as $key => $value) {
354
-            if (is_array($value)) {
355
-                $info[ $key ] = self::strip_objects($value);
356
-            } elseif (is_object($value)) {
357
-                $object_class = get_class($value);
358
-                $info[ $object_class ] = array();
359
-                $info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
360
-                if (method_exists($value, 'ID')) {
361
-                    $info[ $object_class ]['ID'] = $value->ID();
362
-                }
363
-                if (method_exists($value, 'status')) {
364
-                    $info[ $object_class ]['status'] = $value->status();
365
-                } elseif (method_exists($value, 'status_ID')) {
366
-                    $info[ $object_class ]['status'] = $value->status_ID();
367
-                }
368
-                unset($info[ $key ]);
369
-            }
370
-        }
371
-        return (array) $info;
372
-    }
373
-
374
-
375
-
376
-    /**
377
-     * @param mixed      $var
378
-     * @param string     $var_name
379
-     * @param string     $file
380
-     * @param int|string $line
381
-     * @param int|string $heading_tag
382
-     * @param bool       $die
383
-     * @param string     $margin
384
-     */
385
-    public static function printv(
386
-        $var,
387
-        $var_name = '',
388
-        $file = '',
389
-        $line = '',
390
-        $heading_tag = 5,
391
-        $die = false,
392
-        $margin = ''
393
-    ) {
394
-        $var_name = ! $var_name ? 'string' : $var_name;
395
-        $var_name = ucwords(str_replace('$', '', $var_name));
396
-        $is_method = method_exists($var_name, $var);
397
-        $var_name = ucwords(str_replace('_', ' ', $var_name));
398
-        $heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
399
-        $result = EEH_Debug_Tools::headingSpacer($heading_tag);
400
-        $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
401
-        $result .= $is_method
402
-            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
-            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
404
-        $result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
405
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
406
-        if ($die) {
407
-            die($result);
408
-        }
409
-        echo $result;
410
-    }
411
-
412
-
413
-    protected static function headingTag($heading_tag)
414
-    {
415
-        $heading_tag = absint($heading_tag);
416
-        return $heading_tag > 0 && $heading_tag < 7 ? "h{$heading_tag}" : 'h5';
417
-    }
418
-
419
-
420
-    protected static function headingSpacer($heading_tag)
421
-    {
422
-        return EEH_Debug_Tools::plainOutput() && ($heading_tag === 'h1' || $heading_tag === 'h2')
423
-            ? "\n"
424
-            : '';
425
-    }
426
-
427
-
428
-    protected static function plainOutput()
429
-    {
430
-        return defined('EE_TESTS_DIR')
431
-               || (defined('DOING_AJAX') && DOING_AJAX)
432
-               || (
433
-                   isset($_SERVER['REQUEST_URI'])
434
-                   && strpos(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), 'wp-json') !== false
435
-               );
436
-    }
437
-
438
-
439
-    /**
440
-     * @param string $var_name
441
-     * @param string $heading_tag
442
-     * @param string $margin
443
-     * @param int    $line
444
-     * @return string
445
-     */
446
-    protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '', $line = 0)
447
-    {
448
-        if (EEH_Debug_Tools::plainOutput()) {
449
-            $heading = '';
450
-            if ($heading_tag === 'h1' || $heading_tag === 'h2') {
451
-                $heading .= "\n";
452
-            }
453
-            $heading .= "\n{$line}) {$var_name}";
454
-            return $heading;
455
-        }
456
-        $margin = "25px 0 0 {$margin}";
457
-        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
458
-    }
459
-
460
-
461
-
462
-    /**
463
-     * @param string $heading_tag
464
-     * @return string
465
-     */
466
-    protected static function headingX($heading_tag = 'h5')
467
-    {
468
-        if (EEH_Debug_Tools::plainOutput()) {
469
-            return '';
470
-        }
471
-        return '</' . $heading_tag . '>';
472
-    }
473
-
474
-
475
-
476
-    /**
477
-     * @param string $content
478
-     * @return string
479
-     */
480
-    protected static function grey_span($content = '')
481
-    {
482
-        if (EEH_Debug_Tools::plainOutput()) {
483
-            return $content;
484
-        }
485
-        return '<span style="color:#999">' . $content . '</span>';
486
-    }
487
-
488
-
489
-
490
-    /**
491
-     * @param string $file
492
-     * @param int    $line
493
-     * @return string
494
-     */
495
-    protected static function file_and_line($file, $line, $heading_tag)
496
-    {
497
-        if ($file === '' || $line === '') {
498
-            return '';
499
-        }
500
-        $file = str_replace(EE_PLUGIN_DIR_PATH, '/', $file);
501
-        if (EEH_Debug_Tools::plainOutput()) {
502
-            if ($heading_tag === 'h1' || $heading_tag === 'h2') {
503
-                return " ({$file})";
504
-            }
505
-            return '';
506
-        }
507
-        return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
508
-               . $file
509
-               . '<br />line no: '
510
-               . $line
511
-               . '</span>';
512
-    }
513
-
514
-
515
-
516
-    /**
517
-     * @param string $content
518
-     * @return string
519
-     */
520
-    protected static function orange_span($content = '')
521
-    {
522
-        if (EEH_Debug_Tools::plainOutput()) {
523
-            return $content;
524
-        }
525
-        return '<span style="color:#E76700">' . $content . '</span>';
526
-    }
527
-
528
-
529
-
530
-    /**
531
-     * @param mixed $var
532
-     * @return string
533
-     */
534
-    protected static function pre_span($var)
535
-    {
536
-        ob_start();
537
-        var_dump($var);
538
-        $var = ob_get_clean();
539
-        if (EEH_Debug_Tools::plainOutput()) {
540
-            return $var;
541
-        }
542
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
543
-    }
544
-
545
-
546
-
547
-    /**
548
-     * @param mixed      $var
549
-     * @param string     $var_name
550
-     * @param string     $file
551
-     * @param int|string $line
552
-     * @param int|string $heading_tag
553
-     * @param bool       $die
554
-     */
555
-    public static function printr(
556
-        $var,
557
-        $var_name = '',
558
-        $file = '',
559
-        $line = '',
560
-        $heading_tag = 5,
561
-        $die = false
562
-    ) {
563
-        // return;
564
-        $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
565
-        $margin = is_admin() ? ' 180px' : '0';
566
-        // $print_r = false;
567
-        if (is_string($var)) {
568
-            EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
569
-            return;
570
-        }
571
-        if (is_object($var)) {
572
-            $var_name = ! $var_name ? 'object' : $var_name;
573
-            // $print_r = true;
574
-        } elseif (is_array($var)) {
575
-            $var_name = ! $var_name ? 'array' : $var_name;
576
-            // $print_r = true;
577
-        } elseif (is_numeric($var)) {
578
-            $var_name = ! $var_name ? 'numeric' : $var_name;
579
-        } elseif ($var === null) {
580
-            $var_name = ! $var_name ? 'null' : $var_name;
581
-        }
582
-        $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
583
-        $heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
584
-        $result = EEH_Debug_Tools::headingSpacer($heading_tag);
585
-        $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
586
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
587
-            EEH_Debug_Tools::pre_span($var)
588
-        );
589
-        $result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
590
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
591
-        if ($die) {
592
-            die($result);
593
-        }
594
-        echo $result;
595
-    }
596
-
597
-
598
-
599
-    /******************** deprecated ********************/
600
-
601
-
602
-
603
-    /**
604
-     * @deprecated 4.9.39.rc.034
605
-     */
606
-    public function reset_times()
607
-    {
608
-        Benchmark::resetTimes();
609
-    }
610
-
611
-
612
-
613
-    /**
614
-     * @deprecated 4.9.39.rc.034
615
-     * @param null $timer_name
616
-     */
617
-    public function start_timer($timer_name = null)
618
-    {
619
-        Benchmark::startTimer($timer_name);
620
-    }
621
-
622
-
623
-
624
-    /**
625
-     * @deprecated 4.9.39.rc.034
626
-     * @param string $timer_name
627
-     */
628
-    public function stop_timer($timer_name = '')
629
-    {
630
-        Benchmark::stopTimer($timer_name);
631
-    }
632
-
633
-
634
-
635
-    /**
636
-     * @deprecated 4.9.39.rc.034
637
-     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
638
-     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
639
-     * @return void
640
-     */
641
-    public function measure_memory($label, $output_now = false)
642
-    {
643
-        Benchmark::measureMemory($label, $output_now);
644
-    }
645
-
646
-
647
-
648
-    /**
649
-     * @deprecated 4.9.39.rc.034
650
-     * @param int $size
651
-     * @return string
652
-     */
653
-    public function convert($size)
654
-    {
655
-        return Benchmark::convert($size);
656
-    }
657
-
658
-
659
-
660
-    /**
661
-     * @deprecated 4.9.39.rc.034
662
-     * @param bool $output_now
663
-     * @return string
664
-     */
665
-    public function show_times($output_now = true)
666
-    {
667
-        return Benchmark::displayResults($output_now);
668
-    }
669
-
670
-
671
-
672
-    /**
673
-     * @deprecated 4.9.39.rc.034
674
-     * @param string $timer_name
675
-     * @param float  $total_time
676
-     * @return string
677
-     */
678
-    public function format_time($timer_name, $total_time)
679
-    {
680
-        return Benchmark::formatTime($timer_name, $total_time);
681
-    }
18
+	/**
19
+	 *    instance of the EEH_Autoloader object
20
+	 *
21
+	 * @var    $_instance
22
+	 * @access    private
23
+	 */
24
+	private static $_instance;
25
+
26
+	/**
27
+	 * @var array
28
+	 */
29
+	protected $_memory_usage_points = array();
30
+
31
+
32
+
33
+	/**
34
+	 * @singleton method used to instantiate class object
35
+	 * @access    public
36
+	 * @return EEH_Debug_Tools
37
+	 */
38
+	public static function instance()
39
+	{
40
+		// check if class object is instantiated, and instantiated properly
41
+		if (! self::$_instance instanceof EEH_Debug_Tools) {
42
+			self::$_instance = new self();
43
+		}
44
+		return self::$_instance;
45
+	}
46
+
47
+
48
+
49
+	/**
50
+	 * private class constructor
51
+	 */
52
+	private function __construct()
53
+	{
54
+		// load Kint PHP debugging library
55
+		if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests/kint/Kint.class.php')) {
56
+			// despite EE4 having a check for an existing copy of the Kint debugging class,
57
+			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
58
+			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
59
+			// so we've moved it to our test folder so that it is not included with production releases
60
+			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
61
+			require_once(EE_PLUGIN_DIR_PATH . 'tests/kint/Kint.class.php');
62
+		}
63
+		// if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
64
+		// add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
65
+		// }
66
+		$plugin = basename(EE_PLUGIN_DIR_PATH);
67
+		add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
68
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
69
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
70
+	}
71
+
72
+
73
+
74
+	/**
75
+	 *    show_db_name
76
+	 *
77
+	 * @return void
78
+	 */
79
+	public static function show_db_name()
80
+	{
81
+		if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
82
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
83
+				 . DB_NAME
84
+				 . '</p>';
85
+		}
86
+		if (EE_DEBUG) {
87
+			Benchmark::displayResults();
88
+		}
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 *    dump EE_Session object at bottom of page after everything else has happened
95
+	 *
96
+	 * @return void
97
+	 */
98
+	public function espresso_session_footer_dump()
99
+	{
100
+		if ((defined('WP_DEBUG') && WP_DEBUG)
101
+			&& ! defined('DOING_AJAX')
102
+			&& class_exists('Kint')
103
+			&& function_exists('wp_get_current_user')
104
+			&& current_user_can('update_core')
105
+			&& class_exists('EE_Registry')
106
+		) {
107
+			Kint::dump(EE_Registry::instance()->SSN->id());
108
+			Kint::dump(EE_Registry::instance()->SSN);
109
+			//          Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
110
+			$this->espresso_list_hooked_functions();
111
+			Benchmark::displayResults();
112
+		}
113
+	}
114
+
115
+
116
+
117
+	/**
118
+	 *    List All Hooked Functions
119
+	 *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
120
+	 *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
121
+	 *
122
+	 * @param string $tag
123
+	 * @return void
124
+	 */
125
+	public function espresso_list_hooked_functions($tag = '')
126
+	{
127
+		global $wp_filter;
128
+		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
129
+		if ($tag) {
130
+			$hook[ $tag ] = $wp_filter[ $tag ];
131
+			if (! is_array($hook[ $tag ])) {
132
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
133
+				return;
134
+			}
135
+			echo '<h5>For Tag: ' . $tag . '</h5>';
136
+		} else {
137
+			$hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
138
+			ksort($hook);
139
+		}
140
+		foreach ($hook as $tag_name => $priorities) {
141
+			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
142
+			ksort($priorities);
143
+			foreach ($priorities as $priority => $function) {
144
+				echo $priority;
145
+				foreach ($function as $name => $properties) {
146
+					echo "\t$name<br />";
147
+				}
148
+			}
149
+		}
150
+	}
151
+
152
+
153
+
154
+	/**
155
+	 *    registered_filter_callbacks
156
+	 *
157
+	 * @param string $hook_name
158
+	 * @return array
159
+	 */
160
+	public static function registered_filter_callbacks($hook_name = '')
161
+	{
162
+		$filters = array();
163
+		global $wp_filter;
164
+		if (isset($wp_filter[ $hook_name ])) {
165
+			$filters[ $hook_name ] = array();
166
+			foreach ($wp_filter[ $hook_name ] as $priority => $callbacks) {
167
+				$filters[ $hook_name ][ $priority ] = array();
168
+				foreach ($callbacks as $callback) {
169
+					$filters[ $hook_name ][ $priority ][] = $callback['function'];
170
+				}
171
+			}
172
+		}
173
+		return $filters;
174
+	}
175
+
176
+
177
+
178
+	/**
179
+	 *    captures plugin activation errors for debugging
180
+	 *
181
+	 * @return void
182
+	 * @throws EE_Error
183
+	 */
184
+	public static function ee_plugin_activation_errors()
185
+	{
186
+		if (WP_DEBUG) {
187
+			$activation_errors = ob_get_contents();
188
+			if (! empty($activation_errors)) {
189
+				$activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
190
+			}
191
+			espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
192
+			if (class_exists('EEH_File')) {
193
+				try {
194
+					EEH_File::ensure_file_exists_and_is_writable(
195
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html'
196
+					);
197
+					EEH_File::write_to_file(
198
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html',
199
+						$activation_errors
200
+					);
201
+				} catch (EE_Error $e) {
202
+					EE_Error::add_error(
203
+						sprintf(
204
+							__(
205
+								'The Event Espresso activation errors file could not be setup because: %s',
206
+								'event_espresso'
207
+							),
208
+							$e->getMessage()
209
+						),
210
+						__FILE__,
211
+						__FUNCTION__,
212
+						__LINE__
213
+					);
214
+				}
215
+			} else {
216
+				// old school attempt
217
+				file_put_contents(
218
+					EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html',
219
+					$activation_errors
220
+				);
221
+			}
222
+			$activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
223
+			update_option('ee_plugin_activation_errors', $activation_errors);
224
+		}
225
+	}
226
+
227
+
228
+
229
+	/**
230
+	 * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
231
+	 * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
232
+	 * or we want to make sure they use something the right way.
233
+	 *
234
+	 * @access public
235
+	 * @param string $function      The function that was called
236
+	 * @param string $message       A message explaining what has been done incorrectly
237
+	 * @param string $version       The version of Event Espresso where the error was added
238
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
239
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
240
+	 *                              but not have any notices appear until a later version. This allows developers
241
+	 *                              extra time to update their code before notices appear.
242
+	 * @param int    $error_type
243
+	 * @uses   trigger_error()
244
+	 */
245
+	public function doing_it_wrong(
246
+		$function,
247
+		$message,
248
+		$version,
249
+		$applies_when = '',
250
+		$error_type = null
251
+	) {
252
+		$applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
253
+		$error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
254
+		// because we swapped the parameter order around for the last two params,
255
+		// let's verify that some third party isn't still passing an error type value for the third param
256
+		if (is_int($applies_when)) {
257
+			$error_type = $applies_when;
258
+			$applies_when = espresso_version();
259
+		}
260
+		// if not displaying notices yet, then just leave
261
+		if (version_compare(espresso_version(), $applies_when, '<')) {
262
+			return;
263
+		}
264
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
265
+		$version = $version === null
266
+			? ''
267
+			: sprintf(
268
+				__('(This message was added in version %s of Event Espresso)', 'event_espresso'),
269
+				$version
270
+			);
271
+		$error_message = sprintf(
272
+			esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
273
+			$function,
274
+			'<strong>',
275
+			'</strong>',
276
+			$message,
277
+			$version
278
+		);
279
+		// don't trigger error if doing ajax,
280
+		// instead we'll add a transient EE_Error notice that in theory should show on the next request.
281
+		if (defined('DOING_AJAX') && DOING_AJAX) {
282
+			$error_message .= ' ' . esc_html__(
283
+				'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
284
+				'event_espresso'
285
+			);
286
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
287
+			$error_message .= '<ul><li>';
288
+			$error_message .= implode('</li><li>', $request->requestParams());
289
+			$error_message .= '</ul>';
290
+			EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
291
+			// now we set this on the transient so it shows up on the next request.
292
+			EE_Error::get_notices(false, true);
293
+		} else {
294
+			trigger_error($error_message, $error_type);
295
+		}
296
+	}
297
+
298
+
299
+
300
+
301
+	/**
302
+	 * Logger helpers
303
+	 */
304
+	/**
305
+	 * debug
306
+	 *
307
+	 * @param string $class
308
+	 * @param string $func
309
+	 * @param string $line
310
+	 * @param array  $info
311
+	 * @param bool   $display_request
312
+	 * @param string $debug_index
313
+	 * @param string $debug_key
314
+	 * @throws EE_Error
315
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
316
+	 */
317
+	public static function log(
318
+		$class = '',
319
+		$func = '',
320
+		$line = '',
321
+		$info = array(),
322
+		$display_request = false,
323
+		$debug_index = '',
324
+		$debug_key = 'EE_DEBUG_SPCO'
325
+	) {
326
+		if (WP_DEBUG) {
327
+			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
328
+			$debug_data = get_option($debug_key, array());
329
+			$default_data = array(
330
+				$class => $func . '() : ' . $line,
331
+			);
332
+			// don't serialize objects
333
+			$info = self::strip_objects($info);
334
+			$index = ! empty($debug_index) ? $debug_index : 0;
335
+			if (! isset($debug_data[ $index ])) {
336
+				$debug_data[ $index ] = array();
337
+			}
338
+			$debug_data[ $index ][ microtime() ] = array_merge($default_data, $info);
339
+			update_option($debug_key, $debug_data);
340
+		}
341
+	}
342
+
343
+
344
+
345
+	/**
346
+	 * strip_objects
347
+	 *
348
+	 * @param array $info
349
+	 * @return array
350
+	 */
351
+	public static function strip_objects($info = array())
352
+	{
353
+		foreach ($info as $key => $value) {
354
+			if (is_array($value)) {
355
+				$info[ $key ] = self::strip_objects($value);
356
+			} elseif (is_object($value)) {
357
+				$object_class = get_class($value);
358
+				$info[ $object_class ] = array();
359
+				$info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
360
+				if (method_exists($value, 'ID')) {
361
+					$info[ $object_class ]['ID'] = $value->ID();
362
+				}
363
+				if (method_exists($value, 'status')) {
364
+					$info[ $object_class ]['status'] = $value->status();
365
+				} elseif (method_exists($value, 'status_ID')) {
366
+					$info[ $object_class ]['status'] = $value->status_ID();
367
+				}
368
+				unset($info[ $key ]);
369
+			}
370
+		}
371
+		return (array) $info;
372
+	}
373
+
374
+
375
+
376
+	/**
377
+	 * @param mixed      $var
378
+	 * @param string     $var_name
379
+	 * @param string     $file
380
+	 * @param int|string $line
381
+	 * @param int|string $heading_tag
382
+	 * @param bool       $die
383
+	 * @param string     $margin
384
+	 */
385
+	public static function printv(
386
+		$var,
387
+		$var_name = '',
388
+		$file = '',
389
+		$line = '',
390
+		$heading_tag = 5,
391
+		$die = false,
392
+		$margin = ''
393
+	) {
394
+		$var_name = ! $var_name ? 'string' : $var_name;
395
+		$var_name = ucwords(str_replace('$', '', $var_name));
396
+		$is_method = method_exists($var_name, $var);
397
+		$var_name = ucwords(str_replace('_', ' ', $var_name));
398
+		$heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
399
+		$result = EEH_Debug_Tools::headingSpacer($heading_tag);
400
+		$result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
401
+		$result .= $is_method
402
+			? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
+			: EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
404
+		$result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
405
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
406
+		if ($die) {
407
+			die($result);
408
+		}
409
+		echo $result;
410
+	}
411
+
412
+
413
+	protected static function headingTag($heading_tag)
414
+	{
415
+		$heading_tag = absint($heading_tag);
416
+		return $heading_tag > 0 && $heading_tag < 7 ? "h{$heading_tag}" : 'h5';
417
+	}
418
+
419
+
420
+	protected static function headingSpacer($heading_tag)
421
+	{
422
+		return EEH_Debug_Tools::plainOutput() && ($heading_tag === 'h1' || $heading_tag === 'h2')
423
+			? "\n"
424
+			: '';
425
+	}
426
+
427
+
428
+	protected static function plainOutput()
429
+	{
430
+		return defined('EE_TESTS_DIR')
431
+			   || (defined('DOING_AJAX') && DOING_AJAX)
432
+			   || (
433
+				   isset($_SERVER['REQUEST_URI'])
434
+				   && strpos(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), 'wp-json') !== false
435
+			   );
436
+	}
437
+
438
+
439
+	/**
440
+	 * @param string $var_name
441
+	 * @param string $heading_tag
442
+	 * @param string $margin
443
+	 * @param int    $line
444
+	 * @return string
445
+	 */
446
+	protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '', $line = 0)
447
+	{
448
+		if (EEH_Debug_Tools::plainOutput()) {
449
+			$heading = '';
450
+			if ($heading_tag === 'h1' || $heading_tag === 'h2') {
451
+				$heading .= "\n";
452
+			}
453
+			$heading .= "\n{$line}) {$var_name}";
454
+			return $heading;
455
+		}
456
+		$margin = "25px 0 0 {$margin}";
457
+		return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
458
+	}
459
+
460
+
461
+
462
+	/**
463
+	 * @param string $heading_tag
464
+	 * @return string
465
+	 */
466
+	protected static function headingX($heading_tag = 'h5')
467
+	{
468
+		if (EEH_Debug_Tools::plainOutput()) {
469
+			return '';
470
+		}
471
+		return '</' . $heading_tag . '>';
472
+	}
473
+
474
+
475
+
476
+	/**
477
+	 * @param string $content
478
+	 * @return string
479
+	 */
480
+	protected static function grey_span($content = '')
481
+	{
482
+		if (EEH_Debug_Tools::plainOutput()) {
483
+			return $content;
484
+		}
485
+		return '<span style="color:#999">' . $content . '</span>';
486
+	}
487
+
488
+
489
+
490
+	/**
491
+	 * @param string $file
492
+	 * @param int    $line
493
+	 * @return string
494
+	 */
495
+	protected static function file_and_line($file, $line, $heading_tag)
496
+	{
497
+		if ($file === '' || $line === '') {
498
+			return '';
499
+		}
500
+		$file = str_replace(EE_PLUGIN_DIR_PATH, '/', $file);
501
+		if (EEH_Debug_Tools::plainOutput()) {
502
+			if ($heading_tag === 'h1' || $heading_tag === 'h2') {
503
+				return " ({$file})";
504
+			}
505
+			return '';
506
+		}
507
+		return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
508
+			   . $file
509
+			   . '<br />line no: '
510
+			   . $line
511
+			   . '</span>';
512
+	}
513
+
514
+
515
+
516
+	/**
517
+	 * @param string $content
518
+	 * @return string
519
+	 */
520
+	protected static function orange_span($content = '')
521
+	{
522
+		if (EEH_Debug_Tools::plainOutput()) {
523
+			return $content;
524
+		}
525
+		return '<span style="color:#E76700">' . $content . '</span>';
526
+	}
527
+
528
+
529
+
530
+	/**
531
+	 * @param mixed $var
532
+	 * @return string
533
+	 */
534
+	protected static function pre_span($var)
535
+	{
536
+		ob_start();
537
+		var_dump($var);
538
+		$var = ob_get_clean();
539
+		if (EEH_Debug_Tools::plainOutput()) {
540
+			return $var;
541
+		}
542
+		return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
543
+	}
544
+
545
+
546
+
547
+	/**
548
+	 * @param mixed      $var
549
+	 * @param string     $var_name
550
+	 * @param string     $file
551
+	 * @param int|string $line
552
+	 * @param int|string $heading_tag
553
+	 * @param bool       $die
554
+	 */
555
+	public static function printr(
556
+		$var,
557
+		$var_name = '',
558
+		$file = '',
559
+		$line = '',
560
+		$heading_tag = 5,
561
+		$die = false
562
+	) {
563
+		// return;
564
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
565
+		$margin = is_admin() ? ' 180px' : '0';
566
+		// $print_r = false;
567
+		if (is_string($var)) {
568
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
569
+			return;
570
+		}
571
+		if (is_object($var)) {
572
+			$var_name = ! $var_name ? 'object' : $var_name;
573
+			// $print_r = true;
574
+		} elseif (is_array($var)) {
575
+			$var_name = ! $var_name ? 'array' : $var_name;
576
+			// $print_r = true;
577
+		} elseif (is_numeric($var)) {
578
+			$var_name = ! $var_name ? 'numeric' : $var_name;
579
+		} elseif ($var === null) {
580
+			$var_name = ! $var_name ? 'null' : $var_name;
581
+		}
582
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
583
+		$heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
584
+		$result = EEH_Debug_Tools::headingSpacer($heading_tag);
585
+		$result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
586
+		$result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
587
+			EEH_Debug_Tools::pre_span($var)
588
+		);
589
+		$result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
590
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
591
+		if ($die) {
592
+			die($result);
593
+		}
594
+		echo $result;
595
+	}
596
+
597
+
598
+
599
+	/******************** deprecated ********************/
600
+
601
+
602
+
603
+	/**
604
+	 * @deprecated 4.9.39.rc.034
605
+	 */
606
+	public function reset_times()
607
+	{
608
+		Benchmark::resetTimes();
609
+	}
610
+
611
+
612
+
613
+	/**
614
+	 * @deprecated 4.9.39.rc.034
615
+	 * @param null $timer_name
616
+	 */
617
+	public function start_timer($timer_name = null)
618
+	{
619
+		Benchmark::startTimer($timer_name);
620
+	}
621
+
622
+
623
+
624
+	/**
625
+	 * @deprecated 4.9.39.rc.034
626
+	 * @param string $timer_name
627
+	 */
628
+	public function stop_timer($timer_name = '')
629
+	{
630
+		Benchmark::stopTimer($timer_name);
631
+	}
632
+
633
+
634
+
635
+	/**
636
+	 * @deprecated 4.9.39.rc.034
637
+	 * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
638
+	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
639
+	 * @return void
640
+	 */
641
+	public function measure_memory($label, $output_now = false)
642
+	{
643
+		Benchmark::measureMemory($label, $output_now);
644
+	}
645
+
646
+
647
+
648
+	/**
649
+	 * @deprecated 4.9.39.rc.034
650
+	 * @param int $size
651
+	 * @return string
652
+	 */
653
+	public function convert($size)
654
+	{
655
+		return Benchmark::convert($size);
656
+	}
657
+
658
+
659
+
660
+	/**
661
+	 * @deprecated 4.9.39.rc.034
662
+	 * @param bool $output_now
663
+	 * @return string
664
+	 */
665
+	public function show_times($output_now = true)
666
+	{
667
+		return Benchmark::displayResults($output_now);
668
+	}
669
+
670
+
671
+
672
+	/**
673
+	 * @deprecated 4.9.39.rc.034
674
+	 * @param string $timer_name
675
+	 * @param float  $total_time
676
+	 * @return string
677
+	 */
678
+	public function format_time($timer_name, $total_time)
679
+	{
680
+		return Benchmark::formatTime($timer_name, $total_time);
681
+	}
682 682
 }
683 683
 
684 684
 
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
689 689
  */
690 690
 if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
691
-    function dump_wp_query()
692
-    {
693
-        global $wp_query;
694
-        d($wp_query);
695
-    }
691
+	function dump_wp_query()
692
+	{
693
+		global $wp_query;
694
+		d($wp_query);
695
+	}
696 696
 }
697 697
 /**
698 698
  * borrowed from Kint Debugger
699 699
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
700 700
  */
701 701
 if (class_exists('Kint') && ! function_exists('dump_wp')) {
702
-    function dump_wp()
703
-    {
704
-        global $wp;
705
-        d($wp);
706
-    }
702
+	function dump_wp()
703
+	{
704
+		global $wp;
705
+		d($wp);
706
+	}
707 707
 }
708 708
 /**
709 709
  * borrowed from Kint Debugger
710 710
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
711 711
  */
712 712
 if (class_exists('Kint') && ! function_exists('dump_post')) {
713
-    function dump_post()
714
-    {
715
-        global $post;
716
-        d($post);
717
-    }
713
+	function dump_post()
714
+	{
715
+		global $post;
716
+		d($post);
717
+	}
718 718
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     public static function instance()
39 39
     {
40 40
         // check if class object is instantiated, and instantiated properly
41
-        if (! self::$_instance instanceof EEH_Debug_Tools) {
41
+        if ( ! self::$_instance instanceof EEH_Debug_Tools) {
42 42
             self::$_instance = new self();
43 43
         }
44 44
         return self::$_instance;
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
     private function __construct()
53 53
     {
54 54
         // load Kint PHP debugging library
55
-        if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests/kint/Kint.class.php')) {
55
+        if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests/kint/Kint.class.php')) {
56 56
             // despite EE4 having a check for an existing copy of the Kint debugging class,
57 57
             // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
58 58
             // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
59 59
             // so we've moved it to our test folder so that it is not included with production releases
60 60
             // plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
61
-            require_once(EE_PLUGIN_DIR_PATH . 'tests/kint/Kint.class.php');
61
+            require_once(EE_PLUGIN_DIR_PATH.'tests/kint/Kint.class.php');
62 62
         }
63 63
         // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
64 64
         // add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public static function show_db_name()
80 80
     {
81
-        if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
81
+        if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
82 82
             echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
83 83
                  . DB_NAME
84 84
                  . '</p>';
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
         global $wp_filter;
128 128
         echo '<br/><br/><br/><h3>Hooked Functions</h3>';
129 129
         if ($tag) {
130
-            $hook[ $tag ] = $wp_filter[ $tag ];
131
-            if (! is_array($hook[ $tag ])) {
130
+            $hook[$tag] = $wp_filter[$tag];
131
+            if ( ! is_array($hook[$tag])) {
132 132
                 trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
133 133
                 return;
134 134
             }
135
-            echo '<h5>For Tag: ' . $tag . '</h5>';
135
+            echo '<h5>For Tag: '.$tag.'</h5>';
136 136
         } else {
137 137
             $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
138 138
             ksort($hook);
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
     {
162 162
         $filters = array();
163 163
         global $wp_filter;
164
-        if (isset($wp_filter[ $hook_name ])) {
165
-            $filters[ $hook_name ] = array();
166
-            foreach ($wp_filter[ $hook_name ] as $priority => $callbacks) {
167
-                $filters[ $hook_name ][ $priority ] = array();
164
+        if (isset($wp_filter[$hook_name])) {
165
+            $filters[$hook_name] = array();
166
+            foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
167
+                $filters[$hook_name][$priority] = array();
168 168
                 foreach ($callbacks as $callback) {
169
-                    $filters[ $hook_name ][ $priority ][] = $callback['function'];
169
+                    $filters[$hook_name][$priority][] = $callback['function'];
170 170
                 }
171 171
             }
172 172
         }
@@ -185,17 +185,17 @@  discard block
 block discarded – undo
185 185
     {
186 186
         if (WP_DEBUG) {
187 187
             $activation_errors = ob_get_contents();
188
-            if (! empty($activation_errors)) {
189
-                $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
188
+            if ( ! empty($activation_errors)) {
189
+                $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors;
190 190
             }
191
-            espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
191
+            espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php');
192 192
             if (class_exists('EEH_File')) {
193 193
                 try {
194 194
                     EEH_File::ensure_file_exists_and_is_writable(
195
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html'
195
+                        EVENT_ESPRESSO_UPLOAD_DIR.'logs/espresso_plugin_activation_errors.html'
196 196
                     );
197 197
                     EEH_File::write_to_file(
198
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html',
198
+                        EVENT_ESPRESSO_UPLOAD_DIR.'logs/espresso_plugin_activation_errors.html',
199 199
                         $activation_errors
200 200
                     );
201 201
                 } catch (EE_Error $e) {
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
             } else {
216 216
                 // old school attempt
217 217
                 file_put_contents(
218
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs/espresso_plugin_activation_errors.html',
218
+                    EVENT_ESPRESSO_UPLOAD_DIR.'logs/espresso_plugin_activation_errors.html',
219 219
                     $activation_errors
220 220
                 );
221 221
             }
222
-            $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
222
+            $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors;
223 223
             update_option('ee_plugin_activation_errors', $activation_errors);
224 224
         }
225 225
     }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         // don't trigger error if doing ajax,
280 280
         // instead we'll add a transient EE_Error notice that in theory should show on the next request.
281 281
         if (defined('DOING_AJAX') && DOING_AJAX) {
282
-            $error_message .= ' ' . esc_html__(
282
+            $error_message .= ' '.esc_html__(
283 283
                 'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
284 284
                 'event_espresso'
285 285
             );
@@ -324,18 +324,18 @@  discard block
 block discarded – undo
324 324
         $debug_key = 'EE_DEBUG_SPCO'
325 325
     ) {
326 326
         if (WP_DEBUG) {
327
-            $debug_key = $debug_key . '_' . EE_Session::instance()->id();
327
+            $debug_key = $debug_key.'_'.EE_Session::instance()->id();
328 328
             $debug_data = get_option($debug_key, array());
329 329
             $default_data = array(
330
-                $class => $func . '() : ' . $line,
330
+                $class => $func.'() : '.$line,
331 331
             );
332 332
             // don't serialize objects
333 333
             $info = self::strip_objects($info);
334 334
             $index = ! empty($debug_index) ? $debug_index : 0;
335
-            if (! isset($debug_data[ $index ])) {
336
-                $debug_data[ $index ] = array();
335
+            if ( ! isset($debug_data[$index])) {
336
+                $debug_data[$index] = array();
337 337
             }
338
-            $debug_data[ $index ][ microtime() ] = array_merge($default_data, $info);
338
+            $debug_data[$index][microtime()] = array_merge($default_data, $info);
339 339
             update_option($debug_key, $debug_data);
340 340
         }
341 341
     }
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
     {
353 353
         foreach ($info as $key => $value) {
354 354
             if (is_array($value)) {
355
-                $info[ $key ] = self::strip_objects($value);
355
+                $info[$key] = self::strip_objects($value);
356 356
             } elseif (is_object($value)) {
357 357
                 $object_class = get_class($value);
358
-                $info[ $object_class ] = array();
359
-                $info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
358
+                $info[$object_class] = array();
359
+                $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
360 360
                 if (method_exists($value, 'ID')) {
361
-                    $info[ $object_class ]['ID'] = $value->ID();
361
+                    $info[$object_class]['ID'] = $value->ID();
362 362
                 }
363 363
                 if (method_exists($value, 'status')) {
364
-                    $info[ $object_class ]['status'] = $value->status();
364
+                    $info[$object_class]['status'] = $value->status();
365 365
                 } elseif (method_exists($value, 'status_ID')) {
366
-                    $info[ $object_class ]['status'] = $value->status_ID();
366
+                    $info[$object_class]['status'] = $value->status_ID();
367 367
                 }
368
-                unset($info[ $key ]);
368
+                unset($info[$key]);
369 369
             }
370 370
         }
371 371
         return (array) $info;
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
         $result = EEH_Debug_Tools::headingSpacer($heading_tag);
400 400
         $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
401 401
         $result .= $is_method
402
-            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
-            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
402
+            ? EEH_Debug_Tools::grey_span('::').EEH_Debug_Tools::orange_span($var.'()')
403
+            : EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span($var);
404 404
         $result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
405 405
         $result .= EEH_Debug_Tools::headingX($heading_tag);
406 406
         if ($die) {
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             return $heading;
455 455
         }
456 456
         $margin = "25px 0 0 {$margin}";
457
-        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
457
+        return '<'.$heading_tag.' style="color:#2EA2CC; margin:'.$margin.';"><b>'.$var_name.'</b>';
458 458
     }
459 459
 
460 460
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
         if (EEH_Debug_Tools::plainOutput()) {
469 469
             return '';
470 470
         }
471
-        return '</' . $heading_tag . '>';
471
+        return '</'.$heading_tag.'>';
472 472
     }
473 473
 
474 474
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         if (EEH_Debug_Tools::plainOutput()) {
483 483
             return $content;
484 484
         }
485
-        return '<span style="color:#999">' . $content . '</span>';
485
+        return '<span style="color:#999">'.$content.'</span>';
486 486
     }
487 487
 
488 488
 
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         if (EEH_Debug_Tools::plainOutput()) {
523 523
             return $content;
524 524
         }
525
-        return '<span style="color:#E76700">' . $content . '</span>';
525
+        return '<span style="color:#E76700">'.$content.'</span>';
526 526
     }
527 527
 
528 528
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
         if (EEH_Debug_Tools::plainOutput()) {
540 540
             return $var;
541 541
         }
542
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
542
+        return '<pre style="color:#999; padding:1em; background: #fff">'.$var.'</pre>';
543 543
     }
544 544
 
545 545
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
         $heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
584 584
         $result = EEH_Debug_Tools::headingSpacer($heading_tag);
585 585
         $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
586
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
586
+        $result .= EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span(
587 587
             EEH_Debug_Tools::pre_span($var)
588 588
         );
589 589
         $result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +965 added lines, -965 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8 8
 if (! function_exists('espresso_get_template_part')) {
9
-    /**
10
-     * espresso_get_template_part
11
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
12
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
-     *
14
-     * @param string $slug The slug name for the generic template.
15
-     * @param string $name The name of the specialised template.
16
-     * @return string        the html output for the formatted money value
17
-     */
18
-    function espresso_get_template_part($slug = null, $name = null)
19
-    {
20
-        EEH_Template::get_template_part($slug, $name);
21
-    }
9
+	/**
10
+	 * espresso_get_template_part
11
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
12
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
+	 *
14
+	 * @param string $slug The slug name for the generic template.
15
+	 * @param string $name The name of the specialised template.
16
+	 * @return string        the html output for the formatted money value
17
+	 */
18
+	function espresso_get_template_part($slug = null, $name = null)
19
+	{
20
+		EEH_Template::get_template_part($slug, $name);
21
+	}
22 22
 }
23 23
 
24 24
 
25 25
 if (! function_exists('espresso_get_object_css_class')) {
26
-    /**
27
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
-     *
29
-     * @param EE_Base_Class $object the EE object the css class is being generated for
30
-     * @param  string       $prefix added to the beginning of the generated class
31
-     * @param  string       $suffix added to the end of the generated class
32
-     * @return string
33
-     */
34
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
35
-    {
36
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
37
-    }
26
+	/**
27
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
+	 *
29
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
30
+	 * @param  string       $prefix added to the beginning of the generated class
31
+	 * @param  string       $suffix added to the end of the generated class
32
+	 * @return string
33
+	 */
34
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
35
+	{
36
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
37
+	}
38 38
 }
39 39
 
40 40
 
@@ -49,675 +49,675 @@  discard block
 block discarded – undo
49 49
 class EEH_Template
50 50
 {
51 51
 
52
-    private static $_espresso_themes = array();
53
-
54
-
55
-    /**
56
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
57
-     *
58
-     * @return boolean
59
-     */
60
-    public static function is_espresso_theme()
61
-    {
62
-        return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
63
-    }
64
-
65
-    /**
66
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
67
-     *    load it's functions.php file ( if not already loaded )
68
-     *
69
-     * @return void
70
-     */
71
-    public static function load_espresso_theme_functions()
72
-    {
73
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
74
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
75
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
76
-            }
77
-        }
78
-    }
79
-
80
-
81
-    /**
82
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
83
-     *
84
-     * @return array
85
-     */
86
-    public static function get_espresso_themes()
87
-    {
88
-        if (empty(EEH_Template::$_espresso_themes)) {
89
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
90
-            if (empty($espresso_themes)) {
91
-                return array();
92
-            }
93
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
94
-                unset($espresso_themes[ $key ]);
95
-            }
96
-            EEH_Template::$_espresso_themes = array();
97
-            foreach ($espresso_themes as $espresso_theme) {
98
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
99
-            }
100
-        }
101
-        return EEH_Template::$_espresso_themes;
102
-    }
103
-
104
-
105
-    /**
106
-     * EEH_Template::get_template_part
107
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
108
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
109
-     * filtering based off of the entire template part name
110
-     *
111
-     * @param string $slug The slug name for the generic template.
112
-     * @param string $name The name of the specialised template.
113
-     * @param array  $template_args
114
-     * @param bool   $return_string
115
-     * @return string        the html output for the formatted money value
116
-     */
117
-    public static function get_template_part(
118
-        $slug = null,
119
-        $name = null,
120
-        $template_args = array(),
121
-        $return_string = false
122
-    ) {
123
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
124
-        $templates = array();
125
-        $name      = (string) $name;
126
-        if ($name != '') {
127
-            $templates[] = "{$slug}-{$name}.php";
128
-        }
129
-        // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
130
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
131
-            EEH_Template::locate_template($templates, $template_args, true, $return_string);
132
-        }
133
-    }
134
-
135
-
136
-    /**
137
-     *    locate_template
138
-     *    locate a template file by looking in the following places, in the following order:
139
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
140
-     *        <assumed full absolute server path>
141
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
142
-     *        <server path up to>/wp-content/uploads/espresso/templates/
143
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
144
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
145
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
146
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
147
-     *        Example:
148
-     *          You are using the WordPress Twenty Sixteen theme,
149
-     *        and you want to customize the "some-event.template.php" template,
150
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
151
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
152
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
153
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
154
-     *        /relative/path/to/some-event.template.php
155
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
156
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
157
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
158
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
159
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
160
-     *          Had you passed an absolute path to your template that was in some other location,
161
-     *        ie: "/absolute/path/to/some-event.template.php"
162
-     *          then the search would have been :
163
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
-     *        /absolute/path/to/some-event.template.php
165
-     *          and stopped there upon finding it in the second location
166
-     *
167
-     * @param array|string $templates       array of template file names including extension (or just a single string)
168
-     * @param  array       $template_args   an array of arguments to be extracted for use in the template
169
-     * @param  boolean     $load            whether to pass the located template path on to the
170
-     *                                      EEH_Template::display_template() method or simply return it
171
-     * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
172
-     *                                      string
173
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
174
-     *                                      generate a custom template or not. Used in places where you don't actually
175
-     *                                      load the template, you just want to know if there's a custom version of it.
176
-     * @return mixed
177
-     * @throws DomainException
178
-     * @throws InvalidArgumentException
179
-     * @throws InvalidDataTypeException
180
-     * @throws InvalidInterfaceException
181
-     */
182
-    public static function locate_template(
183
-        $templates = array(),
184
-        $template_args = array(),
185
-        $load = true,
186
-        $return_string = true,
187
-        $check_if_custom = false
188
-    ) {
189
-        // first use WP locate_template to check for template in the current theme folder
190
-        $template_path = locate_template($templates);
191
-
192
-        if ($check_if_custom && ! empty($template_path)) {
193
-            return true;
194
-        }
195
-
196
-        // not in the theme
197
-        if (empty($template_path)) {
198
-            // not even a template to look for ?
199
-            if (empty($templates)) {
200
-                $loader = LoaderFactory::getLoader();
201
-                /** @var RequestInterface $request */
202
-                $request = $loader->getShared(RequestInterface::class);
203
-                // get post_type
204
-                $post_type = $request->getRequestParam('post_type');
205
-                /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
206
-                $custom_post_types = $loader->getShared(
207
-                    'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
208
-                );
209
-                // get array of EE Custom Post Types
210
-                $EE_CPTs = $custom_post_types->getDefinitions();
211
-                // build template name based on request
212
-                if (isset($EE_CPTs[ $post_type ])) {
213
-                    $archive_or_single = is_archive() ? 'archive' : '';
214
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
215
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
216
-                }
217
-            }
218
-            // currently active EE template theme
219
-            $current_theme = EE_Config::get_current_theme();
220
-
221
-            // array of paths to folders that may contain templates
222
-            $template_folder_paths = array(
223
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
224
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
225
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
226
-                EVENT_ESPRESSO_TEMPLATE_DIR,
227
-            );
228
-
229
-            // add core plugin folders for checking only if we're not $check_if_custom
230
-            if (! $check_if_custom) {
231
-                $core_paths            = array(
232
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
233
-                    EE_PUBLIC . $current_theme,
234
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
235
-                    EE_TEMPLATES . $current_theme,
236
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
237
-                    EE_PLUGIN_DIR_PATH,
238
-                );
239
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
240
-            }
241
-
242
-            // now filter that array
243
-            $template_folder_paths = apply_filters(
244
-                'FHEE__EEH_Template__locate_template__template_folder_paths',
245
-                $template_folder_paths
246
-            );
247
-            $templates             = is_array($templates) ? $templates : array($templates);
248
-            $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
249
-            // array to hold all possible template paths
250
-            $full_template_paths = array();
251
-
252
-            // loop through $templates
253
-            foreach ($templates as $template) {
254
-                // normalize directory separators
255
-                $template                      = EEH_File::standardise_directory_separators($template);
256
-                $file_name                     = basename($template);
257
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
258
-                // while looping through all template folder paths
259
-                foreach ($template_folder_paths as $template_folder_path) {
260
-                    // normalize directory separators
261
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
262
-                    // determine if any common base path exists between the two paths
263
-                    $common_base_path = EEH_Template::_find_common_base_path(
264
-                        array($template_folder_path, $template_path_minus_file_name)
265
-                    );
266
-                    if ($common_base_path !== '') {
267
-                        // both paths have a common base, so just tack the filename onto our search path
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
269
-                    } else {
270
-                        // no common base path, so let's just concatenate
271
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
272
-                    }
273
-                    // build up our template locations array by adding our resolved paths
274
-                    $full_template_paths[] = $resolved_path;
275
-                }
276
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
277
-                array_unshift($full_template_paths, $template);
278
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
279
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
280
-            }
281
-            // filter final array of full template paths
282
-            $full_template_paths = apply_filters(
283
-                'FHEE__EEH_Template__locate_template__full_template_paths',
284
-                $full_template_paths,
285
-                $file_name
286
-            );
287
-            // now loop through our final array of template location paths and check each location
288
-            foreach ((array) $full_template_paths as $full_template_path) {
289
-                if (is_readable($full_template_path)) {
290
-                    $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
291
-                    break;
292
-                }
293
-            }
294
-        }
295
-
296
-        // hook that can be used to display the full template path that will be used
297
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
298
-
299
-        // if we got it and you want to see it...
300
-        if ($template_path && $load && ! $check_if_custom) {
301
-            if ($return_string) {
302
-                return EEH_Template::display_template($template_path, $template_args, true);
303
-            } else {
304
-                EEH_Template::display_template($template_path, $template_args, false);
305
-            }
306
-        }
307
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
308
-    }
309
-
310
-
311
-    /**
312
-     * _find_common_base_path
313
-     * given two paths, this determines if there is a common base path between the two
314
-     *
315
-     * @param array $paths
316
-     * @return string
317
-     */
318
-    protected static function _find_common_base_path($paths)
319
-    {
320
-        $last_offset      = 0;
321
-        $common_base_path = '';
322
-        while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
323
-            $dir_length = $index - $last_offset + 1;
324
-            $directory  = substr($paths[0], $last_offset, $dir_length);
325
-            foreach ($paths as $path) {
326
-                if (substr($path, $last_offset, $dir_length) != $directory) {
327
-                    return $common_base_path;
328
-                }
329
-            }
330
-            $common_base_path .= $directory;
331
-            $last_offset = $index + 1;
332
-        }
333
-        return substr($common_base_path, 0, -1);
334
-    }
335
-
336
-
337
-    /**
338
-     * load and display a template
339
-     *
340
-     * @param bool|string $template_path server path to the file to be loaded, including file name and extension
341
-     * @param  array      $template_args an array of arguments to be extracted for use in the template
342
-     * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
343
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
344
-     *                                      not found or is not readable
345
-     * @return mixed string
346
-     * @throws \DomainException
347
-     */
348
-    public static function display_template(
349
-        $template_path = false,
350
-        $template_args = array(),
351
-        $return_string = false,
352
-        $throw_exceptions = false
353
-    ) {
354
-
355
-        /**
356
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
357
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
358
-         * the display_template method are templates we DON'T want modified (usually because of js
359
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
360
-         * using this.
361
-         *
362
-         * @since 4.6.0
363
-         */
364
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
365
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
366
-
367
-        // you gimme nuttin - YOU GET NUTTIN !!
368
-        if (! $template_path || ! is_readable($template_path)) {
369
-            return '';
370
-        }
371
-        // if $template_args are not in an array, then make it so
372
-        if (! is_array($template_args) && ! is_object($template_args)) {
373
-            $template_args = array($template_args);
374
-        }
375
-        extract($template_args, EXTR_SKIP);
376
-        // ignore whether template is accessible ?
377
-        if ($throw_exceptions && ! is_readable($template_path)) {
378
-            throw new \DomainException(
379
-                esc_html__(
380
-                    'Invalid, unreadable, or missing file.',
381
-                    'event_espresso'
382
-                )
383
-            );
384
-        }
385
-
386
-
387
-        if ($return_string) {
388
-            // because we want to return a string, we are going to capture the output
389
-            ob_start();
390
-            include($template_path);
391
-            return ob_get_clean();
392
-        } else {
393
-            include($template_path);
394
-        }
395
-        return '';
396
-    }
397
-
398
-
399
-    /**
400
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
401
-     *
402
-     * @param EE_Base_Class $object the EE object the css class is being generated for
403
-     * @param  string       $prefix added to the beginning of the generated class
404
-     * @param  string       $suffix added to the end of the generated class
405
-     * @return string
406
-     */
407
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
408
-    {
409
-        // in the beginning...
410
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
411
-        // da muddle
412
-        $class = '';
413
-        // the end
414
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
415
-        // is the passed object an EE object ?
416
-        if ($object instanceof EE_Base_Class) {
417
-            // grab the exact type of object
418
-            $obj_class = get_class($object);
419
-            // depending on the type of object...
420
-            switch ($obj_class) {
421
-                // no specifics just yet...
422
-                default:
423
-                    $class = strtolower(str_replace('_', '-', $obj_class));
424
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
425
-            }
426
-        }
427
-        return $prefix . $class . $suffix;
428
-    }
429
-
430
-
431
-
432
-    /**
433
-     * EEH_Template::format_currency
434
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
435
-     * the country currency settings from the supplied country ISO code
436
-     *
437
-     * @param  float   $amount       raw money value
438
-     * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
439
-     * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
440
-     * @param string   $CNT_ISO      2 letter ISO code for a country
441
-     * @param string   $cur_code_span_class
442
-     * @return string        the html output for the formatted money value
443
-     * @throws \EE_Error
444
-     */
445
-    public static function format_currency(
446
-        $amount = null,
447
-        $return_raw = false,
448
-        $display_code = true,
449
-        $CNT_ISO = '',
450
-        $cur_code_span_class = 'currency-code'
451
-    ) {
452
-        // ensure amount was received
453
-        if ($amount === null) {
454
-            $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
455
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
456
-            return '';
457
-        }
458
-        // ensure amount is float
459
-        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
460
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
461
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
462
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
463
-        // still a number or was amount converted to a string like "free" ?
464
-        if (is_float($amount_formatted)) {
465
-            // was a country ISO code passed ? if so generate currency config object for that country
466
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
467
-            // verify results
468
-            if (! $mny instanceof EE_Currency_Config) {
469
-                // set default config country currency settings
470
-                $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
471
-                    ? EE_Registry::instance()->CFG->currency
472
-                    : new EE_Currency_Config();
473
-            }
474
-            // format float
475
-            $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
476
-            // add formatting ?
477
-            if (! $return_raw) {
478
-                // add currency sign
479
-                if ($mny->sign_b4) {
480
-                    if ($amount >= 0) {
481
-                        $amount_formatted = $mny->sign . $amount_formatted;
482
-                    } else {
483
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
484
-                    }
485
-                } else {
486
-                    $amount_formatted = $amount_formatted . $mny->sign;
487
-                }
488
-
489
-                // filter to allow global setting of display_code
490
-                $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
491
-
492
-                // add currency code ?
493
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
494
-            }
495
-            // filter results
496
-            $amount_formatted = apply_filters(
497
-                'FHEE__EEH_Template__format_currency__amount_formatted',
498
-                $amount_formatted,
499
-                $mny,
500
-                $return_raw
501
-            );
502
-        }
503
-        // clean up vars
504
-        unset($mny);
505
-        // return formatted currency amount
506
-        return $amount_formatted;
507
-    }
508
-
509
-
510
-    /**
511
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
512
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
513
-     * related status model or model object (i.e. in documentation etc.)
514
-     *
515
-     * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
516
-     *                            match, then 'Unknown' will be returned.
517
-     * @param  boolean $plural    Whether to return plural or not
518
-     * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
519
-     * @return string             The localized label for the status id.
520
-     */
521
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
522
-    {
523
-        /** @type EEM_Status $EEM_Status */
524
-        $EEM_Status = EE_Registry::instance()->load_model('Status');
525
-        $status     = $EEM_Status->localized_status(
526
-            array($status_id => __('unknown', 'event_espresso')),
527
-            $plural,
528
-            $schema
529
-        );
530
-        return $status[ $status_id ];
531
-    }
532
-
533
-
534
-    /**
535
-     * This helper just returns a button or link for the given parameters
536
-     *
537
-     * @param  string $url   the url for the link, note that `esc_url` will be called on it
538
-     * @param  string $label What is the label you want displayed for the button
539
-     * @param  string $class what class is used for the button (defaults to 'button-primary')
540
-     * @param string  $icon
541
-     * @param string  $title
542
-     * @return string the html output for the button
543
-     */
544
-    public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
545
-    {
546
-        $icon_html = '';
547
-        if (! empty($icon)) {
548
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
549
-            $dashicons = array_filter($dashicons);
550
-            $count     = count($dashicons);
551
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
552
-            foreach ($dashicons as $dashicon) {
553
-                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
554
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
555
-            }
556
-            $icon_html .= $count > 1 ? '</span>' : '';
557
-        }
558
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
559
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
560
-        return $button;
561
-    }
562
-
563
-
564
-    /**
565
-     * This returns a generated link that will load the related help tab on admin pages.
566
-     *
567
-     * @param  string     $help_tab_id the id for the connected help tab
568
-     * @param bool|string $page        The page identifier for the page the help tab is on
569
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
570
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
571
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
572
-     * @return string              generated link
573
-     */
574
-    public static function get_help_tab_link(
575
-        $help_tab_id,
576
-        $page = false,
577
-        $action = false,
578
-        $icon_style = false,
579
-        $help_text = false
580
-    ) {
581
-
582
-        if (! $page) {
583
-            $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
584
-        }
585
-
586
-        if (! $action) {
587
-            $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
588
-        }
589
-
590
-        $action = empty($action) ? 'default' : $action;
591
-
592
-
593
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
594
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
595
-        $help_text    = ! $help_text ? '' : $help_text;
596
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__(
597
-            'Click to open the \'Help\' tab for more information about this feature.',
598
-            'event_espresso'
599
-        ) . '" > ' . $help_text . ' </a>';
600
-    }
601
-
602
-
603
-    /**
604
-     * This helper generates the html structure for the jquery joyride plugin with the given params.
605
-     *
606
-     * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
607
-     * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
608
-     * @param EE_Help_Tour
609
-     * @return string         html
610
-     */
611
-    public static function help_tour_stops_generator(EE_Help_Tour $tour)
612
-    {
613
-        $id    = $tour->get_slug();
614
-        $stops = $tour->get_stops();
615
-
616
-        $content = '<ol style="display:none" id="' . $id . '">';
617
-
618
-        foreach ($stops as $stop) {
619
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
620
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
621
-
622
-            // if container is set to modal then let's make sure we set the options accordingly
623
-            if (empty($data_id) && empty($data_class)) {
624
-                $stop['options']['modal']  = true;
625
-                $stop['options']['expose'] = true;
626
-            }
627
-
628
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
629
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
630
-            $inner_content = isset($stop['content']) ? $stop['content'] : '';
631
-
632
-            // options
633
-            if (isset($stop['options']) && is_array($stop['options'])) {
634
-                $options = ' data-options="';
635
-                foreach ($stop['options'] as $option => $value) {
636
-                    $options .= $option . ':' . $value . ';';
637
-                }
638
-                $options .= '"';
639
-            } else {
640
-                $options = '';
641
-            }
642
-
643
-            // let's put all together
644
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
645
-        }
646
-
647
-        $content .= '</ol>';
648
-        return $content;
649
-    }
650
-
651
-
652
-    /**
653
-     * This is a helper method to generate a status legend for a given status array.
654
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
655
-     * status_array.
656
-     *
657
-     * @param  array  $status_array  array of statuses that will make up the legend. In format:
658
-     *                               array(
659
-     *                               'status_item' => 'status_name'
660
-     *                               )
661
-     * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
662
-     *                               the legend.
663
-     * @throws EE_Error
664
-     * @return string               html structure for status.
665
-     */
666
-    public static function status_legend($status_array, $active_status = '')
667
-    {
668
-        if (! is_array($status_array)) {
669
-            throw new EE_Error(esc_html__(
670
-                'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
671
-                'event_espresso'
672
-            ));
673
-        }
674
-
675
-        $setup_array = array();
676
-        foreach ($status_array as $item => $status) {
677
-            $setup_array[ $item ] = array(
678
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
679
-                'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
680
-                'status' => $status,
681
-            );
682
-        }
683
-
684
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
685
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
686
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
687
-        foreach ($setup_array as $item => $details) {
688
-            $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
689
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
690
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
691
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
692
-            $content .= '</dt>' . "\n";
693
-        }
694
-        $content .= '</dl>' . "\n";
695
-        $content .= '</div>' . "\n";
696
-        return $content;
697
-    }
698
-
699
-
700
-    /**
701
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
702
-     * that's nice for presenting in the wp admin
703
-     *
704
-     * @param mixed $data
705
-     * @return string
706
-     */
707
-    public static function layout_array_as_table($data)
708
-    {
709
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
710
-            $data = (array) $data;
711
-        }
712
-        ob_start();
713
-        if (is_array($data)) {
714
-            if (EEH_Array::is_associative_array($data)) {
715
-                ?>
52
+	private static $_espresso_themes = array();
53
+
54
+
55
+	/**
56
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
57
+	 *
58
+	 * @return boolean
59
+	 */
60
+	public static function is_espresso_theme()
61
+	{
62
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
63
+	}
64
+
65
+	/**
66
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
67
+	 *    load it's functions.php file ( if not already loaded )
68
+	 *
69
+	 * @return void
70
+	 */
71
+	public static function load_espresso_theme_functions()
72
+	{
73
+		if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
74
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
75
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
76
+			}
77
+		}
78
+	}
79
+
80
+
81
+	/**
82
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
83
+	 *
84
+	 * @return array
85
+	 */
86
+	public static function get_espresso_themes()
87
+	{
88
+		if (empty(EEH_Template::$_espresso_themes)) {
89
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
90
+			if (empty($espresso_themes)) {
91
+				return array();
92
+			}
93
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
94
+				unset($espresso_themes[ $key ]);
95
+			}
96
+			EEH_Template::$_espresso_themes = array();
97
+			foreach ($espresso_themes as $espresso_theme) {
98
+				EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
99
+			}
100
+		}
101
+		return EEH_Template::$_espresso_themes;
102
+	}
103
+
104
+
105
+	/**
106
+	 * EEH_Template::get_template_part
107
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
108
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
109
+	 * filtering based off of the entire template part name
110
+	 *
111
+	 * @param string $slug The slug name for the generic template.
112
+	 * @param string $name The name of the specialised template.
113
+	 * @param array  $template_args
114
+	 * @param bool   $return_string
115
+	 * @return string        the html output for the formatted money value
116
+	 */
117
+	public static function get_template_part(
118
+		$slug = null,
119
+		$name = null,
120
+		$template_args = array(),
121
+		$return_string = false
122
+	) {
123
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
124
+		$templates = array();
125
+		$name      = (string) $name;
126
+		if ($name != '') {
127
+			$templates[] = "{$slug}-{$name}.php";
128
+		}
129
+		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
130
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
131
+			EEH_Template::locate_template($templates, $template_args, true, $return_string);
132
+		}
133
+	}
134
+
135
+
136
+	/**
137
+	 *    locate_template
138
+	 *    locate a template file by looking in the following places, in the following order:
139
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
140
+	 *        <assumed full absolute server path>
141
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
142
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
143
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
144
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
145
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
146
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
147
+	 *        Example:
148
+	 *          You are using the WordPress Twenty Sixteen theme,
149
+	 *        and you want to customize the "some-event.template.php" template,
150
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
151
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
152
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
153
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
154
+	 *        /relative/path/to/some-event.template.php
155
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
156
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
157
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
158
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
159
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
160
+	 *          Had you passed an absolute path to your template that was in some other location,
161
+	 *        ie: "/absolute/path/to/some-event.template.php"
162
+	 *          then the search would have been :
163
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
+	 *        /absolute/path/to/some-event.template.php
165
+	 *          and stopped there upon finding it in the second location
166
+	 *
167
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
168
+	 * @param  array       $template_args   an array of arguments to be extracted for use in the template
169
+	 * @param  boolean     $load            whether to pass the located template path on to the
170
+	 *                                      EEH_Template::display_template() method or simply return it
171
+	 * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
172
+	 *                                      string
173
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
174
+	 *                                      generate a custom template or not. Used in places where you don't actually
175
+	 *                                      load the template, you just want to know if there's a custom version of it.
176
+	 * @return mixed
177
+	 * @throws DomainException
178
+	 * @throws InvalidArgumentException
179
+	 * @throws InvalidDataTypeException
180
+	 * @throws InvalidInterfaceException
181
+	 */
182
+	public static function locate_template(
183
+		$templates = array(),
184
+		$template_args = array(),
185
+		$load = true,
186
+		$return_string = true,
187
+		$check_if_custom = false
188
+	) {
189
+		// first use WP locate_template to check for template in the current theme folder
190
+		$template_path = locate_template($templates);
191
+
192
+		if ($check_if_custom && ! empty($template_path)) {
193
+			return true;
194
+		}
195
+
196
+		// not in the theme
197
+		if (empty($template_path)) {
198
+			// not even a template to look for ?
199
+			if (empty($templates)) {
200
+				$loader = LoaderFactory::getLoader();
201
+				/** @var RequestInterface $request */
202
+				$request = $loader->getShared(RequestInterface::class);
203
+				// get post_type
204
+				$post_type = $request->getRequestParam('post_type');
205
+				/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
206
+				$custom_post_types = $loader->getShared(
207
+					'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
208
+				);
209
+				// get array of EE Custom Post Types
210
+				$EE_CPTs = $custom_post_types->getDefinitions();
211
+				// build template name based on request
212
+				if (isset($EE_CPTs[ $post_type ])) {
213
+					$archive_or_single = is_archive() ? 'archive' : '';
214
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
215
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
216
+				}
217
+			}
218
+			// currently active EE template theme
219
+			$current_theme = EE_Config::get_current_theme();
220
+
221
+			// array of paths to folders that may contain templates
222
+			$template_folder_paths = array(
223
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
224
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
225
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
226
+				EVENT_ESPRESSO_TEMPLATE_DIR,
227
+			);
228
+
229
+			// add core plugin folders for checking only if we're not $check_if_custom
230
+			if (! $check_if_custom) {
231
+				$core_paths            = array(
232
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
233
+					EE_PUBLIC . $current_theme,
234
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
235
+					EE_TEMPLATES . $current_theme,
236
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
237
+					EE_PLUGIN_DIR_PATH,
238
+				);
239
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
240
+			}
241
+
242
+			// now filter that array
243
+			$template_folder_paths = apply_filters(
244
+				'FHEE__EEH_Template__locate_template__template_folder_paths',
245
+				$template_folder_paths
246
+			);
247
+			$templates             = is_array($templates) ? $templates : array($templates);
248
+			$template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
249
+			// array to hold all possible template paths
250
+			$full_template_paths = array();
251
+
252
+			// loop through $templates
253
+			foreach ($templates as $template) {
254
+				// normalize directory separators
255
+				$template                      = EEH_File::standardise_directory_separators($template);
256
+				$file_name                     = basename($template);
257
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
258
+				// while looping through all template folder paths
259
+				foreach ($template_folder_paths as $template_folder_path) {
260
+					// normalize directory separators
261
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
262
+					// determine if any common base path exists between the two paths
263
+					$common_base_path = EEH_Template::_find_common_base_path(
264
+						array($template_folder_path, $template_path_minus_file_name)
265
+					);
266
+					if ($common_base_path !== '') {
267
+						// both paths have a common base, so just tack the filename onto our search path
268
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
269
+					} else {
270
+						// no common base path, so let's just concatenate
271
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
272
+					}
273
+					// build up our template locations array by adding our resolved paths
274
+					$full_template_paths[] = $resolved_path;
275
+				}
276
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
277
+				array_unshift($full_template_paths, $template);
278
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
279
+				array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
280
+			}
281
+			// filter final array of full template paths
282
+			$full_template_paths = apply_filters(
283
+				'FHEE__EEH_Template__locate_template__full_template_paths',
284
+				$full_template_paths,
285
+				$file_name
286
+			);
287
+			// now loop through our final array of template location paths and check each location
288
+			foreach ((array) $full_template_paths as $full_template_path) {
289
+				if (is_readable($full_template_path)) {
290
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
291
+					break;
292
+				}
293
+			}
294
+		}
295
+
296
+		// hook that can be used to display the full template path that will be used
297
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
298
+
299
+		// if we got it and you want to see it...
300
+		if ($template_path && $load && ! $check_if_custom) {
301
+			if ($return_string) {
302
+				return EEH_Template::display_template($template_path, $template_args, true);
303
+			} else {
304
+				EEH_Template::display_template($template_path, $template_args, false);
305
+			}
306
+		}
307
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
308
+	}
309
+
310
+
311
+	/**
312
+	 * _find_common_base_path
313
+	 * given two paths, this determines if there is a common base path between the two
314
+	 *
315
+	 * @param array $paths
316
+	 * @return string
317
+	 */
318
+	protected static function _find_common_base_path($paths)
319
+	{
320
+		$last_offset      = 0;
321
+		$common_base_path = '';
322
+		while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
323
+			$dir_length = $index - $last_offset + 1;
324
+			$directory  = substr($paths[0], $last_offset, $dir_length);
325
+			foreach ($paths as $path) {
326
+				if (substr($path, $last_offset, $dir_length) != $directory) {
327
+					return $common_base_path;
328
+				}
329
+			}
330
+			$common_base_path .= $directory;
331
+			$last_offset = $index + 1;
332
+		}
333
+		return substr($common_base_path, 0, -1);
334
+	}
335
+
336
+
337
+	/**
338
+	 * load and display a template
339
+	 *
340
+	 * @param bool|string $template_path server path to the file to be loaded, including file name and extension
341
+	 * @param  array      $template_args an array of arguments to be extracted for use in the template
342
+	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
343
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
344
+	 *                                      not found or is not readable
345
+	 * @return mixed string
346
+	 * @throws \DomainException
347
+	 */
348
+	public static function display_template(
349
+		$template_path = false,
350
+		$template_args = array(),
351
+		$return_string = false,
352
+		$throw_exceptions = false
353
+	) {
354
+
355
+		/**
356
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
357
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
358
+		 * the display_template method are templates we DON'T want modified (usually because of js
359
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
360
+		 * using this.
361
+		 *
362
+		 * @since 4.6.0
363
+		 */
364
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
365
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
366
+
367
+		// you gimme nuttin - YOU GET NUTTIN !!
368
+		if (! $template_path || ! is_readable($template_path)) {
369
+			return '';
370
+		}
371
+		// if $template_args are not in an array, then make it so
372
+		if (! is_array($template_args) && ! is_object($template_args)) {
373
+			$template_args = array($template_args);
374
+		}
375
+		extract($template_args, EXTR_SKIP);
376
+		// ignore whether template is accessible ?
377
+		if ($throw_exceptions && ! is_readable($template_path)) {
378
+			throw new \DomainException(
379
+				esc_html__(
380
+					'Invalid, unreadable, or missing file.',
381
+					'event_espresso'
382
+				)
383
+			);
384
+		}
385
+
386
+
387
+		if ($return_string) {
388
+			// because we want to return a string, we are going to capture the output
389
+			ob_start();
390
+			include($template_path);
391
+			return ob_get_clean();
392
+		} else {
393
+			include($template_path);
394
+		}
395
+		return '';
396
+	}
397
+
398
+
399
+	/**
400
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
401
+	 *
402
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
403
+	 * @param  string       $prefix added to the beginning of the generated class
404
+	 * @param  string       $suffix added to the end of the generated class
405
+	 * @return string
406
+	 */
407
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
408
+	{
409
+		// in the beginning...
410
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
411
+		// da muddle
412
+		$class = '';
413
+		// the end
414
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
415
+		// is the passed object an EE object ?
416
+		if ($object instanceof EE_Base_Class) {
417
+			// grab the exact type of object
418
+			$obj_class = get_class($object);
419
+			// depending on the type of object...
420
+			switch ($obj_class) {
421
+				// no specifics just yet...
422
+				default:
423
+					$class = strtolower(str_replace('_', '-', $obj_class));
424
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
425
+			}
426
+		}
427
+		return $prefix . $class . $suffix;
428
+	}
429
+
430
+
431
+
432
+	/**
433
+	 * EEH_Template::format_currency
434
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
435
+	 * the country currency settings from the supplied country ISO code
436
+	 *
437
+	 * @param  float   $amount       raw money value
438
+	 * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
439
+	 * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
440
+	 * @param string   $CNT_ISO      2 letter ISO code for a country
441
+	 * @param string   $cur_code_span_class
442
+	 * @return string        the html output for the formatted money value
443
+	 * @throws \EE_Error
444
+	 */
445
+	public static function format_currency(
446
+		$amount = null,
447
+		$return_raw = false,
448
+		$display_code = true,
449
+		$CNT_ISO = '',
450
+		$cur_code_span_class = 'currency-code'
451
+	) {
452
+		// ensure amount was received
453
+		if ($amount === null) {
454
+			$msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
455
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
456
+			return '';
457
+		}
458
+		// ensure amount is float
459
+		$amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
460
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
461
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
462
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
463
+		// still a number or was amount converted to a string like "free" ?
464
+		if (is_float($amount_formatted)) {
465
+			// was a country ISO code passed ? if so generate currency config object for that country
466
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
467
+			// verify results
468
+			if (! $mny instanceof EE_Currency_Config) {
469
+				// set default config country currency settings
470
+				$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
471
+					? EE_Registry::instance()->CFG->currency
472
+					: new EE_Currency_Config();
473
+			}
474
+			// format float
475
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
476
+			// add formatting ?
477
+			if (! $return_raw) {
478
+				// add currency sign
479
+				if ($mny->sign_b4) {
480
+					if ($amount >= 0) {
481
+						$amount_formatted = $mny->sign . $amount_formatted;
482
+					} else {
483
+						$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
484
+					}
485
+				} else {
486
+					$amount_formatted = $amount_formatted . $mny->sign;
487
+				}
488
+
489
+				// filter to allow global setting of display_code
490
+				$display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
491
+
492
+				// add currency code ?
493
+				$amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
494
+			}
495
+			// filter results
496
+			$amount_formatted = apply_filters(
497
+				'FHEE__EEH_Template__format_currency__amount_formatted',
498
+				$amount_formatted,
499
+				$mny,
500
+				$return_raw
501
+			);
502
+		}
503
+		// clean up vars
504
+		unset($mny);
505
+		// return formatted currency amount
506
+		return $amount_formatted;
507
+	}
508
+
509
+
510
+	/**
511
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
512
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
513
+	 * related status model or model object (i.e. in documentation etc.)
514
+	 *
515
+	 * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
516
+	 *                            match, then 'Unknown' will be returned.
517
+	 * @param  boolean $plural    Whether to return plural or not
518
+	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
519
+	 * @return string             The localized label for the status id.
520
+	 */
521
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
522
+	{
523
+		/** @type EEM_Status $EEM_Status */
524
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
525
+		$status     = $EEM_Status->localized_status(
526
+			array($status_id => __('unknown', 'event_espresso')),
527
+			$plural,
528
+			$schema
529
+		);
530
+		return $status[ $status_id ];
531
+	}
532
+
533
+
534
+	/**
535
+	 * This helper just returns a button or link for the given parameters
536
+	 *
537
+	 * @param  string $url   the url for the link, note that `esc_url` will be called on it
538
+	 * @param  string $label What is the label you want displayed for the button
539
+	 * @param  string $class what class is used for the button (defaults to 'button-primary')
540
+	 * @param string  $icon
541
+	 * @param string  $title
542
+	 * @return string the html output for the button
543
+	 */
544
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
545
+	{
546
+		$icon_html = '';
547
+		if (! empty($icon)) {
548
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
549
+			$dashicons = array_filter($dashicons);
550
+			$count     = count($dashicons);
551
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
552
+			foreach ($dashicons as $dashicon) {
553
+				$type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
554
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
555
+			}
556
+			$icon_html .= $count > 1 ? '</span>' : '';
557
+		}
558
+		$label  = ! empty($icon) ? $icon_html . $label : $label;
559
+		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
560
+		return $button;
561
+	}
562
+
563
+
564
+	/**
565
+	 * This returns a generated link that will load the related help tab on admin pages.
566
+	 *
567
+	 * @param  string     $help_tab_id the id for the connected help tab
568
+	 * @param bool|string $page        The page identifier for the page the help tab is on
569
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
570
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
571
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
572
+	 * @return string              generated link
573
+	 */
574
+	public static function get_help_tab_link(
575
+		$help_tab_id,
576
+		$page = false,
577
+		$action = false,
578
+		$icon_style = false,
579
+		$help_text = false
580
+	) {
581
+
582
+		if (! $page) {
583
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
584
+		}
585
+
586
+		if (! $action) {
587
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
588
+		}
589
+
590
+		$action = empty($action) ? 'default' : $action;
591
+
592
+
593
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
594
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
595
+		$help_text    = ! $help_text ? '' : $help_text;
596
+		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__(
597
+			'Click to open the \'Help\' tab for more information about this feature.',
598
+			'event_espresso'
599
+		) . '" > ' . $help_text . ' </a>';
600
+	}
601
+
602
+
603
+	/**
604
+	 * This helper generates the html structure for the jquery joyride plugin with the given params.
605
+	 *
606
+	 * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
607
+	 * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
608
+	 * @param EE_Help_Tour
609
+	 * @return string         html
610
+	 */
611
+	public static function help_tour_stops_generator(EE_Help_Tour $tour)
612
+	{
613
+		$id    = $tour->get_slug();
614
+		$stops = $tour->get_stops();
615
+
616
+		$content = '<ol style="display:none" id="' . $id . '">';
617
+
618
+		foreach ($stops as $stop) {
619
+			$data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
620
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
621
+
622
+			// if container is set to modal then let's make sure we set the options accordingly
623
+			if (empty($data_id) && empty($data_class)) {
624
+				$stop['options']['modal']  = true;
625
+				$stop['options']['expose'] = true;
626
+			}
627
+
628
+			$custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
629
+			$button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
630
+			$inner_content = isset($stop['content']) ? $stop['content'] : '';
631
+
632
+			// options
633
+			if (isset($stop['options']) && is_array($stop['options'])) {
634
+				$options = ' data-options="';
635
+				foreach ($stop['options'] as $option => $value) {
636
+					$options .= $option . ':' . $value . ';';
637
+				}
638
+				$options .= '"';
639
+			} else {
640
+				$options = '';
641
+			}
642
+
643
+			// let's put all together
644
+			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
645
+		}
646
+
647
+		$content .= '</ol>';
648
+		return $content;
649
+	}
650
+
651
+
652
+	/**
653
+	 * This is a helper method to generate a status legend for a given status array.
654
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
655
+	 * status_array.
656
+	 *
657
+	 * @param  array  $status_array  array of statuses that will make up the legend. In format:
658
+	 *                               array(
659
+	 *                               'status_item' => 'status_name'
660
+	 *                               )
661
+	 * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
662
+	 *                               the legend.
663
+	 * @throws EE_Error
664
+	 * @return string               html structure for status.
665
+	 */
666
+	public static function status_legend($status_array, $active_status = '')
667
+	{
668
+		if (! is_array($status_array)) {
669
+			throw new EE_Error(esc_html__(
670
+				'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
671
+				'event_espresso'
672
+			));
673
+		}
674
+
675
+		$setup_array = array();
676
+		foreach ($status_array as $item => $status) {
677
+			$setup_array[ $item ] = array(
678
+				'class'  => 'ee-status-legend ee-status-legend-' . $status,
679
+				'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
680
+				'status' => $status,
681
+			);
682
+		}
683
+
684
+		$content = '<div class="ee-list-table-legend-container">' . "\n";
685
+		$content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
686
+		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
687
+		foreach ($setup_array as $item => $details) {
688
+			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
689
+			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
690
+			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
691
+			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
692
+			$content .= '</dt>' . "\n";
693
+		}
694
+		$content .= '</dl>' . "\n";
695
+		$content .= '</div>' . "\n";
696
+		return $content;
697
+	}
698
+
699
+
700
+	/**
701
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
702
+	 * that's nice for presenting in the wp admin
703
+	 *
704
+	 * @param mixed $data
705
+	 * @return string
706
+	 */
707
+	public static function layout_array_as_table($data)
708
+	{
709
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
710
+			$data = (array) $data;
711
+		}
712
+		ob_start();
713
+		if (is_array($data)) {
714
+			if (EEH_Array::is_associative_array($data)) {
715
+				?>
716 716
                 <table class="widefat">
717 717
                     <tbody>
718 718
                     <?php
719
-                    foreach ($data as $data_key => $data_values) {
720
-                        ?>
719
+					foreach ($data as $data_key => $data_values) {
720
+						?>
721 721
                         <tr>
722 722
                             <td>
723 723
                                 <?php echo $data_key; ?>
@@ -727,291 +727,291 @@  discard block
 block discarded – undo
727 727
                             </td>
728 728
                         </tr>
729 729
                         <?php
730
-                    } ?>
730
+					} ?>
731 731
                     </tbody>
732 732
                 </table>
733 733
                 <?php
734
-            } else {
735
-                ?>
734
+			} else {
735
+				?>
736 736
                 <ul>
737 737
                     <?php
738
-                    foreach ($data as $datum) {
739
-                        echo "<li>";
740
-                        echo self::layout_array_as_table($datum);
741
-                        echo "</li>";
742
-                    } ?>
738
+					foreach ($data as $datum) {
739
+						echo "<li>";
740
+						echo self::layout_array_as_table($datum);
741
+						echo "</li>";
742
+					} ?>
743 743
                 </ul>
744 744
                 <?php
745
-            }
746
-        } else {
747
-            // simple value
748
-            echo esc_html($data);
749
-        }
750
-        return ob_get_clean();
751
-    }
752
-
753
-
754
-    /**
755
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
756
-     *
757
-     * @since 4.4.0
758
-     * @see   self:get_paging_html() for argument docs.
759
-     * @param        $total_items
760
-     * @param        $current
761
-     * @param        $per_page
762
-     * @param        $url
763
-     * @param bool   $show_num_field
764
-     * @param string $paged_arg_name
765
-     * @param array  $items_label
766
-     * @return string
767
-     */
768
-    public static function paging_html(
769
-        $total_items,
770
-        $current,
771
-        $per_page,
772
-        $url,
773
-        $show_num_field = true,
774
-        $paged_arg_name = 'paged',
775
-        $items_label = array()
776
-    ) {
777
-        echo self::get_paging_html(
778
-            $total_items,
779
-            $current,
780
-            $per_page,
781
-            $url,
782
-            $show_num_field,
783
-            $paged_arg_name,
784
-            $items_label
785
-        );
786
-    }
787
-
788
-
789
-    /**
790
-     * A method for generating paging similar to WP_List_Table
791
-     *
792
-     * @since    4.4.0
793
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
794
-     * @param  integer $total_items     How many total items there are to page.
795
-     * @param  integer $current         What the current page is.
796
-     * @param  integer $per_page        How many items per page.
797
-     * @param  string  $url             What the base url for page links is.
798
-     * @param  boolean $show_num_field  Whether to show the input for changing page number.
799
-     * @param  string  $paged_arg_name  The name of the key for the paged query argument.
800
-     * @param  array   $items_label     An array of singular/plural values for the items label:
801
-     *                                  array(
802
-     *                                  'single' => 'item',
803
-     *                                  'plural' => 'items'
804
-     *                                  )
805
-     * @return  string
806
-     */
807
-    public static function get_paging_html(
808
-        $total_items,
809
-        $current,
810
-        $per_page,
811
-        $url,
812
-        $show_num_field = true,
813
-        $paged_arg_name = 'paged',
814
-        $items_label = array()
815
-    ) {
816
-        $page_links     = array();
817
-        $disable_first  = $disable_last = '';
818
-        $total_items    = (int) $total_items;
819
-        $per_page       = (int) $per_page;
820
-        $current        = (int) $current;
821
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
822
-
823
-        // filter items_label
824
-        $items_label = apply_filters(
825
-            'FHEE__EEH_Template__get_paging_html__items_label',
826
-            $items_label
827
-        );
828
-
829
-        if (empty($items_label)
830
-            || ! is_array($items_label)
831
-            || ! isset($items_label['single'])
832
-            || ! isset($items_label['plural'])
833
-        ) {
834
-            $items_label = array(
835
-                'single' => __('1 item', 'event_espresso'),
836
-                'plural' => __('%s items', 'event_espresso'),
837
-            );
838
-        } else {
839
-            $items_label = array(
840
-                'single' => '1 ' . esc_html($items_label['single']),
841
-                'plural' => '%s ' . esc_html($items_label['plural']),
842
-            );
843
-        }
844
-
845
-        $total_pages = ceil($total_items / $per_page);
846
-
847
-        if ($total_pages <= 1) {
848
-            return '';
849
-        }
850
-
851
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
852
-
853
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
854
-
855
-        if ($current === 1) {
856
-            $disable_first = ' disabled';
857
-        }
858
-        if ($current == $total_pages) {
859
-            $disable_last = ' disabled';
860
-        }
861
-
862
-        $page_links[] = sprintf(
863
-            "<a class='%s' title='%s' href='%s'>%s</a>",
864
-            'first-page' . $disable_first,
865
-            esc_attr__('Go to the first page', 'event_espresso'),
866
-            esc_url(remove_query_arg($paged_arg_name, $url)),
867
-            '&laquo;'
868
-        );
869
-
870
-        $page_links[] = sprintf(
871
-            '<a class="%s" title="%s" href="%s">%s</a>',
872
-            'prev-page' . $disable_first,
873
-            esc_attr__('Go to the previous page', 'event_espresso'),
874
-            esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
875
-            '&lsaquo;'
876
-        );
877
-
878
-        if (! $show_num_field) {
879
-            $html_current_page = $current;
880
-        } else {
881
-            $html_current_page = sprintf(
882
-                "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
883
-                esc_attr__('Current page', 'event_espresso'),
884
-                $current,
885
-                strlen($total_pages)
886
-            );
887
-        }
888
-
889
-        $html_total_pages = sprintf(
890
-            '<span class="total-pages">%s</span>',
891
-            number_format_i18n($total_pages)
892
-        );
893
-        $page_links[]     = sprintf(
894
-            _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
895
-            $html_current_page,
896
-            $html_total_pages,
897
-            '<span class="paging-input">',
898
-            '</span>'
899
-        );
900
-
901
-        $page_links[] = sprintf(
902
-            '<a class="%s" title="%s" href="%s">%s</a>',
903
-            'next-page' . $disable_last,
904
-            esc_attr__('Go to the next page', 'event_espresso'),
905
-            esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
906
-            '&rsaquo;'
907
-        );
908
-
909
-        $page_links[] = sprintf(
910
-            '<a class="%s" title="%s" href="%s">%s</a>',
911
-            'last-page' . $disable_last,
912
-            esc_attr__('Go to the last page', 'event_espresso'),
913
-            esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
914
-            '&raquo;'
915
-        );
916
-
917
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
918
-        // set page class
919
-        if ($total_pages) {
920
-            $page_class = $total_pages < 2 ? ' one-page' : '';
921
-        } else {
922
-            $page_class = ' no-pages';
923
-        }
924
-
925
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
926
-    }
927
-
928
-
929
-    /**
930
-     * @param string $wrap_class
931
-     * @param string $wrap_id
932
-     * @return string
933
-     */
934
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
935
-    {
936
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
937
-        if (! $admin &&
938
-            ! apply_filters(
939
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
940
-                EE_Registry::instance()->CFG->admin->show_reg_footer
941
-            )
942
-        ) {
943
-            return '';
944
-        }
945
-        $tag        = $admin ? 'span' : 'div';
946
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
947
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
948
-        $attributes .= ! empty($wrap_class)
949
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
950
-            : ' class="powered-by-event-espresso-credit"';
951
-        $query_args = array_merge(
952
-            array(
953
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
954
-                'utm_source'   => 'powered_by_event_espresso',
955
-                'utm_medium'   => 'link',
956
-                'utm_campaign' => 'powered_by',
957
-            ),
958
-            $query_args
959
-        );
960
-        $powered_by = apply_filters(
961
-            'FHEE__EEH_Template__powered_by_event_espresso_text',
962
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
963
-        );
964
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
965
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
966
-        return (string) apply_filters(
967
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
968
-            sprintf(
969
-                esc_html_x(
970
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
971
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
972
-                    'event_espresso'
973
-                ),
974
-                "<{$tag}{$attributes}>",
975
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
976
-                $admin ? '' : '<br />'
977
-            ),
978
-            $wrap_class,
979
-            $wrap_id
980
-        );
981
-    }
745
+			}
746
+		} else {
747
+			// simple value
748
+			echo esc_html($data);
749
+		}
750
+		return ob_get_clean();
751
+	}
752
+
753
+
754
+	/**
755
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
756
+	 *
757
+	 * @since 4.4.0
758
+	 * @see   self:get_paging_html() for argument docs.
759
+	 * @param        $total_items
760
+	 * @param        $current
761
+	 * @param        $per_page
762
+	 * @param        $url
763
+	 * @param bool   $show_num_field
764
+	 * @param string $paged_arg_name
765
+	 * @param array  $items_label
766
+	 * @return string
767
+	 */
768
+	public static function paging_html(
769
+		$total_items,
770
+		$current,
771
+		$per_page,
772
+		$url,
773
+		$show_num_field = true,
774
+		$paged_arg_name = 'paged',
775
+		$items_label = array()
776
+	) {
777
+		echo self::get_paging_html(
778
+			$total_items,
779
+			$current,
780
+			$per_page,
781
+			$url,
782
+			$show_num_field,
783
+			$paged_arg_name,
784
+			$items_label
785
+		);
786
+	}
787
+
788
+
789
+	/**
790
+	 * A method for generating paging similar to WP_List_Table
791
+	 *
792
+	 * @since    4.4.0
793
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
794
+	 * @param  integer $total_items     How many total items there are to page.
795
+	 * @param  integer $current         What the current page is.
796
+	 * @param  integer $per_page        How many items per page.
797
+	 * @param  string  $url             What the base url for page links is.
798
+	 * @param  boolean $show_num_field  Whether to show the input for changing page number.
799
+	 * @param  string  $paged_arg_name  The name of the key for the paged query argument.
800
+	 * @param  array   $items_label     An array of singular/plural values for the items label:
801
+	 *                                  array(
802
+	 *                                  'single' => 'item',
803
+	 *                                  'plural' => 'items'
804
+	 *                                  )
805
+	 * @return  string
806
+	 */
807
+	public static function get_paging_html(
808
+		$total_items,
809
+		$current,
810
+		$per_page,
811
+		$url,
812
+		$show_num_field = true,
813
+		$paged_arg_name = 'paged',
814
+		$items_label = array()
815
+	) {
816
+		$page_links     = array();
817
+		$disable_first  = $disable_last = '';
818
+		$total_items    = (int) $total_items;
819
+		$per_page       = (int) $per_page;
820
+		$current        = (int) $current;
821
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
822
+
823
+		// filter items_label
824
+		$items_label = apply_filters(
825
+			'FHEE__EEH_Template__get_paging_html__items_label',
826
+			$items_label
827
+		);
828
+
829
+		if (empty($items_label)
830
+			|| ! is_array($items_label)
831
+			|| ! isset($items_label['single'])
832
+			|| ! isset($items_label['plural'])
833
+		) {
834
+			$items_label = array(
835
+				'single' => __('1 item', 'event_espresso'),
836
+				'plural' => __('%s items', 'event_espresso'),
837
+			);
838
+		} else {
839
+			$items_label = array(
840
+				'single' => '1 ' . esc_html($items_label['single']),
841
+				'plural' => '%s ' . esc_html($items_label['plural']),
842
+			);
843
+		}
844
+
845
+		$total_pages = ceil($total_items / $per_page);
846
+
847
+		if ($total_pages <= 1) {
848
+			return '';
849
+		}
850
+
851
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
852
+
853
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
854
+
855
+		if ($current === 1) {
856
+			$disable_first = ' disabled';
857
+		}
858
+		if ($current == $total_pages) {
859
+			$disable_last = ' disabled';
860
+		}
861
+
862
+		$page_links[] = sprintf(
863
+			"<a class='%s' title='%s' href='%s'>%s</a>",
864
+			'first-page' . $disable_first,
865
+			esc_attr__('Go to the first page', 'event_espresso'),
866
+			esc_url(remove_query_arg($paged_arg_name, $url)),
867
+			'&laquo;'
868
+		);
869
+
870
+		$page_links[] = sprintf(
871
+			'<a class="%s" title="%s" href="%s">%s</a>',
872
+			'prev-page' . $disable_first,
873
+			esc_attr__('Go to the previous page', 'event_espresso'),
874
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
875
+			'&lsaquo;'
876
+		);
877
+
878
+		if (! $show_num_field) {
879
+			$html_current_page = $current;
880
+		} else {
881
+			$html_current_page = sprintf(
882
+				"<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
883
+				esc_attr__('Current page', 'event_espresso'),
884
+				$current,
885
+				strlen($total_pages)
886
+			);
887
+		}
888
+
889
+		$html_total_pages = sprintf(
890
+			'<span class="total-pages">%s</span>',
891
+			number_format_i18n($total_pages)
892
+		);
893
+		$page_links[]     = sprintf(
894
+			_x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
895
+			$html_current_page,
896
+			$html_total_pages,
897
+			'<span class="paging-input">',
898
+			'</span>'
899
+		);
900
+
901
+		$page_links[] = sprintf(
902
+			'<a class="%s" title="%s" href="%s">%s</a>',
903
+			'next-page' . $disable_last,
904
+			esc_attr__('Go to the next page', 'event_espresso'),
905
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
906
+			'&rsaquo;'
907
+		);
908
+
909
+		$page_links[] = sprintf(
910
+			'<a class="%s" title="%s" href="%s">%s</a>',
911
+			'last-page' . $disable_last,
912
+			esc_attr__('Go to the last page', 'event_espresso'),
913
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
914
+			'&raquo;'
915
+		);
916
+
917
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
918
+		// set page class
919
+		if ($total_pages) {
920
+			$page_class = $total_pages < 2 ? ' one-page' : '';
921
+		} else {
922
+			$page_class = ' no-pages';
923
+		}
924
+
925
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
926
+	}
927
+
928
+
929
+	/**
930
+	 * @param string $wrap_class
931
+	 * @param string $wrap_id
932
+	 * @return string
933
+	 */
934
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
935
+	{
936
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
937
+		if (! $admin &&
938
+			! apply_filters(
939
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
940
+				EE_Registry::instance()->CFG->admin->show_reg_footer
941
+			)
942
+		) {
943
+			return '';
944
+		}
945
+		$tag        = $admin ? 'span' : 'div';
946
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
947
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
948
+		$attributes .= ! empty($wrap_class)
949
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
950
+			: ' class="powered-by-event-espresso-credit"';
951
+		$query_args = array_merge(
952
+			array(
953
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
954
+				'utm_source'   => 'powered_by_event_espresso',
955
+				'utm_medium'   => 'link',
956
+				'utm_campaign' => 'powered_by',
957
+			),
958
+			$query_args
959
+		);
960
+		$powered_by = apply_filters(
961
+			'FHEE__EEH_Template__powered_by_event_espresso_text',
962
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
963
+		);
964
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
965
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
966
+		return (string) apply_filters(
967
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
968
+			sprintf(
969
+				esc_html_x(
970
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
971
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
972
+					'event_espresso'
973
+				),
974
+				"<{$tag}{$attributes}>",
975
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
976
+				$admin ? '' : '<br />'
977
+			),
978
+			$wrap_class,
979
+			$wrap_id
980
+		);
981
+	}
982 982
 }
983 983
 
984 984
 
985 985
 
986 986
 
987 987
 if (! function_exists('espresso_pagination')) {
988
-    /**
989
-     *    espresso_pagination
990
-     *
991
-     * @access    public
992
-     * @return    void
993
-     */
994
-    function espresso_pagination()
995
-    {
996
-        global $wp_query;
997
-        $big        = 999999999; // need an unlikely integer
998
-        $pagination = paginate_links(
999
-            array(
1000
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1001
-                'format'       => '?paged=%#%',
1002
-                'current'      => max(1, get_query_var('paged')),
1003
-                'total'        => $wp_query->max_num_pages,
1004
-                'show_all'     => true,
1005
-                'end_size'     => 10,
1006
-                'mid_size'     => 6,
1007
-                'prev_next'    => true,
1008
-                'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
1009
-                'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
1010
-                'type'         => 'plain',
1011
-                'add_args'     => false,
1012
-                'add_fragment' => '',
1013
-            )
1014
-        );
1015
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1016
-    }
988
+	/**
989
+	 *    espresso_pagination
990
+	 *
991
+	 * @access    public
992
+	 * @return    void
993
+	 */
994
+	function espresso_pagination()
995
+	{
996
+		global $wp_query;
997
+		$big        = 999999999; // need an unlikely integer
998
+		$pagination = paginate_links(
999
+			array(
1000
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
1001
+				'format'       => '?paged=%#%',
1002
+				'current'      => max(1, get_query_var('paged')),
1003
+				'total'        => $wp_query->max_num_pages,
1004
+				'show_all'     => true,
1005
+				'end_size'     => 10,
1006
+				'mid_size'     => 6,
1007
+				'prev_next'    => true,
1008
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
1009
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
1010
+				'type'         => 'plain',
1011
+				'add_args'     => false,
1012
+				'add_fragment' => '',
1013
+			)
1014
+		);
1015
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1016
+	}
1017 1017
 }
1018 1018
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\services\loaders\LoaderFactory;
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8
-if (! function_exists('espresso_get_template_part')) {
8
+if ( ! function_exists('espresso_get_template_part')) {
9 9
     /**
10 10
      * espresso_get_template_part
11 11
      * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 }
23 23
 
24 24
 
25
-if (! function_exists('espresso_get_object_css_class')) {
25
+if ( ! function_exists('espresso_get_object_css_class')) {
26 26
     /**
27 27
      * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28 28
      *
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public static function load_espresso_theme_functions()
72 72
     {
73
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
74
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
75
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
73
+        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
74
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php')) {
75
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php');
76 76
             }
77 77
         }
78 78
     }
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
     public static function get_espresso_themes()
87 87
     {
88 88
         if (empty(EEH_Template::$_espresso_themes)) {
89
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
89
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
90 90
             if (empty($espresso_themes)) {
91 91
                 return array();
92 92
             }
93 93
             if (($key = array_search('global_assets', $espresso_themes)) !== false) {
94
-                unset($espresso_themes[ $key ]);
94
+                unset($espresso_themes[$key]);
95 95
             }
96 96
             EEH_Template::$_espresso_themes = array();
97 97
             foreach ($espresso_themes as $espresso_theme) {
98
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
98
+                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
99 99
             }
100 100
         }
101 101
         return EEH_Template::$_espresso_themes;
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
                 // get array of EE Custom Post Types
210 210
                 $EE_CPTs = $custom_post_types->getDefinitions();
211 211
                 // build template name based on request
212
-                if (isset($EE_CPTs[ $post_type ])) {
212
+                if (isset($EE_CPTs[$post_type])) {
213 213
                     $archive_or_single = is_archive() ? 'archive' : '';
214 214
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
215
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
215
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
216 216
                 }
217 217
             }
218 218
             // currently active EE template theme
@@ -221,18 +221,18 @@  discard block
 block discarded – undo
221 221
             // array of paths to folders that may contain templates
222 222
             $template_folder_paths = array(
223 223
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
224
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
224
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
225 225
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
226 226
                 EVENT_ESPRESSO_TEMPLATE_DIR,
227 227
             );
228 228
 
229 229
             // add core plugin folders for checking only if we're not $check_if_custom
230
-            if (! $check_if_custom) {
231
-                $core_paths            = array(
230
+            if ( ! $check_if_custom) {
231
+                $core_paths = array(
232 232
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
233
-                    EE_PUBLIC . $current_theme,
233
+                    EE_PUBLIC.$current_theme,
234 234
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
235
-                    EE_TEMPLATES . $current_theme,
235
+                    EE_TEMPLATES.$current_theme,
236 236
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
237 237
                     EE_PLUGIN_DIR_PATH,
238 238
                 );
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
                     );
266 266
                     if ($common_base_path !== '') {
267 267
                         // both paths have a common base, so just tack the filename onto our search path
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
268
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
269 269
                     } else {
270 270
                         // no common base path, so let's just concatenate
271
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
271
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
272 272
                     }
273 273
                     // build up our template locations array by adding our resolved paths
274 274
                     $full_template_paths[] = $resolved_path;
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
277 277
                 array_unshift($full_template_paths, $template);
278 278
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
279
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
279
+                array_unshift($full_template_paths, get_stylesheet_directory().'/'.$file_name);
280 280
             }
281 281
             // filter final array of full template paths
282 282
             $full_template_paths = apply_filters(
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
         $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
366 366
 
367 367
         // you gimme nuttin - YOU GET NUTTIN !!
368
-        if (! $template_path || ! is_readable($template_path)) {
368
+        if ( ! $template_path || ! is_readable($template_path)) {
369 369
             return '';
370 370
         }
371 371
         // if $template_args are not in an array, then make it so
372
-        if (! is_array($template_args) && ! is_object($template_args)) {
372
+        if ( ! is_array($template_args) && ! is_object($template_args)) {
373 373
             $template_args = array($template_args);
374 374
         }
375 375
         extract($template_args, EXTR_SKIP);
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
408 408
     {
409 409
         // in the beginning...
410
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
410
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
411 411
         // da muddle
412 412
         $class = '';
413 413
         // the end
414
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
414
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
415 415
         // is the passed object an EE object ?
416 416
         if ($object instanceof EE_Base_Class) {
417 417
             // grab the exact type of object
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
                 // no specifics just yet...
422 422
                 default:
423 423
                     $class = strtolower(str_replace('_', '-', $obj_class));
424
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
424
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
425 425
             }
426 426
         }
427
-        return $prefix . $class . $suffix;
427
+        return $prefix.$class.$suffix;
428 428
     }
429 429
 
430 430
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
             // was a country ISO code passed ? if so generate currency config object for that country
466 466
             $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
467 467
             // verify results
468
-            if (! $mny instanceof EE_Currency_Config) {
468
+            if ( ! $mny instanceof EE_Currency_Config) {
469 469
                 // set default config country currency settings
470 470
                 $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
471 471
                     ? EE_Registry::instance()->CFG->currency
@@ -474,23 +474,23 @@  discard block
 block discarded – undo
474 474
             // format float
475 475
             $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
476 476
             // add formatting ?
477
-            if (! $return_raw) {
477
+            if ( ! $return_raw) {
478 478
                 // add currency sign
479 479
                 if ($mny->sign_b4) {
480 480
                     if ($amount >= 0) {
481
-                        $amount_formatted = $mny->sign . $amount_formatted;
481
+                        $amount_formatted = $mny->sign.$amount_formatted;
482 482
                     } else {
483
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
483
+                        $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
484 484
                     }
485 485
                 } else {
486
-                    $amount_formatted = $amount_formatted . $mny->sign;
486
+                    $amount_formatted = $amount_formatted.$mny->sign;
487 487
                 }
488 488
 
489 489
                 // filter to allow global setting of display_code
490 490
                 $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
491 491
 
492 492
                 // add currency code ?
493
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
493
+                $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted;
494 494
             }
495 495
             // filter results
496 496
             $amount_formatted = apply_filters(
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             $plural,
528 528
             $schema
529 529
         );
530
-        return $status[ $status_id ];
530
+        return $status[$status_id];
531 531
     }
532 532
 
533 533
 
@@ -544,19 +544,19 @@  discard block
 block discarded – undo
544 544
     public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
545 545
     {
546 546
         $icon_html = '';
547
-        if (! empty($icon)) {
547
+        if ( ! empty($icon)) {
548 548
             $dashicons = preg_split("(ee-icon |dashicons )", $icon);
549 549
             $dashicons = array_filter($dashicons);
550 550
             $count     = count($dashicons);
551 551
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
552 552
             foreach ($dashicons as $dashicon) {
553 553
                 $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
554
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
554
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
555 555
             }
556 556
             $icon_html .= $count > 1 ? '</span>' : '';
557 557
         }
558
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
559
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
558
+        $label  = ! empty($icon) ? $icon_html.$label : $label;
559
+        $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.esc_url($url).'" class="'.$class.'" title="'.$title.'">'.$label.'</a>';
560 560
         return $button;
561 561
     }
562 562
 
@@ -579,24 +579,24 @@  discard block
 block discarded – undo
579 579
         $help_text = false
580 580
     ) {
581 581
 
582
-        if (! $page) {
582
+        if ( ! $page) {
583 583
             $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
584 584
         }
585 585
 
586
-        if (! $action) {
586
+        if ( ! $action) {
587 587
             $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
588 588
         }
589 589
 
590 590
         $action = empty($action) ? 'default' : $action;
591 591
 
592 592
 
593
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
593
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
594 594
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
595 595
         $help_text    = ! $help_text ? '' : $help_text;
596
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__(
596
+        return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__(
597 597
             'Click to open the \'Help\' tab for more information about this feature.',
598 598
             'event_espresso'
599
-        ) . '" > ' . $help_text . ' </a>';
599
+        ).'" > '.$help_text.' </a>';
600 600
     }
601 601
 
602 602
 
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
         $id    = $tour->get_slug();
614 614
         $stops = $tour->get_stops();
615 615
 
616
-        $content = '<ol style="display:none" id="' . $id . '">';
616
+        $content = '<ol style="display:none" id="'.$id.'">';
617 617
 
618 618
         foreach ($stops as $stop) {
619
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
620
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
619
+            $data_id    = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
620
+            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
621 621
 
622 622
             // if container is set to modal then let's make sure we set the options accordingly
623 623
             if (empty($data_id) && empty($data_class)) {
@@ -625,15 +625,15 @@  discard block
 block discarded – undo
625 625
                 $stop['options']['expose'] = true;
626 626
             }
627 627
 
628
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
629
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
628
+            $custom_class  = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
629
+            $button_text   = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
630 630
             $inner_content = isset($stop['content']) ? $stop['content'] : '';
631 631
 
632 632
             // options
633 633
             if (isset($stop['options']) && is_array($stop['options'])) {
634 634
                 $options = ' data-options="';
635 635
                 foreach ($stop['options'] as $option => $value) {
636
-                    $options .= $option . ':' . $value . ';';
636
+                    $options .= $option.':'.$value.';';
637 637
                 }
638 638
                 $options .= '"';
639 639
             } else {
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
             }
642 642
 
643 643
             // let's put all together
644
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
644
+            $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
645 645
         }
646 646
 
647 647
         $content .= '</ol>';
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
      */
666 666
     public static function status_legend($status_array, $active_status = '')
667 667
     {
668
-        if (! is_array($status_array)) {
668
+        if ( ! is_array($status_array)) {
669 669
             throw new EE_Error(esc_html__(
670 670
                 'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
671 671
                 'event_espresso'
@@ -674,25 +674,25 @@  discard block
 block discarded – undo
674 674
 
675 675
         $setup_array = array();
676 676
         foreach ($status_array as $item => $status) {
677
-            $setup_array[ $item ] = array(
678
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
677
+            $setup_array[$item] = array(
678
+                'class'  => 'ee-status-legend ee-status-legend-'.$status,
679 679
                 'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
680 680
                 'status' => $status,
681 681
             );
682 682
         }
683 683
 
684
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
685
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
686
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
684
+        $content = '<div class="ee-list-table-legend-container">'."\n";
685
+        $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n";
686
+        $content .= '<dl class="ee-list-table-legend">'."\n\t";
687 687
         foreach ($setup_array as $item => $details) {
688 688
             $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
689
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
690
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
691
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
692
-            $content .= '</dt>' . "\n";
689
+            $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
690
+            $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
691
+            $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
692
+            $content .= '</dt>'."\n";
693 693
         }
694
-        $content .= '</dl>' . "\n";
695
-        $content .= '</div>' . "\n";
694
+        $content .= '</dl>'."\n";
695
+        $content .= '</div>'."\n";
696 696
         return $content;
697 697
     }
698 698
 
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
             );
838 838
         } else {
839 839
             $items_label = array(
840
-                'single' => '1 ' . esc_html($items_label['single']),
841
-                'plural' => '%s ' . esc_html($items_label['plural']),
840
+                'single' => '1 '.esc_html($items_label['single']),
841
+                'plural' => '%s '.esc_html($items_label['plural']),
842 842
             );
843 843
         }
844 844
 
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 
851 851
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
852 852
 
853
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
853
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
854 854
 
855 855
         if ($current === 1) {
856 856
             $disable_first = ' disabled';
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 
862 862
         $page_links[] = sprintf(
863 863
             "<a class='%s' title='%s' href='%s'>%s</a>",
864
-            'first-page' . $disable_first,
864
+            'first-page'.$disable_first,
865 865
             esc_attr__('Go to the first page', 'event_espresso'),
866 866
             esc_url(remove_query_arg($paged_arg_name, $url)),
867 867
             '&laquo;'
@@ -869,13 +869,13 @@  discard block
 block discarded – undo
869 869
 
870 870
         $page_links[] = sprintf(
871 871
             '<a class="%s" title="%s" href="%s">%s</a>',
872
-            'prev-page' . $disable_first,
872
+            'prev-page'.$disable_first,
873 873
             esc_attr__('Go to the previous page', 'event_espresso'),
874 874
             esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
875 875
             '&lsaquo;'
876 876
         );
877 877
 
878
-        if (! $show_num_field) {
878
+        if ( ! $show_num_field) {
879 879
             $html_current_page = $current;
880 880
         } else {
881 881
             $html_current_page = sprintf(
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
             '<span class="total-pages">%s</span>',
891 891
             number_format_i18n($total_pages)
892 892
         );
893
-        $page_links[]     = sprintf(
893
+        $page_links[] = sprintf(
894 894
             _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
895 895
             $html_current_page,
896 896
             $html_total_pages,
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 
901 901
         $page_links[] = sprintf(
902 902
             '<a class="%s" title="%s" href="%s">%s</a>',
903
-            'next-page' . $disable_last,
903
+            'next-page'.$disable_last,
904 904
             esc_attr__('Go to the next page', 'event_espresso'),
905 905
             esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
906 906
             '&rsaquo;'
@@ -908,13 +908,13 @@  discard block
 block discarded – undo
908 908
 
909 909
         $page_links[] = sprintf(
910 910
             '<a class="%s" title="%s" href="%s">%s</a>',
911
-            'last-page' . $disable_last,
911
+            'last-page'.$disable_last,
912 912
             esc_attr__('Go to the last page', 'event_espresso'),
913 913
             esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
914 914
             '&raquo;'
915 915
         );
916 916
 
917
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
917
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
918 918
         // set page class
919 919
         if ($total_pages) {
920 920
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
             $page_class = ' no-pages';
923 923
         }
924 924
 
925
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
925
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
926 926
     }
927 927
 
928 928
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
     public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
935 935
     {
936 936
         $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
937
-        if (! $admin &&
937
+        if ( ! $admin &&
938 938
             ! apply_filters(
939 939
                 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
940 940
                 EE_Registry::instance()->CFG->admin->show_reg_footer
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
         );
960 960
         $powered_by = apply_filters(
961 961
             'FHEE__EEH_Template__powered_by_event_espresso_text',
962
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
962
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'
963 963
         );
964 964
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
965 965
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 
985 985
 
986 986
 
987
-if (! function_exists('espresso_pagination')) {
987
+if ( ! function_exists('espresso_pagination')) {
988 988
     /**
989 989
      *    espresso_pagination
990 990
      *
@@ -1012,6 +1012,6 @@  discard block
 block discarded – undo
1012 1012
                 'add_fragment' => '',
1013 1013
             )
1014 1014
         );
1015
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
1015
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
1016 1016
     }
1017 1017
 }
1018 1018
\ No newline at end of file
Please login to merge, or discard this patch.