|
@@ -113,7 +113,7 @@ discard block |
|
|
block discarded – undo |
113
|
113
|
* @param object $post The post object of the cpt that was saved. |
114
|
114
|
* @return void |
115
|
115
|
*/ |
116
|
|
- abstract protected function _insert_update_cpt_item( $post_id, $post ); |
|
116
|
+ abstract protected function _insert_update_cpt_item($post_id, $post); |
117
|
117
|
|
118
|
118
|
|
119
|
119
|
|
|
@@ -126,7 +126,7 @@ discard block |
|
|
block discarded – undo |
126
|
126
|
* @param string $post_id The ID of the cpt that was trashed |
127
|
127
|
* @return void |
128
|
128
|
*/ |
129
|
|
- abstract public function trash_cpt_item( $post_id ); |
|
129
|
+ abstract public function trash_cpt_item($post_id); |
130
|
130
|
|
131
|
131
|
|
132
|
132
|
|
|
@@ -137,7 +137,7 @@ discard block |
|
|
block discarded – undo |
137
|
137
|
* @param string $post_id theID of the cpt that was untrashed |
138
|
138
|
* @return void |
139
|
139
|
*/ |
140
|
|
- abstract public function restore_cpt_item( $post_id ); |
|
140
|
+ abstract public function restore_cpt_item($post_id); |
141
|
141
|
|
142
|
142
|
|
143
|
143
|
|
|
@@ -148,7 +148,7 @@ discard block |
|
|
block discarded – undo |
148
|
148
|
* @param string $post_id the ID of the cpt that was deleted |
149
|
149
|
* @return void |
150
|
150
|
*/ |
151
|
|
- abstract public function delete_cpt_item( $post_id ); |
|
151
|
+ abstract public function delete_cpt_item($post_id); |
152
|
152
|
|
153
|
153
|
|
154
|
154
|
|
|
@@ -161,32 +161,32 @@ discard block |
|
|
block discarded – undo |
161
|
161
|
*/ |
162
|
162
|
protected function _before_page_setup() { |
163
|
163
|
|
164
|
|
- $page = isset( $this->_req_data['page'] ) ? $this->_req_data['page'] : $this->page_slug; |
|
164
|
+ $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug; |
165
|
165
|
|
166
|
|
- $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes ); |
|
166
|
+ $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes); |
167
|
167
|
|
168
|
168
|
//let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page |
169
|
|
- $this->_cpt_object = isset($this->_req_data['action']) && isset( $this->_cpt_routes[$this->_req_data['action']] ) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object( $page ); |
|
169
|
+ $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']]) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object($page); |
170
|
170
|
|
171
|
171
|
//tweak pagenow for page loading. |
172
|
|
- if( ! $this->_pagenow_map ) { |
|
172
|
+ if ( ! $this->_pagenow_map) { |
173
|
173
|
$this->_pagenow_map = array( |
174
|
174
|
'create_new' => 'post-new.php', |
175
|
175
|
'edit' => 'post.php', |
176
|
176
|
'trash' => 'post.php' |
177
|
177
|
); |
178
|
178
|
} |
179
|
|
- add_action( 'current_screen', array( $this, 'modify_pagenow') ); |
|
179
|
+ add_action('current_screen', array($this, 'modify_pagenow')); |
180
|
180
|
|
181
|
181
|
|
182
|
182
|
//TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param. |
183
|
183
|
//get current page from autosave |
184
|
|
- $current_page = isset( $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] ) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
185
|
|
- $this->_current_page = isset( $this->_req_data['current_page'] ) ? $this->_req_data['current_page'] : $current_page; |
|
184
|
+ $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185
|
+ $this->_current_page = isset($this->_req_data['current_page']) ? $this->_req_data['current_page'] : $current_page; |
186
|
186
|
|
187
|
187
|
|
188
|
188
|
//autosave... make sure its only for the correct page |
189
|
|
- if ( !empty($this->_current_page ) && $this->_current_page == $this->page_slug ) { |
|
189
|
+ if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) { |
190
|
190
|
//setup autosave ajax hook |
191
|
191
|
//add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented |
192
|
192
|
} |
|
@@ -202,10 +202,10 @@ discard block |
|
|
block discarded – undo |
202
|
202
|
* |
203
|
203
|
* @return void |
204
|
204
|
*/ |
205
|
|
- public function modify_pagenow( $current_screen ) { |
|
205
|
+ public function modify_pagenow($current_screen) { |
206
|
206
|
global $pagenow; |
207
|
207
|
//possibly reset pagenow. |
208
|
|
- if ( ! empty( $this->_req_data['page'] ) && $this->_req_data['page'] == $this->page_slug && !empty( $this->_req_data['action'] ) && isset( $this->_pagenow_map[$this->_req_data['action'] ] ) ) { |
|
208
|
+ if ( ! empty($this->_req_data['page']) && $this->_req_data['page'] == $this->page_slug && ! empty($this->_req_data['action']) && isset($this->_pagenow_map[$this->_req_data['action']])) { |
209
|
209
|
$pagenow = $this->_pagenow_map[$this->_req_data['action']]; |
210
|
210
|
} |
211
|
211
|
} |
|
@@ -220,8 +220,8 @@ discard block |
|
|
block discarded – undo |
220
|
220
|
* @param array $ids an array of ids for containers that hold form inputs we want autosave to pickup. Typically you would send along the id of a metabox container. |
221
|
221
|
* @return void |
222
|
222
|
*/ |
223
|
|
- protected function _register_autosave_containers( $ids ) { |
224
|
|
- $this->_autosave_containers = array_merge( $this->_autosave_fields, (array) $ids ); |
|
223
|
+ protected function _register_autosave_containers($ids) { |
|
224
|
+ $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids); |
225
|
225
|
} |
226
|
226
|
|
227
|
227
|
|
|
@@ -236,22 +236,22 @@ discard block |
|
|
block discarded – undo |
236
|
236
|
|
237
|
237
|
$containers = array(); |
238
|
238
|
|
239
|
|
- if ( empty( $wp_meta_boxes ) ) |
|
239
|
+ if (empty($wp_meta_boxes)) |
240
|
240
|
return; |
241
|
241
|
|
242
|
|
- $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
242
|
+ $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array(); |
243
|
243
|
|
244
|
|
- foreach ( $current_metaboxes as $box_context ) { |
245
|
|
- foreach ( $box_context as $box_details ) { |
246
|
|
- foreach ( $box_details as $box ) { |
247
|
|
- if ( is_array( $box['callback'] ) && ( $box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks ) ){ |
|
244
|
+ foreach ($current_metaboxes as $box_context) { |
|
245
|
+ foreach ($box_context as $box_details) { |
|
246
|
+ foreach ($box_details as $box) { |
|
247
|
+ if (is_array($box['callback']) && ($box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks)) { |
248
|
248
|
$containers[] = $box['id']; |
249
|
249
|
} |
250
|
250
|
} |
251
|
251
|
} |
252
|
252
|
} |
253
|
253
|
|
254
|
|
- $this->_autosave_containers = array_merge( $this->_autosave_containers, $containers ); |
|
254
|
+ $this->_autosave_containers = array_merge($this->_autosave_containers, $containers); |
255
|
255
|
|
256
|
256
|
//add hidden inputs container |
257
|
257
|
$this->_autosave_containers[] = 'ee-cpt-hidden-inputs'; |
|
@@ -268,13 +268,13 @@ discard block |
|
|
block discarded – undo |
268
|
268
|
wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2 |
269
|
269
|
|
270
|
270
|
//filter _autosave_containers |
271
|
|
- $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this ); |
272
|
|
- $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', $containers, $this ); |
|
271
|
+ $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this); |
|
272
|
+ $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers', $containers, $this); |
273
|
273
|
|
274
|
|
- wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers ); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
274
|
+ wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
275
|
275
|
|
276
|
276
|
$unsaved_data_msg = array( |
277
|
|
- 'eventmsg' => sprintf( __("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
277
|
+ 'eventmsg' => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
278
|
278
|
'inputChanged' => 0 |
279
|
279
|
); |
280
|
280
|
|
|
@@ -286,7 +286,7 @@ discard block |
|
|
block discarded – undo |
286
|
286
|
public function load_page_dependencies() { |
287
|
287
|
try { |
288
|
288
|
$this->_load_page_dependencies(); |
289
|
|
- } catch ( EE_Error $e ) { |
|
289
|
+ } catch (EE_Error $e) { |
290
|
290
|
$e->get_error(); |
291
|
291
|
} |
292
|
292
|
} |
|
@@ -302,7 +302,7 @@ discard block |
|
|
block discarded – undo |
302
|
302
|
protected function _load_page_dependencies() { |
303
|
303
|
|
304
|
304
|
//we only add stuff if this is a cpt_route! |
305
|
|
- if ( !$this->_cpt_route ) { |
|
305
|
+ if ( ! $this->_cpt_route) { |
306
|
306
|
parent::_load_page_dependencies(); |
307
|
307
|
return; |
308
|
308
|
} |
|
@@ -312,72 +312,72 @@ discard block |
|
|
block discarded – undo |
312
|
312
|
|
313
|
313
|
//the following filters are for setting all the redirects on DEFAULT WP custom post type actions |
314
|
314
|
//let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects! Otherwise the redirects will happen on ALL post saves which wouldn't be good of course! |
315
|
|
- add_action('edit_form_after_title', array( $this, 'cpt_post_form_hidden_input') ); |
|
315
|
+ add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input')); |
316
|
316
|
|
317
|
317
|
//inject our Admin page nav tabs... |
318
|
318
|
//let's make sure the nav tabs are set if they aren't already |
319
|
319
|
//if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs(); |
320
|
|
- add_action('post_edit_form_tag', array( $this, 'inject_nav_tabs' ) ); |
|
320
|
+ add_action('post_edit_form_tag', array($this, 'inject_nav_tabs')); |
321
|
321
|
|
322
|
322
|
//modify the post_updated messages array |
323
|
|
- add_action('post_updated_messages', array( $this, 'post_update_messages' ), 10 ); |
|
323
|
+ add_action('post_updated_messages', array($this, 'post_update_messages'), 10); |
324
|
324
|
|
325
|
325
|
//add shortlink button to cpt edit screens. We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts! |
326
|
|
- add_filter( 'pre_get_shortlink', array( $this, 'add_shortlink_button_to_editor' ), 10, 4 ); |
|
326
|
+ add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4); |
327
|
327
|
|
328
|
328
|
//This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class. |
329
|
|
- if ( !empty($this->_labels['publishbox'] ) ) { |
|
329
|
+ if ( ! empty($this->_labels['publishbox'])) { |
330
|
330
|
|
331
|
|
- $box_label = is_array( $this->_labels['publishbox'] ) && isset( $this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
331
|
+ $box_label = is_array($this->_labels['publishbox']) && isset($this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
332
|
332
|
|
333
|
|
- remove_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
334
|
|
- add_meta_box( 'submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
333
|
+ remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
334
|
+ add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
335
|
335
|
} |
336
|
336
|
|
337
|
337
|
//let's add page_templates metabox if this cpt added support for it. |
338
|
|
- if ( $this->_supports_page_templates($this->_cpt_object->name) ) { |
339
|
|
- add_meta_box( 'page_templates', __('Page Template', 'event_espresso' ), array( $this, 'page_template_meta_box' ), $this->_cpt_routes[$this->_req_action], 'side', 'default' ); |
|
338
|
+ if ($this->_supports_page_templates($this->_cpt_object->name)) { |
|
339
|
+ add_meta_box('page_templates', __('Page Template', 'event_espresso'), array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default'); |
340
|
340
|
}/**/ |
341
|
341
|
|
342
|
342
|
|
343
|
343
|
//this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
344
|
|
- if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
345
|
|
- add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
344
|
+ if (method_exists($this, 'extra_permalink_field_buttons')) |
|
345
|
+ add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4); |
346
|
346
|
|
347
|
347
|
//add preview button |
348
|
|
- add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
|
348
|
+ add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4); |
349
|
349
|
|
350
|
350
|
|
351
|
351
|
//insert our own post_stati dropdown |
352
|
|
- add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
|
352
|
+ add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10); |
353
|
353
|
|
354
|
354
|
//This allows adding additional information to the publish post submitbox on the wp post edit form |
355
|
|
- if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
356
|
|
- add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
355
|
+ if (method_exists($this, 'extra_misc_actions_publish_box')) |
|
356
|
+ add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10); |
357
|
357
|
|
358
|
358
|
//This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
359
|
|
- if ( method_exists( $this, 'edit_form_after_title' ) ) |
360
|
|
- add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
359
|
+ if (method_exists($this, 'edit_form_after_title')) |
|
360
|
+ add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10); |
361
|
361
|
|
362
|
362
|
|
363
|
363
|
/** |
364
|
364
|
* Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route. |
365
|
365
|
*/ |
366
|
|
- add_filter( 'clean_url', array( $this, 'switch_core_wp_urls_with_ours' ), 10, 3 ); |
|
366
|
+ add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3); |
367
|
367
|
|
368
|
368
|
|
369
|
369
|
parent::_load_page_dependencies(); |
370
|
370
|
|
371
|
371
|
//notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
372
|
372
|
global $pagenow; |
373
|
|
- do_action( 'load-' . $pagenow ); |
|
373
|
+ do_action('load-'.$pagenow); |
374
|
374
|
|
375
|
375
|
$this->modify_current_screen(); |
376
|
|
- add_action( 'admin_enqueue_scripts', array( $this, 'setup_autosave_hooks'), 30 ); |
|
376
|
+ add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
377
|
377
|
//we route REALLY early. |
378
|
378
|
try { |
379
|
379
|
$this->_route_admin_request(); |
380
|
|
- } catch ( EE_Error $e ) { |
|
380
|
+ } catch (EE_Error $e) { |
381
|
381
|
$e->get_error(); |
382
|
382
|
} |
383
|
383
|
} |
|
@@ -396,21 +396,21 @@ discard block |
|
|
block discarded – undo |
396
|
396
|
* |
397
|
397
|
* @return string possibly a new url for our route. |
398
|
398
|
*/ |
399
|
|
- public function switch_core_wp_urls_with_ours( $good_protocol_url, $original_url, $_context ) { |
|
399
|
+ public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context) { |
400
|
400
|
$routes_to_match = array( |
401
|
401
|
0 => array( |
402
|
402
|
'edit.php?post_type=espresso_attendees', |
403
|
403
|
'admin.php?page=espresso_registrations&action=contact_list' |
404
|
404
|
), |
405
|
405
|
1 => array( |
406
|
|
- 'edit.php?post_type=' . $this->_cpt_object->name, |
407
|
|
- 'admin.php?page=' . $this->_cpt_object->name |
|
406
|
+ 'edit.php?post_type='.$this->_cpt_object->name, |
|
407
|
+ 'admin.php?page='.$this->_cpt_object->name |
408
|
408
|
) |
409
|
409
|
); |
410
|
410
|
|
411
|
|
- foreach( $routes_to_match as $route_matches ) { |
412
|
|
- if ( strpos( $good_protocol_url, $route_matches[0] ) !== false ) { |
413
|
|
- return str_replace( $route_matches[0], $route_matches[1], $good_protocol_url ); |
|
411
|
+ foreach ($routes_to_match as $route_matches) { |
|
412
|
+ if (strpos($good_protocol_url, $route_matches[0]) !== false) { |
|
413
|
+ return str_replace($route_matches[0], $route_matches[1], $good_protocol_url); |
414
|
414
|
|
415
|
415
|
} |
416
|
416
|
} |
|
@@ -426,10 +426,10 @@ discard block |
|
|
block discarded – undo |
426
|
426
|
* @param string $cpt_name The cpt slug we're checking on. |
427
|
427
|
* @return bool True supported, false not. |
428
|
428
|
*/ |
429
|
|
- private function _supports_page_templates( $cpt_name ) { |
|
429
|
+ private function _supports_page_templates($cpt_name) { |
430
|
430
|
$cpt_args = EE_Register_CPTs::get_CPTs(); |
431
|
|
- $cpt_args = isset( $cpt_args[$cpt_name] ) ? $cpt_args[$cpt_name]['args'] : array(); |
432
|
|
- return ! empty( $cpt_args['page_templates'] ) ? TRUE : FALSE; |
|
431
|
+ $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432
|
+ return ! empty($cpt_args['page_templates']) ? TRUE : FALSE; |
433
|
433
|
} |
434
|
434
|
|
435
|
435
|
|
|
@@ -444,9 +444,9 @@ discard block |
|
|
block discarded – undo |
444
|
444
|
public function page_template_meta_box() { |
445
|
445
|
global $post; |
446
|
446
|
$template = ''; |
447
|
|
- if ( count( get_page_templates( $post ) ) != 0 ) { |
448
|
|
- $page_template = get_post_meta( $post->ID, '_wp_page_template', TRUE ); |
449
|
|
- $template = !empty( $page_template ) ? $page_template : ''; |
|
447
|
+ if (count(get_page_templates($post)) != 0) { |
|
448
|
+ $page_template = get_post_meta($post->ID, '_wp_page_template', TRUE); |
|
449
|
+ $template = ! empty($page_template) ? $page_template : ''; |
450
|
450
|
} |
451
|
451
|
?> |
452
|
452
|
<p><strong><?php _e('Template') ?></strong></p> |
|
@@ -470,10 +470,10 @@ discard block |
|
|
block discarded – undo |
470
|
470
|
* @param string $new_slug what the slug is |
471
|
471
|
* @return string The new html string for the permalink area |
472
|
472
|
*/ |
473
|
|
- public function preview_button_html( $return, $id, $new_title, $new_slug ) { |
474
|
|
- $post = get_post( $id ); |
475
|
|
- if ( 'publish' != get_post_status( $post ) ) { |
476
|
|
- $return .= '<span_id="view-post-btn"><a href="' . wp_get_shortlink($id, 'post') . '" class="button button-small">' . __('Preview', 'event_espresso') . '</a></span>' . "\n"; |
|
473
|
+ public function preview_button_html($return, $id, $new_title, $new_slug) { |
|
474
|
+ $post = get_post($id); |
|
475
|
+ if ('publish' != get_post_status($post)) { |
|
476
|
+ $return .= '<span_id="view-post-btn"><a href="'.wp_get_shortlink($id, 'post').'" class="button button-small">'.__('Preview', 'event_espresso').'</a></span>'."\n"; |
477
|
477
|
} |
478
|
478
|
return $return; |
479
|
479
|
} |
|
@@ -493,18 +493,18 @@ discard block |
|
|
block discarded – undo |
493
|
493
|
'cur_status' => $this->_cpt_model_obj->status(), |
494
|
494
|
'statuses' => $statuses, |
495
|
495
|
'cur_status_label' => $cur_status_label, |
496
|
|
- 'localized_status_save' => sprintf( __('Save %s', 'event_espresso'), $cur_status_label ) |
|
496
|
+ 'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label) |
497
|
497
|
); |
498
|
498
|
|
499
|
499
|
//we'll add a trash post status (WP doesn't add one for some reason) |
500
|
|
- if ( $this->_cpt_model_obj->status() == 'trash' ) { |
|
500
|
+ if ($this->_cpt_model_obj->status() == 'trash') { |
501
|
501
|
$template_args['cur_status_label'] = __('Trashed', 'event_espresso'); |
502
|
502
|
$statuses['trash'] = __('Trashed', 'event_espresso'); |
503
|
503
|
$template_args['statuses'] = $statuses; |
504
|
504
|
} |
505
|
505
|
|
506
|
|
- $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
507
|
|
- EEH_Template::display_template( $template, $template_args ); |
|
506
|
+ $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php'; |
|
507
|
+ EEH_Template::display_template($template, $template_args); |
508
|
508
|
} |
509
|
509
|
|
510
|
510
|
|
|
@@ -543,22 +543,22 @@ discard block |
|
|
block discarded – undo |
543
|
543
|
public function do_extra_autosave_stuff() { |
544
|
544
|
|
545
|
545
|
//next let's check for the autosave nonce (we'll use _verify_nonce ) |
546
|
|
- $nonce = isset( $this->_req_data['autosavenonce'] ) ? $this->_req_data['autosavenonce'] : NULL; |
547
|
|
- $this->_verify_nonce( $nonce, 'autosave' ); |
|
546
|
+ $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : NULL; |
|
547
|
+ $this->_verify_nonce($nonce, 'autosave'); |
548
|
548
|
|
549
|
549
|
|
550
|
550
|
//make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
551
|
|
- if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
551
|
+ if ( ! defined('DOING_AUTOSAVE')) define('DOING_AUTOSAVE', true); |
552
|
552
|
|
553
|
553
|
//if we made it here then the nonce checked out. Let's run our methods and actions |
554
|
|
- if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
555
|
|
- call_user_func( array( $this, '_ee_autosave_' . $this->_current_view ) ); |
|
554
|
+ if (method_exists($this, '_ee_autosave_'.$this->_current_view)) { |
|
555
|
+ call_user_func(array($this, '_ee_autosave_'.$this->_current_view)); |
556
|
556
|
} else { |
557
|
557
|
$this->_template_args['success'] = TRUE; |
558
|
558
|
} |
559
|
559
|
|
560
|
|
- do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this ); |
561
|
|
- do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class( $this ), $this ); |
|
560
|
+ do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
|
561
|
+ do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this); |
562
|
562
|
|
563
|
563
|
//now let's return json |
564
|
564
|
$this->_return_json(); |
|
@@ -578,18 +578,18 @@ discard block |
|
|
block discarded – undo |
578
|
578
|
protected function _extend_page_config_for_cpt() { |
579
|
579
|
|
580
|
580
|
//before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
581
|
|
- if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
581
|
+ if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) |
582
|
582
|
return; |
583
|
583
|
|
584
|
584
|
//set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
585
|
|
- if ( !empty( $this->_cpt_object ) ) { |
586
|
|
- $this->_page_routes = array_merge( array( |
|
585
|
+ if ( ! empty($this->_cpt_object)) { |
|
586
|
+ $this->_page_routes = array_merge(array( |
587
|
587
|
'create_new' => '_create_new_cpt_item', |
588
|
588
|
'edit' => '_edit_cpt_item' |
589
|
|
- ), $this->_page_routes ); |
|
589
|
+ ), $this->_page_routes); |
590
|
590
|
|
591
|
591
|
|
592
|
|
- $this->_page_config = array_merge( array( |
|
592
|
+ $this->_page_config = array_merge(array( |
593
|
593
|
'create_new' => array( |
594
|
594
|
'nav' => array( |
595
|
595
|
'label' => $this->_cpt_object->labels->add_new_item, |
|
@@ -611,23 +611,23 @@ discard block |
|
|
block discarded – undo |
611
|
611
|
} |
612
|
612
|
|
613
|
613
|
//load the next section only if this is a matching cpt route as set in the cpt routes array. |
614
|
|
- if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
614
|
+ if ( ! isset($this->_cpt_routes[$this->_req_action])) |
615
|
615
|
return; |
616
|
616
|
|
617
|
617
|
|
618
|
|
- $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
|
618
|
+ $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? TRUE : FALSE; |
619
|
619
|
//add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') ); |
620
|
620
|
|
621
|
621
|
|
622
|
|
- if ( empty( $this->_cpt_object ) ) { |
623
|
|
- $msg = sprintf( __('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).'), $this->page_slug, $this->_req_action, get_class($this) ); |
624
|
|
- throw new EE_Error( $msg ); |
|
622
|
+ if (empty($this->_cpt_object)) { |
|
623
|
+ $msg = sprintf(__('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).'), $this->page_slug, $this->_req_action, get_class($this)); |
|
624
|
+ throw new EE_Error($msg); |
625
|
625
|
} |
626
|
626
|
|
627
|
627
|
|
628
|
|
- if ( $this->_cpt_route ) { |
629
|
|
- $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
630
|
|
- $this->_set_model_object( $id ); |
|
628
|
+ if ($this->_cpt_route) { |
|
629
|
+ $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
630
|
+ $this->_set_model_object($id); |
631
|
631
|
} |
632
|
632
|
|
633
|
633
|
} |
|
@@ -643,12 +643,12 @@ discard block |
|
|
block discarded – undo |
643
|
643
|
* @param int $id The id to retrieve the model object for. If empty we set a default object. |
644
|
644
|
* @return void |
645
|
645
|
*/ |
646
|
|
- protected function _set_model_object( $id = NULL, $ignore_route_check = false ) { |
|
646
|
+ protected function _set_model_object($id = NULL, $ignore_route_check = false) { |
647
|
647
|
$model = null; |
648
|
|
- if ( empty( $this->_cpt_model_names ) |
|
648
|
+ if (empty($this->_cpt_model_names) |
649
|
649
|
|| ( |
650
|
650
|
! $ignore_route_check |
651
|
|
- && ! isset( $this->_cpt_routes[ $this->_req_action ] ) |
|
651
|
+ && ! isset($this->_cpt_routes[$this->_req_action]) |
652
|
652
|
) |
653
|
653
|
|| ( |
654
|
654
|
$this->_cpt_model_obj instanceof EE_CPT_Base |
|
@@ -659,21 +659,21 @@ discard block |
|
|
block discarded – undo |
659
|
659
|
} |
660
|
660
|
|
661
|
661
|
//if ignore_route_check is true, then get the model name via EE_Register_CPTs |
662
|
|
- if ( $ignore_route_check ) { |
|
662
|
+ if ($ignore_route_check) { |
663
|
663
|
$model_names = EE_Register_CPTs::get_cpt_model_names(); |
664
|
|
- $post_type = get_post_type( $id ); |
665
|
|
- if ( isset( $model_names[ $post_type ] ) ) { |
666
|
|
- $model = EE_Registry::instance()->load_model( $model_names[ $post_type ] ); |
|
664
|
+ $post_type = get_post_type($id); |
|
665
|
+ if (isset($model_names[$post_type])) { |
|
666
|
+ $model = EE_Registry::instance()->load_model($model_names[$post_type]); |
667
|
667
|
} |
668
|
668
|
} else { |
669
|
|
- $model = EE_Registry::instance()->load_model( $this->_cpt_model_names[$this->_req_action] ); |
|
669
|
+ $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]); |
670
|
670
|
} |
671
|
671
|
|
672
|
|
- if ( $model instanceof EEM_Base ) { |
673
|
|
- $this->_cpt_model_obj = ! empty( $id ) ? $model->get_one_by_ID( $id ) : $model->create_default_object(); |
|
672
|
+ if ($model instanceof EEM_Base) { |
|
673
|
+ $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object(); |
674
|
674
|
} |
675
|
675
|
|
676
|
|
- do_action( 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object' ); |
|
676
|
+ do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object'); |
677
|
677
|
} |
678
|
678
|
|
679
|
679
|
|
|
@@ -687,47 +687,47 @@ discard block |
|
|
block discarded – undo |
687
|
687
|
*/ |
688
|
688
|
public function admin_init_global() { |
689
|
689
|
|
690
|
|
- $post = isset( $this->_req_data['post'] ) ? get_post( $this->_req_data['post'] ) : NULL; |
|
690
|
+ $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : NULL; |
691
|
691
|
|
692
|
692
|
//its possible this is a new save so let's catch that instead |
693
|
|
- $post = isset( $this->_req_data['post_ID'] ) ? get_post( $this->_req_data['post_ID'] ) : $post; |
|
693
|
+ $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post; |
694
|
694
|
$post_type = $post ? $post->post_type : false; |
695
|
695
|
|
696
|
696
|
$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork'; |
697
|
697
|
|
698
|
|
- $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
698
|
+ $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
699
|
699
|
|
700
|
|
- add_filter( 'get_delete_post_link', array( $this, 'modify_delete_post_link'), 10, 3 ); |
701
|
|
- add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link'), 10, 3 ); |
|
700
|
+ add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3); |
|
701
|
+ add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
702
|
702
|
|
703
|
703
|
|
704
|
|
- if ( $post_type === $route_to_check ) { |
705
|
|
- add_filter('redirect_post_location', array( $this, 'cpt_post_location_redirect'), 10, 2 ); |
|
704
|
+ if ($post_type === $route_to_check) { |
|
705
|
+ add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2); |
706
|
706
|
//catch trashed wp redirect |
707
|
|
- add_filter('wp_redirect', array( $this, 'cpt_trash_post_location_redirect' ), 10, 2 ); |
|
707
|
+ add_filter('wp_redirect', array($this, 'cpt_trash_post_location_redirect'), 10, 2); |
708
|
708
|
} |
709
|
709
|
|
710
|
710
|
//now let's filter redirect if we're on a revision page and the revision is for an event CPT. |
711
|
|
- $revision = isset( $this->_req_data['revision'] ) ? $this->_req_data['revision'] : NULL; |
|
711
|
+ $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
712
|
712
|
|
713
|
713
|
/**var_dump($this->_req_data); |
714
|
714
|
exit();/**/ |
715
|
715
|
|
716
|
|
- if ( !empty( $revision ) ) { |
717
|
|
- $action = isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : NULL; |
|
716
|
+ if ( ! empty($revision)) { |
|
717
|
+ $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : NULL; |
718
|
718
|
|
719
|
719
|
//doing a restore? |
720
|
|
- if ( !empty( $action ) && $action == 'restore' ) { |
|
720
|
+ if ( ! empty($action) && $action == 'restore') { |
721
|
721
|
|
722
|
722
|
//get post for revision |
723
|
|
- $rev_post = get_post( $revision ); |
724
|
|
- $rev_parent = get_post( $rev_post->post_parent ); |
|
723
|
+ $rev_post = get_post($revision); |
|
724
|
+ $rev_parent = get_post($rev_post->post_parent); |
725
|
725
|
|
726
|
726
|
//only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts. |
727
|
|
- if ( $rev_parent && $rev_parent->post_type == $this->page_slug ) { |
728
|
|
- add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2 ); |
|
727
|
+ if ($rev_parent && $rev_parent->post_type == $this->page_slug) { |
|
728
|
+ add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2); |
729
|
729
|
//restores of revisions |
730
|
|
- add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2 ); |
|
730
|
+ add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2); |
731
|
731
|
} |
732
|
732
|
} |
733
|
733
|
|
|
@@ -736,15 +736,15 @@ discard block |
|
|
block discarded – undo |
736
|
736
|
//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! |
737
|
737
|
|
738
|
738
|
|
739
|
|
- if ( $post_type && $post_type === $route_to_check ) { |
|
739
|
+ if ($post_type && $post_type === $route_to_check) { |
740
|
740
|
//$post_id, $post |
741
|
|
- add_action('save_post', array( $this, 'insert_update'), 10, 3 ); |
|
741
|
+ add_action('save_post', array($this, 'insert_update'), 10, 3); |
742
|
742
|
|
743
|
743
|
//$post_id |
744
|
|
- add_action('trashed_post', array( $this, 'before_trash_cpt_item' ), 10 ); |
745
|
|
- add_action('trashed_post', array( $this, 'dont_permanently_delete_ee_cpts'), 10 ); |
746
|
|
- add_action('untrashed_post', array( $this, 'before_restore_cpt_item'), 10 ); |
747
|
|
- add_action('after_delete_post', array( $this, 'before_delete_cpt_item'), 10 ); |
|
744
|
+ add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10); |
|
745
|
+ add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10); |
|
746
|
+ add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10); |
|
747
|
+ add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10); |
748
|
748
|
} |
749
|
749
|
|
750
|
750
|
} |
|
@@ -758,13 +758,13 @@ discard block |
|
|
block discarded – undo |
758
|
758
|
* |
759
|
759
|
* @param int $post_id |
760
|
760
|
*/ |
761
|
|
- public function before_trash_cpt_item( $post_id ) { |
762
|
|
- $this->_set_model_object( $post_id, true ); |
|
761
|
+ public function before_trash_cpt_item($post_id) { |
|
762
|
+ $this->_set_model_object($post_id, true); |
763
|
763
|
//if our cpt object isn't existent then get out immediately. |
764
|
|
- if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
764
|
+ if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
765
|
765
|
return; |
766
|
766
|
} |
767
|
|
- $this->trash_cpt_item( $post_id ); |
|
767
|
+ $this->trash_cpt_item($post_id); |
768
|
768
|
} |
769
|
769
|
|
770
|
770
|
|
|
@@ -774,13 +774,13 @@ discard block |
|
|
block discarded – undo |
774
|
774
|
* |
775
|
775
|
* @param $post_id |
776
|
776
|
*/ |
777
|
|
- public function before_restore_cpt_item( $post_id ) { |
778
|
|
- $this->_set_model_object( $post_id, true ); |
|
777
|
+ public function before_restore_cpt_item($post_id) { |
|
778
|
+ $this->_set_model_object($post_id, true); |
779
|
779
|
//if our cpt object isn't existent then get out immediately. |
780
|
|
- if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
780
|
+ if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
781
|
781
|
return; |
782
|
782
|
} |
783
|
|
- $this->restore_cpt_item( $post_id ); |
|
783
|
+ $this->restore_cpt_item($post_id); |
784
|
784
|
} |
785
|
785
|
|
786
|
786
|
|
|
@@ -789,13 +789,13 @@ discard block |
|
|
block discarded – undo |
789
|
789
|
* Execute some basic checks before calling the delete_cpt_item method in the child class. |
790
|
790
|
* @param $post_id |
791
|
791
|
*/ |
792
|
|
- public function before_delete_cpt_item( $post_id ) { |
793
|
|
- $this->_set_model_object( $post_id, true ); |
|
792
|
+ public function before_delete_cpt_item($post_id) { |
|
793
|
+ $this->_set_model_object($post_id, true); |
794
|
794
|
//if our cpt object isn't existent then get out immediately. |
795
|
|
- if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
795
|
+ if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
796
|
796
|
return; |
797
|
797
|
} |
798
|
|
- $this->delete_cpt_item( $post_id ); |
|
798
|
+ $this->delete_cpt_item($post_id); |
799
|
799
|
} |
800
|
800
|
|
801
|
801
|
|
|
@@ -807,15 +807,15 @@ discard block |
|
|
block discarded – undo |
807
|
807
|
* @return void |
808
|
808
|
*/ |
809
|
809
|
public function verify_cpt_object() { |
810
|
|
- $label = !empty( $this->_cpt_object ) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
810
|
+ $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
811
|
811
|
// verify event object |
812
|
|
- if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
813
|
|
- throw new EE_Error( sprintf( __('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', 'event_espresso' ), $label ) ); |
|
812
|
+ if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
813
|
+ throw new EE_Error(sprintf(__('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', 'event_espresso'), $label)); |
814
|
814
|
} |
815
|
815
|
//if auto-draft then throw an error |
816
|
|
- if ( $this->_cpt_model_obj->get('status') == 'auto-draft' ) { |
|
816
|
+ if ($this->_cpt_model_obj->get('status') == 'auto-draft') { |
817
|
817
|
EE_Error::overwrite_errors(); |
818
|
|
- EE_Error::add_error( sprintf( __('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.'), $label ), __FILE__, __FUNCTION__, __LINE__ ); |
|
818
|
+ EE_Error::add_error(sprintf(__('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.'), $label), __FILE__, __FUNCTION__, __LINE__); |
819
|
819
|
} |
820
|
820
|
} |
821
|
821
|
|
|
@@ -844,22 +844,22 @@ discard block |
|
|
block discarded – undo |
844
|
844
|
public function load_global_scripts_styles() { |
845
|
845
|
parent::load_global_scripts_styles(); |
846
|
846
|
|
847
|
|
- if ( $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
847
|
+ if ($this->_cpt_model_obj instanceof EE_CPT_Base) { |
848
|
848
|
//setup custom post status object for localize script but only if we've got a cpt object |
849
|
849
|
$statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
850
|
850
|
|
851
|
|
- if ( !empty($statuses) ) { |
|
851
|
+ if ( ! empty($statuses)) { |
852
|
852
|
//get ALL statuses! |
853
|
853
|
$statuses = $this->_cpt_model_obj->get_all_post_statuses(); |
854
|
854
|
//setup object |
855
|
855
|
$ee_cpt_statuses = array(); |
856
|
|
- foreach ( $statuses as $status => $label ) { |
|
856
|
+ foreach ($statuses as $status => $label) { |
857
|
857
|
$ee_cpt_statuses[$status] = array( |
858
|
858
|
'label' => $label, |
859
|
|
- 'save_label' => sprintf( __('Save as %s', 'event_espresso'), $label ) |
|
859
|
+ 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label) |
860
|
860
|
); |
861
|
861
|
} |
862
|
|
- wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses ); |
|
862
|
+ wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses); |
863
|
863
|
} |
864
|
864
|
} |
865
|
865
|
} |
|
@@ -874,11 +874,11 @@ discard block |
|
|
block discarded – undo |
874
|
874
|
* @param bool $update Whether this is an update or a new save. |
875
|
875
|
* @return void |
876
|
876
|
*/ |
877
|
|
- public function insert_update( $post_id, $post, $update ) { |
|
877
|
+ public function insert_update($post_id, $post, $update) { |
878
|
878
|
|
879
|
879
|
//make sure that if this is a revision OR trash action that we don't do any updates! |
880
|
880
|
if ( |
881
|
|
- isset( $this->_req_data['action'] ) |
|
881
|
+ isset($this->_req_data['action']) |
882
|
882
|
&& ( |
883
|
883
|
$this->_req_data['action'] == 'restore' |
884
|
884
|
|| $this->_req_data['action'] == 'trash' |
|
@@ -887,10 +887,10 @@ discard block |
|
|
block discarded – undo |
887
|
887
|
return; |
888
|
888
|
} |
889
|
889
|
|
890
|
|
- $this->_set_model_object( $post_id, true ); |
|
890
|
+ $this->_set_model_object($post_id, true); |
891
|
891
|
|
892
|
892
|
//if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit. |
893
|
|
- if ( $update |
|
893
|
+ if ($update |
894
|
894
|
&& ( |
895
|
895
|
! $this->_cpt_model_obj instanceof EE_CPT_Base |
896
|
896
|
|| $this->_cpt_model_obj->ID() !== $post_id |
|
@@ -911,19 +911,19 @@ discard block |
|
|
block discarded – undo |
911
|
911
|
}/**/ //TODO reactivate after autosave is implemented in 4.2 |
912
|
912
|
|
913
|
913
|
//take care of updating any selected page_template IF this cpt supports it. |
914
|
|
- if ( $this->_supports_page_templates($post->post_type ) && !empty( $this->_req_data['page_template'] ) ) { |
|
914
|
+ if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) { |
915
|
915
|
$post->page_template = $this->_req_data['page_template']; |
916
|
|
- $page_templates = wp_get_theme()->get_page_templates( $post ); |
917
|
|
- if ( 'default' != $this->_req_data['page_template'] && ! isset( $page_templates[ $this->_req_data['page_template'] ] ) ) { |
918
|
|
- EE_Error::add_error( __('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
916
|
+ $page_templates = wp_get_theme()->get_page_templates($post); |
|
917
|
+ if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) { |
|
918
|
+ EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
919
|
919
|
} else { |
920
|
|
- update_post_meta( $post_id, '_wp_page_template', $this->_req_data['page_template'] ); |
|
920
|
+ update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']); |
921
|
921
|
} |
922
|
922
|
} |
923
|
923
|
|
924
|
|
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
924
|
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
925
|
925
|
return; //TODO we'll remove this after reimplementing autosave in 4.2 |
926
|
|
- $this->_insert_update_cpt_item( $post_id, $post ); |
|
926
|
+ $this->_insert_update_cpt_item($post_id, $post); |
927
|
927
|
} |
928
|
928
|
|
929
|
929
|
|
|
@@ -936,15 +936,15 @@ discard block |
|
|
block discarded – undo |
936
|
936
|
* @param int $post_id ID of the post |
937
|
937
|
* @return void |
938
|
938
|
*/ |
939
|
|
- public function dont_permanently_delete_ee_cpts( $post_id ) { |
|
939
|
+ public function dont_permanently_delete_ee_cpts($post_id) { |
940
|
940
|
//only do this if we're actually processing one of our CPTs |
941
|
941
|
//if our cpt object isn't existent then get out immediately. |
942
|
|
- if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
942
|
+ if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
943
|
943
|
return; |
944
|
944
|
} |
945
|
945
|
|
946
|
|
- delete_post_meta( $post_id, '_wp_trash_meta_status' ); |
947
|
|
- delete_post_meta( $post_id, '_wp_trash_meta_time'); |
|
946
|
+ delete_post_meta($post_id, '_wp_trash_meta_status'); |
|
947
|
+ delete_post_meta($post_id, '_wp_trash_meta_time'); |
948
|
948
|
|
949
|
949
|
//our cpts may have comments so let's take care of that too |
950
|
950
|
delete_post_meta($post_id, '_wp_trash_meta_comments_status'); |
|
@@ -962,14 +962,14 @@ discard block |
|
|
block discarded – undo |
962
|
962
|
* @param int $revision_id ID of revision being restored |
963
|
963
|
* @return void |
964
|
964
|
*/ |
965
|
|
- public function restore_revision( $post_id, $revision_id ) { |
966
|
|
- $this->_restore_cpt_item( $post_id, $revision_id ); |
|
965
|
+ public function restore_revision($post_id, $revision_id) { |
|
966
|
+ $this->_restore_cpt_item($post_id, $revision_id); |
967
|
967
|
|
968
|
968
|
//global action |
969
|
|
- do_action( 'AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
969
|
+ do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
970
|
970
|
|
971
|
971
|
//class specific action so you can limit hooking into a specific page. |
972
|
|
- do_action( 'AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id ); |
|
972
|
+ do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id); |
973
|
973
|
} |
974
|
974
|
|
975
|
975
|
|
|
@@ -980,7 +980,7 @@ discard block |
|
|
block discarded – undo |
980
|
980
|
* @param int $revision_id ID of revision for item |
981
|
981
|
* @return void |
982
|
982
|
*/ |
983
|
|
- abstract protected function _restore_cpt_item( $post_id, $revision_id ); |
|
983
|
+ abstract protected function _restore_cpt_item($post_id, $revision_id); |
984
|
984
|
|
985
|
985
|
|
986
|
986
|
|
|
@@ -999,9 +999,9 @@ discard block |
|
|
block discarded – undo |
999
|
999
|
*/ |
1000
|
1000
|
public function modify_current_screen() { |
1001
|
1001
|
//ONLY do this if the current page_route IS a cpt route |
1002
|
|
- if ( !$this->_cpt_route ) return; |
|
1002
|
+ if ( ! $this->_cpt_route) return; |
1003
|
1003
|
//routing things REALLY early b/c this is a cpt admin page |
1004
|
|
- set_current_screen( $this->_cpt_routes[$this->_req_action]); |
|
1004
|
+ set_current_screen($this->_cpt_routes[$this->_req_action]); |
1005
|
1005
|
$this->_current_screen = get_current_screen(); |
1006
|
1006
|
$this->_current_screen->base = 'event-espresso'; |
1007
|
1007
|
$this->_add_help_tabs(); //we make sure we add any help tabs back in! |
|
@@ -1022,8 +1022,8 @@ discard block |
|
|
block discarded – undo |
1022
|
1022
|
* @param string $title The new title (or existing if there is no editor_title defined) |
1023
|
1023
|
* @return string |
1024
|
1024
|
*/ |
1025
|
|
- public function add_custom_editor_default_title( $title ) { |
1026
|
|
- return isset( $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] ) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
1025
|
+ public function add_custom_editor_default_title($title) { |
|
1026
|
+ return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
1027
|
1027
|
} |
1028
|
1028
|
|
1029
|
1029
|
|
|
@@ -1036,11 +1036,11 @@ discard block |
|
|
block discarded – undo |
1036
|
1036
|
* @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
1037
|
1037
|
* @return string |
1038
|
1038
|
*/ |
1039
|
|
- public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
1040
|
|
- if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
1041
|
|
- $post = get_post( $id ); |
1042
|
|
- if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
1043
|
|
- $shortlink = home_url('?p=' . $post->ID); |
|
1039
|
+ public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs) { |
|
1040
|
+ if ( ! empty($id) && '' != get_option('permalink_structure')) { |
|
1041
|
+ $post = get_post($id); |
|
1042
|
+ if (isset($post->post_type) && $this->page_slug == $post->post_type) |
|
1043
|
+ $shortlink = home_url('?p='.$post->ID); |
1044
|
1044
|
} |
1045
|
1045
|
return $shortlink; |
1046
|
1046
|
} |
|
@@ -1053,10 +1053,10 @@ discard block |
|
|
block discarded – undo |
1053
|
1053
|
* @return void |
1054
|
1054
|
*/ |
1055
|
1055
|
public function route_admin_request() { |
1056
|
|
- if ( $this->_cpt_route ) return; |
|
1056
|
+ if ($this->_cpt_route) return; |
1057
|
1057
|
try { |
1058
|
1058
|
$this->_route_admin_request(); |
1059
|
|
- } catch ( EE_Error $e ) { |
|
1059
|
+ } catch (EE_Error $e) { |
1060
|
1060
|
$e->get_error(); |
1061
|
1061
|
} |
1062
|
1062
|
} |
|
@@ -1069,12 +1069,12 @@ discard block |
|
|
block discarded – undo |
1069
|
1069
|
* @return string html |
1070
|
1070
|
*/ |
1071
|
1071
|
public function cpt_post_form_hidden_input() { |
1072
|
|
- echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
1072
|
+ echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />'; |
1073
|
1073
|
|
1074
|
1074
|
//we're also going to add the route value and the current page so we can direct autosave parsing correctly |
1075
|
1075
|
echo '<div id="ee-cpt-hidden-inputs">'; |
1076
|
|
- echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
1077
|
|
- echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
1076
|
+ echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />'; |
|
1077
|
+ echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />'; |
1078
|
1078
|
echo '</div>'; |
1079
|
1079
|
} |
1080
|
1080
|
|
|
@@ -1087,12 +1087,12 @@ discard block |
|
|
block discarded – undo |
1087
|
1087
|
* @param int $status Status for http header |
1088
|
1088
|
* @return string new (or original) url to redirect to. |
1089
|
1089
|
*/ |
1090
|
|
- public function revision_redirect( $location, $status ) { |
|
1090
|
+ public function revision_redirect($location, $status) { |
1091
|
1091
|
//get revision |
1092
|
1092
|
$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
1093
|
1093
|
|
1094
|
1094
|
//can't do anything without revision so let's get out if not present |
1095
|
|
- if ( empty( $rev_id ) ) |
|
1095
|
+ if (empty($rev_id)) |
1096
|
1096
|
return $location; |
1097
|
1097
|
|
1098
|
1098
|
//get rev_post_data |
|
@@ -1106,8 +1106,8 @@ discard block |
|
|
block discarded – undo |
1106
|
1106
|
'message' => 5 |
1107
|
1107
|
); |
1108
|
1108
|
|
1109
|
|
- $this->_process_notices( $query_args, TRUE ); |
1110
|
|
- return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1109
|
+ $this->_process_notices($query_args, TRUE); |
|
1110
|
+ return self::add_query_args_and_nonce($query_args, $admin_url); |
1111
|
1111
|
} |
1112
|
1112
|
|
1113
|
1113
|
|
|
@@ -1120,16 +1120,16 @@ discard block |
|
|
block discarded – undo |
1120
|
1120
|
* @param string $context optional, defaults to display. How to write the '&' |
1121
|
1121
|
* @return string the link |
1122
|
1122
|
*/ |
1123
|
|
- public function modify_edit_post_link( $link, $id, $context ) { |
1124
|
|
- $post = get_post( $id ); |
1125
|
|
- if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1123
|
+ public function modify_edit_post_link($link, $id, $context) { |
|
1124
|
+ $post = get_post($id); |
|
1125
|
+ if ( ! isset($this->_req_data['action']) || ! isset($this->_cpt_routes[$this->_req_data['action']]) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
1126
|
1126
|
return $link; |
1127
|
1127
|
$query_args = array( |
1128
|
1128
|
'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1129
|
1129
|
'post' => $id |
1130
|
1130
|
); |
1131
|
1131
|
|
1132
|
|
- return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1132
|
+ return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
1133
|
1133
|
} |
1134
|
1134
|
|
1135
|
1135
|
|
|
@@ -1141,12 +1141,12 @@ discard block |
|
|
block discarded – undo |
1141
|
1141
|
* @param bool $force_delete whether this is forcing a hard delete instead of trash |
1142
|
1142
|
* @return string new delete link |
1143
|
1143
|
*/ |
1144
|
|
- public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
|
1144
|
+ public function modify_delete_post_link($delete_link, $post_id, $force_delete) { |
1145
|
1145
|
$post = get_post($post_id); |
1146
|
|
- if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1146
|
+ if ( ! isset($this->_req_data['action']) || (isset($this->_cpt_routes[$this->_req_data['action']]) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']])) |
1147
|
1147
|
return $delete_link; |
1148
|
1148
|
|
1149
|
|
- return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
|
1149
|
+ return add_query_arg(array('current_route' => 'trash'), $delete_link); |
1150
|
1150
|
} |
1151
|
1151
|
|
1152
|
1152
|
|
|
@@ -1157,16 +1157,16 @@ discard block |
|
|
block discarded – undo |
1157
|
1157
|
* @param string $status status |
1158
|
1158
|
* @return string url to redirect to |
1159
|
1159
|
*/ |
1160
|
|
- public function cpt_trash_post_location_redirect( $location, $status ) { |
1161
|
|
- if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1160
|
+ public function cpt_trash_post_location_redirect($location, $status) { |
|
1161
|
+ if (isset($this->_req_data['action']) && $this->_req_data['action'] !== 'trash' && empty($this->_req_data['post'])) |
1162
|
1162
|
return $location; |
1163
|
1163
|
|
1164
|
|
- $post = get_post( $this->_req_data['post'] ); |
1165
|
|
- $query_args = array( 'action' => 'default' ); |
|
1164
|
+ $post = get_post($this->_req_data['post']); |
|
1165
|
+ $query_args = array('action' => 'default'); |
1166
|
1166
|
$this->_cpt_object = get_post_type_object($post->post_type); |
1167
|
|
- EE_Error::add_success( sprintf( __('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name) ); |
1168
|
|
- $this->_process_notices( $query_args, TRUE ); |
1169
|
|
- return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1167
|
+ EE_Error::add_success(sprintf(__('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name)); |
|
1168
|
+ $this->_process_notices($query_args, TRUE); |
|
1169
|
+ return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
1170
|
1170
|
} |
1171
|
1171
|
|
1172
|
1172
|
|
|
@@ -1181,7 +1181,7 @@ discard block |
|
|
block discarded – undo |
1181
|
1181
|
* @param string $post_id This is the 'ID' value of the wp_posts table |
1182
|
1182
|
* @return string the new location to redirect to |
1183
|
1183
|
*/ |
1184
|
|
- public function cpt_post_location_redirect( $location, $post_id ) { |
|
1184
|
+ public function cpt_post_location_redirect($location, $post_id) { |
1185
|
1185
|
//we DO have a match so let's setup the url |
1186
|
1186
|
|
1187
|
1187
|
//we have to get the post to determine our route |
|
@@ -1189,14 +1189,14 @@ discard block |
|
|
block discarded – undo |
1189
|
1189
|
$edit_route = $this->_cpt_edit_routes[$post->post_type]; |
1190
|
1190
|
|
1191
|
1191
|
//shared query_args |
1192
|
|
- $query_args = array( 'action' => $edit_route, 'post' => $post_id ); |
|
1192
|
+ $query_args = array('action' => $edit_route, 'post' => $post_id); |
1193
|
1193
|
$admin_url = $this->_admin_base_url; |
1194
|
1194
|
// $append = ''; |
1195
|
1195
|
|
1196
|
|
- if ( isset( $this->_req_data['save'] ) || isset( $this->_req_data['publish'] ) ) { |
1197
|
|
- $status = get_post_status( $post_id ); |
1198
|
|
- if ( isset( $this->_req_data['publish'] ) ) { |
1199
|
|
- switch ( $status ) { |
|
1196
|
+ if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) { |
|
1197
|
+ $status = get_post_status($post_id); |
|
1198
|
+ if (isset($this->_req_data['publish'])) { |
|
1199
|
+ switch ($status) { |
1200
|
1200
|
case 'pending': |
1201
|
1201
|
$message = 8; |
1202
|
1202
|
break; |
|
@@ -1209,13 +1209,13 @@ discard block |
|
|
block discarded – undo |
1209
|
1209
|
} else { |
1210
|
1210
|
$message = 'draft' == $status ? 10 : 1; |
1211
|
1211
|
} |
1212
|
|
- } else if ( isset( $this->_req_data['addmeta']) && $this->_req_data['addmeta'] ) { |
|
1212
|
+ } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) { |
1213
|
1213
|
$message = 2; |
1214
|
1214
|
// $append = '#postcustom'; |
1215
|
|
- } else if ( isset( $this->_req_data['deletemeta']) && $this->_req_data['deletemeta'] ) { |
|
1215
|
+ } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) { |
1216
|
1216
|
$message = 3; |
1217
|
1217
|
// $append = '#postcustom'; |
1218
|
|
- } elseif ( $this->_req_data['action'] == 'post-quickpress-save-cont' ) { |
|
1218
|
+ } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') { |
1219
|
1219
|
$message = 7; |
1220
|
1220
|
} else { |
1221
|
1221
|
$message = 4; |
|
@@ -1223,12 +1223,12 @@ discard block |
|
|
block discarded – undo |
1223
|
1223
|
|
1224
|
1224
|
//change the message if the post type is not viewable on the frontend |
1225
|
1225
|
$this->_cpt_object = get_post_type_object($post->post_type); |
1226
|
|
- $message = $message === 1 && !$this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1226
|
+ $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message; |
1227
|
1227
|
|
1228
|
|
- $query_args = array_merge( array( 'message' => $message ), $query_args ); |
|
1228
|
+ $query_args = array_merge(array('message' => $message), $query_args); |
1229
|
1229
|
|
1230
|
|
- $this->_process_notices( $query_args, TRUE ); |
1231
|
|
- return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1230
|
+ $this->_process_notices($query_args, TRUE); |
|
1231
|
+ return self::add_query_args_and_nonce($query_args, $admin_url); |
1232
|
1232
|
} |
1233
|
1233
|
|
1234
|
1234
|
|
|
@@ -1260,10 +1260,10 @@ discard block |
|
|
block discarded – undo |
1260
|
1260
|
* @param array $messages the original messages array |
1261
|
1261
|
* @return array the new messages array |
1262
|
1262
|
*/ |
1263
|
|
- public function post_update_messages( $messages ) { |
|
1263
|
+ public function post_update_messages($messages) { |
1264
|
1264
|
global $post; |
1265
|
|
- $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
1266
|
|
- $id = empty( $id ) && is_object( $post ) ? $post->ID : NULL; |
|
1265
|
+ $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1266
|
+ $id = empty($id) && is_object($post) ? $post->ID : NULL; |
1267
|
1267
|
|
1268
|
1268
|
// $post_type = $post ? $post->post_type : false; |
1269
|
1269
|
|
|
@@ -1276,9 +1276,9 @@ discard block |
|
|
block discarded – undo |
1276
|
1276
|
0 => '', //Unused. Messages start at index 1. |
1277
|
1277
|
|
1278
|
1278
|
1 => sprintf( |
1279
|
|
- __( '%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1279
|
+ __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
1280
|
1280
|
$this->_cpt_object->labels->singular_name, |
1281
|
|
- '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1281
|
+ '<a href="'.esc_url(get_permalink($id)).'">', |
1282
|
1282
|
'</a>' |
1283
|
1283
|
), |
1284
|
1284
|
|
|
@@ -1286,38 +1286,38 @@ discard block |
|
|
block discarded – undo |
1286
|
1286
|
|
1287
|
1287
|
3 => __('Custom field deleted.'), |
1288
|
1288
|
|
1289
|
|
- 4 => sprintf( __( '%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1289
|
+ 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
1290
|
1290
|
|
1291
|
|
- 5 => isset( $_GET['revision'] ) ? sprintf( __('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title( (int) $_GET['revision'], FALSE ) ) : FALSE, |
|
1291
|
+ 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], FALSE)) : FALSE, |
1292
|
1292
|
|
1293
|
1293
|
6 => sprintf( |
1294
|
|
- __( '%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1294
|
+ __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
1295
|
1295
|
$this->_cpt_object->labels->singular_name, |
1296
|
|
- '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1296
|
+ '<a href="'.esc_url(get_permalink($id)).'">', |
1297
|
1297
|
'</a>' |
1298
|
1298
|
), |
1299
|
1299
|
|
1300
|
|
- 7 => sprintf( __( '%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1300
|
+ 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
1301
|
1301
|
|
1302
|
1302
|
8 => sprintf( |
1303
|
1303
|
__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
1304
|
1304
|
$this->_cpt_object->labels->singular_name, |
1305
|
|
- '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) . '">', |
|
1305
|
+ '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">', |
1306
|
1306
|
'</a>' |
1307
|
1307
|
), |
1308
|
1308
|
|
1309
|
1309
|
9 => sprintf( |
1310
|
|
- __( '%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1310
|
+ __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
1311
|
1311
|
$this->_cpt_object->labels->singular_name, |
1312
|
|
- '<strong>' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date )) . '</strong>', |
1313
|
|
- '<a target="_blank" href="' . esc_url( get_permalink( $id )), |
|
1312
|
+ '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>', |
|
1313
|
+ '<a target="_blank" href="'.esc_url(get_permalink($id)), |
1314
|
1314
|
'</a>' |
1315
|
1315
|
), |
1316
|
1316
|
|
1317
|
1317
|
10 => sprintf( |
1318
|
1318
|
__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
1319
|
1319
|
$this->_cpt_object->labels->singular_name, |
1320
|
|
- '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) , |
|
1320
|
+ '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
1321
|
1321
|
'</a>' |
1322
|
1322
|
) |
1323
|
1323
|
); |
|
@@ -1344,24 +1344,24 @@ discard block |
|
|
block discarded – undo |
1344
|
1344
|
$post_type_object = $this->_cpt_object; |
1345
|
1345
|
$title = $post_type_object->labels->add_new_item; |
1346
|
1346
|
$editing = TRUE; |
1347
|
|
- wp_enqueue_script( 'autosave' ); |
1348
|
|
- $post = $post = get_default_post_to_edit( $this->_cpt_routes[$this->_req_action], TRUE ); |
|
1347
|
+ wp_enqueue_script('autosave'); |
|
1348
|
+ $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], TRUE); |
1349
|
1349
|
$post_ID = $post->ID; |
1350
|
1350
|
$is_IE = $is_IE; |
1351
|
1351
|
|
1352
|
|
- add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1352
|
+ add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
1353
|
1353
|
|
1354
|
1354
|
//modify the default editor title field with default title. |
1355
|
|
- add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1355
|
+ add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
1356
|
1356
|
|
1357
|
|
- include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1357
|
+ include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
1358
|
1358
|
} |
1359
|
1359
|
|
1360
|
1360
|
|
1361
|
1361
|
|
1362
|
1362
|
|
1363
|
1363
|
public function add_new_admin_page_global() { |
1364
|
|
- $admin_page = !empty( $this->_req_data['post'] ) ? 'post-php' : 'post-new-php'; |
|
1364
|
+ $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php'; |
1365
|
1365
|
?> |
1366
|
1366
|
<script type="text/javascript"> |
1367
|
1367
|
adminpage = '<?php echo $admin_page; ?>'; |
|
@@ -1383,16 +1383,16 @@ discard block |
|
|
block discarded – undo |
1383
|
1383
|
*/ |
1384
|
1384
|
protected function _edit_cpt_item() { |
1385
|
1385
|
global $post, $title, $is_IE, $post_type, $post_type_object; |
1386
|
|
- $post_id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
1387
|
|
- $post = !empty( $post_id ) ? get_post( $post_id, OBJECT, 'edit' ) : NULL; |
|
1386
|
+ $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1387
|
+ $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : NULL; |
1388
|
1388
|
|
1389
|
|
- if ( empty ( $post ) ) { |
1390
|
|
- wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') ); |
|
1389
|
+ if (empty ($post)) { |
|
1390
|
+ wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
1391
|
1391
|
} |
1392
|
1392
|
|
1393
|
|
- if ( ! empty( $_GET['get-post-lock'] ) ) { |
1394
|
|
- wp_set_post_lock( $post_id ); |
1395
|
|
- wp_redirect( get_edit_post_link( $post_id, 'url' ) ); |
|
1393
|
+ if ( ! empty($_GET['get-post-lock'])) { |
|
1394
|
+ wp_set_post_lock($post_id); |
|
1395
|
+ wp_redirect(get_edit_post_link($post_id, 'url')); |
1396
|
1396
|
exit(); |
1397
|
1397
|
} |
1398
|
1398
|
|
|
@@ -1404,32 +1404,32 @@ discard block |
|
|
block discarded – undo |
1404
|
1404
|
$post_type_object = $this->_cpt_object; |
1405
|
1405
|
$is_IE = $is_IE; |
1406
|
1406
|
|
1407
|
|
- if ( ! wp_check_post_lock( $post->ID ) ) { |
1408
|
|
- $active_post_lock = wp_set_post_lock( $post->ID ); |
|
1407
|
+ if ( ! wp_check_post_lock($post->ID)) { |
|
1408
|
+ $active_post_lock = wp_set_post_lock($post->ID); |
1409
|
1409
|
//wp_enqueue_script('autosave'); |
1410
|
1410
|
} |
1411
|
1411
|
|
1412
|
1412
|
$title = $this->_cpt_object->labels->edit_item; |
1413
|
1413
|
|
1414
|
|
- add_action('admin_footer', '_admin_notice_post_locked' ); |
|
1414
|
+ add_action('admin_footer', '_admin_notice_post_locked'); |
1415
|
1415
|
|
1416
|
|
- if ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && !isset( $this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']] ) ) { |
1417
|
|
- $create_new_action = apply_filters( 'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this ); |
|
1416
|
+ if (isset($this->_cpt_routes[$this->_req_data['action']]) && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])) { |
|
1417
|
+ $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this); |
1418
|
1418
|
|
1419
|
|
- $post_new_file = EE_Admin_Page::add_query_args_and_nonce( array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php' ); |
|
1419
|
+ $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php'); |
1420
|
1420
|
} |
1421
|
1421
|
|
1422
|
|
- if ( post_type_supports($this->_cpt_routes[$this->_req_action], 'comments') ) { |
|
1422
|
+ if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) { |
1423
|
1423
|
wp_enqueue_script('admin-comments'); |
1424
|
1424
|
enqueue_comment_hotkeys_js(); |
1425
|
1425
|
} |
1426
|
1426
|
|
1427
|
|
- add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1427
|
+ add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
1428
|
1428
|
|
1429
|
1429
|
//modify the default editor title field with default title. |
1430
|
|
- add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1430
|
+ add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
1431
|
1431
|
|
1432
|
|
- include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1432
|
+ include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
1433
|
1433
|
|
1434
|
1434
|
} |
1435
|
1435
|
|