|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* LSX_Activities_Admin |
|
4
|
|
|
* |
|
5
|
|
|
* @package LSX_Activities_Admin |
|
6
|
|
|
* @author LightSpeed |
|
7
|
|
|
* @license GPL-2.0+ |
|
8
|
|
|
* @link |
|
9
|
|
|
* @copyright 2018 LightSpeedDevelopment |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Main plugin class. |
|
14
|
|
|
* |
|
15
|
|
|
* @package LSX_Activities_Admin |
|
16
|
|
|
* @author LightSpeed |
|
17
|
|
|
*/ |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
class LSX_Activities_Admin extends LSX_Activities { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Constructor |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct() { |
|
|
|
|
|
|
25
|
|
|
$this->set_vars(); |
|
26
|
|
|
|
|
27
|
|
|
add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
28
|
|
|
add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
29
|
|
|
|
|
30
|
|
|
add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
31
|
|
|
add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
32
|
|
|
add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
33
|
|
|
|
|
34
|
|
|
add_filter( 'lsx_to_team_custom_fields', array( $this, 'custom_fields' ) ); |
|
35
|
|
|
add_filter( 'lsx_to_special_custom_fields', array( $this, 'custom_fields' ) ); |
|
36
|
|
|
add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
37
|
|
|
} |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
|
|
|
|
|
40
|
|
|
* Register the activity post type config |
|
41
|
|
|
* |
|
42
|
|
|
* @param $objects |
|
|
|
|
|
|
43
|
|
|
* @return array |
|
44
|
|
|
*/ |
|
45
|
|
|
public function post_type_config( $objects ) { |
|
46
|
|
|
foreach ( $this->post_types as $key => $label ) { |
|
|
|
|
|
|
47
|
|
|
if ( file_exists( LSX_ACTIVITIES_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
|
|
|
|
|
48
|
|
|
$objects[ $key ] = include LSX_ACTIVITIES_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
|
|
|
|
|
51
|
|
|
return $objects; |
|
|
|
|
|
|
52
|
|
|
} |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
/** |
|
|
|
|
|
|
55
|
|
|
* Register the activity metabox config |
|
56
|
|
|
* |
|
57
|
|
|
* @param $meta_boxes |
|
|
|
|
|
|
58
|
|
|
* @return array |
|
59
|
|
|
*/ |
|
60
|
|
|
public function meta_box_config( $meta_boxes ) { |
|
61
|
|
|
foreach ( $this->post_types as $key => $label ) { |
|
|
|
|
|
|
62
|
|
|
if ( file_exists( LSX_ACTIVITIES_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
|
|
|
|
|
63
|
|
|
$meta_boxes[ $key ] = include LSX_ACTIVITIES_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
|
|
|
|
|
66
|
|
|
return $meta_boxes; |
|
|
|
|
|
|
67
|
|
|
} |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
/** |
|
|
|
|
|
|
70
|
|
|
* Adds in the gallery fields to the Tour Operators Post Types. |
|
71
|
|
|
*/ |
|
72
|
|
|
public function custom_fields( $fields ) { |
|
73
|
|
|
global $post, $typenow, $current_screen; |
|
74
|
|
|
|
|
75
|
|
|
$post_type = false; |
|
76
|
|
|
|
|
77
|
|
|
if ( $post && $post->post_type ) { |
|
|
|
|
|
|
78
|
|
|
$post_type = $post->post_type; |
|
79
|
|
|
} elseif ( $typenow ) { |
|
|
|
|
|
|
80
|
|
|
$post_type = $typenow; |
|
81
|
|
|
} elseif ( $current_screen && $current_screen->post_type ) { |
|
|
|
|
|
|
82
|
|
|
$post_type = $current_screen->post_type; |
|
83
|
|
|
} elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
|
|
|
|
|
84
|
|
|
$post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
|
|
|
|
|
85
|
|
|
} elseif ( isset( $_REQUEST['post'] ) ) { |
|
|
|
|
|
|
86
|
|
|
$post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
if ( false !== $post_type ) { |
|
|
|
|
|
|
90
|
|
|
$fields[] = array( |
|
91
|
|
|
'id' => 'activity_title', |
|
|
|
|
|
|
92
|
|
|
'name' => 'Activities', |
|
93
|
|
|
'type' => 'title', |
|
94
|
|
|
'cols' => 12, |
|
95
|
|
|
); |
|
96
|
|
|
$fields[] = array( |
|
97
|
|
|
'id' => 'activity_to_' . $post_type, |
|
|
|
|
|
|
98
|
|
|
'name' => 'Activities related with this ' . $post_type, |
|
|
|
|
|
|
99
|
|
|
'type' => 'post_select', |
|
|
|
|
|
|
100
|
|
|
'use_ajax' => false, |
|
|
|
|
|
|
101
|
|
|
'query' => array( |
|
|
|
|
|
|
102
|
|
|
'post_type' => 'activity', |
|
|
|
|
|
|
103
|
|
|
'nopagin' => true, |
|
|
|
|
|
|
104
|
|
|
'posts_per_page' => '-1', |
|
105
|
|
|
'orderby' => 'title', |
|
|
|
|
|
|
106
|
|
|
'order' => 'ASC', |
|
|
|
|
|
|
107
|
|
|
), |
|
108
|
|
|
'repeatable' => true, |
|
109
|
|
|
'allow_none' => true, |
|
110
|
|
|
'cols' => 12, |
|
|
|
|
|
|
111
|
|
|
); |
|
112
|
|
|
} |
|
|
|
|
|
|
113
|
|
|
return $fields; |
|
114
|
|
|
} |
|
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
new LSX_Activities_Admin(); |
|
117
|
|
|
|