Completed
Branch BUG/3575-event-deletion-previe... (bbeda1)
by
unknown
06:40 queued 04:49
created
core/libraries/messages/EE_Messenger_Collection.lib.php 2 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -14,185 +14,185 @@
 block discarded – undo
14 14
 class EE_Messenger_Collection extends EE_Object_Collection
15 15
 {
16 16
 
17
-    /**
18
-     * EE_Messenger_Collection constructor.
19
-     */
20
-    public function __construct()
21
-    {
22
-        $this->interface = 'EE_messenger';
23
-    }
24
-
25
-
26
-
27
-    /**
28
-     * add
29
-     *
30
-     * attaches an object to the Collection
31
-     * and sets any supplied data associated with the current iterator entry
32
-     * by calling EE_Object_Collection::set_info()
33
-     *
34
-     * @access public
35
-     * @param object $object
36
-     * @param mixed  $info
37
-     * @return bool
38
-     */
39
-    public function add($object, $info = null)
40
-    {
41
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
42
-        return parent::add($object, $info);
43
-    }
44
-
45
-
46
-
47
-    /**
48
-     * set_info
49
-     *
50
-     * Sets the data associated with an object in the Collection
51
-     * if no $info is supplied, then the spl_object_hash() is used
52
-     *
53
-     * @access public
54
-     * @param object $object
55
-     * @param mixed  $info
56
-     * @return bool
57
-     */
58
-    public function set_info($object, $info = null)
59
-    {
60
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
61
-        return parent::set_info($object, $info);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * get_by_info
68
-     *
69
-     * finds and returns an object in the Collection based on the info that was set using addObject()
70
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
71
-     *
72
-     * @access public
73
-     * @param mixed
74
-     * @return null | object
75
-     */
76
-    public function get_by_info($info)
77
-    {
78
-        return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
79
-    }
80
-
81
-
82
-
83
-    /**
84
-     * has
85
-     *
86
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
87
-     *
88
-     * @access public
89
-     * @param object $object
90
-     * @return bool
91
-     */
92
-    public function has($object)
93
-    {
94
-        return parent::has($object);
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * has_by_name
101
-     *
102
-     * returns TRUE or FALSE depending on whether the supplied messenger name is within the Collection
103
-     *
104
-     * @access public
105
-     * @param string $messenger_name
106
-     * @return bool
107
-     */
108
-    public function has_by_name($messenger_name)
109
-    {
110
-        return $this->get_by_info($messenger_name) instanceof $this->interface ? true : false;
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * remove
117
-     *
118
-     * detaches an object from the Collection
119
-     *
120
-     * @access public
121
-     * @param $object
122
-     * @return bool
123
-     */
124
-    public function remove($object)
125
-    {
126
-        return parent::remove($object);
127
-    }
128
-
129
-
130
-
131
-    /**
132
-     * current
133
-     *
134
-     * current object from the Collection
135
-     *
136
-     * @access public
137
-     * @return EE_messenger
138
-     */
139
-    public function current()
140
-    {
141
-        return parent::current();
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     * set_current
148
-     *
149
-     * advances pointer to the provided object
150
-     *
151
-     * @access public
152
-     * @param $object
153
-     * @return void
154
-     */
155
-    public function set_current($object)
156
-    {
157
-        parent::set_current($object);
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * set_current_by_info
164
-     *
165
-     * advances pointer to the object whose info matches that which was provided
166
-     *
167
-     * @access public
168
-     * @param $info
169
-     * @return void
170
-     */
171
-    public function set_current_by_info($info)
172
-    {
173
-        parent::set_current_by_info($info);
174
-    }
175
-
176
-
177
-
178
-    /**
179
-     * show_collection_classes
180
-     *
181
-     * displays list of collection classes if WP_DEBUG is on
182
-     *
183
-     * @access public
184
-     * @return void
185
-     */
186
-    public function show_collection_classes()
187
-    {
188
-        if (WP_DEBUG) {
189
-            $this->rewind();
190
-            while ($this->valid()) {
191
-                echo '<h5 style="color:#2EA2CC;">
17
+	/**
18
+	 * EE_Messenger_Collection constructor.
19
+	 */
20
+	public function __construct()
21
+	{
22
+		$this->interface = 'EE_messenger';
23
+	}
24
+
25
+
26
+
27
+	/**
28
+	 * add
29
+	 *
30
+	 * attaches an object to the Collection
31
+	 * and sets any supplied data associated with the current iterator entry
32
+	 * by calling EE_Object_Collection::set_info()
33
+	 *
34
+	 * @access public
35
+	 * @param object $object
36
+	 * @param mixed  $info
37
+	 * @return bool
38
+	 */
39
+	public function add($object, $info = null)
40
+	{
41
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
42
+		return parent::add($object, $info);
43
+	}
44
+
45
+
46
+
47
+	/**
48
+	 * set_info
49
+	 *
50
+	 * Sets the data associated with an object in the Collection
51
+	 * if no $info is supplied, then the spl_object_hash() is used
52
+	 *
53
+	 * @access public
54
+	 * @param object $object
55
+	 * @param mixed  $info
56
+	 * @return bool
57
+	 */
58
+	public function set_info($object, $info = null)
59
+	{
60
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
61
+		return parent::set_info($object, $info);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * get_by_info
68
+	 *
69
+	 * finds and returns an object in the Collection based on the info that was set using addObject()
70
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
71
+	 *
72
+	 * @access public
73
+	 * @param mixed
74
+	 * @return null | object
75
+	 */
76
+	public function get_by_info($info)
77
+	{
78
+		return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
79
+	}
80
+
81
+
82
+
83
+	/**
84
+	 * has
85
+	 *
86
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
87
+	 *
88
+	 * @access public
89
+	 * @param object $object
90
+	 * @return bool
91
+	 */
92
+	public function has($object)
93
+	{
94
+		return parent::has($object);
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * has_by_name
101
+	 *
102
+	 * returns TRUE or FALSE depending on whether the supplied messenger name is within the Collection
103
+	 *
104
+	 * @access public
105
+	 * @param string $messenger_name
106
+	 * @return bool
107
+	 */
108
+	public function has_by_name($messenger_name)
109
+	{
110
+		return $this->get_by_info($messenger_name) instanceof $this->interface ? true : false;
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * remove
117
+	 *
118
+	 * detaches an object from the Collection
119
+	 *
120
+	 * @access public
121
+	 * @param $object
122
+	 * @return bool
123
+	 */
124
+	public function remove($object)
125
+	{
126
+		return parent::remove($object);
127
+	}
128
+
129
+
130
+
131
+	/**
132
+	 * current
133
+	 *
134
+	 * current object from the Collection
135
+	 *
136
+	 * @access public
137
+	 * @return EE_messenger
138
+	 */
139
+	public function current()
140
+	{
141
+		return parent::current();
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 * set_current
148
+	 *
149
+	 * advances pointer to the provided object
150
+	 *
151
+	 * @access public
152
+	 * @param $object
153
+	 * @return void
154
+	 */
155
+	public function set_current($object)
156
+	{
157
+		parent::set_current($object);
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * set_current_by_info
164
+	 *
165
+	 * advances pointer to the object whose info matches that which was provided
166
+	 *
167
+	 * @access public
168
+	 * @param $info
169
+	 * @return void
170
+	 */
171
+	public function set_current_by_info($info)
172
+	{
173
+		parent::set_current_by_info($info);
174
+	}
175
+
176
+
177
+
178
+	/**
179
+	 * show_collection_classes
180
+	 *
181
+	 * displays list of collection classes if WP_DEBUG is on
182
+	 *
183
+	 * @access public
184
+	 * @return void
185
+	 */
186
+	public function show_collection_classes()
187
+	{
188
+		if (WP_DEBUG) {
189
+			$this->rewind();
190
+			while ($this->valid()) {
191
+				echo '<h5 style="color:#2EA2CC;">
192 192
                     ' . __CLASS__ . ' class : . <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
193 193
                     </h5>';
194
-                $this->next();
195
-            }
196
-        }
197
-    }
194
+				$this->next();
195
+			}
196
+		}
197
+	}
198 198
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@
 block discarded – undo
189 189
             $this->rewind();
190 190
             while ($this->valid()) {
191 191
                 echo '<h5 style="color:#2EA2CC;">
192
-                    ' . __CLASS__ . ' class : . <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
192
+                    ' . __CLASS__.' class : . <span style="color:#E76700">'.esc_html($this->getInfo()).'</span>
193 193
                     </h5>';
194 194
                 $this->next();
195 195
             }
Please login to merge, or discard this patch.
core/EE_Maintenance_Mode.core.php 2 patches
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -16,340 +16,340 @@
 block discarded – undo
16 16
 class EE_Maintenance_Mode implements ResettableInterface
17 17
 {
18 18
 
19
-    /**
20
-     * constants available to client code for interpreting the values of EE_Maintenance_Mode::level().
21
-     * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal)
22
-     */
23
-    const level_0_not_in_maintenance = 0;
24
-
25
-    /**
26
-     * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled
27
-     * but the admin backend should be running as normal. Maybe an admin can view the frontend though
28
-     */
29
-    const level_1_frontend_only_maintenance = 1;
30
-
31
-    /**
32
-     * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running
33
-     * is the maintenance mode stuff, which will require users to update all addons, and then finish running all
34
-     * migration scripts before taking the site out of maintenance mode
35
-     */
36
-    const level_2_complete_maintenance = 2;
37
-
38
-    /**
39
-     * the name of the option which stores the current level of maintenance mode
40
-     */
41
-    const option_name_maintenance_mode = 'ee_maintenance_mode';
42
-
43
-
44
-    /**
45
-     * @var EE_Maintenance_Mode $_instance
46
-     */
47
-    private static $_instance;
48
-
49
-    /**
50
-     * @var EE_Registry $EE
51
-     */
52
-    protected $EE;
53
-
54
-
55
-    /**
56
-     * @singleton method used to instantiate class object
57
-     * @return EE_Maintenance_Mode
58
-     */
59
-    public static function instance()
60
-    {
61
-        // check if class object is instantiated
62
-        if (! self::$_instance instanceof EE_Maintenance_Mode) {
63
-            self::$_instance = new self();
64
-        }
65
-        return self::$_instance;
66
-    }
67
-
68
-
69
-    /**
70
-     * Resets maintenance mode (mostly just re-checks whether we should be in maintenance mode)
71
-     *
72
-     * @return EE_Maintenance_Mode
73
-     * @throws EE_Error
74
-     */
75
-    public static function reset()
76
-    {
77
-        self::instance()->set_maintenance_mode_if_db_old();
78
-        return self::instance();
79
-    }
80
-
81
-
82
-    /**
83
-     *private constructor to prevent direct creation
84
-     */
85
-    private function __construct()
86
-    {
87
-        // if M-Mode level 2 is engaged, we still need basic assets loaded
88
-        add_action('wp_enqueue_scripts', [$this, 'load_assets_required_for_m_mode']);
89
-        // shut 'er down for maintenance ?
90
-        add_filter('the_content', [$this, 'the_content'], 2);
91
-        // add powered by EE msg
92
-        add_action('shutdown', [$this, 'display_maintenance_mode_notice'], 10);
93
-    }
94
-
95
-
96
-    /**
97
-     * retrieves the maintenance mode option value from the db
98
-     *
99
-     * @return int
100
-     */
101
-    public function real_level()
102
-    {
103
-        return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
104
-    }
105
-
106
-
107
-    /**
108
-     * Returns whether the models reportedly are able to run queries or not
109
-     * (ie, if the system thinks their tables are present and up-to-date).
110
-     *
111
-     * @return boolean
112
-     */
113
-    public function models_can_query()
114
-    {
115
-        return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
116
-    }
117
-
118
-
119
-    /**
120
-     * Determines whether we're in maintenance mode and what level. However, while the site
121
-     * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear
122
-     * to them as if teh site isn't in maintenance mode.
123
-     * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode)
124
-     * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode
125
-     * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
126
-     *
127
-     * @return int
128
-     */
129
-    public function level()
130
-    {
131
-        $maintenance_mode_level = $this->real_level();
132
-        // if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
133
-        if (
134
-            $maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1
135
-            && ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests
136
-            && current_user_can('administrator') // when the user is an admin
137
-        ) {
138
-            $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
139
-        }
140
-        return $maintenance_mode_level;
141
-    }
142
-
143
-
144
-    /**
145
-     * Determines if we need to put EE in maintenance mode because the database needs updating
146
-     *
147
-     * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
148
-     * @throws EE_Error
149
-     */
150
-    public function set_maintenance_mode_if_db_old()
151
-    {
152
-        LoaderFactory::getLoader()->getShared('Data_Migration_Manager');
153
-        if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
154
-            update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
155
-            return true;
156
-        }
157
-        if ($this->level() === self::level_2_complete_maintenance) {
158
-            // we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
159
-            // then we shouldn't be in mm2. (Maybe an addon got deactivated?)
160
-            update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
161
-            return false;
162
-        }
163
-        return false;
164
-    }
165
-
166
-
167
-    /**
168
-     * Updates the maintenance level on the site
169
-     *
170
-     * @param int $level
171
-     * @return void
172
-     */
173
-    public function set_maintenance_level($level)
174
-    {
175
-        do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
176
-        update_option(self::option_name_maintenance_mode, (int) $level);
177
-    }
178
-
179
-
180
-    /**
181
-     * returns TRUE if M-Mode is engaged and the current request is not for the admin
182
-     *
183
-     * @return bool
184
-     */
185
-    public static function disable_frontend_for_maintenance()
186
-    {
187
-        return (! is_admin() && EE_Maintenance_Mode::instance()->level());
188
-    }
189
-
190
-
191
-    /**
192
-     * @return void
193
-     */
194
-    public function load_assets_required_for_m_mode()
195
-    {
196
-        if (
197
-            $this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance
198
-            && ! wp_script_is('espresso_core')
199
-        ) {
200
-            wp_register_style(
201
-                'espresso_default',
202
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
203
-                ['dashicons'],
204
-                EVENT_ESPRESSO_VERSION
205
-            );
206
-            wp_enqueue_style('espresso_default');
207
-            wp_register_script(
208
-                'espresso_core',
209
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
210
-                ['jquery'],
211
-                EVENT_ESPRESSO_VERSION,
212
-                true
213
-            );
214
-            wp_enqueue_script('espresso_core');
215
-        }
216
-    }
217
-
218
-
219
-    /**
220
-     * replacement EE CPT template that displays message notifying site visitors
221
-     * that EE has been temporarily placed into maintenance mode
222
-     * does NOT get called on non-EE-CPT requests
223
-     *
224
-     * @return    string
225
-     */
226
-    public static function template_include()
227
-    {
228
-        // shut 'er down for maintenance ? then don't use any of our templates for our endpoints
229
-        return get_template_directory() . '/index.php';
230
-    }
231
-
232
-
233
-    /**
234
-     * displays message notifying site visitors that EE has been temporarily
235
-     * placed into maintenance mode when post_type != EE CPT
236
-     *
237
-     * @param string $the_content
238
-     * @return string
239
-     */
240
-    public function the_content($the_content)
241
-    {
242
-        // check if M-mode is engaged and for EE shortcode
243
-        if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
244
-            // this can eventually be moved to a template, or edited via admin. But for now...
245
-            $the_content = sprintf(
246
-                esc_html__(
247
-                    '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s',
248
-                    'event_espresso'
249
-                ),
250
-                '<h3>',
251
-                '</h3><p>',
252
-                '</p>'
253
-            );
254
-        }
255
-        return $the_content;
256
-    }
257
-
258
-
259
-    /**
260
-     * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
261
-     */
262
-    public function display_maintenance_mode_notice()
263
-    {
264
-        /** @var CurrentPage $current_page */
265
-        $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
266
-        // check if M-mode is engaged and for EE shortcode
267
-        if (
268
-            ! (defined('DOING_AJAX') && DOING_AJAX)
269
-            && $this->real_level()
270
-            && ! is_admin()
271
-            && current_user_can('administrator')
272
-            && $current_page->isEspressoPage()
273
-        ) {
274
-            printf(
275
-                esc_html__(
276
-                    '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s',
277
-                    'event_espresso'
278
-                ),
279
-                '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
280
-                '"><span class="dashicons dashicons-no"></span></a><p>',
281
-                ' &raquo; <a href="' . add_query_arg(
282
-                    ['page' => 'espresso_maintenance_settings'],
283
-                    admin_url('admin.php')
284
-                ) . '">',
285
-                '</a></p></div>'
286
-            );
287
-        }
288
-    }
289
-    // espresso-notices important-notice ee-attention
290
-
291
-
292
-    /**
293
-     * override magic methods
294
-     */
295
-    final public function __destruct()
296
-    {
297
-    }
298
-
299
-
300
-    final public function __call($a, $b)
301
-    {
302
-    }
303
-
304
-
305
-    final public function __get($a)
306
-    {
307
-    }
308
-
309
-
310
-    final public function __set($a, $b)
311
-    {
312
-    }
313
-
314
-
315
-    final public function __isset($a)
316
-    {
317
-    }
318
-
319
-
320
-    final public function __unset($a)
321
-    {
322
-    }
323
-
324
-
325
-    final public function __sleep()
326
-    {
327
-        return [];
328
-    }
329
-
330
-
331
-    final public function __wakeup()
332
-    {
333
-    }
334
-
335
-
336
-    final public function __invoke()
337
-    {
338
-    }
339
-
340
-
341
-    final public static function __set_state($a = null)
342
-    {
343
-        return EE_Maintenance_Mode::instance();
344
-    }
345
-
346
-
347
-    final public function __clone()
348
-    {
349
-    }
19
+	/**
20
+	 * constants available to client code for interpreting the values of EE_Maintenance_Mode::level().
21
+	 * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal)
22
+	 */
23
+	const level_0_not_in_maintenance = 0;
24
+
25
+	/**
26
+	 * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled
27
+	 * but the admin backend should be running as normal. Maybe an admin can view the frontend though
28
+	 */
29
+	const level_1_frontend_only_maintenance = 1;
30
+
31
+	/**
32
+	 * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running
33
+	 * is the maintenance mode stuff, which will require users to update all addons, and then finish running all
34
+	 * migration scripts before taking the site out of maintenance mode
35
+	 */
36
+	const level_2_complete_maintenance = 2;
37
+
38
+	/**
39
+	 * the name of the option which stores the current level of maintenance mode
40
+	 */
41
+	const option_name_maintenance_mode = 'ee_maintenance_mode';
42
+
43
+
44
+	/**
45
+	 * @var EE_Maintenance_Mode $_instance
46
+	 */
47
+	private static $_instance;
48
+
49
+	/**
50
+	 * @var EE_Registry $EE
51
+	 */
52
+	protected $EE;
53
+
54
+
55
+	/**
56
+	 * @singleton method used to instantiate class object
57
+	 * @return EE_Maintenance_Mode
58
+	 */
59
+	public static function instance()
60
+	{
61
+		// check if class object is instantiated
62
+		if (! self::$_instance instanceof EE_Maintenance_Mode) {
63
+			self::$_instance = new self();
64
+		}
65
+		return self::$_instance;
66
+	}
67
+
68
+
69
+	/**
70
+	 * Resets maintenance mode (mostly just re-checks whether we should be in maintenance mode)
71
+	 *
72
+	 * @return EE_Maintenance_Mode
73
+	 * @throws EE_Error
74
+	 */
75
+	public static function reset()
76
+	{
77
+		self::instance()->set_maintenance_mode_if_db_old();
78
+		return self::instance();
79
+	}
80
+
81
+
82
+	/**
83
+	 *private constructor to prevent direct creation
84
+	 */
85
+	private function __construct()
86
+	{
87
+		// if M-Mode level 2 is engaged, we still need basic assets loaded
88
+		add_action('wp_enqueue_scripts', [$this, 'load_assets_required_for_m_mode']);
89
+		// shut 'er down for maintenance ?
90
+		add_filter('the_content', [$this, 'the_content'], 2);
91
+		// add powered by EE msg
92
+		add_action('shutdown', [$this, 'display_maintenance_mode_notice'], 10);
93
+	}
94
+
95
+
96
+	/**
97
+	 * retrieves the maintenance mode option value from the db
98
+	 *
99
+	 * @return int
100
+	 */
101
+	public function real_level()
102
+	{
103
+		return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
104
+	}
105
+
106
+
107
+	/**
108
+	 * Returns whether the models reportedly are able to run queries or not
109
+	 * (ie, if the system thinks their tables are present and up-to-date).
110
+	 *
111
+	 * @return boolean
112
+	 */
113
+	public function models_can_query()
114
+	{
115
+		return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
116
+	}
117
+
118
+
119
+	/**
120
+	 * Determines whether we're in maintenance mode and what level. However, while the site
121
+	 * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear
122
+	 * to them as if teh site isn't in maintenance mode.
123
+	 * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode)
124
+	 * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode
125
+	 * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
126
+	 *
127
+	 * @return int
128
+	 */
129
+	public function level()
130
+	{
131
+		$maintenance_mode_level = $this->real_level();
132
+		// if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
133
+		if (
134
+			$maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1
135
+			&& ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests
136
+			&& current_user_can('administrator') // when the user is an admin
137
+		) {
138
+			$maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
139
+		}
140
+		return $maintenance_mode_level;
141
+	}
142
+
143
+
144
+	/**
145
+	 * Determines if we need to put EE in maintenance mode because the database needs updating
146
+	 *
147
+	 * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
148
+	 * @throws EE_Error
149
+	 */
150
+	public function set_maintenance_mode_if_db_old()
151
+	{
152
+		LoaderFactory::getLoader()->getShared('Data_Migration_Manager');
153
+		if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
154
+			update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
155
+			return true;
156
+		}
157
+		if ($this->level() === self::level_2_complete_maintenance) {
158
+			// we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
159
+			// then we shouldn't be in mm2. (Maybe an addon got deactivated?)
160
+			update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
161
+			return false;
162
+		}
163
+		return false;
164
+	}
165
+
166
+
167
+	/**
168
+	 * Updates the maintenance level on the site
169
+	 *
170
+	 * @param int $level
171
+	 * @return void
172
+	 */
173
+	public function set_maintenance_level($level)
174
+	{
175
+		do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
176
+		update_option(self::option_name_maintenance_mode, (int) $level);
177
+	}
178
+
179
+
180
+	/**
181
+	 * returns TRUE if M-Mode is engaged and the current request is not for the admin
182
+	 *
183
+	 * @return bool
184
+	 */
185
+	public static function disable_frontend_for_maintenance()
186
+	{
187
+		return (! is_admin() && EE_Maintenance_Mode::instance()->level());
188
+	}
189
+
190
+
191
+	/**
192
+	 * @return void
193
+	 */
194
+	public function load_assets_required_for_m_mode()
195
+	{
196
+		if (
197
+			$this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance
198
+			&& ! wp_script_is('espresso_core')
199
+		) {
200
+			wp_register_style(
201
+				'espresso_default',
202
+				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
203
+				['dashicons'],
204
+				EVENT_ESPRESSO_VERSION
205
+			);
206
+			wp_enqueue_style('espresso_default');
207
+			wp_register_script(
208
+				'espresso_core',
209
+				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
210
+				['jquery'],
211
+				EVENT_ESPRESSO_VERSION,
212
+				true
213
+			);
214
+			wp_enqueue_script('espresso_core');
215
+		}
216
+	}
217
+
218
+
219
+	/**
220
+	 * replacement EE CPT template that displays message notifying site visitors
221
+	 * that EE has been temporarily placed into maintenance mode
222
+	 * does NOT get called on non-EE-CPT requests
223
+	 *
224
+	 * @return    string
225
+	 */
226
+	public static function template_include()
227
+	{
228
+		// shut 'er down for maintenance ? then don't use any of our templates for our endpoints
229
+		return get_template_directory() . '/index.php';
230
+	}
231
+
232
+
233
+	/**
234
+	 * displays message notifying site visitors that EE has been temporarily
235
+	 * placed into maintenance mode when post_type != EE CPT
236
+	 *
237
+	 * @param string $the_content
238
+	 * @return string
239
+	 */
240
+	public function the_content($the_content)
241
+	{
242
+		// check if M-mode is engaged and for EE shortcode
243
+		if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
244
+			// this can eventually be moved to a template, or edited via admin. But for now...
245
+			$the_content = sprintf(
246
+				esc_html__(
247
+					'%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s',
248
+					'event_espresso'
249
+				),
250
+				'<h3>',
251
+				'</h3><p>',
252
+				'</p>'
253
+			);
254
+		}
255
+		return $the_content;
256
+	}
257
+
258
+
259
+	/**
260
+	 * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
261
+	 */
262
+	public function display_maintenance_mode_notice()
263
+	{
264
+		/** @var CurrentPage $current_page */
265
+		$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
266
+		// check if M-mode is engaged and for EE shortcode
267
+		if (
268
+			! (defined('DOING_AJAX') && DOING_AJAX)
269
+			&& $this->real_level()
270
+			&& ! is_admin()
271
+			&& current_user_can('administrator')
272
+			&& $current_page->isEspressoPage()
273
+		) {
274
+			printf(
275
+				esc_html__(
276
+					'%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s',
277
+					'event_espresso'
278
+				),
279
+				'<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
280
+				'"><span class="dashicons dashicons-no"></span></a><p>',
281
+				' &raquo; <a href="' . add_query_arg(
282
+					['page' => 'espresso_maintenance_settings'],
283
+					admin_url('admin.php')
284
+				) . '">',
285
+				'</a></p></div>'
286
+			);
287
+		}
288
+	}
289
+	// espresso-notices important-notice ee-attention
290
+
291
+
292
+	/**
293
+	 * override magic methods
294
+	 */
295
+	final public function __destruct()
296
+	{
297
+	}
298
+
299
+
300
+	final public function __call($a, $b)
301
+	{
302
+	}
303
+
304
+
305
+	final public function __get($a)
306
+	{
307
+	}
308
+
309
+
310
+	final public function __set($a, $b)
311
+	{
312
+	}
313
+
314
+
315
+	final public function __isset($a)
316
+	{
317
+	}
318
+
319
+
320
+	final public function __unset($a)
321
+	{
322
+	}
323
+
324
+
325
+	final public function __sleep()
326
+	{
327
+		return [];
328
+	}
329
+
330
+
331
+	final public function __wakeup()
332
+	{
333
+	}
334
+
335
+
336
+	final public function __invoke()
337
+	{
338
+	}
339
+
340
+
341
+	final public static function __set_state($a = null)
342
+	{
343
+		return EE_Maintenance_Mode::instance();
344
+	}
345
+
346
+
347
+	final public function __clone()
348
+	{
349
+	}
350 350
 
351 351
 
352
-    final public static function __callStatic($a, $b)
353
-    {
354
-    }
352
+	final public static function __callStatic($a, $b)
353
+	{
354
+	}
355 355
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public static function instance()
60 60
     {
61 61
         // check if class object is instantiated
62
-        if (! self::$_instance instanceof EE_Maintenance_Mode) {
62
+        if ( ! self::$_instance instanceof EE_Maintenance_Mode) {
63 63
             self::$_instance = new self();
64 64
         }
65 65
         return self::$_instance;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public static function disable_frontend_for_maintenance()
186 186
     {
187
-        return (! is_admin() && EE_Maintenance_Mode::instance()->level());
187
+        return ( ! is_admin() && EE_Maintenance_Mode::instance()->level());
188 188
     }
189 189
 
190 190
 
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
         ) {
200 200
             wp_register_style(
201 201
                 'espresso_default',
202
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
202
+                EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
203 203
                 ['dashicons'],
204 204
                 EVENT_ESPRESSO_VERSION
205 205
             );
206 206
             wp_enqueue_style('espresso_default');
207 207
             wp_register_script(
208 208
                 'espresso_core',
209
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
209
+                EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
210 210
                 ['jquery'],
211 211
                 EVENT_ESPRESSO_VERSION,
212 212
                 true
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     public static function template_include()
227 227
     {
228 228
         // shut 'er down for maintenance ? then don't use any of our templates for our endpoints
229
-        return get_template_directory() . '/index.php';
229
+        return get_template_directory().'/index.php';
230 230
     }
231 231
 
232 232
 
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
                 ),
279 279
                 '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
280 280
                 '"><span class="dashicons dashicons-no"></span></a><p>',
281
-                ' &raquo; <a href="' . add_query_arg(
281
+                ' &raquo; <a href="'.add_query_arg(
282 282
                     ['page' => 'espresso_maintenance_settings'],
283 283
                     admin_url('admin.php')
284
-                ) . '">',
284
+                ).'">',
285 285
                 '</a></p></div>'
286 286
             );
287 287
         }
Please login to merge, or discard this patch.
core/db_models/EEM_System_Status.model.php 2 patches
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -6,79 +6,79 @@  discard block
 block discarded – undo
6 6
 class EEM_System_Status
7 7
 {
8 8
 
9
-    // private instance of the EEM_System_Status object
10
-    protected static $_instance = null;
9
+	// private instance of the EEM_System_Status object
10
+	protected static $_instance = null;
11 11
 
12 12
 
13 13
 
14
-    /**
15
-     *      This function is a singleton method used to instantiate the EEM_Attendee object
16
-     *
17
-     *      @access public
18
-     *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
19
-     *      @return EEM_System_Status
20
-     */
21
-    public static function instance()
22
-    {
14
+	/**
15
+	 *      This function is a singleton method used to instantiate the EEM_Attendee object
16
+	 *
17
+	 *      @access public
18
+	 *      @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
19
+	 *      @return EEM_System_Status
20
+	 */
21
+	public static function instance()
22
+	{
23 23
 
24
-        // check if instance of EEM_System_Status already exists
25
-        if (self::$_instance === null) {
26
-            // instantiate EEM_System_Status
27
-            self::$_instance = new self();
28
-        }
29
-        return self::$_instance;
30
-    }
31
-    private function __construct()
32
-    {
33
-    }
34
-    /**
35
-     *
36
-     * @return array where each key is a function name on this class, and each value is SOMETHING--
37
-     * it might be a value, an array, or an object
38
-     */
39
-    public function get_system_stati()
40
-    {
41
-        return apply_filters(
42
-            'FHEE__EEM_System_Status__get_system_stati',
43
-            array(
44
-                'ee_version' => $this->get_ee_version(),
45
-                'ee_activation_history' => $this->get_ee_activation_history(),
46
-                'ee_config' => $this->get_ee_config(),
47
-                'ee_migration_history' => $this->get_ee_migration_history(),
48
-                'active_plugins' => $this->get_active_plugins(),
49
-                'wp_settings' => $this->get_wp_settings(),
50
-                'wp_maintenance_mode' => $this->get_wp_maintenance_mode(),
51
-                'https_enabled' => $this->get_https_enabled(),
52
-                'logging_enabled' => $this->get_logging_enabled(),
53
-                'remote_posting' => $this->get_remote_posting(),
54
-                'php_version' => $this->php_version(),
55
-                'php.ini_settings' => $this->get_php_ini_all(),
56
-                'php_info' => $this->get_php_info(),
57
-            ),
58
-            $this
59
-        );
60
-    }
61
-    /**
62
-     *
63
-     * @return string
64
-     */
65
-    public function get_ee_version()
66
-    {
67
-        return espresso_version();
68
-    }
69
-    /**
70
-     *
71
-     * @return string
72
-     */
73
-    public function php_version()
74
-    {
75
-        return phpversion();
76
-    }
77
-    /**
78
-     *
79
-     * @return array, where each key is a plugin name (lower-cased), values are sub-arrays.
80
-     * Sub-arrays like described in wp function get_plugin_data. Ie,     *
81
-     *  'Name' => 'Plugin Name',
24
+		// check if instance of EEM_System_Status already exists
25
+		if (self::$_instance === null) {
26
+			// instantiate EEM_System_Status
27
+			self::$_instance = new self();
28
+		}
29
+		return self::$_instance;
30
+	}
31
+	private function __construct()
32
+	{
33
+	}
34
+	/**
35
+	 *
36
+	 * @return array where each key is a function name on this class, and each value is SOMETHING--
37
+	 * it might be a value, an array, or an object
38
+	 */
39
+	public function get_system_stati()
40
+	{
41
+		return apply_filters(
42
+			'FHEE__EEM_System_Status__get_system_stati',
43
+			array(
44
+				'ee_version' => $this->get_ee_version(),
45
+				'ee_activation_history' => $this->get_ee_activation_history(),
46
+				'ee_config' => $this->get_ee_config(),
47
+				'ee_migration_history' => $this->get_ee_migration_history(),
48
+				'active_plugins' => $this->get_active_plugins(),
49
+				'wp_settings' => $this->get_wp_settings(),
50
+				'wp_maintenance_mode' => $this->get_wp_maintenance_mode(),
51
+				'https_enabled' => $this->get_https_enabled(),
52
+				'logging_enabled' => $this->get_logging_enabled(),
53
+				'remote_posting' => $this->get_remote_posting(),
54
+				'php_version' => $this->php_version(),
55
+				'php.ini_settings' => $this->get_php_ini_all(),
56
+				'php_info' => $this->get_php_info(),
57
+			),
58
+			$this
59
+		);
60
+	}
61
+	/**
62
+	 *
63
+	 * @return string
64
+	 */
65
+	public function get_ee_version()
66
+	{
67
+		return espresso_version();
68
+	}
69
+	/**
70
+	 *
71
+	 * @return string
72
+	 */
73
+	public function php_version()
74
+	{
75
+		return phpversion();
76
+	}
77
+	/**
78
+	 *
79
+	 * @return array, where each key is a plugin name (lower-cased), values are sub-arrays.
80
+	 * Sub-arrays like described in wp function get_plugin_data. Ie,     *
81
+	 *  'Name' => 'Plugin Name',
82 82
         'PluginURI' => 'Plugin URI',
83 83
         'Version' => 'Version',
84 84
         'Description' => 'Description',
@@ -87,231 +87,231 @@  discard block
 block discarded – undo
87 87
         'TextDomain' => 'Text Domain',
88 88
         'DomainPath' => 'Domain Path',
89 89
         'Network' => 'Network',
90
-     */
91
-    public function get_active_plugins()
92
-    {
93
-        $active_plugins = (array) get_option('active_plugins', array());
94
-        if (is_multisite()) {
95
-            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
96
-        }
97
-        $active_plugins = array_map('strtolower', $active_plugins);
98
-        $plugin_info = array();
99
-        foreach ($active_plugins as $plugin) {
100
-                $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
90
+	 */
91
+	public function get_active_plugins()
92
+	{
93
+		$active_plugins = (array) get_option('active_plugins', array());
94
+		if (is_multisite()) {
95
+			$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
96
+		}
97
+		$active_plugins = array_map('strtolower', $active_plugins);
98
+		$plugin_info = array();
99
+		foreach ($active_plugins as $plugin) {
100
+				$plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
101 101
 
102
-                $plugin_info[ $plugin ] = $plugin_data;
103
-        }
104
-        return $plugin_info;
105
-    }
102
+				$plugin_info[ $plugin ] = $plugin_data;
103
+		}
104
+		return $plugin_info;
105
+	}
106 106
 
107
-    /**
108
-     *
109
-     * @return array with keys 'home_url' and 'site_url'
110
-     */
111
-    public function get_wp_settings()
112
-    {
113
-        $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT);
114
-        if ($wp_memory_int < 67108864) {
115
-            $wp_memory_to_display = '<mark class="error">';
116
-            $wp_memory_to_display .= sprintf(
117
-                esc_html__(
118
-                    '%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s',
119
-                    'event_espresso'
120
-                ),
121
-                WP_MEMORY_LIMIT,
122
-                '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">',
123
-                '</a>"'
124
-            );
125
-            $wp_memory_to_display .= '</mark>';
126
-        } else {
127
-            $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>';
128
-        }
129
-        return array(
130
-            'name' => get_bloginfo('name', 'display'),
131
-            'is_multisite' => is_multisite(),
132
-            'version' =>  get_bloginfo('version', 'display'),
133
-            'home_url' => home_url(),
134
-            'site_url' => site_url(),
135
-            'WP_DEBUG' => WP_DEBUG,
136
-            'permalink_structure' => get_option('permalink_structure'),
137
-            'theme' => wp_get_theme(),
138
-            'gmt_offset' => get_option('gmt_offset'),
139
-            'timezone_string' => get_option('timezone_string'),
140
-            'admin_email' =>  get_bloginfo('admin_email', 'display'),
141
-            'language' => get_bloginfo('language', 'display'),
142
-            'wp_max_upload_size' => size_format(wp_max_upload_size()),
143
-            'wp_memory' => $wp_memory_to_display
144
-            );
145
-    }
107
+	/**
108
+	 *
109
+	 * @return array with keys 'home_url' and 'site_url'
110
+	 */
111
+	public function get_wp_settings()
112
+	{
113
+		$wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT);
114
+		if ($wp_memory_int < 67108864) {
115
+			$wp_memory_to_display = '<mark class="error">';
116
+			$wp_memory_to_display .= sprintf(
117
+				esc_html__(
118
+					'%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s',
119
+					'event_espresso'
120
+				),
121
+				WP_MEMORY_LIMIT,
122
+				'<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">',
123
+				'</a>"'
124
+			);
125
+			$wp_memory_to_display .= '</mark>';
126
+		} else {
127
+			$wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>';
128
+		}
129
+		return array(
130
+			'name' => get_bloginfo('name', 'display'),
131
+			'is_multisite' => is_multisite(),
132
+			'version' =>  get_bloginfo('version', 'display'),
133
+			'home_url' => home_url(),
134
+			'site_url' => site_url(),
135
+			'WP_DEBUG' => WP_DEBUG,
136
+			'permalink_structure' => get_option('permalink_structure'),
137
+			'theme' => wp_get_theme(),
138
+			'gmt_offset' => get_option('gmt_offset'),
139
+			'timezone_string' => get_option('timezone_string'),
140
+			'admin_email' =>  get_bloginfo('admin_email', 'display'),
141
+			'language' => get_bloginfo('language', 'display'),
142
+			'wp_max_upload_size' => size_format(wp_max_upload_size()),
143
+			'wp_memory' => $wp_memory_to_display
144
+			);
145
+	}
146 146
 
147
-    /**
148
-     * Gets an array of information about the history of ee versions installed
149
-     * @return array
150
-     */
151
-    public function get_ee_activation_history()
152
-    {
153
-        return get_option('espresso_db_update');
154
-    }
147
+	/**
148
+	 * Gets an array of information about the history of ee versions installed
149
+	 * @return array
150
+	 */
151
+	public function get_ee_activation_history()
152
+	{
153
+		return get_option('espresso_db_update');
154
+	}
155 155
 
156 156
 
157
-    /**
158
-     * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed
159
-     * @return EE_Data_Migration_Script_Base[]
160
-     */
161
-    public function get_ee_migration_history()
162
-    {
163
-        $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
164
-        $presentable_migration_scripts = array();
165
-        foreach ($options as $option_array) {
166
-            $presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']);
167
-        }
168
-        return $presentable_migration_scripts;
157
+	/**
158
+	 * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed
159
+	 * @return EE_Data_Migration_Script_Base[]
160
+	 */
161
+	public function get_ee_migration_history()
162
+	{
163
+		$options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
164
+		$presentable_migration_scripts = array();
165
+		foreach ($options as $option_array) {
166
+			$presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']);
167
+		}
168
+		return $presentable_migration_scripts;
169 169
 //      return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran();
170
-    }
170
+	}
171 171
 
172
-    /**
173
-     *
174
-     * @return array like EE_Config class
175
-     */
176
-    public function get_ee_config()
177
-    {
178
-        return EE_Config::instance();
179
-    }
172
+	/**
173
+	 *
174
+	 * @return array like EE_Config class
175
+	 */
176
+	public function get_ee_config()
177
+	{
178
+		return EE_Config::instance();
179
+	}
180 180
 
181
-    /**
182
-     * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463
183
-     * @return array like the output of phpinfo(), but in an array
184
-     */
185
-    public function get_php_info()
186
-    {
187
-        ob_start();
188
-        phpinfo(-1);
181
+	/**
182
+	 * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463
183
+	 * @return array like the output of phpinfo(), but in an array
184
+	 */
185
+	public function get_php_info()
186
+	{
187
+		ob_start();
188
+		phpinfo(-1);
189 189
 
190
-        $pi = preg_replace(
191
-            array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms',
192
-            '#<h1>Configuration</h1>#',  "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
193
-            "#[ \t]+#", '#&nbsp;#', '#  +#', '# class=".*?"#', '%&#039;%',
194
-            '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
195
-            . '<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
196
-            '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
197
-            '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
198
-            "# +#", '#<tr>#', '#</tr>#'),
199
-            array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ',
200
-            '<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' .
201
-            "\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>',
202
-            '<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
203
-            '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
204
-            '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'),
205
-            ob_get_clean()
206
-        );
190
+		$pi = preg_replace(
191
+			array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms',
192
+			'#<h1>Configuration</h1>#',  "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
193
+			"#[ \t]+#", '#&nbsp;#', '#  +#', '# class=".*?"#', '%&#039;%',
194
+			'#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
195
+			. '<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
196
+			'#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
197
+			'#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
198
+			"# +#", '#<tr>#', '#</tr>#'),
199
+			array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ',
200
+			'<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' .
201
+			"\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>',
202
+			'<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
203
+			'<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
204
+			'<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'),
205
+			ob_get_clean()
206
+		);
207 207
 
208
-        $sections = explode('<h2>', strip_tags($pi, '<h2><th><td>'));
209
-        unset($sections[0]);
208
+		$sections = explode('<h2>', strip_tags($pi, '<h2><th><td>'));
209
+		unset($sections[0]);
210 210
 
211
-        $pi = array();
212
-        foreach ($sections as $section) {
213
-            $n = substr($section, 0, strpos($section, '</h2>'));
214
-            preg_match_all(
215
-                '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
216
-                $section,
217
-                $askapache,
218
-                PREG_SET_ORDER
219
-            );
220
-            foreach ($askapache as $m) {
221
-                $m2 = isset($m[2]) ? $m[2] : null;
222
-            }
223
-              $pi[ $n ][ $m[1] ] = (!isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2);
224
-        }
211
+		$pi = array();
212
+		foreach ($sections as $section) {
213
+			$n = substr($section, 0, strpos($section, '</h2>'));
214
+			preg_match_all(
215
+				'#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
216
+				$section,
217
+				$askapache,
218
+				PREG_SET_ORDER
219
+			);
220
+			foreach ($askapache as $m) {
221
+				$m2 = isset($m[2]) ? $m[2] : null;
222
+			}
223
+			  $pi[ $n ][ $m[1] ] = (!isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2);
224
+		}
225 225
 
226
-        return $pi;
227
-    }
226
+		return $pi;
227
+	}
228 228
 
229
-    /**
230
-     * Checks if site responds ot HTTPS
231
-     * @return boolean
232
-     */
233
-    public function get_https_enabled()
234
-    {
235
-        $home = str_replace("http://", "https://", home_url());
236
-        $response = wp_remote_get($home);
237
-        if ($response instanceof WP_Error) {
238
-            $error_string = '';
239
-            foreach ($response->errors as $short_name => $description_array) {
240
-                $error_string .= "<b>$short_name</b>: " . implode(", ", $description_array);
241
-            }
242
-            return $error_string;
243
-        }
244
-        return "ok!";
245
-    }
246
-    /**
247
-     * Whether or not a .maintenance file is detected
248
-     * @return string descripting wp_maintenance_mode status
249
-     */
250
-    public function get_wp_maintenance_mode()
251
-    {
252
-        $opened = file_exists(ABSPATH . '.maintenance');
253
-        return $opened ? sprintf(esc_html__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : esc_html__('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
254
-    }
255
-    /**
256
-     * Whether or not logging is enabled
257
-     * @return string descripting logging's status
258
-     */
259
-    public function get_logging_enabled()
260
-    {
261
-            $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a');
262
-            return $opened ? esc_html__('Log Directory is writable', 'event_espresso') : sprintf(esc_html__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ;
263
-    }
264
-    /**
265
-     *  Whether curl ro fsock works
266
-     * @return string describing posting's status
267
-     */
268
-    public function get_remote_posting()
269
-    {
270
-        $fsock_works = function_exists('fsockopen');
271
-        $curl_works = function_exists('curl_init');
272
-        if ($fsock_works && $curl_works) {
273
-            $status = esc_html__('Your server has fsockopen and cURL enabled.', 'event_espresso');
274
-        } elseif ($fsock_works) {
275
-            $status = esc_html__('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso');
276
-        } elseif ($curl_works) {
277
-            $status = esc_html__('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
278
-        } else {
279
-            $status = esc_html__('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso') . '</mark>';
280
-        }
281
-        return $status;
282
-    }
283
-    /**
284
-     * Gets all the php.ini settings
285
-     * @return array
286
-     */
287
-    public function get_php_ini_all()
288
-    {
289
-        return ini_get_all();
290
-    }
291
-    /**
292
-     * Transforms the php.ini notation for numbers (like '2M') to an integer.
293
-     *
294
-     * @param type $size
295
-     * @return int
296
-     */
297
-    public function let_to_num($size)
298
-    {
299
-        $l      = substr($size, -1);
300
-        $ret    = substr($size, 0, -1);
301
-        // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
302
-        switch (strtoupper($l)) {
303
-            case 'P':
304
-                $ret *= 1024;
305
-            case 'T':
306
-                $ret *= 1024;
307
-            case 'G':
308
-                $ret *= 1024;
309
-            case 'M':
310
-                $ret *= 1024;
311
-            case 'K':
312
-                $ret *= 1024;
313
-        }
314
-        // phpcs:enable
315
-        return $ret;
316
-    }
229
+	/**
230
+	 * Checks if site responds ot HTTPS
231
+	 * @return boolean
232
+	 */
233
+	public function get_https_enabled()
234
+	{
235
+		$home = str_replace("http://", "https://", home_url());
236
+		$response = wp_remote_get($home);
237
+		if ($response instanceof WP_Error) {
238
+			$error_string = '';
239
+			foreach ($response->errors as $short_name => $description_array) {
240
+				$error_string .= "<b>$short_name</b>: " . implode(", ", $description_array);
241
+			}
242
+			return $error_string;
243
+		}
244
+		return "ok!";
245
+	}
246
+	/**
247
+	 * Whether or not a .maintenance file is detected
248
+	 * @return string descripting wp_maintenance_mode status
249
+	 */
250
+	public function get_wp_maintenance_mode()
251
+	{
252
+		$opened = file_exists(ABSPATH . '.maintenance');
253
+		return $opened ? sprintf(esc_html__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : esc_html__('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
254
+	}
255
+	/**
256
+	 * Whether or not logging is enabled
257
+	 * @return string descripting logging's status
258
+	 */
259
+	public function get_logging_enabled()
260
+	{
261
+			$opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a');
262
+			return $opened ? esc_html__('Log Directory is writable', 'event_espresso') : sprintf(esc_html__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ;
263
+	}
264
+	/**
265
+	 *  Whether curl ro fsock works
266
+	 * @return string describing posting's status
267
+	 */
268
+	public function get_remote_posting()
269
+	{
270
+		$fsock_works = function_exists('fsockopen');
271
+		$curl_works = function_exists('curl_init');
272
+		if ($fsock_works && $curl_works) {
273
+			$status = esc_html__('Your server has fsockopen and cURL enabled.', 'event_espresso');
274
+		} elseif ($fsock_works) {
275
+			$status = esc_html__('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso');
276
+		} elseif ($curl_works) {
277
+			$status = esc_html__('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
278
+		} else {
279
+			$status = esc_html__('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso') . '</mark>';
280
+		}
281
+		return $status;
282
+	}
283
+	/**
284
+	 * Gets all the php.ini settings
285
+	 * @return array
286
+	 */
287
+	public function get_php_ini_all()
288
+	{
289
+		return ini_get_all();
290
+	}
291
+	/**
292
+	 * Transforms the php.ini notation for numbers (like '2M') to an integer.
293
+	 *
294
+	 * @param type $size
295
+	 * @return int
296
+	 */
297
+	public function let_to_num($size)
298
+	{
299
+		$l      = substr($size, -1);
300
+		$ret    = substr($size, 0, -1);
301
+		// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
302
+		switch (strtoupper($l)) {
303
+			case 'P':
304
+				$ret *= 1024;
305
+			case 'T':
306
+				$ret *= 1024;
307
+			case 'G':
308
+				$ret *= 1024;
309
+			case 'M':
310
+				$ret *= 1024;
311
+			case 'K':
312
+				$ret *= 1024;
313
+		}
314
+		// phpcs:enable
315
+		return $ret;
316
+	}
317 317
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
         $active_plugins = array_map('strtolower', $active_plugins);
98 98
         $plugin_info = array();
99 99
         foreach ($active_plugins as $plugin) {
100
-                $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
100
+                $plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
101 101
 
102
-                $plugin_info[ $plugin ] = $plugin_data;
102
+                $plugin_info[$plugin] = $plugin_data;
103 103
         }
104 104
         return $plugin_info;
105 105
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             );
125 125
             $wp_memory_to_display .= '</mark>';
126 126
         } else {
127
-            $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>';
127
+            $wp_memory_to_display = '<mark class="yes">'.size_format($wp_memory_int).'</mark>';
128 128
         }
129 129
         return array(
130 130
             'name' => get_bloginfo('name', 'display'),
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
164 164
         $presentable_migration_scripts = array();
165 165
         foreach ($options as $option_array) {
166
-            $presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']);
166
+            $presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name'])] = maybe_unserialize($option_array['option_value']);
167 167
         }
168 168
         return $presentable_migration_scripts;
169 169
 //      return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran();
@@ -189,18 +189,18 @@  discard block
 block discarded – undo
189 189
 
190 190
         $pi = preg_replace(
191 191
             array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms',
192
-            '#<h1>Configuration</h1>#',  "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
192
+            '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
193 193
             "#[ \t]+#", '#&nbsp;#', '#  +#', '# class=".*?"#', '%&#039;%',
194 194
             '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
195 195
             . '<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
196 196
             '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
197 197
             '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
198 198
             "# +#", '#<tr>#', '#</tr>#'),
199
-            array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ',
200
-            '<h2>PHP Configuration</h2>' . "\n" . '<tr><td>PHP Version</td><td>$2</td></tr>' .
201
-            "\n" . '<tr><td>PHP Egg</td><td>$1</td></tr>',
199
+            array('$1', '', '', '', '</$1>'."\n", '<', ' ', ' ', ' ', '', ' ',
200
+            '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'.
201
+            "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>',
202 202
             '<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
203
-            '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
203
+            '<tr><td>Zend Engine</td><td>$2</td></tr>'."\n".
204 204
             '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'),
205 205
             ob_get_clean()
206 206
         );
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             foreach ($askapache as $m) {
221 221
                 $m2 = isset($m[2]) ? $m[2] : null;
222 222
             }
223
-              $pi[ $n ][ $m[1] ] = (!isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2);
223
+              $pi[$n][$m[1]] = ( ! isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2);
224 224
         }
225 225
 
226 226
         return $pi;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         if ($response instanceof WP_Error) {
238 238
             $error_string = '';
239 239
             foreach ($response->errors as $short_name => $description_array) {
240
-                $error_string .= "<b>$short_name</b>: " . implode(", ", $description_array);
240
+                $error_string .= "<b>$short_name</b>: ".implode(", ", $description_array);
241 241
             }
242 242
             return $error_string;
243 243
         }
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
      */
250 250
     public function get_wp_maintenance_mode()
251 251
     {
252
-        $opened = file_exists(ABSPATH . '.maintenance');
253
-        return $opened ? sprintf(esc_html__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : esc_html__('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
252
+        $opened = file_exists(ABSPATH.'.maintenance');
253
+        return $opened ? sprintf(esc_html__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : esc_html__('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso');
254 254
     }
255 255
     /**
256 256
      * Whether or not logging is enabled
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function get_logging_enabled()
260 260
     {
261
-            $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a');
262
-            return $opened ? esc_html__('Log Directory is writable', 'event_espresso') : sprintf(esc_html__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ;
261
+            $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR.'/logs/espresso_log.txt', 'a');
262
+            return $opened ? esc_html__('Log Directory is writable', 'event_espresso') : sprintf(esc_html__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>');
263 263
     }
264 264
     /**
265 265
      *  Whether curl ro fsock works
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         } elseif ($curl_works) {
277 277
             $status = esc_html__('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
278 278
         } else {
279
-            $status = esc_html__('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso') . '</mark>';
279
+            $status = esc_html__('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso').'</mark>';
280 280
         }
281 281
         return $status;
282 282
     }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 2 patches
Indentation   +1486 added lines, -1486 removed lines patch added patch discarded remove patch
@@ -28,492 +28,492 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    /**
32
-     * This gets set in _setup_cpt
33
-     * It will contain the object for the custom post type.
34
-     *
35
-     * @var EE_CPT_Base
36
-     */
37
-    protected $_cpt_object;
38
-
39
-
40
-    /**
41
-     * a boolean flag to set whether the current route is a cpt route or not.
42
-     *
43
-     * @var bool
44
-     */
45
-    protected $_cpt_route = false;
46
-
47
-
48
-    /**
49
-     * This property allows cpt classes to define multiple routes as cpt routes.
50
-     * //in this array we define what the custom post type for this route is.
51
-     * array(
52
-     * 'route_name' => 'custom_post_type_slug'
53
-     * )
54
-     *
55
-     * @var array
56
-     */
57
-    protected $_cpt_routes = [];
58
-
59
-
60
-    /**
61
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
62
-     * in this format:
63
-     * array(
64
-     * 'post_type_slug' => 'edit_route'
65
-     * )
66
-     *
67
-     * @var array
68
-     */
69
-    protected $_cpt_edit_routes = [];
70
-
71
-
72
-    /**
73
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
-     * _cpt_model_names property should be in the following format: array(
76
-     * 'route_defined_by_action_param' => 'Model_Name')
77
-     *
78
-     * @var array $_cpt_model_names
79
-     */
80
-    protected $_cpt_model_names = [];
81
-
82
-
83
-    /**
84
-     * @var EE_CPT_Base
85
-     */
86
-    protected $_cpt_model_obj = false;
87
-
88
-    /**
89
-     * @var LoaderInterface $loader ;
90
-     */
91
-    protected $loader;
92
-
93
-    /**
94
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
95
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
96
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
97
-     * Registration of containers should be done before load_page_dependencies() is run.
98
-     *
99
-     * @var array()
100
-     */
101
-    protected $_autosave_containers = [];
102
-
103
-    protected $_autosave_fields     = [];
104
-
105
-    /**
106
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
107
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
108
-     *
109
-     * @var array
110
-     */
111
-    protected $_pagenow_map;
112
-
113
-
114
-    /**
115
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
116
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
117
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
118
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
119
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
120
-     *
121
-     * @abstract
122
-     * @param string      $post_id The ID of the cpt that was saved (so you can link relationally)
123
-     * @param EE_CPT_Base $post    The post object of the cpt that was saved.
124
-     * @return void
125
-     */
126
-    abstract protected function _insert_update_cpt_item($post_id, $post);
127
-
128
-
129
-    /**
130
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
131
-     *
132
-     * @abstract
133
-     * @param string $post_id The ID of the cpt that was trashed
134
-     * @return void
135
-     */
136
-    abstract public function trash_cpt_item($post_id);
137
-
138
-
139
-    /**
140
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
141
-     *
142
-     * @param string $post_id theID of the cpt that was untrashed
143
-     * @return void
144
-     */
145
-    abstract public function restore_cpt_item($post_id);
146
-
147
-
148
-    /**
149
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
150
-     * from the db
151
-     *
152
-     * @param string $post_id the ID of the cpt that was deleted
153
-     * @return void
154
-     */
155
-    abstract public function delete_cpt_item($post_id);
156
-
157
-
158
-    /**
159
-     * @return LoaderInterface
160
-     * @throws InvalidArgumentException
161
-     * @throws InvalidDataTypeException
162
-     * @throws InvalidInterfaceException
163
-     */
164
-    protected function getLoader()
165
-    {
166
-        if (! $this->loader instanceof LoaderInterface) {
167
-            $this->loader = LoaderFactory::getLoader();
168
-        }
169
-        return $this->loader;
170
-    }
171
-
172
-
173
-    /**
174
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
175
-     *
176
-     * @return void
177
-     */
178
-    protected function _before_page_setup()
179
-    {
180
-        $this->raw_req_action = $this->request->getRequestParam('action');
181
-        $this->raw_req_page = $this->request->getRequestParam('page');
182
-        $this->_cpt_routes = array_merge(
183
-            [
184
-                'create_new' => $this->page_slug,
185
-                'edit'       => $this->page_slug,
186
-                'trash'      => $this->page_slug,
187
-            ],
188
-            $this->_cpt_routes
189
-        );
190
-        $cpt_route_action  = isset($this->_cpt_routes[ $this->raw_req_action ])
191
-            ? $this->_cpt_routes[ $this->raw_req_action ]
192
-            : null;
193
-        // let's see if the current route has a value for cpt_object_slug. if it does, we use that instead of the page
194
-        $page              = $this->raw_req_page ?: $this->page_slug;
195
-        $page              = $cpt_route_action ?: $page;
196
-        $this->_cpt_object = get_post_type_object($page);
197
-        // tweak pagenow for page loading.
198
-        if (! $this->_pagenow_map) {
199
-            $this->_pagenow_map = [
200
-                'create_new' => 'post-new.php',
201
-                'edit'       => 'post.php',
202
-                'trash'      => 'post.php',
203
-            ];
204
-        }
205
-        add_action('current_screen', [$this, 'modify_pagenow']);
206
-        // TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
207
-        // get current page from autosave
208
-        $current_page        = $this->request->getRequestParam('ee_autosave_data[ee-cpt-hidden-inputs][current_page]');
209
-        $this->_current_page = $this->request->getRequestParam('current_page', $current_page);
210
-    }
211
-
212
-
213
-    /**
214
-     * Simply ensure that we simulate the correct post route for cpt screens
215
-     *
216
-     * @param WP_Screen $current_screen
217
-     * @return void
218
-     */
219
-    public function modify_pagenow($current_screen)
220
-    {
221
-        // possibly reset pagenow.
222
-        if (
223
-            $this->page_slug === $this->raw_req_page
224
-            && isset($this->_pagenow_map[ $this->raw_req_action ])
225
-        ) {
226
-            global $pagenow, $hook_suffix;
227
-            $pagenow     = $this->_pagenow_map[ $this->raw_req_action ];
228
-            $hook_suffix = $pagenow;
229
-        }
230
-    }
231
-
232
-
233
-    /**
234
-     * This method is used to register additional autosave containers to the _autosave_containers property.
235
-     *
236
-     * @param array $ids  an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
237
-     *                    you would send along the id of a metabox container.
238
-     * @return void
239
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
240
-     *                    automatically register the id for the post metabox as a container.
241
-     */
242
-    protected function _register_autosave_containers($ids)
243
-    {
244
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
245
-    }
246
-
247
-
248
-    /**
249
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
250
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
251
-     */
252
-    protected function _set_autosave_containers()
253
-    {
254
-        global $wp_meta_boxes;
255
-        $containers = [];
256
-        if (empty($wp_meta_boxes)) {
257
-            return;
258
-        }
259
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : [];
260
-        foreach ($current_metaboxes as $box_context) {
261
-            foreach ($box_context as $box_details) {
262
-                foreach ($box_details as $box) {
263
-                    if (
264
-                        is_array($box) && is_array($box['callback'])
265
-                        && (
266
-                            $box['callback'][0] instanceof EE_Admin_Page
267
-                            || $box['callback'][0] instanceof EE_Admin_Hooks
268
-                        )
269
-                    ) {
270
-                        $containers[] = $box['id'];
271
-                    }
272
-                }
273
-            }
274
-        }
275
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
276
-        // add hidden inputs container
277
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
278
-    }
279
-
280
-
281
-    protected function _load_autosave_scripts_styles()
282
-    {
283
-        /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
31
+	/**
32
+	 * This gets set in _setup_cpt
33
+	 * It will contain the object for the custom post type.
34
+	 *
35
+	 * @var EE_CPT_Base
36
+	 */
37
+	protected $_cpt_object;
38
+
39
+
40
+	/**
41
+	 * a boolean flag to set whether the current route is a cpt route or not.
42
+	 *
43
+	 * @var bool
44
+	 */
45
+	protected $_cpt_route = false;
46
+
47
+
48
+	/**
49
+	 * This property allows cpt classes to define multiple routes as cpt routes.
50
+	 * //in this array we define what the custom post type for this route is.
51
+	 * array(
52
+	 * 'route_name' => 'custom_post_type_slug'
53
+	 * )
54
+	 *
55
+	 * @var array
56
+	 */
57
+	protected $_cpt_routes = [];
58
+
59
+
60
+	/**
61
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
62
+	 * in this format:
63
+	 * array(
64
+	 * 'post_type_slug' => 'edit_route'
65
+	 * )
66
+	 *
67
+	 * @var array
68
+	 */
69
+	protected $_cpt_edit_routes = [];
70
+
71
+
72
+	/**
73
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
+	 * _cpt_model_names property should be in the following format: array(
76
+	 * 'route_defined_by_action_param' => 'Model_Name')
77
+	 *
78
+	 * @var array $_cpt_model_names
79
+	 */
80
+	protected $_cpt_model_names = [];
81
+
82
+
83
+	/**
84
+	 * @var EE_CPT_Base
85
+	 */
86
+	protected $_cpt_model_obj = false;
87
+
88
+	/**
89
+	 * @var LoaderInterface $loader ;
90
+	 */
91
+	protected $loader;
92
+
93
+	/**
94
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
95
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
96
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
97
+	 * Registration of containers should be done before load_page_dependencies() is run.
98
+	 *
99
+	 * @var array()
100
+	 */
101
+	protected $_autosave_containers = [];
102
+
103
+	protected $_autosave_fields     = [];
104
+
105
+	/**
106
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
107
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
108
+	 *
109
+	 * @var array
110
+	 */
111
+	protected $_pagenow_map;
112
+
113
+
114
+	/**
115
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
116
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
117
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
118
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
119
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
120
+	 *
121
+	 * @abstract
122
+	 * @param string      $post_id The ID of the cpt that was saved (so you can link relationally)
123
+	 * @param EE_CPT_Base $post    The post object of the cpt that was saved.
124
+	 * @return void
125
+	 */
126
+	abstract protected function _insert_update_cpt_item($post_id, $post);
127
+
128
+
129
+	/**
130
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
131
+	 *
132
+	 * @abstract
133
+	 * @param string $post_id The ID of the cpt that was trashed
134
+	 * @return void
135
+	 */
136
+	abstract public function trash_cpt_item($post_id);
137
+
138
+
139
+	/**
140
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
141
+	 *
142
+	 * @param string $post_id theID of the cpt that was untrashed
143
+	 * @return void
144
+	 */
145
+	abstract public function restore_cpt_item($post_id);
146
+
147
+
148
+	/**
149
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
150
+	 * from the db
151
+	 *
152
+	 * @param string $post_id the ID of the cpt that was deleted
153
+	 * @return void
154
+	 */
155
+	abstract public function delete_cpt_item($post_id);
156
+
157
+
158
+	/**
159
+	 * @return LoaderInterface
160
+	 * @throws InvalidArgumentException
161
+	 * @throws InvalidDataTypeException
162
+	 * @throws InvalidInterfaceException
163
+	 */
164
+	protected function getLoader()
165
+	{
166
+		if (! $this->loader instanceof LoaderInterface) {
167
+			$this->loader = LoaderFactory::getLoader();
168
+		}
169
+		return $this->loader;
170
+	}
171
+
172
+
173
+	/**
174
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
175
+	 *
176
+	 * @return void
177
+	 */
178
+	protected function _before_page_setup()
179
+	{
180
+		$this->raw_req_action = $this->request->getRequestParam('action');
181
+		$this->raw_req_page = $this->request->getRequestParam('page');
182
+		$this->_cpt_routes = array_merge(
183
+			[
184
+				'create_new' => $this->page_slug,
185
+				'edit'       => $this->page_slug,
186
+				'trash'      => $this->page_slug,
187
+			],
188
+			$this->_cpt_routes
189
+		);
190
+		$cpt_route_action  = isset($this->_cpt_routes[ $this->raw_req_action ])
191
+			? $this->_cpt_routes[ $this->raw_req_action ]
192
+			: null;
193
+		// let's see if the current route has a value for cpt_object_slug. if it does, we use that instead of the page
194
+		$page              = $this->raw_req_page ?: $this->page_slug;
195
+		$page              = $cpt_route_action ?: $page;
196
+		$this->_cpt_object = get_post_type_object($page);
197
+		// tweak pagenow for page loading.
198
+		if (! $this->_pagenow_map) {
199
+			$this->_pagenow_map = [
200
+				'create_new' => 'post-new.php',
201
+				'edit'       => 'post.php',
202
+				'trash'      => 'post.php',
203
+			];
204
+		}
205
+		add_action('current_screen', [$this, 'modify_pagenow']);
206
+		// TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
207
+		// get current page from autosave
208
+		$current_page        = $this->request->getRequestParam('ee_autosave_data[ee-cpt-hidden-inputs][current_page]');
209
+		$this->_current_page = $this->request->getRequestParam('current_page', $current_page);
210
+	}
211
+
212
+
213
+	/**
214
+	 * Simply ensure that we simulate the correct post route for cpt screens
215
+	 *
216
+	 * @param WP_Screen $current_screen
217
+	 * @return void
218
+	 */
219
+	public function modify_pagenow($current_screen)
220
+	{
221
+		// possibly reset pagenow.
222
+		if (
223
+			$this->page_slug === $this->raw_req_page
224
+			&& isset($this->_pagenow_map[ $this->raw_req_action ])
225
+		) {
226
+			global $pagenow, $hook_suffix;
227
+			$pagenow     = $this->_pagenow_map[ $this->raw_req_action ];
228
+			$hook_suffix = $pagenow;
229
+		}
230
+	}
231
+
232
+
233
+	/**
234
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
235
+	 *
236
+	 * @param array $ids  an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
237
+	 *                    you would send along the id of a metabox container.
238
+	 * @return void
239
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
240
+	 *                    automatically register the id for the post metabox as a container.
241
+	 */
242
+	protected function _register_autosave_containers($ids)
243
+	{
244
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
245
+	}
246
+
247
+
248
+	/**
249
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
250
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
251
+	 */
252
+	protected function _set_autosave_containers()
253
+	{
254
+		global $wp_meta_boxes;
255
+		$containers = [];
256
+		if (empty($wp_meta_boxes)) {
257
+			return;
258
+		}
259
+		$current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : [];
260
+		foreach ($current_metaboxes as $box_context) {
261
+			foreach ($box_context as $box_details) {
262
+				foreach ($box_details as $box) {
263
+					if (
264
+						is_array($box) && is_array($box['callback'])
265
+						&& (
266
+							$box['callback'][0] instanceof EE_Admin_Page
267
+							|| $box['callback'][0] instanceof EE_Admin_Hooks
268
+						)
269
+					) {
270
+						$containers[] = $box['id'];
271
+					}
272
+				}
273
+			}
274
+		}
275
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
276
+		// add hidden inputs container
277
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
278
+	}
279
+
280
+
281
+	protected function _load_autosave_scripts_styles()
282
+	{
283
+		/*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
284 284
         wp_enqueue_script('cpt-autosave');/**/ // todo re-enable when we start doing autosave again in 4.2
285 285
 
286
-        // filter _autosave_containers
287
-        $containers = apply_filters(
288
-            'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
289
-            $this->_autosave_containers,
290
-            $this
291
-        );
292
-        $containers = apply_filters(
293
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
294
-            $containers,
295
-            $this
296
-        );
297
-
298
-        wp_localize_script(
299
-            'event_editor_js',
300
-            'EE_AUTOSAVE_IDS',
301
-            $containers
302
-        ); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
303
-
304
-        $unsaved_data_msg = [
305
-            'eventmsg'     => sprintf(
306
-                wp_strip_all_tags(
307
-                    __(
308
-                        "The changes you made to this %s will be lost if you navigate away from this page.",
309
-                        'event_espresso'
310
-                    )
311
-                ),
312
-                $this->_cpt_object->labels->singular_name
313
-            ),
314
-            'inputChanged' => 0,
315
-        ];
316
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
317
-    }
318
-
319
-
320
-    public function load_page_dependencies()
321
-    {
322
-        try {
323
-            $this->_load_page_dependencies();
324
-        } catch (EE_Error $e) {
325
-            $e->get_error();
326
-        }
327
-    }
328
-
329
-
330
-    /**
331
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
332
-     *
333
-     * @return void
334
-     */
335
-    protected function _load_page_dependencies()
336
-    {
337
-        // we only add stuff if this is a cpt_route!
338
-        if (! $this->_cpt_route) {
339
-            parent::_load_page_dependencies();
340
-            return;
341
-        }
342
-        // now let's do some automatic filters into the wp_system
343
-        // and we'll check to make sure the CHILD class
344
-        // automatically has the required methods in place.
345
-        // the following filters are for setting all the redirects
346
-        // on DEFAULT WP custom post type actions
347
-        // let's add a hidden input to the post-edit form
348
-        // so we know when we have to trigger our custom redirects!
349
-        // Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
350
-        add_action('edit_form_after_title', [$this, 'cpt_post_form_hidden_input']);
351
-        // inject our Admin page nav tabs...
352
-        // let's make sure the nav tabs are set if they aren't already
353
-        // if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
354
-        add_action('post_edit_form_tag', [$this, 'inject_nav_tabs']);
355
-        // modify the post_updated messages array
356
-        add_action('post_updated_messages', [$this, 'post_update_messages'], 10);
357
-        // add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
358
-        // cpts use the same format for shortlinks as posts!
359
-        add_filter('pre_get_shortlink', [$this, 'add_shortlink_button_to_editor'], 10, 4);
360
-        // This basically allows us to change the title of the "publish" metabox area
361
-        // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
362
-        if (! empty($this->_labels['publishbox'])) {
363
-            $box_label = is_array($this->_labels['publishbox'])
364
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
365
-                ? $this->_labels['publishbox'][ $this->_req_action ]
366
-                : $this->_labels['publishbox'];
367
-            add_meta_box(
368
-                'submitdiv',
369
-                $box_label,
370
-                'post_submit_meta_box',
371
-                $this->_cpt_routes[ $this->_req_action ],
372
-                'side',
373
-                'core'
374
-            );
375
-        }
376
-        // let's add page_templates metabox if this cpt added support for it.
377
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
378
-            add_meta_box(
379
-                'page_templates',
380
-                esc_html__('Page Template', 'event_espresso'),
381
-                [$this, 'page_template_meta_box'],
382
-                $this->_cpt_routes[ $this->_req_action ],
383
-                'side',
384
-                'default'
385
-            );
386
-        }
387
-        // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
388
-        if (method_exists($this, 'extra_permalink_field_buttons')) {
389
-            add_filter('get_sample_permalink_html', [$this, 'extra_permalink_field_buttons'], 10, 4);
390
-        }
391
-        // add preview button
392
-        add_filter('get_sample_permalink_html', [$this, 'preview_button_html'], 5, 4);
393
-        // insert our own post_stati dropdown
394
-        add_action('post_submitbox_misc_actions', [$this, 'custom_post_stati_dropdown'], 10);
395
-        // This allows adding additional information to the publish post submitbox on the wp post edit form
396
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
397
-            add_action('post_submitbox_misc_actions', [$this, 'extra_misc_actions_publish_box'], 10);
398
-        }
399
-        // This allows for adding additional stuff after the title field on the wp post edit form.
400
-        // This is also before the wp_editor for post description field.
401
-        if (method_exists($this, 'edit_form_after_title')) {
402
-            add_action('edit_form_after_title', [$this, 'edit_form_after_title'], 10);
403
-        }
404
-        /**
405
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
406
-         */
407
-        add_filter('clean_url', [$this, 'switch_core_wp_urls_with_ours'], 10, 3);
408
-        parent::_load_page_dependencies();
409
-        // notice we are ALSO going to load the pagenow hook set for this route
410
-        // (see _before_page_setup for the reset of the pagenow global ).
411
-        // This is for any plugins that are doing things properly
412
-        // and hooking into the load page hook for core wp cpt routes.
413
-        global $pagenow;
414
-        add_action('load-' . $pagenow, [$this, 'modify_current_screen'], 20);
415
-        do_action('load-' . $pagenow);
416
-        add_action('admin_enqueue_scripts', [$this, 'setup_autosave_hooks'], 30);
417
-        // we route REALLY early.
418
-        try {
419
-            $this->_route_admin_request();
420
-        } catch (EE_Error $e) {
421
-            $e->get_error();
422
-        }
423
-    }
424
-
425
-
426
-    /**
427
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
428
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
429
-     * route instead.
430
-     *
431
-     * @param string $good_protocol_url The escaped url.
432
-     * @param string $original_url      The original url.
433
-     * @param string $_context          The context sent to the esc_url method.
434
-     * @return string possibly a new url for our route.
435
-     */
436
-    public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
437
-    {
438
-        $routes_to_match = [
439
-            0 => [
440
-                'edit.php?post_type=espresso_attendees',
441
-                'admin.php?page=espresso_registrations&action=contact_list',
442
-            ],
443
-            1 => [
444
-                'edit.php?post_type=' . $this->_cpt_object->name,
445
-                'admin.php?page=' . $this->_cpt_object->name,
446
-            ],
447
-        ];
448
-        foreach ($routes_to_match as $route_matches) {
449
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
450
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
451
-            }
452
-        }
453
-        return $good_protocol_url;
454
-    }
455
-
456
-
457
-    /**
458
-     * Determine whether the current cpt supports page templates or not.
459
-     *
460
-     * @param string $cpt_name The cpt slug we're checking on.
461
-     * @return bool True supported, false not.
462
-     * @throws InvalidArgumentException
463
-     * @throws InvalidDataTypeException
464
-     * @throws InvalidInterfaceException
465
-     * @since %VER%
466
-     */
467
-    private function _supports_page_templates($cpt_name)
468
-    {
469
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
470
-        $custom_post_types = $this->getLoader()->getShared(
471
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
472
-        );
473
-        $cpt_args          = $custom_post_types->getDefinitions();
474
-        $cpt_args          = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : [];
475
-        $cpt_has_support   = ! empty($cpt_args['page_templates']);
476
-
477
-        // if the installed version of WP is > 4.7 we do some additional checks.
478
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
479
-            $post_templates = wp_get_theme()->get_post_templates();
480
-            // if there are $post_templates for this cpt, then we return false for this method because
481
-            // that means we aren't going to load our page template manager and leave that up to the native
482
-            // cpt template manager.
483
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
484
-        }
485
-
486
-        return $cpt_has_support;
487
-    }
488
-
489
-
490
-    /**
491
-     * Callback for the page_templates metabox selector.
492
-     *
493
-     * @return void
494
-     * @since %VER%
495
-     */
496
-    public function page_template_meta_box()
497
-    {
498
-        global $post;
499
-        $template = '';
500
-
501
-        if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
502
-            $page_template_count = count(get_page_templates());
503
-        } else {
504
-            $page_template_count = count(get_page_templates($post));
505
-        };
506
-
507
-        if ($page_template_count) {
508
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
509
-            $template      = ! empty($page_template) ? $page_template : '';
510
-        }
511
-        ?>
286
+		// filter _autosave_containers
287
+		$containers = apply_filters(
288
+			'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
289
+			$this->_autosave_containers,
290
+			$this
291
+		);
292
+		$containers = apply_filters(
293
+			'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
294
+			$containers,
295
+			$this
296
+		);
297
+
298
+		wp_localize_script(
299
+			'event_editor_js',
300
+			'EE_AUTOSAVE_IDS',
301
+			$containers
302
+		); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
303
+
304
+		$unsaved_data_msg = [
305
+			'eventmsg'     => sprintf(
306
+				wp_strip_all_tags(
307
+					__(
308
+						"The changes you made to this %s will be lost if you navigate away from this page.",
309
+						'event_espresso'
310
+					)
311
+				),
312
+				$this->_cpt_object->labels->singular_name
313
+			),
314
+			'inputChanged' => 0,
315
+		];
316
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
317
+	}
318
+
319
+
320
+	public function load_page_dependencies()
321
+	{
322
+		try {
323
+			$this->_load_page_dependencies();
324
+		} catch (EE_Error $e) {
325
+			$e->get_error();
326
+		}
327
+	}
328
+
329
+
330
+	/**
331
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
332
+	 *
333
+	 * @return void
334
+	 */
335
+	protected function _load_page_dependencies()
336
+	{
337
+		// we only add stuff if this is a cpt_route!
338
+		if (! $this->_cpt_route) {
339
+			parent::_load_page_dependencies();
340
+			return;
341
+		}
342
+		// now let's do some automatic filters into the wp_system
343
+		// and we'll check to make sure the CHILD class
344
+		// automatically has the required methods in place.
345
+		// the following filters are for setting all the redirects
346
+		// on DEFAULT WP custom post type actions
347
+		// let's add a hidden input to the post-edit form
348
+		// so we know when we have to trigger our custom redirects!
349
+		// Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
350
+		add_action('edit_form_after_title', [$this, 'cpt_post_form_hidden_input']);
351
+		// inject our Admin page nav tabs...
352
+		// let's make sure the nav tabs are set if they aren't already
353
+		// if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
354
+		add_action('post_edit_form_tag', [$this, 'inject_nav_tabs']);
355
+		// modify the post_updated messages array
356
+		add_action('post_updated_messages', [$this, 'post_update_messages'], 10);
357
+		// add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE,
358
+		// cpts use the same format for shortlinks as posts!
359
+		add_filter('pre_get_shortlink', [$this, 'add_shortlink_button_to_editor'], 10, 4);
360
+		// This basically allows us to change the title of the "publish" metabox area
361
+		// on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
362
+		if (! empty($this->_labels['publishbox'])) {
363
+			$box_label = is_array($this->_labels['publishbox'])
364
+						 && isset($this->_labels['publishbox'][ $this->_req_action ])
365
+				? $this->_labels['publishbox'][ $this->_req_action ]
366
+				: $this->_labels['publishbox'];
367
+			add_meta_box(
368
+				'submitdiv',
369
+				$box_label,
370
+				'post_submit_meta_box',
371
+				$this->_cpt_routes[ $this->_req_action ],
372
+				'side',
373
+				'core'
374
+			);
375
+		}
376
+		// let's add page_templates metabox if this cpt added support for it.
377
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
378
+			add_meta_box(
379
+				'page_templates',
380
+				esc_html__('Page Template', 'event_espresso'),
381
+				[$this, 'page_template_meta_box'],
382
+				$this->_cpt_routes[ $this->_req_action ],
383
+				'side',
384
+				'default'
385
+			);
386
+		}
387
+		// this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
388
+		if (method_exists($this, 'extra_permalink_field_buttons')) {
389
+			add_filter('get_sample_permalink_html', [$this, 'extra_permalink_field_buttons'], 10, 4);
390
+		}
391
+		// add preview button
392
+		add_filter('get_sample_permalink_html', [$this, 'preview_button_html'], 5, 4);
393
+		// insert our own post_stati dropdown
394
+		add_action('post_submitbox_misc_actions', [$this, 'custom_post_stati_dropdown'], 10);
395
+		// This allows adding additional information to the publish post submitbox on the wp post edit form
396
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
397
+			add_action('post_submitbox_misc_actions', [$this, 'extra_misc_actions_publish_box'], 10);
398
+		}
399
+		// This allows for adding additional stuff after the title field on the wp post edit form.
400
+		// This is also before the wp_editor for post description field.
401
+		if (method_exists($this, 'edit_form_after_title')) {
402
+			add_action('edit_form_after_title', [$this, 'edit_form_after_title'], 10);
403
+		}
404
+		/**
405
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
406
+		 */
407
+		add_filter('clean_url', [$this, 'switch_core_wp_urls_with_ours'], 10, 3);
408
+		parent::_load_page_dependencies();
409
+		// notice we are ALSO going to load the pagenow hook set for this route
410
+		// (see _before_page_setup for the reset of the pagenow global ).
411
+		// This is for any plugins that are doing things properly
412
+		// and hooking into the load page hook for core wp cpt routes.
413
+		global $pagenow;
414
+		add_action('load-' . $pagenow, [$this, 'modify_current_screen'], 20);
415
+		do_action('load-' . $pagenow);
416
+		add_action('admin_enqueue_scripts', [$this, 'setup_autosave_hooks'], 30);
417
+		// we route REALLY early.
418
+		try {
419
+			$this->_route_admin_request();
420
+		} catch (EE_Error $e) {
421
+			$e->get_error();
422
+		}
423
+	}
424
+
425
+
426
+	/**
427
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
428
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
429
+	 * route instead.
430
+	 *
431
+	 * @param string $good_protocol_url The escaped url.
432
+	 * @param string $original_url      The original url.
433
+	 * @param string $_context          The context sent to the esc_url method.
434
+	 * @return string possibly a new url for our route.
435
+	 */
436
+	public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
437
+	{
438
+		$routes_to_match = [
439
+			0 => [
440
+				'edit.php?post_type=espresso_attendees',
441
+				'admin.php?page=espresso_registrations&action=contact_list',
442
+			],
443
+			1 => [
444
+				'edit.php?post_type=' . $this->_cpt_object->name,
445
+				'admin.php?page=' . $this->_cpt_object->name,
446
+			],
447
+		];
448
+		foreach ($routes_to_match as $route_matches) {
449
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
450
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
451
+			}
452
+		}
453
+		return $good_protocol_url;
454
+	}
455
+
456
+
457
+	/**
458
+	 * Determine whether the current cpt supports page templates or not.
459
+	 *
460
+	 * @param string $cpt_name The cpt slug we're checking on.
461
+	 * @return bool True supported, false not.
462
+	 * @throws InvalidArgumentException
463
+	 * @throws InvalidDataTypeException
464
+	 * @throws InvalidInterfaceException
465
+	 * @since %VER%
466
+	 */
467
+	private function _supports_page_templates($cpt_name)
468
+	{
469
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
470
+		$custom_post_types = $this->getLoader()->getShared(
471
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
472
+		);
473
+		$cpt_args          = $custom_post_types->getDefinitions();
474
+		$cpt_args          = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : [];
475
+		$cpt_has_support   = ! empty($cpt_args['page_templates']);
476
+
477
+		// if the installed version of WP is > 4.7 we do some additional checks.
478
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
479
+			$post_templates = wp_get_theme()->get_post_templates();
480
+			// if there are $post_templates for this cpt, then we return false for this method because
481
+			// that means we aren't going to load our page template manager and leave that up to the native
482
+			// cpt template manager.
483
+			$cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
484
+		}
485
+
486
+		return $cpt_has_support;
487
+	}
488
+
489
+
490
+	/**
491
+	 * Callback for the page_templates metabox selector.
492
+	 *
493
+	 * @return void
494
+	 * @since %VER%
495
+	 */
496
+	public function page_template_meta_box()
497
+	{
498
+		global $post;
499
+		$template = '';
500
+
501
+		if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
502
+			$page_template_count = count(get_page_templates());
503
+		} else {
504
+			$page_template_count = count(get_page_templates($post));
505
+		};
506
+
507
+		if ($page_template_count) {
508
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
509
+			$template      = ! empty($page_template) ? $page_template : '';
510
+		}
511
+		?>
512 512
         <p><strong><?php esc_html_e('Template', 'event_espresso') ?></strong></p>
513 513
         <label class="screen-reader-text" for="page_template"><?php esc_html_e(
514
-            'Page Template',
515
-            'event_espresso'
516
-        ) ?></label>
514
+			'Page Template',
515
+			'event_espresso'
516
+		) ?></label>
517 517
         <select
518 518
             name="page_template" id="page_template"
519 519
         >
@@ -521,473 +521,473 @@  discard block
 block discarded – undo
521 521
             <?php page_template_dropdown($template); ?>
522 522
         </select>
523 523
         <?php
524
-    }
525
-
526
-
527
-    /**
528
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
529
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
530
-     *
531
-     * @param string $return    the current html
532
-     * @param int    $id        the post id for the page
533
-     * @param string $new_title What the title is
534
-     * @param string $new_slug  what the slug is
535
-     * @return string            The new html string for the permalink area
536
-     */
537
-    public function preview_button_html($return, $id, $new_title, $new_slug)
538
-    {
539
-        $post = get_post($id);
540
-        if ('publish' !== get_post_status($post)) {
541
-            $return .= '<span_id="view-post-btn"><a target="_blank" href="'
542
-                       . get_preview_post_link($id)
543
-                       . '" class="button button-small">'
544
-                       . esc_html__('Preview', 'event_espresso')
545
-                       . '</a></span>'
546
-                       . "\n";
547
-        }
548
-        return $return;
549
-    }
550
-
551
-
552
-    /**
553
-     * add our custom post stati dropdown on the wp post page for this cpt
554
-     *
555
-     * @return void
556
-     */
557
-    public function custom_post_stati_dropdown()
558
-    {
559
-
560
-        $statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
561
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
562
-            ? $statuses[ $this->_cpt_model_obj->status() ]
563
-            : '';
564
-        $template_args    = [
565
-            'cur_status'            => $this->_cpt_model_obj->status(),
566
-            'statuses'              => $statuses,
567
-            'cur_status_label'      => $cur_status_label,
568
-            'localized_status_save' => sprintf(esc_html__('Save %s', 'event_espresso'), $cur_status_label),
569
-        ];
570
-        // we'll add a trash post status (WP doesn't add one for some reason)
571
-        if ($this->_cpt_model_obj->status() === 'trash') {
572
-            $template_args['cur_status_label'] = esc_html__('Trashed', 'event_espresso');
573
-            $statuses['trash']                 = esc_html__('Trashed', 'event_espresso');
574
-            $template_args['statuses']         = $statuses;
575
-        }
576
-
577
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
578
-        EEH_Template::display_template($template, $template_args);
579
-    }
580
-
581
-
582
-    public function setup_autosave_hooks()
583
-    {
584
-        $this->_set_autosave_containers();
585
-        $this->_load_autosave_scripts_styles();
586
-    }
587
-
588
-
589
-    /**
590
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a post object (available
591
-     * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
592
-     * for the nonce in here, but then this method looks for two things:
593
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
594
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
595
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
596
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
597
-     * template args.
598
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
599
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
600
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
601
-     *    $this->_template_args['data']['items'] = array(
602
-     *        'event-datetime-ids' => '1,2,3';
603
-     *    );
604
-     *    Keep in mind the following things:
605
-     *    - "where" index is for the input with the id as that string.
606
-     *    - "what" index is what will be used for the value of that input.
607
-     *
608
-     * @return void
609
-     * @throws EE_Error
610
-     */
611
-    public function do_extra_autosave_stuff()
612
-    {
613
-        // next let's check for the autosave nonce (we'll use _verify_nonce )
614
-        $nonce = $this->request->getRequestParam('autosavenonce');
615
-        $this->_verify_nonce($nonce, 'autosave');
616
-        // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
617
-        if (! defined('DOING_AUTOSAVE')) {
618
-            define('DOING_AUTOSAVE', true);
619
-        }
620
-        // if we made it here then the nonce checked out.  Let's run our methods and actions
621
-        $autosave = "_ee_autosave_{$this->_current_view}";
622
-        if (method_exists($this, $autosave)) {
623
-            $this->$autosave();
624
-        } else {
625
-            $this->_template_args['success'] = true;
626
-        }
627
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
628
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
629
-        // now let's return json
630
-        $this->_return_json();
631
-    }
632
-
633
-
634
-    /**
635
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
636
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
637
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
638
-     *
639
-     * @return void
640
-     * @throws EE_Error
641
-     * @throws ReflectionException
642
-     */
643
-    protected function _extend_page_config_for_cpt()
644
-    {
645
-        // before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
646
-        if ($this->raw_req_page !== $this->page_slug) {
647
-            return;
648
-        }
649
-        // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
650
-        if (! empty($this->_cpt_object)) {
651
-            $this->_page_routes = array_merge(
652
-                [
653
-                    'create_new' => '_create_new_cpt_item',
654
-                    'edit'       => '_edit_cpt_item',
655
-                ],
656
-                $this->_page_routes
657
-            );
658
-            $this->_page_config = array_merge(
659
-                [
660
-                    'create_new' => [
661
-                        'nav'           => [
662
-                            'label' => $this->_cpt_object->labels->add_new_item,
663
-                            'order' => 5,
664
-                        ],
665
-                        'require_nonce' => false,
666
-                    ],
667
-                    'edit'       => [
668
-                        'nav'           => [
669
-                            'label'      => $this->_cpt_object->labels->edit_item,
670
-                            'order'      => 5,
671
-                            'persistent' => false,
672
-                            'url'        => '',
673
-                        ],
674
-                        'require_nonce' => false,
675
-                    ],
676
-                ],
677
-                $this->_page_config
678
-            );
679
-        }
680
-        // load the next section only if this is a matching cpt route as set in the cpt routes array.
681
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
682
-            return;
683
-        }
684
-        $this->_cpt_route = true;
685
-        // $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]);
686
-        // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
687
-        if (empty($this->_cpt_object)) {
688
-            $msg = sprintf(
689
-                esc_html__(
690
-                    'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
691
-                    'event_espresso'
692
-                ),
693
-                $this->page_slug,
694
-                $this->_req_action,
695
-                get_class($this)
696
-            );
697
-            throw new EE_Error($msg);
698
-        }
699
-        $this->_set_model_object($this->request->getRequestParam('post'));
700
-    }
701
-
702
-
703
-    /**
704
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
705
-     *
706
-     * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
707
-     * @param bool   $ignore_route_check
708
-     * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
709
-     * @throws EE_Error
710
-     * @throws InvalidArgumentException
711
-     * @throws InvalidDataTypeException
712
-     * @throws InvalidInterfaceException
713
-     * @throws ReflectionException
714
-     */
715
-    protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
716
-    {
717
-        $model = null;
718
-        if (
719
-            empty($this->_cpt_model_names)
720
-            || (
721
-                ! $ignore_route_check
722
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
723
-            )
724
-            || (
725
-                $this->_cpt_model_obj instanceof EE_CPT_Base
726
-                && $this->_cpt_model_obj->ID() === $id
727
-            )
728
-        ) {
729
-            // get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
730
-            return;
731
-        }
732
-        // if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
733
-        if ($ignore_route_check) {
734
-            $post_type = get_post_type($id);
735
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
736
-            $custom_post_types = $this->getLoader()->getShared(
737
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
738
-            );
739
-            $model_names       = $custom_post_types->getCustomPostTypeModelNames($post_type);
740
-            if (isset($model_names[ $post_type ])) {
741
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
742
-            }
743
-        } else {
744
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
745
-        }
746
-        if ($model instanceof EEM_Base) {
747
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
748
-        }
749
-        do_action(
750
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
751
-            $this->_cpt_model_obj,
752
-            $req_type
753
-        );
754
-    }
755
-
756
-
757
-    /**
758
-     * admin_init_global
759
-     * This runs all the code that we want executed within the WP admin_init hook.
760
-     * This method executes for ALL EE Admin pages.
761
-     *
762
-     * @return void
763
-     */
764
-    public function admin_init_global()
765
-    {
766
-        $post = $this->request->getRequestParam('post');
767
-        // its possible this is a new save so let's catch that instead
768
-        $post           = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
769
-        $post_type      = $post instanceof WP_Post ? $post->post_type : false;
770
-        $current_route  = isset($this->_req_data['current_route'])
771
-            ? $this->_req_data['current_route']
772
-            : 'shouldneverwork';
773
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
774
-            ? $this->_cpt_routes[ $current_route ]
775
-            : '';
776
-        add_filter('get_delete_post_link', [$this, 'modify_delete_post_link'], 10, 3);
777
-        add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 3);
778
-        if ($post_type === $route_to_check) {
779
-            add_filter('redirect_post_location', [$this, 'cpt_post_location_redirect'], 10, 2);
780
-        }
781
-        // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
782
-        $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
783
-        if (! empty($revision)) {
784
-            $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
785
-            // doing a restore?
786
-            if (! empty($action) && $action === 'restore') {
787
-                // get post for revision
788
-                $rev_post   = get_post($revision);
789
-                $rev_parent = get_post($rev_post->post_parent);
790
-                // only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
791
-                if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
792
-                    add_filter('wp_redirect', [$this, 'revision_redirect'], 10, 2);
793
-                    // restores of revisions
794
-                    add_action('wp_restore_post_revision', [$this, 'restore_revision'], 10, 2);
795
-                }
796
-            }
797
-        }
798
-        // NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
799
-        if ($post_type && $post_type === $route_to_check) {
800
-            // $post_id, $post
801
-            add_action('save_post', [$this, 'insert_update'], 10, 3);
802
-            // $post_id
803
-            add_action('trashed_post', [$this, 'before_trash_cpt_item'], 10);
804
-            add_action('trashed_post', [$this, 'dont_permanently_delete_ee_cpts'], 10);
805
-            add_action('untrashed_post', [$this, 'before_restore_cpt_item'], 10);
806
-            add_action('after_delete_post', [$this, 'before_delete_cpt_item'], 10);
807
-        }
808
-    }
809
-
810
-
811
-    /**
812
-     * Callback for the WordPress trashed_post hook.
813
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
814
-     *
815
-     * @param int $post_id
816
-     * @throws \EE_Error
817
-     * @throws ReflectionException
818
-     */
819
-    public function before_trash_cpt_item($post_id)
820
-    {
821
-        $this->_set_model_object($post_id, true, 'trash');
822
-        // if our cpt object isn't existent then get out immediately.
823
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
824
-            return;
825
-        }
826
-        $this->trash_cpt_item($post_id);
827
-    }
828
-
829
-
830
-    /**
831
-     * Callback for the WordPress untrashed_post hook.
832
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
833
-     *
834
-     * @param $post_id
835
-     * @throws \EE_Error
836
-     * @throws ReflectionException
837
-     */
838
-    public function before_restore_cpt_item($post_id)
839
-    {
840
-        $this->_set_model_object($post_id, true, 'restore');
841
-        // if our cpt object isn't existent then get out immediately.
842
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
843
-            return;
844
-        }
845
-        $this->restore_cpt_item($post_id);
846
-    }
847
-
848
-
849
-    /**
850
-     * Callback for the WordPress after_delete_post hook.
851
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
852
-     *
853
-     * @param $post_id
854
-     * @throws \EE_Error
855
-     * @throws ReflectionException
856
-     */
857
-    public function before_delete_cpt_item($post_id)
858
-    {
859
-        $this->_set_model_object($post_id, true, 'delete');
860
-        // if our cpt object isn't existent then get out immediately.
861
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
862
-            return;
863
-        }
864
-        $this->delete_cpt_item($post_id);
865
-    }
866
-
867
-
868
-    /**
869
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
870
-     * accordingly.
871
-     *
872
-     * @return void
873
-     * @throws EE_Error
874
-     * @throws ReflectionException
875
-     */
876
-    public function verify_cpt_object()
877
-    {
878
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
879
-        // verify event object
880
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
881
-            throw new EE_Error(
882
-                sprintf(
883
-                    esc_html__(
884
-                        'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
885
-                        'event_espresso'
886
-                    ),
887
-                    $label
888
-                )
889
-            );
890
-        }
891
-        // if auto-draft then throw an error
892
-        if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
893
-            EE_Error::overwrite_errors();
894
-            EE_Error::add_error(
895
-                sprintf(
896
-                    esc_html__(
897
-                        'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
898
-                        'event_espresso'
899
-                    ),
900
-                    $label
901
-                ),
902
-                __FILE__,
903
-                __FUNCTION__,
904
-                __LINE__
905
-            );
906
-        }
907
-    }
908
-
909
-
910
-    /**
911
-     * admin_footer_scripts_global
912
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
913
-     * will apply on ALL EE_Admin pages.
914
-     *
915
-     * @return void
916
-     */
917
-    public function admin_footer_scripts_global()
918
-    {
919
-        $this->_add_admin_page_ajax_loading_img();
920
-        $this->_add_admin_page_overlay();
921
-    }
922
-
923
-
924
-    /**
925
-     * add in any global scripts for cpt routes
926
-     *
927
-     * @return void
928
-     */
929
-    public function load_global_scripts_styles()
930
-    {
931
-        parent::load_global_scripts_styles();
932
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
933
-            // setup custom post status object for localize script but only if we've got a cpt object
934
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
935
-            if (! empty($statuses)) {
936
-                // get ALL statuses!
937
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
938
-                // setup object
939
-                $ee_cpt_statuses = [];
940
-                foreach ($statuses as $status => $label) {
941
-                    $ee_cpt_statuses[ $status ] = [
942
-                        'label'      => $label,
943
-                        'save_label' => sprintf(
944
-                            wp_strip_all_tags(__('Save as %s', 'event_espresso')),
945
-                            $label
946
-                        ),
947
-                    ];
948
-                }
949
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
950
-            }
951
-        }
952
-    }
953
-
954
-
955
-    /**
956
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
957
-     * insert/updates
958
-     *
959
-     * @param int     $post_id ID of post being updated
960
-     * @param WP_Post $post    Post object from WP
961
-     * @param bool    $update  Whether this is an update or a new save.
962
-     * @return void
963
-     * @throws \EE_Error
964
-     * @throws ReflectionException
965
-     */
966
-    public function insert_update($post_id, $post, $update)
967
-    {
968
-        // make sure that if this is a revision OR trash action that we don't do any updates!
969
-        if (
970
-            isset($this->_req_data['action'])
971
-            && (
972
-                $this->_req_data['action'] === 'restore'
973
-                || $this->_req_data['action'] === 'trash'
974
-            )
975
-        ) {
976
-            return;
977
-        }
978
-        $this->_set_model_object($post_id, true, 'insert_update');
979
-        // if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
980
-        if (
981
-            $update
982
-            && (
983
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
984
-                || $this->_cpt_model_obj->ID() !== $post_id
985
-            )
986
-        ) {
987
-            return;
988
-        }
989
-        // check for autosave and update our req_data property accordingly.
990
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
524
+	}
525
+
526
+
527
+	/**
528
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
529
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
530
+	 *
531
+	 * @param string $return    the current html
532
+	 * @param int    $id        the post id for the page
533
+	 * @param string $new_title What the title is
534
+	 * @param string $new_slug  what the slug is
535
+	 * @return string            The new html string for the permalink area
536
+	 */
537
+	public function preview_button_html($return, $id, $new_title, $new_slug)
538
+	{
539
+		$post = get_post($id);
540
+		if ('publish' !== get_post_status($post)) {
541
+			$return .= '<span_id="view-post-btn"><a target="_blank" href="'
542
+					   . get_preview_post_link($id)
543
+					   . '" class="button button-small">'
544
+					   . esc_html__('Preview', 'event_espresso')
545
+					   . '</a></span>'
546
+					   . "\n";
547
+		}
548
+		return $return;
549
+	}
550
+
551
+
552
+	/**
553
+	 * add our custom post stati dropdown on the wp post page for this cpt
554
+	 *
555
+	 * @return void
556
+	 */
557
+	public function custom_post_stati_dropdown()
558
+	{
559
+
560
+		$statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
561
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
562
+			? $statuses[ $this->_cpt_model_obj->status() ]
563
+			: '';
564
+		$template_args    = [
565
+			'cur_status'            => $this->_cpt_model_obj->status(),
566
+			'statuses'              => $statuses,
567
+			'cur_status_label'      => $cur_status_label,
568
+			'localized_status_save' => sprintf(esc_html__('Save %s', 'event_espresso'), $cur_status_label),
569
+		];
570
+		// we'll add a trash post status (WP doesn't add one for some reason)
571
+		if ($this->_cpt_model_obj->status() === 'trash') {
572
+			$template_args['cur_status_label'] = esc_html__('Trashed', 'event_espresso');
573
+			$statuses['trash']                 = esc_html__('Trashed', 'event_espresso');
574
+			$template_args['statuses']         = $statuses;
575
+		}
576
+
577
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
578
+		EEH_Template::display_template($template, $template_args);
579
+	}
580
+
581
+
582
+	public function setup_autosave_hooks()
583
+	{
584
+		$this->_set_autosave_containers();
585
+		$this->_load_autosave_scripts_styles();
586
+	}
587
+
588
+
589
+	/**
590
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a post object (available
591
+	 * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
592
+	 * for the nonce in here, but then this method looks for two things:
593
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
594
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
595
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
596
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
597
+	 * template args.
598
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
599
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
600
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
601
+	 *    $this->_template_args['data']['items'] = array(
602
+	 *        'event-datetime-ids' => '1,2,3';
603
+	 *    );
604
+	 *    Keep in mind the following things:
605
+	 *    - "where" index is for the input with the id as that string.
606
+	 *    - "what" index is what will be used for the value of that input.
607
+	 *
608
+	 * @return void
609
+	 * @throws EE_Error
610
+	 */
611
+	public function do_extra_autosave_stuff()
612
+	{
613
+		// next let's check for the autosave nonce (we'll use _verify_nonce )
614
+		$nonce = $this->request->getRequestParam('autosavenonce');
615
+		$this->_verify_nonce($nonce, 'autosave');
616
+		// make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
617
+		if (! defined('DOING_AUTOSAVE')) {
618
+			define('DOING_AUTOSAVE', true);
619
+		}
620
+		// if we made it here then the nonce checked out.  Let's run our methods and actions
621
+		$autosave = "_ee_autosave_{$this->_current_view}";
622
+		if (method_exists($this, $autosave)) {
623
+			$this->$autosave();
624
+		} else {
625
+			$this->_template_args['success'] = true;
626
+		}
627
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
628
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
629
+		// now let's return json
630
+		$this->_return_json();
631
+	}
632
+
633
+
634
+	/**
635
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
636
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
637
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
638
+	 *
639
+	 * @return void
640
+	 * @throws EE_Error
641
+	 * @throws ReflectionException
642
+	 */
643
+	protected function _extend_page_config_for_cpt()
644
+	{
645
+		// before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
646
+		if ($this->raw_req_page !== $this->page_slug) {
647
+			return;
648
+		}
649
+		// set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
650
+		if (! empty($this->_cpt_object)) {
651
+			$this->_page_routes = array_merge(
652
+				[
653
+					'create_new' => '_create_new_cpt_item',
654
+					'edit'       => '_edit_cpt_item',
655
+				],
656
+				$this->_page_routes
657
+			);
658
+			$this->_page_config = array_merge(
659
+				[
660
+					'create_new' => [
661
+						'nav'           => [
662
+							'label' => $this->_cpt_object->labels->add_new_item,
663
+							'order' => 5,
664
+						],
665
+						'require_nonce' => false,
666
+					],
667
+					'edit'       => [
668
+						'nav'           => [
669
+							'label'      => $this->_cpt_object->labels->edit_item,
670
+							'order'      => 5,
671
+							'persistent' => false,
672
+							'url'        => '',
673
+						],
674
+						'require_nonce' => false,
675
+					],
676
+				],
677
+				$this->_page_config
678
+			);
679
+		}
680
+		// load the next section only if this is a matching cpt route as set in the cpt routes array.
681
+		if (! isset($this->_cpt_routes[ $this->_req_action ])) {
682
+			return;
683
+		}
684
+		$this->_cpt_route = true;
685
+		// $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]);
686
+		// add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
687
+		if (empty($this->_cpt_object)) {
688
+			$msg = sprintf(
689
+				esc_html__(
690
+					'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
691
+					'event_espresso'
692
+				),
693
+				$this->page_slug,
694
+				$this->_req_action,
695
+				get_class($this)
696
+			);
697
+			throw new EE_Error($msg);
698
+		}
699
+		$this->_set_model_object($this->request->getRequestParam('post'));
700
+	}
701
+
702
+
703
+	/**
704
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
705
+	 *
706
+	 * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
707
+	 * @param bool   $ignore_route_check
708
+	 * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
709
+	 * @throws EE_Error
710
+	 * @throws InvalidArgumentException
711
+	 * @throws InvalidDataTypeException
712
+	 * @throws InvalidInterfaceException
713
+	 * @throws ReflectionException
714
+	 */
715
+	protected function _set_model_object($id = null, $ignore_route_check = false, $req_type = '')
716
+	{
717
+		$model = null;
718
+		if (
719
+			empty($this->_cpt_model_names)
720
+			|| (
721
+				! $ignore_route_check
722
+				&& ! isset($this->_cpt_routes[ $this->_req_action ])
723
+			)
724
+			|| (
725
+				$this->_cpt_model_obj instanceof EE_CPT_Base
726
+				&& $this->_cpt_model_obj->ID() === $id
727
+			)
728
+		) {
729
+			// get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
730
+			return;
731
+		}
732
+		// if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
733
+		if ($ignore_route_check) {
734
+			$post_type = get_post_type($id);
735
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
736
+			$custom_post_types = $this->getLoader()->getShared(
737
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
738
+			);
739
+			$model_names       = $custom_post_types->getCustomPostTypeModelNames($post_type);
740
+			if (isset($model_names[ $post_type ])) {
741
+				$model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
742
+			}
743
+		} else {
744
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
745
+		}
746
+		if ($model instanceof EEM_Base) {
747
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
748
+		}
749
+		do_action(
750
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
751
+			$this->_cpt_model_obj,
752
+			$req_type
753
+		);
754
+	}
755
+
756
+
757
+	/**
758
+	 * admin_init_global
759
+	 * This runs all the code that we want executed within the WP admin_init hook.
760
+	 * This method executes for ALL EE Admin pages.
761
+	 *
762
+	 * @return void
763
+	 */
764
+	public function admin_init_global()
765
+	{
766
+		$post = $this->request->getRequestParam('post');
767
+		// its possible this is a new save so let's catch that instead
768
+		$post           = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
769
+		$post_type      = $post instanceof WP_Post ? $post->post_type : false;
770
+		$current_route  = isset($this->_req_data['current_route'])
771
+			? $this->_req_data['current_route']
772
+			: 'shouldneverwork';
773
+		$route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
774
+			? $this->_cpt_routes[ $current_route ]
775
+			: '';
776
+		add_filter('get_delete_post_link', [$this, 'modify_delete_post_link'], 10, 3);
777
+		add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 3);
778
+		if ($post_type === $route_to_check) {
779
+			add_filter('redirect_post_location', [$this, 'cpt_post_location_redirect'], 10, 2);
780
+		}
781
+		// now let's filter redirect if we're on a revision page and the revision is for an event CPT.
782
+		$revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
783
+		if (! empty($revision)) {
784
+			$action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
785
+			// doing a restore?
786
+			if (! empty($action) && $action === 'restore') {
787
+				// get post for revision
788
+				$rev_post   = get_post($revision);
789
+				$rev_parent = get_post($rev_post->post_parent);
790
+				// only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
791
+				if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
792
+					add_filter('wp_redirect', [$this, 'revision_redirect'], 10, 2);
793
+					// restores of revisions
794
+					add_action('wp_restore_post_revision', [$this, 'restore_revision'], 10, 2);
795
+				}
796
+			}
797
+		}
798
+		// NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
799
+		if ($post_type && $post_type === $route_to_check) {
800
+			// $post_id, $post
801
+			add_action('save_post', [$this, 'insert_update'], 10, 3);
802
+			// $post_id
803
+			add_action('trashed_post', [$this, 'before_trash_cpt_item'], 10);
804
+			add_action('trashed_post', [$this, 'dont_permanently_delete_ee_cpts'], 10);
805
+			add_action('untrashed_post', [$this, 'before_restore_cpt_item'], 10);
806
+			add_action('after_delete_post', [$this, 'before_delete_cpt_item'], 10);
807
+		}
808
+	}
809
+
810
+
811
+	/**
812
+	 * Callback for the WordPress trashed_post hook.
813
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
814
+	 *
815
+	 * @param int $post_id
816
+	 * @throws \EE_Error
817
+	 * @throws ReflectionException
818
+	 */
819
+	public function before_trash_cpt_item($post_id)
820
+	{
821
+		$this->_set_model_object($post_id, true, 'trash');
822
+		// if our cpt object isn't existent then get out immediately.
823
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
824
+			return;
825
+		}
826
+		$this->trash_cpt_item($post_id);
827
+	}
828
+
829
+
830
+	/**
831
+	 * Callback for the WordPress untrashed_post hook.
832
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
833
+	 *
834
+	 * @param $post_id
835
+	 * @throws \EE_Error
836
+	 * @throws ReflectionException
837
+	 */
838
+	public function before_restore_cpt_item($post_id)
839
+	{
840
+		$this->_set_model_object($post_id, true, 'restore');
841
+		// if our cpt object isn't existent then get out immediately.
842
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
843
+			return;
844
+		}
845
+		$this->restore_cpt_item($post_id);
846
+	}
847
+
848
+
849
+	/**
850
+	 * Callback for the WordPress after_delete_post hook.
851
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
852
+	 *
853
+	 * @param $post_id
854
+	 * @throws \EE_Error
855
+	 * @throws ReflectionException
856
+	 */
857
+	public function before_delete_cpt_item($post_id)
858
+	{
859
+		$this->_set_model_object($post_id, true, 'delete');
860
+		// if our cpt object isn't existent then get out immediately.
861
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
862
+			return;
863
+		}
864
+		$this->delete_cpt_item($post_id);
865
+	}
866
+
867
+
868
+	/**
869
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
870
+	 * accordingly.
871
+	 *
872
+	 * @return void
873
+	 * @throws EE_Error
874
+	 * @throws ReflectionException
875
+	 */
876
+	public function verify_cpt_object()
877
+	{
878
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
879
+		// verify event object
880
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
881
+			throw new EE_Error(
882
+				sprintf(
883
+					esc_html__(
884
+						'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
885
+						'event_espresso'
886
+					),
887
+					$label
888
+				)
889
+			);
890
+		}
891
+		// if auto-draft then throw an error
892
+		if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
893
+			EE_Error::overwrite_errors();
894
+			EE_Error::add_error(
895
+				sprintf(
896
+					esc_html__(
897
+						'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
898
+						'event_espresso'
899
+					),
900
+					$label
901
+				),
902
+				__FILE__,
903
+				__FUNCTION__,
904
+				__LINE__
905
+			);
906
+		}
907
+	}
908
+
909
+
910
+	/**
911
+	 * admin_footer_scripts_global
912
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
913
+	 * will apply on ALL EE_Admin pages.
914
+	 *
915
+	 * @return void
916
+	 */
917
+	public function admin_footer_scripts_global()
918
+	{
919
+		$this->_add_admin_page_ajax_loading_img();
920
+		$this->_add_admin_page_overlay();
921
+	}
922
+
923
+
924
+	/**
925
+	 * add in any global scripts for cpt routes
926
+	 *
927
+	 * @return void
928
+	 */
929
+	public function load_global_scripts_styles()
930
+	{
931
+		parent::load_global_scripts_styles();
932
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
933
+			// setup custom post status object for localize script but only if we've got a cpt object
934
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
935
+			if (! empty($statuses)) {
936
+				// get ALL statuses!
937
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
938
+				// setup object
939
+				$ee_cpt_statuses = [];
940
+				foreach ($statuses as $status => $label) {
941
+					$ee_cpt_statuses[ $status ] = [
942
+						'label'      => $label,
943
+						'save_label' => sprintf(
944
+							wp_strip_all_tags(__('Save as %s', 'event_espresso')),
945
+							$label
946
+						),
947
+					];
948
+				}
949
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
950
+			}
951
+		}
952
+	}
953
+
954
+
955
+	/**
956
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
957
+	 * insert/updates
958
+	 *
959
+	 * @param int     $post_id ID of post being updated
960
+	 * @param WP_Post $post    Post object from WP
961
+	 * @param bool    $update  Whether this is an update or a new save.
962
+	 * @return void
963
+	 * @throws \EE_Error
964
+	 * @throws ReflectionException
965
+	 */
966
+	public function insert_update($post_id, $post, $update)
967
+	{
968
+		// make sure that if this is a revision OR trash action that we don't do any updates!
969
+		if (
970
+			isset($this->_req_data['action'])
971
+			&& (
972
+				$this->_req_data['action'] === 'restore'
973
+				|| $this->_req_data['action'] === 'trash'
974
+			)
975
+		) {
976
+			return;
977
+		}
978
+		$this->_set_model_object($post_id, true, 'insert_update');
979
+		// if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
980
+		if (
981
+			$update
982
+			&& (
983
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
984
+				|| $this->_cpt_model_obj->ID() !== $post_id
985
+			)
986
+		) {
987
+			return;
988
+		}
989
+		// check for autosave and update our req_data property accordingly.
990
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
991 991
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
992 992
 
993 993
                 foreach ( (array) $values as $key => $value ) {
@@ -997,554 +997,554 @@  discard block
 block discarded – undo
997 997
 
998 998
         }/**/ // TODO reactivate after autosave is implemented in 4.2
999 999
 
1000
-        // take care of updating any selected page_template IF this cpt supports it.
1001
-        if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1002
-            // wp version aware.
1003
-            if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1004
-                $page_templates = wp_get_theme()->get_page_templates();
1005
-            } else {
1006
-                $post->page_template = $this->_req_data['page_template'];
1007
-                $page_templates      = wp_get_theme()->get_page_templates($post);
1008
-            }
1009
-            if (
1010
-                'default' != $this->_req_data['page_template']
1011
-                && ! isset($page_templates[ $this->_req_data['page_template'] ])
1012
-            ) {
1013
-                EE_Error::add_error(
1014
-                    esc_html__('Invalid Page Template.', 'event_espresso'),
1015
-                    __FILE__,
1016
-                    __FUNCTION__,
1017
-                    __LINE__
1018
-                );
1019
-            } else {
1020
-                update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1021
-            }
1022
-        }
1023
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1024
-            return;
1025
-        } //TODO we'll remove this after reimplementing autosave in 4.2
1026
-        $this->_insert_update_cpt_item($post_id, $post);
1027
-    }
1028
-
1029
-
1030
-    /**
1031
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1032
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1033
-     * so we don't have to check for our CPT.
1034
-     *
1035
-     * @param int $post_id ID of the post
1036
-     * @return void
1037
-     */
1038
-    public function dont_permanently_delete_ee_cpts($post_id)
1039
-    {
1040
-        // only do this if we're actually processing one of our CPTs
1041
-        // if our cpt object isn't existent then get out immediately.
1042
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1043
-            return;
1044
-        }
1045
-        delete_post_meta($post_id, '_wp_trash_meta_status');
1046
-        delete_post_meta($post_id, '_wp_trash_meta_time');
1047
-        // our cpts may have comments so let's take care of that too
1048
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1049
-    }
1050
-
1051
-
1052
-    /**
1053
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1054
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1055
-     * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1056
-     *
1057
-     * @param int $post_id     ID of cpt item
1058
-     * @param int $revision_id ID of revision being restored
1059
-     * @return void
1060
-     */
1061
-    public function restore_revision($post_id, $revision_id)
1062
-    {
1063
-        $this->_restore_cpt_item($post_id, $revision_id);
1064
-        // global action
1065
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1066
-        // class specific action so you can limit hooking into a specific page.
1067
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1068
-    }
1069
-
1070
-
1071
-    /**
1072
-     * @param int $post_id     ID of cpt item
1073
-     * @param int $revision_id ID of revision for item
1074
-     * @return void
1075
-     * @see restore_revision() for details
1076
-     */
1077
-    abstract protected function _restore_cpt_item($post_id, $revision_id);
1078
-
1079
-
1080
-    /**
1081
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
1082
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1083
-     * To fix we have to reset the current_screen using the page_slug
1084
-     * (which is identical - or should be - to our registered_post_type id.)
1085
-     * Also, since the core WP file loads the admin_header.php for WP
1086
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1087
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1088
-     *
1089
-     * @return void
1090
-     * @throws EE_Error
1091
-     * @throws EE_Error
1092
-     */
1093
-    public function modify_current_screen()
1094
-    {
1095
-        // ONLY do this if the current page_route IS a cpt route
1096
-        if (! $this->_cpt_route) {
1097
-            return;
1098
-        }
1099
-        // routing things REALLY early b/c this is a cpt admin page
1100
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1101
-        $this->_current_screen       = get_current_screen();
1102
-        $this->_current_screen->base = 'event-espresso';
1103
-        $this->_add_help_tabs(); // we make sure we add any help tabs back in!
1104
-        /*try {
1000
+		// take care of updating any selected page_template IF this cpt supports it.
1001
+		if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
1002
+			// wp version aware.
1003
+			if (RecommendedVersions::compareWordPressVersion('4.7', '>=')) {
1004
+				$page_templates = wp_get_theme()->get_page_templates();
1005
+			} else {
1006
+				$post->page_template = $this->_req_data['page_template'];
1007
+				$page_templates      = wp_get_theme()->get_page_templates($post);
1008
+			}
1009
+			if (
1010
+				'default' != $this->_req_data['page_template']
1011
+				&& ! isset($page_templates[ $this->_req_data['page_template'] ])
1012
+			) {
1013
+				EE_Error::add_error(
1014
+					esc_html__('Invalid Page Template.', 'event_espresso'),
1015
+					__FILE__,
1016
+					__FUNCTION__,
1017
+					__LINE__
1018
+				);
1019
+			} else {
1020
+				update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
1021
+			}
1022
+		}
1023
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1024
+			return;
1025
+		} //TODO we'll remove this after reimplementing autosave in 4.2
1026
+		$this->_insert_update_cpt_item($post_id, $post);
1027
+	}
1028
+
1029
+
1030
+	/**
1031
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
1032
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
1033
+	 * so we don't have to check for our CPT.
1034
+	 *
1035
+	 * @param int $post_id ID of the post
1036
+	 * @return void
1037
+	 */
1038
+	public function dont_permanently_delete_ee_cpts($post_id)
1039
+	{
1040
+		// only do this if we're actually processing one of our CPTs
1041
+		// if our cpt object isn't existent then get out immediately.
1042
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1043
+			return;
1044
+		}
1045
+		delete_post_meta($post_id, '_wp_trash_meta_status');
1046
+		delete_post_meta($post_id, '_wp_trash_meta_time');
1047
+		// our cpts may have comments so let's take care of that too
1048
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
1049
+	}
1050
+
1051
+
1052
+	/**
1053
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1054
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1055
+	 * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1056
+	 *
1057
+	 * @param int $post_id     ID of cpt item
1058
+	 * @param int $revision_id ID of revision being restored
1059
+	 * @return void
1060
+	 */
1061
+	public function restore_revision($post_id, $revision_id)
1062
+	{
1063
+		$this->_restore_cpt_item($post_id, $revision_id);
1064
+		// global action
1065
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1066
+		// class specific action so you can limit hooking into a specific page.
1067
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1068
+	}
1069
+
1070
+
1071
+	/**
1072
+	 * @param int $post_id     ID of cpt item
1073
+	 * @param int $revision_id ID of revision for item
1074
+	 * @return void
1075
+	 * @see restore_revision() for details
1076
+	 */
1077
+	abstract protected function _restore_cpt_item($post_id, $revision_id);
1078
+
1079
+
1080
+	/**
1081
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
1082
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1083
+	 * To fix we have to reset the current_screen using the page_slug
1084
+	 * (which is identical - or should be - to our registered_post_type id.)
1085
+	 * Also, since the core WP file loads the admin_header.php for WP
1086
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1087
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1088
+	 *
1089
+	 * @return void
1090
+	 * @throws EE_Error
1091
+	 * @throws EE_Error
1092
+	 */
1093
+	public function modify_current_screen()
1094
+	{
1095
+		// ONLY do this if the current page_route IS a cpt route
1096
+		if (! $this->_cpt_route) {
1097
+			return;
1098
+		}
1099
+		// routing things REALLY early b/c this is a cpt admin page
1100
+		set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1101
+		$this->_current_screen       = get_current_screen();
1102
+		$this->_current_screen->base = 'event-espresso';
1103
+		$this->_add_help_tabs(); // we make sure we add any help tabs back in!
1104
+		/*try {
1105 1105
             $this->_route_admin_request();
1106 1106
         } catch ( EE_Error $e ) {
1107 1107
             $e->get_error();
1108 1108
         }/**/
1109
-    }
1110
-
1111
-
1112
-    /**
1113
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1114
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1115
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1116
-     * default to be.
1117
-     *
1118
-     * @param string $title The new title (or existing if there is no editor_title defined)
1119
-     * @return string
1120
-     */
1121
-    public function add_custom_editor_default_title($title)
1122
-    {
1123
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1124
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1125
-            : $title;
1126
-    }
1127
-
1128
-
1129
-    /**
1130
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1131
-     *
1132
-     * @param string $shortlink   The already generated shortlink
1133
-     * @param int    $id          Post ID for this item
1134
-     * @param string $context     The context for the link
1135
-     * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1136
-     * @return string
1137
-     */
1138
-    public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1139
-    {
1140
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1141
-            $post = get_post($id);
1142
-            if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1143
-                $shortlink = home_url('?p=' . $post->ID);
1144
-            }
1145
-        }
1146
-        return $shortlink;
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1152
-     * already run in modify_current_screen())
1153
-     *
1154
-     * @return void
1155
-     */
1156
-    public function route_admin_request()
1157
-    {
1158
-        if ($this->_cpt_route) {
1159
-            return;
1160
-        }
1161
-        try {
1162
-            $this->_route_admin_request();
1163
-        } catch (EE_Error $e) {
1164
-            $e->get_error();
1165
-        }
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1171
-     *
1172
-     * @return void
1173
-     */
1174
-    public function cpt_post_form_hidden_input()
1175
-    {
1176
-        // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1177
-        echo '
1109
+	}
1110
+
1111
+
1112
+	/**
1113
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1114
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1115
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1116
+	 * default to be.
1117
+	 *
1118
+	 * @param string $title The new title (or existing if there is no editor_title defined)
1119
+	 * @return string
1120
+	 */
1121
+	public function add_custom_editor_default_title($title)
1122
+	{
1123
+		return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1124
+			? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1125
+			: $title;
1126
+	}
1127
+
1128
+
1129
+	/**
1130
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1131
+	 *
1132
+	 * @param string $shortlink   The already generated shortlink
1133
+	 * @param int    $id          Post ID for this item
1134
+	 * @param string $context     The context for the link
1135
+	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1136
+	 * @return string
1137
+	 */
1138
+	public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1139
+	{
1140
+		if (! empty($id) && get_option('permalink_structure') !== '') {
1141
+			$post = get_post($id);
1142
+			if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1143
+				$shortlink = home_url('?p=' . $post->ID);
1144
+			}
1145
+		}
1146
+		return $shortlink;
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1152
+	 * already run in modify_current_screen())
1153
+	 *
1154
+	 * @return void
1155
+	 */
1156
+	public function route_admin_request()
1157
+	{
1158
+		if ($this->_cpt_route) {
1159
+			return;
1160
+		}
1161
+		try {
1162
+			$this->_route_admin_request();
1163
+		} catch (EE_Error $e) {
1164
+			$e->get_error();
1165
+		}
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1171
+	 *
1172
+	 * @return void
1173
+	 */
1174
+	public function cpt_post_form_hidden_input()
1175
+	{
1176
+		// we're also going to add the route value and the current page so we can direct autosave parsing correctly
1177
+		echo '
1178 1178
         <input type="hidden" name="ee_cpt_item_redirect_url" value="' . esc_url_raw($this->_admin_base_url) . '"/>
1179 1179
         <div id="ee-cpt-hidden-inputs">
1180 1180
             <input type="hidden" id="current_route" name="current_route" value="' . esc_attr($this->_current_view) . '"/>
1181 1181
             <input type="hidden" id="current_page" name="current_page" value="' . esc_attr($this->page_slug) . '"/>
1182 1182
         </div>';
1183
-    }
1184
-
1185
-
1186
-    /**
1187
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1188
-     *
1189
-     * @param string $location Original location url
1190
-     * @param int    $status   Status for http header
1191
-     * @return string           new (or original) url to redirect to.
1192
-     * @throws EE_Error
1193
-     * @throws EE_Error
1194
-     */
1195
-    public function revision_redirect($location, $status)
1196
-    {
1197
-        // get revision
1198
-        $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1199
-        // can't do anything without revision so let's get out if not present
1200
-        if (empty($rev_id)) {
1201
-            return $location;
1202
-        }
1203
-        // get rev_post_data
1204
-        $rev        = get_post($rev_id);
1205
-        $admin_url  = $this->_admin_base_url;
1206
-        $query_args = [
1207
-            'action'   => 'edit',
1208
-            'post'     => $rev->post_parent,
1209
-            'revision' => $rev_id,
1210
-            'message'  => 5,
1211
-        ];
1212
-        $this->_process_notices($query_args, true);
1213
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1214
-    }
1215
-
1216
-
1217
-    /**
1218
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1219
-     *
1220
-     * @param string $link    the original generated link
1221
-     * @param int    $id      post id
1222
-     * @param string $context optional, defaults to display.  How to write the '&'
1223
-     * @return string          the link
1224
-     */
1225
-    public function modify_edit_post_link($link, $id, $context)
1226
-    {
1227
-        $post = get_post($id);
1228
-        if (
1229
-            ! isset($this->_req_data['action'])
1230
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1231
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1232
-        ) {
1233
-            return $link;
1234
-        }
1235
-        $query_args = [
1236
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1237
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1238
-                : 'edit',
1239
-            'post'   => $id,
1240
-        ];
1241
-        return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1247
-     * our routes.
1248
-     *
1249
-     * @param string $delete_link  original delete link
1250
-     * @param int    $post_id      id of cpt object
1251
-     * @param bool   $force_delete whether this is forcing a hard delete instead of trash
1252
-     * @return string new delete link
1253
-     * @throws EE_Error
1254
-     * @throws ReflectionException
1255
-     */
1256
-    public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1257
-    {
1258
-        $post = get_post($post_id);
1259
-
1260
-        if (
1261
-            empty($this->_req_data['action'])
1262
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1263
-            || ! $post instanceof WP_Post
1264
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1265
-        ) {
1266
-            return $delete_link;
1267
-        }
1268
-        $this->_set_model_object($post->ID, true);
1269
-
1270
-        // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1271
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1272
-
1273
-        return EE_Admin_Page::add_query_args_and_nonce(
1274
-            [
1275
-                'page'   => $this->_req_data['page'],
1276
-                'action' => $action,
1277
-                $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1278
-                         => $post->ID,
1279
-            ],
1280
-            admin_url()
1281
-        );
1282
-    }
1283
-
1284
-
1285
-    /**
1286
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1287
-     * so that we can hijack the default redirect locations for wp custom post types
1288
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1289
-     *
1290
-     * @param string $location This is the incoming currently set redirect location
1291
-     * @param string $post_id  This is the 'ID' value of the wp_posts table
1292
-     * @return string           the new location to redirect to
1293
-     * @throws EE_Error
1294
-     * @throws EE_Error
1295
-     */
1296
-    public function cpt_post_location_redirect($location, $post_id)
1297
-    {
1298
-        // we DO have a match so let's setup the url
1299
-        // we have to get the post to determine our route
1300
-        $post       = get_post($post_id);
1301
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1302
-        // shared query_args
1303
-        $query_args = ['action' => $edit_route, 'post' => $post_id];
1304
-        $admin_url  = $this->_admin_base_url;
1305
-        if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1306
-            $status = get_post_status($post_id);
1307
-            if (isset($this->_req_data['publish'])) {
1308
-                switch ($status) {
1309
-                    case 'pending':
1310
-                        $message = 8;
1311
-                        break;
1312
-                    case 'future':
1313
-                        $message = 9;
1314
-                        break;
1315
-                    default:
1316
-                        $message = 6;
1317
-                }
1318
-            } else {
1319
-                $message = 'draft' === $status ? 10 : 1;
1320
-            }
1321
-        } elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1322
-            $message = 2;
1323
-        } elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1324
-            $message = 3;
1325
-        } elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1326
-            $message = 7;
1327
-        } else {
1328
-            $message = 4;
1329
-        }
1330
-        // change the message if the post type is not viewable on the frontend
1331
-        $this->_cpt_object = get_post_type_object($post->post_type);
1332
-        $message           = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1333
-        $query_args        = array_merge(['message' => $message], $query_args);
1334
-        $this->_process_notices($query_args, true);
1335
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     * This method is called to inject nav tabs on core WP cpt pages
1341
-     *
1342
-     * @return void
1343
-     * @throws EE_Error
1344
-     * @throws EE_Error
1345
-     */
1346
-    public function inject_nav_tabs()
1347
-    {
1348
-        // can we hijack and insert the nav_tabs?
1349
-        $nav_tabs = $this->_get_main_nav_tabs();
1350
-        // first close off existing form tag
1351
-        $html = '>';
1352
-        $html .= $nav_tabs;
1353
-        // now let's handle the remaining tag ( missing ">" is CORRECT )
1354
-        $html .= '<span></span';
1355
-        echo $html;  // already escaped
1356
-    }
1357
-
1358
-
1359
-    /**
1360
-     * This just sets up the post update messages when an update form is loaded
1361
-     *
1362
-     * @param array $messages the original messages array
1363
-     * @return array           the new messages array
1364
-     */
1365
-    public function post_update_messages($messages)
1366
-    {
1367
-        global $post;
1368
-        $id       = $this->request->getRequestParam('post');
1369
-        $id       = empty($id) && is_object($post) ? $post->ID : null;
1370
-        $revision = $this->request->getRequestParam('revision', 0, 'int');
1371
-
1372
-        $messages[ $post->post_type ] = [
1373
-            0  => '', // Unused. Messages start at index 1.
1374
-            1  => sprintf(
1375
-                esc_html__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1376
-                $this->_cpt_object->labels->singular_name,
1377
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1378
-                '</a>'
1379
-            ),
1380
-            2  => esc_html__('Custom field updated', 'event_espresso'),
1381
-            3  => esc_html__('Custom field deleted.', 'event_espresso'),
1382
-            4  => sprintf(esc_html__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1383
-            5  => $revision
1384
-                ? sprintf(
1385
-                    esc_html__('%s restored to revision from %s', 'event_espresso'),
1386
-                    $this->_cpt_object->labels->singular_name,
1387
-                    wp_post_revision_title($revision, false)
1388
-                )
1389
-                : false,
1390
-            6  => sprintf(
1391
-                esc_html__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1392
-                $this->_cpt_object->labels->singular_name,
1393
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1394
-                '</a>'
1395
-            ),
1396
-            7  => sprintf(esc_html__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1397
-            8  => sprintf(
1398
-                esc_html__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1399
-                $this->_cpt_object->labels->singular_name,
1400
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1401
-                '</a>'
1402
-            ),
1403
-            9  => sprintf(
1404
-                esc_html__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1405
-                $this->_cpt_object->labels->singular_name,
1406
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1407
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1408
-                '</a>'
1409
-            ),
1410
-            10 => sprintf(
1411
-                esc_html__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1412
-                $this->_cpt_object->labels->singular_name,
1413
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1414
-                '</a>'
1415
-            ),
1416
-        ];
1417
-        return $messages;
1418
-    }
1419
-
1420
-
1421
-    /**
1422
-     * default method for the 'create_new' route for cpt admin pages.
1423
-     * For reference what to include in here, see wp-admin/post-new.php
1424
-     *
1425
-     * @return void
1426
-     */
1427
-    protected function _create_new_cpt_item()
1428
-    {
1429
-        // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1430
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1431
-        $post_type        = $this->_cpt_routes[ $this->_req_action ];
1432
-        $post_type_object = $this->_cpt_object;
1433
-        $title            = $post_type_object->labels->add_new_item;
1434
-        $post             = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1435
-        add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1436
-        // modify the default editor title field with default title.
1437
-        add_filter('enter_title_here', [$this, 'add_custom_editor_default_title'], 10);
1438
-        $this->loadEditorTemplate(true);
1439
-    }
1440
-
1441
-
1442
-    /**
1443
-     * Enqueues auto-save and loads the editor template
1444
-     *
1445
-     * @param bool $creating
1446
-     */
1447
-    private function loadEditorTemplate($creating = true)
1448
-    {
1449
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1450
-        // these vars are used by the template
1451
-        $editing = true;
1452
-        $post_ID = $post->ID;
1453
-        if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1454
-            // only enqueue autosave when creating event (necessary to get permalink/url generated)
1455
-            // otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1456
-            if ($creating) {
1457
-                wp_enqueue_script('autosave');
1458
-            } else {
1459
-                if (
1460
-                    isset($this->_cpt_routes[ $this->_req_data['action'] ])
1461
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1462
-                ) {
1463
-                    $create_new_action = apply_filters(
1464
-                        'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1465
-                        'create_new',
1466
-                        $this
1467
-                    );
1468
-                    $post_new_file     = EE_Admin_Page::add_query_args_and_nonce(
1469
-                        [
1470
-                            'action' => $create_new_action,
1471
-                            'page'   => $this->page_slug,
1472
-                        ],
1473
-                        'admin.php'
1474
-                    );
1475
-                }
1476
-            }
1477
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1478
-        }
1479
-    }
1480
-
1481
-
1482
-    public function add_new_admin_page_global()
1483
-    {
1484
-        $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1485
-        ?>
1183
+	}
1184
+
1185
+
1186
+	/**
1187
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1188
+	 *
1189
+	 * @param string $location Original location url
1190
+	 * @param int    $status   Status for http header
1191
+	 * @return string           new (or original) url to redirect to.
1192
+	 * @throws EE_Error
1193
+	 * @throws EE_Error
1194
+	 */
1195
+	public function revision_redirect($location, $status)
1196
+	{
1197
+		// get revision
1198
+		$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1199
+		// can't do anything without revision so let's get out if not present
1200
+		if (empty($rev_id)) {
1201
+			return $location;
1202
+		}
1203
+		// get rev_post_data
1204
+		$rev        = get_post($rev_id);
1205
+		$admin_url  = $this->_admin_base_url;
1206
+		$query_args = [
1207
+			'action'   => 'edit',
1208
+			'post'     => $rev->post_parent,
1209
+			'revision' => $rev_id,
1210
+			'message'  => 5,
1211
+		];
1212
+		$this->_process_notices($query_args, true);
1213
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1214
+	}
1215
+
1216
+
1217
+	/**
1218
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1219
+	 *
1220
+	 * @param string $link    the original generated link
1221
+	 * @param int    $id      post id
1222
+	 * @param string $context optional, defaults to display.  How to write the '&'
1223
+	 * @return string          the link
1224
+	 */
1225
+	public function modify_edit_post_link($link, $id, $context)
1226
+	{
1227
+		$post = get_post($id);
1228
+		if (
1229
+			! isset($this->_req_data['action'])
1230
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1231
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1232
+		) {
1233
+			return $link;
1234
+		}
1235
+		$query_args = [
1236
+			'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1237
+				? $this->_cpt_edit_routes[ $post->post_type ]
1238
+				: 'edit',
1239
+			'post'   => $id,
1240
+		];
1241
+		return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1247
+	 * our routes.
1248
+	 *
1249
+	 * @param string $delete_link  original delete link
1250
+	 * @param int    $post_id      id of cpt object
1251
+	 * @param bool   $force_delete whether this is forcing a hard delete instead of trash
1252
+	 * @return string new delete link
1253
+	 * @throws EE_Error
1254
+	 * @throws ReflectionException
1255
+	 */
1256
+	public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1257
+	{
1258
+		$post = get_post($post_id);
1259
+
1260
+		if (
1261
+			empty($this->_req_data['action'])
1262
+			|| ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1263
+			|| ! $post instanceof WP_Post
1264
+			|| $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1265
+		) {
1266
+			return $delete_link;
1267
+		}
1268
+		$this->_set_model_object($post->ID, true);
1269
+
1270
+		// returns something like `trash_event` or `trash_attendee` or `trash_venue`
1271
+		$action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1272
+
1273
+		return EE_Admin_Page::add_query_args_and_nonce(
1274
+			[
1275
+				'page'   => $this->_req_data['page'],
1276
+				'action' => $action,
1277
+				$this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name()
1278
+						 => $post->ID,
1279
+			],
1280
+			admin_url()
1281
+		);
1282
+	}
1283
+
1284
+
1285
+	/**
1286
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1287
+	 * so that we can hijack the default redirect locations for wp custom post types
1288
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1289
+	 *
1290
+	 * @param string $location This is the incoming currently set redirect location
1291
+	 * @param string $post_id  This is the 'ID' value of the wp_posts table
1292
+	 * @return string           the new location to redirect to
1293
+	 * @throws EE_Error
1294
+	 * @throws EE_Error
1295
+	 */
1296
+	public function cpt_post_location_redirect($location, $post_id)
1297
+	{
1298
+		// we DO have a match so let's setup the url
1299
+		// we have to get the post to determine our route
1300
+		$post       = get_post($post_id);
1301
+		$edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1302
+		// shared query_args
1303
+		$query_args = ['action' => $edit_route, 'post' => $post_id];
1304
+		$admin_url  = $this->_admin_base_url;
1305
+		if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1306
+			$status = get_post_status($post_id);
1307
+			if (isset($this->_req_data['publish'])) {
1308
+				switch ($status) {
1309
+					case 'pending':
1310
+						$message = 8;
1311
+						break;
1312
+					case 'future':
1313
+						$message = 9;
1314
+						break;
1315
+					default:
1316
+						$message = 6;
1317
+				}
1318
+			} else {
1319
+				$message = 'draft' === $status ? 10 : 1;
1320
+			}
1321
+		} elseif (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1322
+			$message = 2;
1323
+		} elseif (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1324
+			$message = 3;
1325
+		} elseif ($this->_req_data['action'] === 'post-quickpress-save-cont') {
1326
+			$message = 7;
1327
+		} else {
1328
+			$message = 4;
1329
+		}
1330
+		// change the message if the post type is not viewable on the frontend
1331
+		$this->_cpt_object = get_post_type_object($post->post_type);
1332
+		$message           = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1333
+		$query_args        = array_merge(['message' => $message], $query_args);
1334
+		$this->_process_notices($query_args, true);
1335
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 * This method is called to inject nav tabs on core WP cpt pages
1341
+	 *
1342
+	 * @return void
1343
+	 * @throws EE_Error
1344
+	 * @throws EE_Error
1345
+	 */
1346
+	public function inject_nav_tabs()
1347
+	{
1348
+		// can we hijack and insert the nav_tabs?
1349
+		$nav_tabs = $this->_get_main_nav_tabs();
1350
+		// first close off existing form tag
1351
+		$html = '>';
1352
+		$html .= $nav_tabs;
1353
+		// now let's handle the remaining tag ( missing ">" is CORRECT )
1354
+		$html .= '<span></span';
1355
+		echo $html;  // already escaped
1356
+	}
1357
+
1358
+
1359
+	/**
1360
+	 * This just sets up the post update messages when an update form is loaded
1361
+	 *
1362
+	 * @param array $messages the original messages array
1363
+	 * @return array           the new messages array
1364
+	 */
1365
+	public function post_update_messages($messages)
1366
+	{
1367
+		global $post;
1368
+		$id       = $this->request->getRequestParam('post');
1369
+		$id       = empty($id) && is_object($post) ? $post->ID : null;
1370
+		$revision = $this->request->getRequestParam('revision', 0, 'int');
1371
+
1372
+		$messages[ $post->post_type ] = [
1373
+			0  => '', // Unused. Messages start at index 1.
1374
+			1  => sprintf(
1375
+				esc_html__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1376
+				$this->_cpt_object->labels->singular_name,
1377
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1378
+				'</a>'
1379
+			),
1380
+			2  => esc_html__('Custom field updated', 'event_espresso'),
1381
+			3  => esc_html__('Custom field deleted.', 'event_espresso'),
1382
+			4  => sprintf(esc_html__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1383
+			5  => $revision
1384
+				? sprintf(
1385
+					esc_html__('%s restored to revision from %s', 'event_espresso'),
1386
+					$this->_cpt_object->labels->singular_name,
1387
+					wp_post_revision_title($revision, false)
1388
+				)
1389
+				: false,
1390
+			6  => sprintf(
1391
+				esc_html__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1392
+				$this->_cpt_object->labels->singular_name,
1393
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1394
+				'</a>'
1395
+			),
1396
+			7  => sprintf(esc_html__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1397
+			8  => sprintf(
1398
+				esc_html__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1399
+				$this->_cpt_object->labels->singular_name,
1400
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1401
+				'</a>'
1402
+			),
1403
+			9  => sprintf(
1404
+				esc_html__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1405
+				$this->_cpt_object->labels->singular_name,
1406
+				'<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1407
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1408
+				'</a>'
1409
+			),
1410
+			10 => sprintf(
1411
+				esc_html__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1412
+				$this->_cpt_object->labels->singular_name,
1413
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1414
+				'</a>'
1415
+			),
1416
+		];
1417
+		return $messages;
1418
+	}
1419
+
1420
+
1421
+	/**
1422
+	 * default method for the 'create_new' route for cpt admin pages.
1423
+	 * For reference what to include in here, see wp-admin/post-new.php
1424
+	 *
1425
+	 * @return void
1426
+	 */
1427
+	protected function _create_new_cpt_item()
1428
+	{
1429
+		// gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1430
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1431
+		$post_type        = $this->_cpt_routes[ $this->_req_action ];
1432
+		$post_type_object = $this->_cpt_object;
1433
+		$title            = $post_type_object->labels->add_new_item;
1434
+		$post             = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1435
+		add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1436
+		// modify the default editor title field with default title.
1437
+		add_filter('enter_title_here', [$this, 'add_custom_editor_default_title'], 10);
1438
+		$this->loadEditorTemplate(true);
1439
+	}
1440
+
1441
+
1442
+	/**
1443
+	 * Enqueues auto-save and loads the editor template
1444
+	 *
1445
+	 * @param bool $creating
1446
+	 */
1447
+	private function loadEditorTemplate($creating = true)
1448
+	{
1449
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1450
+		// these vars are used by the template
1451
+		$editing = true;
1452
+		$post_ID = $post->ID;
1453
+		if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1454
+			// only enqueue autosave when creating event (necessary to get permalink/url generated)
1455
+			// otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1456
+			if ($creating) {
1457
+				wp_enqueue_script('autosave');
1458
+			} else {
1459
+				if (
1460
+					isset($this->_cpt_routes[ $this->_req_data['action'] ])
1461
+					&& ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1462
+				) {
1463
+					$create_new_action = apply_filters(
1464
+						'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1465
+						'create_new',
1466
+						$this
1467
+					);
1468
+					$post_new_file     = EE_Admin_Page::add_query_args_and_nonce(
1469
+						[
1470
+							'action' => $create_new_action,
1471
+							'page'   => $this->page_slug,
1472
+						],
1473
+						'admin.php'
1474
+					);
1475
+				}
1476
+			}
1477
+			include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1478
+		}
1479
+	}
1480
+
1481
+
1482
+	public function add_new_admin_page_global()
1483
+	{
1484
+		$admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1485
+		?>
1486 1486
         <script type="text/javascript">
1487 1487
             adminpage = '<?php echo $admin_page; ?>';
1488 1488
         </script>
1489 1489
         <?php
1490
-    }
1491
-
1492
-
1493
-    /**
1494
-     * default method for the 'edit' route for cpt admin pages
1495
-     * For reference on what to put in here, refer to wp-admin/post.php
1496
-     *
1497
-     * @return string   template for edit cpt form
1498
-     */
1499
-    protected function _edit_cpt_item()
1500
-    {
1501
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1502
-        $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1503
-        $post    = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1504
-        if (empty($post)) {
1505
-            wp_die(esc_html__(
1506
-                'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?',
1507
-                'event_espresso'
1508
-            ));
1509
-        }
1510
-
1511
-        $post_lock = $this->request->getRequestParam('get-post-lock');
1512
-        if ($post_lock) {
1513
-            wp_set_post_lock($post_id);
1514
-            wp_redirect(get_edit_post_link($post_id, 'url'));
1515
-            exit();
1516
-        }
1517
-
1518
-        // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1519
-        $post_type        = $this->_cpt_routes[ $this->_req_action ];
1520
-        $post_type_object = $this->_cpt_object;
1521
-
1522
-        if (! wp_check_post_lock($post->ID)) {
1523
-            wp_set_post_lock($post->ID);
1524
-        }
1525
-        add_action('admin_footer', '_admin_notice_post_locked');
1526
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1527
-            wp_enqueue_script('admin-comments');
1528
-            enqueue_comment_hotkeys_js();
1529
-        }
1530
-        add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1531
-        // modify the default editor title field with default title.
1532
-        add_filter('enter_title_here', [$this, 'add_custom_editor_default_title'], 10);
1533
-        $this->loadEditorTemplate(false);
1534
-    }
1535
-
1536
-
1537
-
1538
-    /**
1539
-     * some getters
1540
-     */
1541
-    /**
1542
-     * This returns the protected _cpt_model_obj property
1543
-     *
1544
-     * @return EE_CPT_Base
1545
-     */
1546
-    public function get_cpt_model_obj()
1547
-    {
1548
-        return $this->_cpt_model_obj;
1549
-    }
1490
+	}
1491
+
1492
+
1493
+	/**
1494
+	 * default method for the 'edit' route for cpt admin pages
1495
+	 * For reference on what to put in here, refer to wp-admin/post.php
1496
+	 *
1497
+	 * @return string   template for edit cpt form
1498
+	 */
1499
+	protected function _edit_cpt_item()
1500
+	{
1501
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1502
+		$post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1503
+		$post    = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1504
+		if (empty($post)) {
1505
+			wp_die(esc_html__(
1506
+				'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?',
1507
+				'event_espresso'
1508
+			));
1509
+		}
1510
+
1511
+		$post_lock = $this->request->getRequestParam('get-post-lock');
1512
+		if ($post_lock) {
1513
+			wp_set_post_lock($post_id);
1514
+			wp_redirect(get_edit_post_link($post_id, 'url'));
1515
+			exit();
1516
+		}
1517
+
1518
+		// template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1519
+		$post_type        = $this->_cpt_routes[ $this->_req_action ];
1520
+		$post_type_object = $this->_cpt_object;
1521
+
1522
+		if (! wp_check_post_lock($post->ID)) {
1523
+			wp_set_post_lock($post->ID);
1524
+		}
1525
+		add_action('admin_footer', '_admin_notice_post_locked');
1526
+		if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1527
+			wp_enqueue_script('admin-comments');
1528
+			enqueue_comment_hotkeys_js();
1529
+		}
1530
+		add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1531
+		// modify the default editor title field with default title.
1532
+		add_filter('enter_title_here', [$this, 'add_custom_editor_default_title'], 10);
1533
+		$this->loadEditorTemplate(false);
1534
+	}
1535
+
1536
+
1537
+
1538
+	/**
1539
+	 * some getters
1540
+	 */
1541
+	/**
1542
+	 * This returns the protected _cpt_model_obj property
1543
+	 *
1544
+	 * @return EE_CPT_Base
1545
+	 */
1546
+	public function get_cpt_model_obj()
1547
+	{
1548
+		return $this->_cpt_model_obj;
1549
+	}
1550 1550
 }
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      */
164 164
     protected function getLoader()
165 165
     {
166
-        if (! $this->loader instanceof LoaderInterface) {
166
+        if ( ! $this->loader instanceof LoaderInterface) {
167 167
             $this->loader = LoaderFactory::getLoader();
168 168
         }
169 169
         return $this->loader;
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
             ],
188 188
             $this->_cpt_routes
189 189
         );
190
-        $cpt_route_action  = isset($this->_cpt_routes[ $this->raw_req_action ])
191
-            ? $this->_cpt_routes[ $this->raw_req_action ]
190
+        $cpt_route_action = isset($this->_cpt_routes[$this->raw_req_action])
191
+            ? $this->_cpt_routes[$this->raw_req_action]
192 192
             : null;
193 193
         // let's see if the current route has a value for cpt_object_slug. if it does, we use that instead of the page
194 194
         $page              = $this->raw_req_page ?: $this->page_slug;
195 195
         $page              = $cpt_route_action ?: $page;
196 196
         $this->_cpt_object = get_post_type_object($page);
197 197
         // tweak pagenow for page loading.
198
-        if (! $this->_pagenow_map) {
198
+        if ( ! $this->_pagenow_map) {
199 199
             $this->_pagenow_map = [
200 200
                 'create_new' => 'post-new.php',
201 201
                 'edit'       => 'post.php',
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
         // possibly reset pagenow.
222 222
         if (
223 223
             $this->page_slug === $this->raw_req_page
224
-            && isset($this->_pagenow_map[ $this->raw_req_action ])
224
+            && isset($this->_pagenow_map[$this->raw_req_action])
225 225
         ) {
226 226
             global $pagenow, $hook_suffix;
227
-            $pagenow     = $this->_pagenow_map[ $this->raw_req_action ];
227
+            $pagenow     = $this->_pagenow_map[$this->raw_req_action];
228 228
             $hook_suffix = $pagenow;
229 229
         }
230 230
     }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         if (empty($wp_meta_boxes)) {
257 257
             return;
258 258
         }
259
-        $current_metaboxes = isset($wp_meta_boxes[ $this->page_slug ]) ? $wp_meta_boxes[ $this->page_slug ] : [];
259
+        $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : [];
260 260
         foreach ($current_metaboxes as $box_context) {
261 261
             foreach ($box_context as $box_details) {
262 262
                 foreach ($box_details as $box) {
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
             $this
291 291
         );
292 292
         $containers = apply_filters(
293
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
293
+            'FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers',
294 294
             $containers,
295 295
             $this
296 296
         );
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     protected function _load_page_dependencies()
336 336
     {
337 337
         // we only add stuff if this is a cpt_route!
338
-        if (! $this->_cpt_route) {
338
+        if ( ! $this->_cpt_route) {
339 339
             parent::_load_page_dependencies();
340 340
             return;
341 341
         }
@@ -359,16 +359,16 @@  discard block
 block discarded – undo
359 359
         add_filter('pre_get_shortlink', [$this, 'add_shortlink_button_to_editor'], 10, 4);
360 360
         // This basically allows us to change the title of the "publish" metabox area
361 361
         // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
362
-        if (! empty($this->_labels['publishbox'])) {
362
+        if ( ! empty($this->_labels['publishbox'])) {
363 363
             $box_label = is_array($this->_labels['publishbox'])
364
-                         && isset($this->_labels['publishbox'][ $this->_req_action ])
365
-                ? $this->_labels['publishbox'][ $this->_req_action ]
364
+                         && isset($this->_labels['publishbox'][$this->_req_action])
365
+                ? $this->_labels['publishbox'][$this->_req_action]
366 366
                 : $this->_labels['publishbox'];
367 367
             add_meta_box(
368 368
                 'submitdiv',
369 369
                 $box_label,
370 370
                 'post_submit_meta_box',
371
-                $this->_cpt_routes[ $this->_req_action ],
371
+                $this->_cpt_routes[$this->_req_action],
372 372
                 'side',
373 373
                 'core'
374 374
             );
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
                 'page_templates',
380 380
                 esc_html__('Page Template', 'event_espresso'),
381 381
                 [$this, 'page_template_meta_box'],
382
-                $this->_cpt_routes[ $this->_req_action ],
382
+                $this->_cpt_routes[$this->_req_action],
383 383
                 'side',
384 384
                 'default'
385 385
             );
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
         // This is for any plugins that are doing things properly
412 412
         // and hooking into the load page hook for core wp cpt routes.
413 413
         global $pagenow;
414
-        add_action('load-' . $pagenow, [$this, 'modify_current_screen'], 20);
415
-        do_action('load-' . $pagenow);
414
+        add_action('load-'.$pagenow, [$this, 'modify_current_screen'], 20);
415
+        do_action('load-'.$pagenow);
416 416
         add_action('admin_enqueue_scripts', [$this, 'setup_autosave_hooks'], 30);
417 417
         // we route REALLY early.
418 418
         try {
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
                 'admin.php?page=espresso_registrations&action=contact_list',
442 442
             ],
443 443
             1 => [
444
-                'edit.php?post_type=' . $this->_cpt_object->name,
445
-                'admin.php?page=' . $this->_cpt_object->name,
444
+                'edit.php?post_type='.$this->_cpt_object->name,
445
+                'admin.php?page='.$this->_cpt_object->name,
446 446
             ],
447 447
         ];
448 448
         foreach ($routes_to_match as $route_matches) {
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
             'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
472 472
         );
473 473
         $cpt_args          = $custom_post_types->getDefinitions();
474
-        $cpt_args          = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : [];
474
+        $cpt_args          = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : [];
475 475
         $cpt_has_support   = ! empty($cpt_args['page_templates']);
476 476
 
477 477
         // if the installed version of WP is > 4.7 we do some additional checks.
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
             // if there are $post_templates for this cpt, then we return false for this method because
481 481
             // that means we aren't going to load our page template manager and leave that up to the native
482 482
             // cpt template manager.
483
-            $cpt_has_support = ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
483
+            $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
484 484
         }
485 485
 
486 486
         return $cpt_has_support;
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 
560 560
         $statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
561 561
         $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
562
-            ? $statuses[ $this->_cpt_model_obj->status() ]
562
+            ? $statuses[$this->_cpt_model_obj->status()]
563 563
             : '';
564 564
         $template_args    = [
565 565
             'cur_status'            => $this->_cpt_model_obj->status(),
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             $template_args['statuses']         = $statuses;
575 575
         }
576 576
 
577
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
577
+        $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php';
578 578
         EEH_Template::display_template($template, $template_args);
579 579
     }
580 580
 
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
         $nonce = $this->request->getRequestParam('autosavenonce');
615 615
         $this->_verify_nonce($nonce, 'autosave');
616 616
         // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
617
-        if (! defined('DOING_AUTOSAVE')) {
617
+        if ( ! defined('DOING_AUTOSAVE')) {
618 618
             define('DOING_AUTOSAVE', true);
619 619
         }
620 620
         // if we made it here then the nonce checked out.  Let's run our methods and actions
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
             $this->_template_args['success'] = true;
626 626
         }
627 627
         do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
628
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
628
+        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this);
629 629
         // now let's return json
630 630
         $this->_return_json();
631 631
     }
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
             return;
648 648
         }
649 649
         // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
650
-        if (! empty($this->_cpt_object)) {
650
+        if ( ! empty($this->_cpt_object)) {
651 651
             $this->_page_routes = array_merge(
652 652
                 [
653 653
                     'create_new' => '_create_new_cpt_item',
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
             );
679 679
         }
680 680
         // load the next section only if this is a matching cpt route as set in the cpt routes array.
681
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
681
+        if ( ! isset($this->_cpt_routes[$this->_req_action])) {
682 682
             return;
683 683
         }
684 684
         $this->_cpt_route = true;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             empty($this->_cpt_model_names)
720 720
             || (
721 721
                 ! $ignore_route_check
722
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
722
+                && ! isset($this->_cpt_routes[$this->_req_action])
723 723
             )
724 724
             || (
725 725
                 $this->_cpt_model_obj instanceof EE_CPT_Base
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
                 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
738 738
             );
739 739
             $model_names       = $custom_post_types->getCustomPostTypeModelNames($post_type);
740
-            if (isset($model_names[ $post_type ])) {
741
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
740
+            if (isset($model_names[$post_type])) {
741
+                $model = EE_Registry::instance()->load_model($model_names[$post_type]);
742 742
             }
743 743
         } else {
744
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
744
+            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
745 745
         }
746 746
         if ($model instanceof EEM_Base) {
747 747
             $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
         $current_route  = isset($this->_req_data['current_route'])
771 771
             ? $this->_req_data['current_route']
772 772
             : 'shouldneverwork';
773
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
774
-            ? $this->_cpt_routes[ $current_route ]
773
+        $route_to_check = $post_type && isset($this->_cpt_routes[$current_route])
774
+            ? $this->_cpt_routes[$current_route]
775 775
             : '';
776 776
         add_filter('get_delete_post_link', [$this, 'modify_delete_post_link'], 10, 3);
777 777
         add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 3);
@@ -780,10 +780,10 @@  discard block
 block discarded – undo
780 780
         }
781 781
         // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
782 782
         $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
783
-        if (! empty($revision)) {
783
+        if ( ! empty($revision)) {
784 784
             $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
785 785
             // doing a restore?
786
-            if (! empty($action) && $action === 'restore') {
786
+            if ( ! empty($action) && $action === 'restore') {
787 787
                 // get post for revision
788 788
                 $rev_post   = get_post($revision);
789 789
                 $rev_parent = get_post($rev_post->post_parent);
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
     {
821 821
         $this->_set_model_object($post_id, true, 'trash');
822 822
         // if our cpt object isn't existent then get out immediately.
823
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
823
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
824 824
             return;
825 825
         }
826 826
         $this->trash_cpt_item($post_id);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
     {
840 840
         $this->_set_model_object($post_id, true, 'restore');
841 841
         // if our cpt object isn't existent then get out immediately.
842
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
842
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
843 843
             return;
844 844
         }
845 845
         $this->restore_cpt_item($post_id);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
     {
859 859
         $this->_set_model_object($post_id, true, 'delete');
860 860
         // if our cpt object isn't existent then get out immediately.
861
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
861
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
862 862
             return;
863 863
         }
864 864
         $this->delete_cpt_item($post_id);
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
     {
878 878
         $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
879 879
         // verify event object
880
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
880
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
881 881
             throw new EE_Error(
882 882
                 sprintf(
883 883
                     esc_html__(
@@ -932,13 +932,13 @@  discard block
 block discarded – undo
932 932
         if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
933 933
             // setup custom post status object for localize script but only if we've got a cpt object
934 934
             $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
935
-            if (! empty($statuses)) {
935
+            if ( ! empty($statuses)) {
936 936
                 // get ALL statuses!
937 937
                 $statuses = $this->_cpt_model_obj->get_all_post_statuses();
938 938
                 // setup object
939 939
                 $ee_cpt_statuses = [];
940 940
                 foreach ($statuses as $status => $label) {
941
-                    $ee_cpt_statuses[ $status ] = [
941
+                    $ee_cpt_statuses[$status] = [
942 942
                         'label'      => $label,
943 943
                         'save_label' => sprintf(
944 944
                             wp_strip_all_tags(__('Save as %s', 'event_espresso')),
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
             }
1009 1009
             if (
1010 1010
                 'default' != $this->_req_data['page_template']
1011
-                && ! isset($page_templates[ $this->_req_data['page_template'] ])
1011
+                && ! isset($page_templates[$this->_req_data['page_template']])
1012 1012
             ) {
1013 1013
                 EE_Error::add_error(
1014 1014
                     esc_html__('Invalid Page Template.', 'event_espresso'),
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
     {
1040 1040
         // only do this if we're actually processing one of our CPTs
1041 1041
         // if our cpt object isn't existent then get out immediately.
1042
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1042
+        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
1043 1043
             return;
1044 1044
         }
1045 1045
         delete_post_meta($post_id, '_wp_trash_meta_status');
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
         // global action
1065 1065
         do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1066 1066
         // class specific action so you can limit hooking into a specific page.
1067
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1067
+        do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id);
1068 1068
     }
1069 1069
 
1070 1070
 
@@ -1093,11 +1093,11 @@  discard block
 block discarded – undo
1093 1093
     public function modify_current_screen()
1094 1094
     {
1095 1095
         // ONLY do this if the current page_route IS a cpt route
1096
-        if (! $this->_cpt_route) {
1096
+        if ( ! $this->_cpt_route) {
1097 1097
             return;
1098 1098
         }
1099 1099
         // routing things REALLY early b/c this is a cpt admin page
1100
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1100
+        set_current_screen($this->_cpt_routes[$this->_req_action]);
1101 1101
         $this->_current_screen       = get_current_screen();
1102 1102
         $this->_current_screen->base = 'event-espresso';
1103 1103
         $this->_add_help_tabs(); // we make sure we add any help tabs back in!
@@ -1120,8 +1120,8 @@  discard block
 block discarded – undo
1120 1120
      */
1121 1121
     public function add_custom_editor_default_title($title)
1122 1122
     {
1123
-        return isset($this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ])
1124
-            ? $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1123
+        return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1124
+            ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1125 1125
             : $title;
1126 1126
     }
1127 1127
 
@@ -1137,10 +1137,10 @@  discard block
 block discarded – undo
1137 1137
      */
1138 1138
     public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1139 1139
     {
1140
-        if (! empty($id) && get_option('permalink_structure') !== '') {
1140
+        if ( ! empty($id) && get_option('permalink_structure') !== '') {
1141 1141
             $post = get_post($id);
1142 1142
             if (isset($post->post_type) && $this->page_slug === $post->post_type) {
1143
-                $shortlink = home_url('?p=' . $post->ID);
1143
+                $shortlink = home_url('?p='.$post->ID);
1144 1144
             }
1145 1145
         }
1146 1146
         return $shortlink;
@@ -1175,10 +1175,10 @@  discard block
 block discarded – undo
1175 1175
     {
1176 1176
         // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1177 1177
         echo '
1178
-        <input type="hidden" name="ee_cpt_item_redirect_url" value="' . esc_url_raw($this->_admin_base_url) . '"/>
1178
+        <input type="hidden" name="ee_cpt_item_redirect_url" value="' . esc_url_raw($this->_admin_base_url).'"/>
1179 1179
         <div id="ee-cpt-hidden-inputs">
1180
-            <input type="hidden" id="current_route" name="current_route" value="' . esc_attr($this->_current_view) . '"/>
1181
-            <input type="hidden" id="current_page" name="current_page" value="' . esc_attr($this->page_slug) . '"/>
1180
+            <input type="hidden" id="current_route" name="current_route" value="' . esc_attr($this->_current_view).'"/>
1181
+            <input type="hidden" id="current_page" name="current_page" value="' . esc_attr($this->page_slug).'"/>
1182 1182
         </div>';
1183 1183
     }
1184 1184
 
@@ -1227,14 +1227,14 @@  discard block
 block discarded – undo
1227 1227
         $post = get_post($id);
1228 1228
         if (
1229 1229
             ! isset($this->_req_data['action'])
1230
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1231
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1230
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1231
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1232 1232
         ) {
1233 1233
             return $link;
1234 1234
         }
1235 1235
         $query_args = [
1236
-            'action' => isset($this->_cpt_edit_routes[ $post->post_type ])
1237
-                ? $this->_cpt_edit_routes[ $post->post_type ]
1236
+            'action' => isset($this->_cpt_edit_routes[$post->post_type])
1237
+                ? $this->_cpt_edit_routes[$post->post_type]
1238 1238
                 : 'edit',
1239 1239
             'post'   => $id,
1240 1240
         ];
@@ -1259,16 +1259,16 @@  discard block
 block discarded – undo
1259 1259
 
1260 1260
         if (
1261 1261
             empty($this->_req_data['action'])
1262
-            || ! isset($this->_cpt_routes[ $this->_req_data['action'] ])
1262
+            || ! isset($this->_cpt_routes[$this->_req_data['action']])
1263 1263
             || ! $post instanceof WP_Post
1264
-            || $post->post_type !== $this->_cpt_routes[ $this->_req_data['action'] ]
1264
+            || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1265 1265
         ) {
1266 1266
             return $delete_link;
1267 1267
         }
1268 1268
         $this->_set_model_object($post->ID, true);
1269 1269
 
1270 1270
         // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1271
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1271
+        $action = 'trash_'.str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1272 1272
 
1273 1273
         return EE_Admin_Page::add_query_args_and_nonce(
1274 1274
             [
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
         // we DO have a match so let's setup the url
1299 1299
         // we have to get the post to determine our route
1300 1300
         $post       = get_post($post_id);
1301
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1301
+        $edit_route = $this->_cpt_edit_routes[$post->post_type];
1302 1302
         // shared query_args
1303 1303
         $query_args = ['action' => $edit_route, 'post' => $post_id];
1304 1304
         $admin_url  = $this->_admin_base_url;
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
         $html .= $nav_tabs;
1353 1353
         // now let's handle the remaining tag ( missing ">" is CORRECT )
1354 1354
         $html .= '<span></span';
1355
-        echo $html;  // already escaped
1355
+        echo $html; // already escaped
1356 1356
     }
1357 1357
 
1358 1358
 
@@ -1369,12 +1369,12 @@  discard block
 block discarded – undo
1369 1369
         $id       = empty($id) && is_object($post) ? $post->ID : null;
1370 1370
         $revision = $this->request->getRequestParam('revision', 0, 'int');
1371 1371
 
1372
-        $messages[ $post->post_type ] = [
1372
+        $messages[$post->post_type] = [
1373 1373
             0  => '', // Unused. Messages start at index 1.
1374 1374
             1  => sprintf(
1375 1375
                 esc_html__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1376 1376
                 $this->_cpt_object->labels->singular_name,
1377
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1377
+                '<a href="'.esc_url(get_permalink($id)).'">',
1378 1378
                 '</a>'
1379 1379
             ),
1380 1380
             2  => esc_html__('Custom field updated', 'event_espresso'),
@@ -1390,27 +1390,27 @@  discard block
 block discarded – undo
1390 1390
             6  => sprintf(
1391 1391
                 esc_html__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1392 1392
                 $this->_cpt_object->labels->singular_name,
1393
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1393
+                '<a href="'.esc_url(get_permalink($id)).'">',
1394 1394
                 '</a>'
1395 1395
             ),
1396 1396
             7  => sprintf(esc_html__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1397 1397
             8  => sprintf(
1398 1398
                 esc_html__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1399 1399
                 $this->_cpt_object->labels->singular_name,
1400
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1400
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">',
1401 1401
                 '</a>'
1402 1402
             ),
1403 1403
             9  => sprintf(
1404 1404
                 esc_html__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1405 1405
                 $this->_cpt_object->labels->singular_name,
1406
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1407
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1406
+                '<strong>'.date_i18n('M j, Y @ G:i', strtotime($post->post_date)).'</strong>',
1407
+                '<a target="_blank" href="'.esc_url(get_permalink($id)),
1408 1408
                 '</a>'
1409 1409
             ),
1410 1410
             10 => sprintf(
1411 1411
                 esc_html__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1412 1412
                 $this->_cpt_object->labels->singular_name,
1413
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1413
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1414 1414
                 '</a>'
1415 1415
             ),
1416 1416
         ];
@@ -1428,10 +1428,10 @@  discard block
 block discarded – undo
1428 1428
     {
1429 1429
         // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1430 1430
         global $post, $title, $is_IE, $post_type, $post_type_object;
1431
-        $post_type        = $this->_cpt_routes[ $this->_req_action ];
1431
+        $post_type        = $this->_cpt_routes[$this->_req_action];
1432 1432
         $post_type_object = $this->_cpt_object;
1433 1433
         $title            = $post_type_object->labels->add_new_item;
1434
-        $post             = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1434
+        $post             = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1435 1435
         add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1436 1436
         // modify the default editor title field with default title.
1437 1437
         add_filter('enter_title_here', [$this, 'add_custom_editor_default_title'], 10);
@@ -1457,15 +1457,15 @@  discard block
 block discarded – undo
1457 1457
                 wp_enqueue_script('autosave');
1458 1458
             } else {
1459 1459
                 if (
1460
-                    isset($this->_cpt_routes[ $this->_req_data['action'] ])
1461
-                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $this->_req_data['action'] ])
1460
+                    isset($this->_cpt_routes[$this->_req_data['action']])
1461
+                    && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1462 1462
                 ) {
1463 1463
                     $create_new_action = apply_filters(
1464 1464
                         'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1465 1465
                         'create_new',
1466 1466
                         $this
1467 1467
                     );
1468
-                    $post_new_file     = EE_Admin_Page::add_query_args_and_nonce(
1468
+                    $post_new_file = EE_Admin_Page::add_query_args_and_nonce(
1469 1469
                         [
1470 1470
                             'action' => $create_new_action,
1471 1471
                             'page'   => $this->page_slug,
@@ -1474,7 +1474,7 @@  discard block
 block discarded – undo
1474 1474
                     );
1475 1475
                 }
1476 1476
             }
1477
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1477
+            include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1478 1478
         }
1479 1479
     }
1480 1480
 
@@ -1516,14 +1516,14 @@  discard block
 block discarded – undo
1516 1516
         }
1517 1517
 
1518 1518
         // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1519
-        $post_type        = $this->_cpt_routes[ $this->_req_action ];
1519
+        $post_type        = $this->_cpt_routes[$this->_req_action];
1520 1520
         $post_type_object = $this->_cpt_object;
1521 1521
 
1522
-        if (! wp_check_post_lock($post->ID)) {
1522
+        if ( ! wp_check_post_lock($post->ID)) {
1523 1523
             wp_set_post_lock($post->ID);
1524 1524
         }
1525 1525
         add_action('admin_footer', '_admin_notice_post_locked');
1526
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1526
+        if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1527 1527
             wp_enqueue_script('admin-comments');
1528 1528
             enqueue_comment_hotkeys_js();
1529 1529
         }
Please login to merge, or discard this patch.
core/admin/templates/espresso_ratings_request_content.template.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <div class="padding">
2 2
     <p><?php
3
-        esc_html_e(
4
-            'We need your help to continue maintaining and providing this plugin for free. You can help by leaving a positive review in the WordPress plugin directory. 5 star ratings bring Event Espresso Decaf to the attention of more users which increases our support and features for this version of Event Espresso.',
5
-            'event_espresso'
6
-        ); ?></p>
3
+		esc_html_e(
4
+			'We need your help to continue maintaining and providing this plugin for free. You can help by leaving a positive review in the WordPress plugin directory. 5 star ratings bring Event Espresso Decaf to the attention of more users which increases our support and features for this version of Event Espresso.',
5
+			'event_espresso'
6
+		); ?></p>
7 7
     <p><?php esc_html_e('Rate it five stars today!', 'event_espresso'); ?></p><span
8 8
         class="ee-wp-blue dashicons dashicons-star-filled"></span><span
9 9
         class="ee-wp-blue dashicons dashicons-star-filled"></span><span
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
         class="ee-wp-blue dashicons dashicons-star-filled"></span>
13 13
     <p><a class="button button-primary"
14 14
           href="https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Fview%2Fplugin-reviews%2Fevent-espresso-decaf%3Frate%3D5%23postform"><?php
15
-            esc_html_e(
16
-                'Rate It!',
17
-                'event_espresso'
18
-            ); ?></a></p>
15
+			esc_html_e(
16
+				'Rate It!',
17
+				'event_espresso'
18
+			); ?></a></p>
19 19
 </div>
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/admin_general_metabox_contents_espresso_sponsors.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     <a href="https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=banner"
12 12
        target="_blank"
13 13
     >
14
-        <img src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/manage-events-faster-240x240.jpg'); ?>" />
14
+        <img src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/manage-events-faster-240x240.jpg'); ?>" />
15 15
     </a>
16 16
     <p>Visit
17 17
         <a href="https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign
Please login to merge, or discard this patch.
core/admin/templates/admin_wrapper_ajax.template.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 
14 14
     <div class="ee-notices"><?php echo isset($ajax_notices) ? $ajax_notices  : '';// already escaped ?></div>
15 15
     <?php
16
-    do_action('AHEE__admin_wrapper__template__before_admin_page_content');
17
-    echo $before_admin_page_content; // already escaped
18
-    echo $admin_page_content; // already escaped
19
-    echo $after_admin_page_content; // already escaped
20
-    do_action('AHEE__admin_wrapper__template__after_admin_page_content');
21
-    ?>
16
+	do_action('AHEE__admin_wrapper__template__before_admin_page_content');
17
+	echo $before_admin_page_content; // already escaped
18
+	echo $admin_page_content; // already escaped
19
+	echo $after_admin_page_content; // already escaped
20
+	do_action('AHEE__admin_wrapper__template__after_admin_page_content');
21
+	?>
22 22
 </div>
23 23
 <!-- espresso-admin -->
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 <div class="wrap espresso-admin">
12 12
     <h1><?php esc_attr_e('Event Espresso', 'event_espresso'); ?>&nbsp;-&nbsp;<?php echo $admin_page_title; // already escaped ?></h1>
13 13
 
14
-    <div class="ee-notices"><?php echo isset($ajax_notices) ? $ajax_notices  : '';// already escaped ?></div>
14
+    <div class="ee-notices"><?php echo isset($ajax_notices) ? $ajax_notices : ''; // already escaped ?></div>
15 15
     <?php
16 16
     do_action('AHEE__admin_wrapper__template__before_admin_page_content');
17 17
     echo $before_admin_page_content; // already escaped
Please login to merge, or discard this patch.
core/admin/templates/about_admin_wrapper.template.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
 
25 25
 
26 26
     <?php
27
-    do_action('AHEE__admin_wrapper__template__before_about_admin_page_content');
28
-    echo $about_admin_page_content; // already escaped
29
-    do_action('AHEE__admin_wrapper__template__after_about_admin_page_content');
30
-    ?>
27
+	do_action('AHEE__admin_wrapper__template__before_about_admin_page_content');
28
+	echo $about_admin_page_content; // already escaped
29
+	do_action('AHEE__admin_wrapper__template__after_about_admin_page_content');
30
+	?>
31 31
 
32 32
 </div>
Please login to merge, or discard this patch.
core/admin/templates/admin_details_legend.template.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
     </dl>
22 22
     <dl class="alignleft ee-list-table-legend">
23 23
                 <?php $count = 1;
24
-            endif; ?>
24
+			endif; ?>
25 25
         <dt id="ee-legend-item-<?php echo esc_attr($item); ?>">
26 26
             <?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?>
27 27
             <?php
28
-            if (strpos($details['class'], '<span') !== false) {
29
-                echo $class; // already escaped
30
-            } else { ?>
28
+			if (strpos($details['class'], '<span') !== false) {
29
+				echo $class; // already escaped
30
+			} else { ?>
31 31
             <span class="<?php echo esc_attr($class); ?>">
32 32
                 <?php if (! empty($details['icon'])) : ?>
33 33
                     <img alt="<?php echo esc_attr($details['desc']); ?>"
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
                 <?php endif; ?>
38 38
             </span>
39 39
                 <?php
40
-            } ?>
40
+			} ?>
41 41
             <span class="ee-legend-description"><?php echo esc_html($details['desc']); ?></span>
42 42
         </dt>
43 43
             <?php $count++;
44
-        endforeach; ?>
44
+		endforeach; ?>
45 45
     </dl>
46 46
     <div style="clear:both"></div>
47 47
 </div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
                 echo $class; // already escaped
30 30
             } else { ?>
31 31
             <span class="<?php echo esc_attr($class); ?>">
32
-                <?php if (! empty($details['icon'])) : ?>
32
+                <?php if ( ! empty($details['icon'])) : ?>
33 33
                     <img alt="<?php echo esc_attr($details['desc']); ?>"
34 34
                          class="ee-legend-icon"
35 35
                          src="<?php echo esc_url_raw($details['icon']); ?>"
Please login to merge, or discard this patch.