1
|
|
|
<?php |
|
|
|
|
2
|
|
|
namespace lsx_health_plan\classes; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Contains the LSX_Team functions post type |
6
|
|
|
* |
7
|
|
|
* @package lsx-health-plan |
8
|
|
|
*/ |
9
|
|
|
class LSX_Team { |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Holds class instance |
13
|
|
|
* |
14
|
|
|
* @var object \lsx_health_plan\classes\LSX_Team() |
15
|
|
|
*/ |
16
|
|
|
protected static $instance = null; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Constructor. |
20
|
|
|
*/ |
21
|
|
|
public function __construct() { |
|
|
|
|
22
|
|
|
$this->default_types = array( |
|
|
|
|
23
|
|
|
\lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ), |
24
|
|
|
\lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
25
|
|
|
\lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ), |
26
|
|
|
\lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
27
|
|
|
\lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ), |
28
|
|
|
); |
29
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
30
|
|
|
add_action( 'cmb2_admin_init', array( $this, 'related_team_metabox' ) ); |
31
|
|
|
add_action( 'cmb2_admin_init', array( $this, 'additional_single_team_metabox' ) ); |
32
|
|
|
add_action( 'lsx_entry_bottom', array( $this, 'hp_team_member_tabs' ) ); |
33
|
|
|
add_action( 'wp_head', array( $this, 'remove_archive_original_team_header' ), 99 ); |
34
|
|
|
} |
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Return an instance of this class. |
38
|
|
|
* |
39
|
|
|
* @since 1.0.0 |
40
|
|
|
* |
41
|
|
|
* @return object \lsx_health_plan\classes\LSX_Team() A single instance of this class. |
42
|
|
|
*/ |
43
|
|
|
public static function get_instance() { |
44
|
|
|
// If the single instance hasn't been set, set it now. |
45
|
|
|
if ( null === self::$instance ) { |
|
|
|
|
46
|
|
|
self::$instance = new self(); |
47
|
|
|
} |
|
|
|
|
48
|
|
|
return self::$instance; |
49
|
|
|
} |
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Load lsx team related css. |
53
|
|
|
* |
54
|
|
|
* @package lsx |
55
|
|
|
* @subpackage lsx-health-plan |
56
|
|
|
* |
57
|
|
|
*/ |
|
|
|
|
58
|
|
|
public function assets() { |
59
|
|
|
wp_enqueue_style( 'lsx-health-plan-team', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan-team.css', array(), LSX_HEALTH_PLAN_VER ); |
60
|
|
|
} |
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Define the related team member metabox and field configurations. |
64
|
|
|
*/ |
65
|
|
|
public function related_team_metabox() { |
66
|
|
|
foreach ( $this->default_types as $type => $default_type ) { |
|
|
|
|
67
|
|
|
$cmb = new_cmb2_box( |
68
|
|
|
array( |
69
|
|
|
'id' => $default_type . '_related_team_member__metabox', |
|
|
|
|
70
|
|
|
'title' => __( 'Related Team Member', 'lsx-health-plan' ), |
71
|
|
|
'object_types' => array( $default_type ), // Post type. |
72
|
|
|
'context' => 'normal', |
73
|
|
|
'priority' => 'low', |
74
|
|
|
'show_names' => true, |
75
|
|
|
) |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
$cmb->add_field( |
79
|
|
|
array( |
80
|
|
|
'name' => __( 'Related Team Member', 'lsx-health-plan' ), |
81
|
|
|
'desc' => __( 'Connect the related team member that applies to this ', 'lsx-health-plan' ) . $default_type, |
82
|
|
|
'id' => $default_type . '_connected_team_member', |
83
|
|
|
'type' => 'post_search_ajax', |
84
|
|
|
'limit' => 4, // Limit selection to X items only (default 1). |
85
|
|
|
'sortable' => true, // Allow selected items to be sortable (default false). |
86
|
|
|
'query_args' => array( |
87
|
|
|
'post_type' => array( 'team' ), |
88
|
|
|
'post_status' => array( 'publish' ), |
89
|
|
|
'posts_per_page' => -1, |
90
|
|
|
), |
91
|
|
|
) |
92
|
|
|
); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
} |
|
|
|
|
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Adding additional custom fields to the single members, related with Health Plan. |
99
|
|
|
*/ |
100
|
|
|
public function additional_single_team_metabox() { |
101
|
|
|
$cmb = new_cmb2_box( |
102
|
|
|
array( |
103
|
|
|
'id' => 'lsx__team', |
104
|
|
|
'title' => '', |
105
|
|
|
'object_types' => array( 'team' ), // Post type. |
106
|
|
|
'context' => 'normal', |
107
|
|
|
'priority' => 'high', |
108
|
|
|
'show_names' => true, |
109
|
|
|
) |
110
|
|
|
); |
111
|
|
|
|
112
|
|
|
$cmb->add_field( |
113
|
|
|
array( |
114
|
|
|
'name' => __( 'Team Member Experience', 'lsx-health-plan' ), |
|
|
|
|
115
|
|
|
'desc' => __( 'Add additional experience to this team member', 'lsx-health-plan' ), |
|
|
|
|
116
|
|
|
'id' => 'team_member_experience', |
|
|
|
|
117
|
|
|
'type' => 'wysiwyg', |
|
|
|
|
118
|
|
|
) |
119
|
|
|
); |
120
|
|
|
|
121
|
|
|
$cmb->add_field( |
122
|
|
|
array( |
123
|
|
|
'name' => __( 'Featured Plans', 'lsx-health-plan' ), |
124
|
|
|
'desc' => __( 'Connect the related plans to this team member', 'lsx-health-plan' ), |
125
|
|
|
'id' => 'connected_team_member_plan', |
126
|
|
|
'type' => 'post_search_ajax', |
127
|
|
|
'limit' => 3, |
128
|
|
|
'sortable' => true, |
129
|
|
|
'query_args' => array( |
130
|
|
|
'post_type' => array( 'plan' ), |
131
|
|
|
'post_status' => array( 'publish' ), |
132
|
|
|
'posts_per_page' => -1, |
133
|
|
|
), |
134
|
|
|
) |
135
|
|
|
); |
136
|
|
|
|
137
|
|
|
} |
|
|
|
|
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Adds custom tabs to the team member single pages. |
141
|
|
|
* |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
public function hp_team_member_tabs() { |
145
|
|
|
if ( is_single() && is_singular( 'team' ) ) { |
|
|
|
|
146
|
|
|
require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/team.php'; |
147
|
|
|
} |
148
|
|
|
} |
|
|
|
|
149
|
|
|
|
150
|
|
|
public function remove_archive_original_team_header() { |
|
|
|
|
151
|
|
|
if ( is_single() && is_singular( 'team' ) ) { |
|
|
|
|
152
|
|
|
remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
153
|
|
|
} |
154
|
|
|
} |
|
|
|
|
155
|
|
|
} |
156
|
|
|
|