Passed
Push — master ( 2c632e...2916ae )
by Warwick
02:47 queued 13s
created
classes/class-lsx-team-frontend.php 1 patch
Indentation   +300 added lines, -300 removed lines patch added patch discarded remove patch
@@ -13,166 +13,166 @@  discard block
 block discarded – undo
13 13
 
14 14
 class LSX_Team_Frontend {
15 15
 
16
-	/**
17
-	 * Holds the previous role, so we know when to output a new title.
18
-	 */
19
-	var $previous_role = '';
20
-
21
-
22
-	public function __construct() {
23
-
24
-		$this->options = team_get_options();
25
-
26
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 );
27
-		add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
28
-		add_filter( 'template_include', array( $this, 'single_template_include' ), 99 );
29
-		add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 );
30
-
31
-		if ( ! empty( $this->options['display']['team_disable_single'] ) ) {
32
-			add_action( 'template_redirect', array( $this, 'disable_single' ) );
33
-		}
34
-
35
-		if ( ! empty( $this->options['display']['group_by_role'] ) ) {
36
-			add_action( 'pre_get_posts', array( $this, 'pre_get_posts_order_by_role' ) );
37
-			add_action( 'lsx_entry_before', array( $this, 'entry_before' ) );
38
-		}
39
-
40
-		add_action( 'pre_get_posts', array( $this, 'disable_pagination_on_archive' ) );
41
-
42
-		if ( is_admin() ) {
43
-			add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 );
44
-		}
45
-
46
-		add_filter( 'lsx_fonts_css', array( $this, 'customizer_fonts_handler' ), 15 );
47
-		add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 );
48
-		add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_single_title' ), 15 );
49
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
50
-
51
-		add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) );
52
-		add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) );
53
-		add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) );
54
-
55
-		add_filter( 'wpseo_schema_graph_pieces', array( $this, 'add_graph_pieces' ), 11, 2 );
56
-	}
57
-
58
-	/**
59
-	 * Return an instance of this class.
60
-	 *
61
-	 * @since 1.0.0
62
-	 *
63
-	 * @return    object lsx_team\classes    A single instance of this class.
64
-	 */
65
-	public static function get_instance() {
66
-		// If the single instance hasn't been set, set it now.
67
-		if ( null === self::$instance ) {
68
-			self::$instance = new self();
69
-		}
70
-		return self::$instance;
71
-	}
72
-
73
-	public function enqueue_scripts( $plugins ) {
74
-		$has_slick = wp_script_is( 'slick', 'queue' );
75
-
76
-		if ( ! $has_slick ) {
77
-			wp_enqueue_style( 'slick', LSX_TEAM_URL . 'assets/css/vendor/slick.css', array(), LSX_TEAM_VER, null );
78
-			wp_enqueue_script( 'slick', LSX_TEAM_URL . 'assets/js/vendor/slick.min.js', array( 'jquery' ), null, LSX_TEAM_VER, true );
79
-		}
80
-
81
-		wp_enqueue_script( 'lsx-team', LSX_TEAM_URL . 'assets/js/lsx-team.min.js', array( 'jquery', 'slick' ), LSX_TEAM_VER, true );
82
-
83
-		$params = apply_filters( 'lsx_team_js_params', array(
84
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
85
-		));
86
-
87
-		wp_localize_script( 'lsx-team', 'lsx_team_params', $params );
88
-
89
-		wp_enqueue_style( 'lsx-team', LSX_TEAM_URL . 'assets/css/lsx-team.css', array(), LSX_TEAM_VER );
90
-		wp_style_add_data( 'lsx-team', 'rtl', 'replace' );
91
-	}
92
-
93
-	/**
94
-	 * Allow data params for Slick slider addon.
95
-	 */
96
-	public function wp_kses_allowed_html( $allowedtags, $context ) {
97
-		$allowedtags['div']['data-slick'] = true;
98
-		return $allowedtags;
99
-	}
100
-
101
-	/**
102
-	 * Single template.
103
-	 */
104
-	public function single_template_include( $template ) {
105
-		if ( is_main_query() && is_singular( 'team' ) ) {
106
-			if ( empty( locate_template( array( 'single-team.php' ) ) ) && file_exists( LSX_TEAM_PATH . 'templates/single-team.php' ) ) {
107
-				$template = LSX_TEAM_PATH . 'templates/single-team.php';
108
-			}
109
-		}
110
-
111
-		return $template;
112
-	}
113
-
114
-	/**
115
-	 * Archive template.
116
-	 */
117
-	public function archive_template_include( $template ) {
118
-		if ( is_main_query() && is_post_type_archive( 'team' ) ) {
119
-			if ( empty( locate_template( array( 'archive-team.php' ) ) ) && file_exists( LSX_TEAM_PATH . 'templates/archive-team.php' ) ) {
120
-				$template = LSX_TEAM_PATH . 'templates/archive-team.php';
121
-			}
122
-		}
123
-
124
-		return $template;
125
-	}
126
-
127
-	/**
128
-	 * Removes access to single team member posts.
129
-	 */
130
-	public function disable_single() {
131
-		$queried_post_type = get_query_var( 'post_type' );
132
-
133
-		if ( is_single() && 'team' === $queried_post_type ) {
134
-			wp_redirect( home_url(), 301 );
135
-			exit;
136
-		}
137
-	}
138
-
139
-	/**
140
-	 * Disable pagination.
141
-	 */
142
-	public function disable_pagination_on_archive( $query ) {
143
-		if ( $query->is_main_query() && $query->is_post_type_archive( 'team' ) ) {
144
-			$query->set( 'posts_per_page', -1 );
145
-			$query->set( 'no_found_rows', true );
146
-		}
147
-	}
148
-
149
-	/**
150
-	 * Handle fonts that might be change by LSX Customiser.
151
-	 */
152
-	public function customizer_fonts_handler( $css_fonts ) {
153
-		global $wp_filesystem;
154
-
155
-		$css_fonts_file = LSX_TEAM_PATH . '/assets/css/lsx-team-fonts.css';
156
-
157
-		if ( file_exists( $css_fonts_file ) ) {
158
-			if ( empty( $wp_filesystem ) ) {
159
-				require_once( ABSPATH . 'wp-admin/includes/file.php' );
160
-				WP_Filesystem();
161
-			}
162
-
163
-			if ( $wp_filesystem ) {
164
-				$css_fonts .= $wp_filesystem->get_contents( $css_fonts_file );
165
-			}
166
-		}
167
-
168
-		return $css_fonts;
169
-	}
170
-
171
-	/**
172
-	 * Handle body colours that might be change by LSX Customiser.
173
-	 */
174
-	public function customizer_body_colours_handler( $css, $colors ) {
175
-		$css .= '
16
+     /**
17
+      * Holds the previous role, so we know when to output a new title.
18
+      */
19
+     var $previous_role = '';
20
+
21
+
22
+     public function __construct() {
23
+
24
+          $this->options = team_get_options();
25
+
26
+          add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 );
27
+          add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
28
+          add_filter( 'template_include', array( $this, 'single_template_include' ), 99 );
29
+          add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 );
30
+
31
+          if ( ! empty( $this->options['display']['team_disable_single'] ) ) {
32
+               add_action( 'template_redirect', array( $this, 'disable_single' ) );
33
+          }
34
+
35
+          if ( ! empty( $this->options['display']['group_by_role'] ) ) {
36
+               add_action( 'pre_get_posts', array( $this, 'pre_get_posts_order_by_role' ) );
37
+               add_action( 'lsx_entry_before', array( $this, 'entry_before' ) );
38
+          }
39
+
40
+          add_action( 'pre_get_posts', array( $this, 'disable_pagination_on_archive' ) );
41
+
42
+          if ( is_admin() ) {
43
+               add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 );
44
+          }
45
+
46
+          add_filter( 'lsx_fonts_css', array( $this, 'customizer_fonts_handler' ), 15 );
47
+          add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 );
48
+          add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_single_title' ), 15 );
49
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
50
+
51
+          add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) );
52
+          add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) );
53
+          add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) );
54
+
55
+          add_filter( 'wpseo_schema_graph_pieces', array( $this, 'add_graph_pieces' ), 11, 2 );
56
+     }
57
+
58
+     /**
59
+      * Return an instance of this class.
60
+      *
61
+      * @since 1.0.0
62
+      *
63
+      * @return    object lsx_team\classes    A single instance of this class.
64
+      */
65
+     public static function get_instance() {
66
+          // If the single instance hasn't been set, set it now.
67
+          if ( null === self::$instance ) {
68
+               self::$instance = new self();
69
+          }
70
+          return self::$instance;
71
+     }
72
+
73
+     public function enqueue_scripts( $plugins ) {
74
+          $has_slick = wp_script_is( 'slick', 'queue' );
75
+
76
+          if ( ! $has_slick ) {
77
+               wp_enqueue_style( 'slick', LSX_TEAM_URL . 'assets/css/vendor/slick.css', array(), LSX_TEAM_VER, null );
78
+               wp_enqueue_script( 'slick', LSX_TEAM_URL . 'assets/js/vendor/slick.min.js', array( 'jquery' ), null, LSX_TEAM_VER, true );
79
+          }
80
+
81
+          wp_enqueue_script( 'lsx-team', LSX_TEAM_URL . 'assets/js/lsx-team.min.js', array( 'jquery', 'slick' ), LSX_TEAM_VER, true );
82
+
83
+          $params = apply_filters( 'lsx_team_js_params', array(
84
+               'ajax_url' => admin_url( 'admin-ajax.php' ),
85
+          ));
86
+
87
+          wp_localize_script( 'lsx-team', 'lsx_team_params', $params );
88
+
89
+          wp_enqueue_style( 'lsx-team', LSX_TEAM_URL . 'assets/css/lsx-team.css', array(), LSX_TEAM_VER );
90
+          wp_style_add_data( 'lsx-team', 'rtl', 'replace' );
91
+     }
92
+
93
+     /**
94
+      * Allow data params for Slick slider addon.
95
+      */
96
+     public function wp_kses_allowed_html( $allowedtags, $context ) {
97
+          $allowedtags['div']['data-slick'] = true;
98
+          return $allowedtags;
99
+     }
100
+
101
+     /**
102
+      * Single template.
103
+      */
104
+     public function single_template_include( $template ) {
105
+          if ( is_main_query() && is_singular( 'team' ) ) {
106
+               if ( empty( locate_template( array( 'single-team.php' ) ) ) && file_exists( LSX_TEAM_PATH . 'templates/single-team.php' ) ) {
107
+                    $template = LSX_TEAM_PATH . 'templates/single-team.php';
108
+               }
109
+          }
110
+
111
+          return $template;
112
+     }
113
+
114
+     /**
115
+      * Archive template.
116
+      */
117
+     public function archive_template_include( $template ) {
118
+          if ( is_main_query() && is_post_type_archive( 'team' ) ) {
119
+               if ( empty( locate_template( array( 'archive-team.php' ) ) ) && file_exists( LSX_TEAM_PATH . 'templates/archive-team.php' ) ) {
120
+                    $template = LSX_TEAM_PATH . 'templates/archive-team.php';
121
+               }
122
+          }
123
+
124
+          return $template;
125
+     }
126
+
127
+     /**
128
+      * Removes access to single team member posts.
129
+      */
130
+     public function disable_single() {
131
+          $queried_post_type = get_query_var( 'post_type' );
132
+
133
+          if ( is_single() && 'team' === $queried_post_type ) {
134
+               wp_redirect( home_url(), 301 );
135
+               exit;
136
+          }
137
+     }
138
+
139
+     /**
140
+      * Disable pagination.
141
+      */
142
+     public function disable_pagination_on_archive( $query ) {
143
+          if ( $query->is_main_query() && $query->is_post_type_archive( 'team' ) ) {
144
+               $query->set( 'posts_per_page', -1 );
145
+               $query->set( 'no_found_rows', true );
146
+          }
147
+     }
148
+
149
+     /**
150
+      * Handle fonts that might be change by LSX Customiser.
151
+      */
152
+     public function customizer_fonts_handler( $css_fonts ) {
153
+          global $wp_filesystem;
154
+
155
+          $css_fonts_file = LSX_TEAM_PATH . '/assets/css/lsx-team-fonts.css';
156
+
157
+          if ( file_exists( $css_fonts_file ) ) {
158
+               if ( empty( $wp_filesystem ) ) {
159
+                    require_once( ABSPATH . 'wp-admin/includes/file.php' );
160
+                    WP_Filesystem();
161
+               }
162
+
163
+               if ( $wp_filesystem ) {
164
+                    $css_fonts .= $wp_filesystem->get_contents( $css_fonts_file );
165
+               }
166
+          }
167
+
168
+          return $css_fonts;
169
+     }
170
+
171
+     /**
172
+      * Handle body colours that might be change by LSX Customiser.
173
+      */
174
+     public function customizer_body_colours_handler( $css, $colors ) {
175
+          $css .= '
176 176
 			@import "' . LSX_TEAM_PATH . '/assets/css/scss/customizer-team-body-colours";
177 177
 
178 178
 			/**
@@ -188,109 +188,109 @@  discard block
 block discarded – undo
188 188
 			);
189 189
 		';
190 190
 
191
-		return $css;
192
-	}
193
-
194
-	/**
195
-	 * Change the LSX Banners title for team archive.
196
-	 */
197
-	public function lsx_banner_archive_title( $title ) {
198
-		if ( is_main_query() && is_post_type_archive( 'team' ) ) {
199
-			$title = '<h1 class="page-title">' . esc_html__( 'Team', 'lsx-team' ) . '</h1>';
200
-		}
201
-
202
-		return $title;
203
-	}
204
-
205
-	/**
206
-	 * Change the LSX Banners title for team single.
207
-	 */
208
-	public function lsx_banner_single_title( $title ) {
209
-		if ( is_main_query() && is_singular( 'team' ) ) {
210
-			$title = '<h1 class="page-title">' . esc_html__( 'Team', 'lsx-team' ) . '</h1>';
211
-		}
212
-
213
-		return $title;
214
-	}
215
-
216
-	/**
217
-	 * Remove the "Archives:" from the post type recipes.
218
-	 *
219
-	 * @param string $title the term title.
220
-	 * @return string
221
-	 */
222
-	public function get_the_archive_title( $title ) {
223
-		if ( is_post_type_archive( 'team' ) ) {
224
-			$title = __( 'Team', 'lsx-health-plan' );
225
-		}
226
-		return $title;
227
-	}
228
-
229
-	/**
230
-	 * Remove the "continue reading" when the single is disabled.
231
-	 */
232
-	public function change_excerpt_more( $excerpt_more ) {
233
-		global $post;
234
-
235
-		if ( 'team' === $post->post_type ) {
236
-			if ( ! empty( team_get_option( 'team_disable_single' ) ) ) {
237
-				$excerpt_more = '';
238
-			}
239
-		}
240
-
241
-		return $excerpt_more;
242
-	}
243
-
244
-	/**
245
-	 * Change the word count when crop the content to excerpt (single team relations).
246
-	 */
247
-	public function change_excerpt_length( $excerpt_word_count ) {
248
-		global $post;
249
-
250
-		if ( is_singular( 'team' ) && ( 'project' === $post->post_type || 'testimonial' === $post->post_type ) ) {
251
-			$excerpt_word_count = 20;
252
-		}
253
-
254
-		return $excerpt_word_count;
255
-	}
256
-
257
-	/**
258
-	 * Change the allowed tags crop the content to excerpt (single team relations).
259
-	 */
260
-	public function change_excerpt_strip_tags( $allowed_tags ) {
261
-		global $post;
262
-
263
-		if ( is_singular( 'team' ) && ( 'project' === $post->post_type || 'testimonial' === $post->post_type ) ) {
264
-			$allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
265
-		}
266
-
267
-		return $allowed_tags;
268
-	}
269
-
270
-	/**
271
-	 * @param $query \WP_Query()
272
-	 *
273
-	 * @return mixed
274
-	 */
275
-	public function pre_get_posts_order_by_role( $query ) {
276
-		if ( ! is_admin() && $query->is_main_query() && $query->is_post_type_archive( 'team' ) ) {
277
-			$post_ids = $this->order_by_role_query();
278
-			if ( ! empty( $post_ids ) ) {
279
-				$query->set( 'post__in', $post_ids );
280
-				$query->set( 'orderby', 'post__in' );
281
-			}
282
-		}
283
-		return $query;
284
-	}
285
-
286
-	/**
287
-	 * Grabs the team members ordered by the Roles Slug and the title alphabetical
288
-	 */
289
-	public function order_by_role_query() {
290
-		global $wpdb;
291
-		$post_ids = array();
292
-
293
-		$results = $wpdb->get_results( $wpdb->prepare("
191
+          return $css;
192
+     }
193
+
194
+     /**
195
+      * Change the LSX Banners title for team archive.
196
+      */
197
+     public function lsx_banner_archive_title( $title ) {
198
+          if ( is_main_query() && is_post_type_archive( 'team' ) ) {
199
+               $title = '<h1 class="page-title">' . esc_html__( 'Team', 'lsx-team' ) . '</h1>';
200
+          }
201
+
202
+          return $title;
203
+     }
204
+
205
+     /**
206
+      * Change the LSX Banners title for team single.
207
+      */
208
+     public function lsx_banner_single_title( $title ) {
209
+          if ( is_main_query() && is_singular( 'team' ) ) {
210
+               $title = '<h1 class="page-title">' . esc_html__( 'Team', 'lsx-team' ) . '</h1>';
211
+          }
212
+
213
+          return $title;
214
+     }
215
+
216
+     /**
217
+      * Remove the "Archives:" from the post type recipes.
218
+      *
219
+      * @param string $title the term title.
220
+      * @return string
221
+      */
222
+     public function get_the_archive_title( $title ) {
223
+          if ( is_post_type_archive( 'team' ) ) {
224
+               $title = __( 'Team', 'lsx-health-plan' );
225
+          }
226
+          return $title;
227
+     }
228
+
229
+     /**
230
+      * Remove the "continue reading" when the single is disabled.
231
+      */
232
+     public function change_excerpt_more( $excerpt_more ) {
233
+          global $post;
234
+
235
+          if ( 'team' === $post->post_type ) {
236
+               if ( ! empty( team_get_option( 'team_disable_single' ) ) ) {
237
+                    $excerpt_more = '';
238
+               }
239
+          }
240
+
241
+          return $excerpt_more;
242
+     }
243
+
244
+     /**
245
+      * Change the word count when crop the content to excerpt (single team relations).
246
+      */
247
+     public function change_excerpt_length( $excerpt_word_count ) {
248
+          global $post;
249
+
250
+          if ( is_singular( 'team' ) && ( 'project' === $post->post_type || 'testimonial' === $post->post_type ) ) {
251
+               $excerpt_word_count = 20;
252
+          }
253
+
254
+          return $excerpt_word_count;
255
+     }
256
+
257
+     /**
258
+      * Change the allowed tags crop the content to excerpt (single team relations).
259
+      */
260
+     public function change_excerpt_strip_tags( $allowed_tags ) {
261
+          global $post;
262
+
263
+          if ( is_singular( 'team' ) && ( 'project' === $post->post_type || 'testimonial' === $post->post_type ) ) {
264
+               $allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
265
+          }
266
+
267
+          return $allowed_tags;
268
+     }
269
+
270
+     /**
271
+      * @param $query \WP_Query()
272
+      *
273
+      * @return mixed
274
+      */
275
+     public function pre_get_posts_order_by_role( $query ) {
276
+          if ( ! is_admin() && $query->is_main_query() && $query->is_post_type_archive( 'team' ) ) {
277
+               $post_ids = $this->order_by_role_query();
278
+               if ( ! empty( $post_ids ) ) {
279
+                    $query->set( 'post__in', $post_ids );
280
+                    $query->set( 'orderby', 'post__in' );
281
+               }
282
+          }
283
+          return $query;
284
+     }
285
+
286
+     /**
287
+      * Grabs the team members ordered by the Roles Slug and the title alphabetical
288
+      */
289
+     public function order_by_role_query() {
290
+          global $wpdb;
291
+          $post_ids = array();
292
+
293
+          $results = $wpdb->get_results( $wpdb->prepare("
294 294
 			SELECT posts.ID, posts.post_title, terms.slug
295 295
 			FROM {$wpdb->posts} AS posts
296 296
 			INNER JOIN {$wpdb->term_relationships} as rels
@@ -305,43 +305,43 @@  discard block
 block discarded – undo
305 305
 			ORDER BY terms.lsx_team_term_order, posts.post_name
306 306
          ", 'team', 'publish', 'team_role' ) );
307 307
 
308
-		if ( ! empty( $results ) ) {
309
-			$post_ids = wp_list_pluck( $results, 'ID' );
310
-		}
311
-		return $post_ids;
312
-	}
313
-
314
-
315
-	/**
316
-	 * Outputs the Role Title if its found
317
-	 */
318
-	public function entry_before() {
319
-		if ( is_post_type_archive( 'team' ) ) {
320
-			$all_roles    = wc_get_object_terms( get_the_ID(), 'team_role' );
321
-			$this_role    = '';
322
-			$this_role_id = '';
323
-			if ( ! empty( $all_roles ) ) {
324
-				$this_role    = $all_roles[0];
325
-				$this_role_id = $this_role->term_id;
326
-			}
327
-
328
-			if ( '' === $this->previous_role || $this->previous_role !== $this_role_id ) {
329
-				echo '<h2 class="role-title text-center col-xs-12 col-sm-12 col-md-12">' . wp_kses_post( $this_role->name ) . '</h2>';
330
-				$this->previous_role = $this_role_id;
331
-			}
332
-		}
333
-	}
334
-	/**
335
-	 * Adds Pieces
336
-	 */
337
-	public function add_graph_pieces( $pieces, $context ) {
338
-		// Scheme Class.
339
-		if ( class_exists( 'LSX_Schema_Graph_Piece' ) ) {
340
-			require_once LSX_TEAM_PATH . '/classes/class-lsx-team-schema.php';
341
-			$pieces[] = new \LSX_Team_Schema( $context );
342
-		}
343
-		return $pieces;
344
-	}
308
+          if ( ! empty( $results ) ) {
309
+               $post_ids = wp_list_pluck( $results, 'ID' );
310
+          }
311
+          return $post_ids;
312
+     }
313
+
314
+
315
+     /**
316
+      * Outputs the Role Title if its found
317
+      */
318
+     public function entry_before() {
319
+          if ( is_post_type_archive( 'team' ) ) {
320
+               $all_roles    = wc_get_object_terms( get_the_ID(), 'team_role' );
321
+               $this_role    = '';
322
+               $this_role_id = '';
323
+               if ( ! empty( $all_roles ) ) {
324
+                    $this_role    = $all_roles[0];
325
+                    $this_role_id = $this_role->term_id;
326
+               }
327
+
328
+               if ( '' === $this->previous_role || $this->previous_role !== $this_role_id ) {
329
+                    echo '<h2 class="role-title text-center col-xs-12 col-sm-12 col-md-12">' . wp_kses_post( $this_role->name ) . '</h2>';
330
+                    $this->previous_role = $this_role_id;
331
+               }
332
+          }
333
+     }
334
+     /**
335
+      * Adds Pieces
336
+      */
337
+     public function add_graph_pieces( $pieces, $context ) {
338
+          // Scheme Class.
339
+          if ( class_exists( 'LSX_Schema_Graph_Piece' ) ) {
340
+               require_once LSX_TEAM_PATH . '/classes/class-lsx-team-schema.php';
341
+               $pieces[] = new \LSX_Team_Schema( $context );
342
+          }
343
+          return $pieces;
344
+     }
345 345
 }
346 346
 
347 347
 $lsx_team_frontend = new LSX_Team_Frontend();
Please login to merge, or discard this patch.
classes/class-lsx-team-core.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -7,86 +7,86 @@
 block discarded – undo
7 7
  */
8 8
 class LSX_Team_Core {
9 9
 
10
-	/**
11
-	 * Holds class instance
12
-	 *
13
-	 * @since 1.0.0
14
-	 *
15
-	 * @var      object LSX_Team_Core()
16
-	 */
17
-	protected static $instance = null;
10
+     /**
11
+      * Holds class instance
12
+      *
13
+      * @since 1.0.0
14
+      *
15
+      * @var      object LSX_Team_Core()
16
+      */
17
+     protected static $instance = null;
18 18
 
19
-	/**
20
-	 * Holds class instance
21
-	 *
22
-	 * @since 1.0.0
23
-	 *
24
-	 * @var      object \MAG_CMB2_Field_Post_Search_Ajax()
25
-	 */
26
-	public $cmb2_post_search_ajax = false;
19
+     /**
20
+      * Holds class instance
21
+      *
22
+      * @since 1.0.0
23
+      *
24
+      * @var      object \MAG_CMB2_Field_Post_Search_Ajax()
25
+      */
26
+     public $cmb2_post_search_ajax = false;
27 27
 
28
-	/**
29
-	 * Contructor
30
-	 */
31
-	public function __construct() {
32
-		add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) );
33
-		$this->load_vendors();
34
-	}
28
+     /**
29
+      * Contructor
30
+      */
31
+     public function __construct() {
32
+          add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) );
33
+          $this->load_vendors();
34
+     }
35 35
 
36
-	/**
37
-	 * Return an instance of this class.
38
-	 *
39
-	 * @since 1.0.0
40
-	 *
41
-	 * @return    object \lsx_team\classes\Core()    A single instance of this class.
42
-	 */
43
-	public static function get_instance() {
36
+     /**
37
+      * Return an instance of this class.
38
+      *
39
+      * @since 1.0.0
40
+      *
41
+      * @return    object \lsx_team\classes\Core()    A single instance of this class.
42
+      */
43
+     public static function get_instance() {
44 44
 
45
-		// If the single instance hasn't been set, set it now.
46
-		if ( null === self::$instance ) {
47
-			self::$instance = new self();
48
-		}
45
+          // If the single instance hasn't been set, set it now.
46
+          if ( null === self::$instance ) {
47
+               self::$instance = new self();
48
+          }
49 49
 
50
-		return self::$instance;
50
+          return self::$instance;
51 51
 
52
-	}
52
+     }
53 53
 
54
-	/**
55
-	 * Loads the plugin functions.
56
-	 */
57
-	private function load_vendors() {
58
-		// Configure custom fields.
59
-		if ( ! class_exists( 'CMB2' ) ) {
60
-			require_once LSX_TEAM_PATH . 'vendor/CMB2/init.php';
61
-		}
62
-	}
54
+     /**
55
+      * Loads the plugin functions.
56
+      */
57
+     private function load_vendors() {
58
+          // Configure custom fields.
59
+          if ( ! class_exists( 'CMB2' ) ) {
60
+               require_once LSX_TEAM_PATH . 'vendor/CMB2/init.php';
61
+          }
62
+     }
63 63
 
64
-	/**
65
-	 * Returns the post types currently active
66
-	 *
67
-	 * @return void
68
-	 */
69
-	public function get_post_types() {
70
-		$post_types = apply_filters( 'lsx_team_post_types', isset( $this->post_types ) );
71
-		foreach ( $post_types as $index => $post_type ) {
72
-			$is_disabled = \cmb2_get_option( 'lsx_team_options', $post_type . '_disabled', false );
73
-			if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) {
74
-				unset( $post_types[ $index ] );
75
-			}
76
-		}
77
-		return $post_types;
78
-	}
64
+     /**
65
+      * Returns the post types currently active
66
+      *
67
+      * @return void
68
+      */
69
+     public function get_post_types() {
70
+          $post_types = apply_filters( 'lsx_team_post_types', isset( $this->post_types ) );
71
+          foreach ( $post_types as $index => $post_type ) {
72
+               $is_disabled = \cmb2_get_option( 'lsx_team_options', $post_type . '_disabled', false );
73
+               if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) {
74
+                    unset( $post_types[ $index ] );
75
+               }
76
+          }
77
+          return $post_types;
78
+     }
79 79
 
80
-	/**
81
-	 * Includes the Post Search Ajax if it is there.
82
-	 *
83
-	 * @return void
84
-	 */
85
-	public function cmb2_post_search_ajax() {
86
-		require_once LSX_TEAM_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php';
87
-		if ( method_exists( 'MAG_CMB2_Field_Post_Search_Ajax', 'get_instance' ) ) {
88
-			$this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance();
89
-		}
90
-	}
80
+     /**
81
+      * Includes the Post Search Ajax if it is there.
82
+      *
83
+      * @return void
84
+      */
85
+     public function cmb2_post_search_ajax() {
86
+          require_once LSX_TEAM_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php';
87
+          if ( method_exists( 'MAG_CMB2_Field_Post_Search_Ajax', 'get_instance' ) ) {
88
+               $this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance();
89
+          }
90
+     }
91 91
 }
92 92
 LSX_Team_Core::get_instance();
Please login to merge, or discard this patch.
classes/admin/class-settings-theme.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -9,186 +9,186 @@  discard block
 block discarded – undo
9 9
  */
10 10
 class Settings_Theme {
11 11
 
12
-	/**
13
-	 * Holds class instance
14
-	 *
15
-	 * @since 1.0.0
16
-	 *
17
-	 * @var      object \lsx_team\classes\admin\Settings_Theme()
18
-	 */
19
-	protected static $instance = null;
12
+     /**
13
+      * Holds class instance
14
+      *
15
+      * @since 1.0.0
16
+      *
17
+      * @var      object \lsx_team\classes\admin\Settings_Theme()
18
+      */
19
+     protected static $instance = null;
20 20
 
21
-	/**
22
-	 * Will return true if this is the LSX Search settings page.
23
-	 *
24
-	 * @var array
25
-	 */
26
-	public $is_options_page = false;
21
+     /**
22
+      * Will return true if this is the LSX Search settings page.
23
+      *
24
+      * @var array
25
+      */
26
+     public $is_options_page = false;
27 27
 
28
-	/**
29
-	 * Holds the id and labels for the navigation.
30
-	 *
31
-	 * @var array
32
-	 */
33
-	public $navigation = array();
28
+     /**
29
+      * Holds the id and labels for the navigation.
30
+      *
31
+      * @var array
32
+      */
33
+     public $navigation = array();
34 34
 
35
-	/**
36
-	 * Contructor
37
-	 */
38
-	public function __construct() {
39
-		add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );
40
-		add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );
41
-		add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );
42
-		add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );
43
-		add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );
44
-		add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );
45
-		add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );
46
-		add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );
47
-	}
35
+     /**
36
+      * Contructor
37
+      */
38
+     public function __construct() {
39
+          add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );
40
+          add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );
41
+          add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );
42
+          add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );
43
+          add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );
44
+          add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );
45
+          add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );
46
+          add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );
47
+     }
48 48
 
49
-	/**
50
-	 * Return an instance of this class.
51
-	 *
52
-	 * @since 1.0.0
53
-	 *
54
-	 * @return    object \lsx_team\classes\admin\Settings_Theme()    A single instance of this class.
55
-	 */
56
-	public static function get_instance() {
57
-		// If the single instance hasn't been set, set it now.
58
-		if ( null == self::$instance ) {
59
-			self::$instance = new self();
60
-		}
61
-		return self::$instance;
62
-	}
49
+     /**
50
+      * Return an instance of this class.
51
+      *
52
+      * @since 1.0.0
53
+      *
54
+      * @return    object \lsx_team\classes\admin\Settings_Theme()    A single instance of this class.
55
+      */
56
+     public static function get_instance() {
57
+          // If the single instance hasn't been set, set it now.
58
+          if ( null == self::$instance ) {
59
+               self::$instance = new self();
60
+          }
61
+          return self::$instance;
62
+     }
63 63
 
64
-	/**
65
-	 * Disable CMB2 styles on front end forms.
66
-	 *
67
-	 * @return bool $enabled Whether to enable (enqueue) styles.
68
-	 */
69
-	public function disable_cmb2_styles( $enabled ) {
70
-		if ( is_admin() ) {
71
-			$current_screen = get_current_screen();
72
-			if ( is_object( $current_screen ) && 'team_page_lsx_team_options' === $current_screen->id ) {
73
-				$enabled = false;
74
-			}
75
-		}
76
-		return $enabled;
77
-	}
64
+     /**
65
+      * Disable CMB2 styles on front end forms.
66
+      *
67
+      * @return bool $enabled Whether to enable (enqueue) styles.
68
+      */
69
+     public function disable_cmb2_styles( $enabled ) {
70
+          if ( is_admin() ) {
71
+               $current_screen = get_current_screen();
72
+               if ( is_object( $current_screen ) && 'team_page_lsx_team_options' === $current_screen->id ) {
73
+                    $enabled = false;
74
+               }
75
+          }
76
+          return $enabled;
77
+     }
78 78
 
79
-	/**
80
-	 * Generates the tabbed navigation for the settings page.
81
-	 *
82
-	 * @param string $cmb_id
83
-	 * @param string $object_id
84
-	 * @param string $object_type
85
-	 * @param object $cmb2_obj
86
-	 * @return void
87
-	 */
88
-	public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
89
-		if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) {
90
-			$this->navigation      = array();
91
-			$this->is_options_page = true;
92
-			if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) {
93
-				foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) {
94
-					if ( 'title' === $field['type'] ) {
95
-						$this->navigation[ $field_index ] = $field['name'];
96
-					}
97
-				}
98
-			}
99
-			$this->output_navigation();
100
-		}
101
-	}
79
+     /**
80
+      * Generates the tabbed navigation for the settings page.
81
+      *
82
+      * @param string $cmb_id
83
+      * @param string $object_id
84
+      * @param string $object_type
85
+      * @param object $cmb2_obj
86
+      * @return void
87
+      */
88
+     public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
89
+          if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) {
90
+               $this->navigation      = array();
91
+               $this->is_options_page = true;
92
+               if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) {
93
+                    foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) {
94
+                         if ( 'title' === $field['type'] ) {
95
+                              $this->navigation[ $field_index ] = $field['name'];
96
+                         }
97
+                    }
98
+               }
99
+               $this->output_navigation();
100
+          }
101
+     }
102 102
 
103
-	/**
104
-	 * Outputs the WP style navigation for the Settings page.
105
-	 *
106
-	 * @return void
107
-	 */
108
-	public function output_navigation() {
109
-		if ( ! empty( $this->navigation ) ) {
110
-			?>
103
+     /**
104
+      * Outputs the WP style navigation for the Settings page.
105
+      *
106
+      * @return void
107
+      */
108
+     public function output_navigation() {
109
+          if ( ! empty( $this->navigation ) ) {
110
+               ?>
111 111
 			<div class="wp-filter hide-if-no-js">
112 112
 				<ul class="filter-links">
113 113
 					<?php
114
-					$first_tab    = true;
115
-					$total        = count( $this->navigation );
116
-					$count        = 0;
117
-					$separator    = ' |';
118
-					$selected_tab = '';
119
-					if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) {
120
-						$selected_tab  = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) );
121
-						$selected_tab  = 'settings_' . $selected_tab;
122
-					}
123
-					foreach ( $this->navigation as $key => $label ) {
124
-						$count++;
125
-						$current_css = '';
126
-						if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) {
127
-							$first_tab   = false;
128
-							$current_css = 'current';
129
-						}
130
-						if ( $count === $total ) {
131
-							$separator = '';
132
-						}
133
-						?>
114
+                         $first_tab    = true;
115
+                         $total        = count( $this->navigation );
116
+                         $count        = 0;
117
+                         $separator    = ' |';
118
+                         $selected_tab = '';
119
+                         if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) {
120
+                              $selected_tab  = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) );
121
+                              $selected_tab  = 'settings_' . $selected_tab;
122
+                         }
123
+                         foreach ( $this->navigation as $key => $label ) {
124
+                              $count++;
125
+                              $current_css = '';
126
+                              if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) {
127
+                                   $first_tab   = false;
128
+                                   $current_css = 'current';
129
+                              }
130
+                              if ( $count === $total ) {
131
+                                   $separator = '';
132
+                              }
133
+                              ?>
134 134
 							<li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li>
135 135
 						<?php
136
-					}
137
-					?>
136
+                         }
137
+                         ?>
138 138
 				</ul>
139 139
 			</div>
140 140
 			<?php
141
-		}
142
-	}
141
+          }
142
+     }
143 143
 
144
-	/**
145
-	 * Outputs the opening tab div.
146
-	 *
147
-	 * @param object $field CMB2_Field();
148
-	 * @return void
149
-	 */
150
-	public function output_tab_open_div( $field ) {
151
-		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) {
152
-			?>
144
+     /**
145
+      * Outputs the opening tab div.
146
+      *
147
+      * @param object $field CMB2_Field();
148
+      * @return void
149
+      */
150
+     public function output_tab_open_div( $field ) {
151
+          if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) {
152
+               ?>
153 153
 			<div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden">
154 154
 			<?php
155
-		}
156
-	}
155
+          }
156
+     }
157 157
 
158
-	/**
159
-	 * Outputs the opening closing div.
160
-	 *
161
-	 * @param object $field CMB2_Field();
162
-	 * @return void
163
-	 */
164
-	public function output_tab_closing_div( $field ) {
165
-		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) {
166
-			?>
158
+     /**
159
+      * Outputs the opening closing div.
160
+      *
161
+      * @param object $field CMB2_Field();
162
+      * @return void
163
+      */
164
+     public function output_tab_closing_div( $field ) {
165
+          if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) {
166
+               ?>
167 167
 			</div>
168 168
 			<?php
169
-		}
170
-	}
169
+          }
170
+     }
171 171
 
172
-	public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
173
-		return;
174
-	}
172
+     public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
173
+          return;
174
+     }
175 175
 
176
-	public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) {
177
-		return '';
178
-	}
176
+     public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) {
177
+          return '';
178
+     }
179 179
 
180
-	/**
181
-	 * Outputs the Script for the tabbed navigation.
182
-	 *
183
-	 * @param string $cmb_id
184
-	 * @param string $object_id
185
-	 * @param string $object_type
186
-	 * @param object $cmb2_obj
187
-	 * @return void
188
-	 */
189
-	public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
190
-		if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) {
191
-			?>
180
+     /**
181
+      * Outputs the Script for the tabbed navigation.
182
+      *
183
+      * @param string $cmb_id
184
+      * @param string $object_id
185
+      * @param string $object_type
186
+      * @param object $cmb2_obj
187
+      * @return void
188
+      */
189
+     public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
190
+          if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) {
191
+               ?>
192 192
 			<script>
193 193
 				var LSX_TEAM_CMB2 = Object.create( null );
194 194
 
@@ -261,25 +261,25 @@  discard block
 block discarded – undo
261 261
 				} )( jQuery, window, document );
262 262
 			</script>
263 263
 			<?php
264
-		}
265
-	}
264
+          }
265
+     }
266 266
 
267
-	/**
268
-	 * This will add the tab selection to the url.
269
-	 *
270
-	 * @param string $url
271
-	 * @return void
272
-	 */
273
-	public function add_tab_argument( $url ) {
274
-		if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine
275
-			$tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine
276
-			$tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine
277
-			if ( 'single' !== $tab_selection ) {
278
-				$url = add_query_arg( 'cmb_tab', $tab_selection, $url );
279
-			} else {
280
-				$url = remove_query_arg( 'cmb_tab', $url );
281
-			}
282
-		}
283
-		return $url;
284
-	}
267
+     /**
268
+      * This will add the tab selection to the url.
269
+      *
270
+      * @param string $url
271
+      * @return void
272
+      */
273
+     public function add_tab_argument( $url ) {
274
+          if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine
275
+               $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine
276
+               $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine
277
+               if ( 'single' !== $tab_selection ) {
278
+                    $url = add_query_arg( 'cmb_tab', $tab_selection, $url );
279
+               } else {
280
+                    $url = remove_query_arg( 'cmb_tab', $url );
281
+               }
282
+          }
283
+          return $url;
284
+     }
285 285
 }
Please login to merge, or discard this patch.
templates/content-single-team.php 1 patch
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -5,137 +5,137 @@
 block discarded – undo
5 5
 ?>
6 6
 
7 7
 <?php
8
-	global $lsx_team;
9
-
10
-	$thumbnail = $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-single' );
11
-
12
-	$job_title = get_post_meta( get_the_ID(), 'lsx_job_title', true );
13
-
14
-	$links = array(
15
-		'facebook'  => get_post_meta( get_the_ID(), 'lsx_facebook', true ),
16
-		'twitter'   => get_post_meta( get_the_ID(), 'lsx_twitter', true ),
17
-		'linkedin'  => get_post_meta( get_the_ID(), 'lsx_linkedin', true ),
18
-		'github'    => get_post_meta( get_the_ID(), 'lsx_github', true ),
19
-		'wordpress' => get_post_meta( get_the_ID(), 'lsx_wordpress', true ),
20
-	);
21
-
22
-	foreach ( $links as $service => $link ) {
23
-		if ( empty( $link ) ) {
24
-			unset( $links[ $service ] );
25
-		}
26
-	}
27
-
28
-	$email = get_post_meta( get_the_ID(), 'lsx_email_contact', true );
29
-	$phone = get_post_meta( get_the_ID(), 'lsx_tel', true );
30
-	$skype = get_post_meta( get_the_ID(), 'lsx_skype', true );
31
-
32
-	$phone_attr = $phone;
33
-	$phone_attr = str_replace( ' ', '', $phone_attr );
34
-	$phone_attr = str_replace( '+', '', $phone_attr );
35
-	$phone_attr = str_replace( '(', '', $phone_attr );
36
-	$phone_attr = str_replace( ')', '', $phone_attr );
37
-	$phone_attr = str_replace( '.', '', $phone_attr );
38
-
39
-	// Tabs
40
-
41
-	$tabs = array();
42
-
43
-	// Tab Posts
44
-
45
-	$site_user = get_post_meta( get_the_ID(), 'lsx_site_user', true );
46
-
47
-	if ( ! empty( $site_user ) ) {
48
-		if ( is_user_member_of_blog( $site_user ) ) {
49
-			$user_posts = count_user_posts( $site_user, 'post' );
50
-
51
-			if ( $user_posts > 0 ) {
52
-				$params = array(
53
-					'post_type' => 'post',
54
-					'author' => $site_user,
55
-					'posts_per_page' => 9,
56
-					'order' => 'DESC',
57
-					'orderby' => 'date',
58
-					'fields' => 'ids',
59
-					'tax_query' => array(
60
-						array(
61
-							'taxonomy' => 'post_format',
62
-							'field' => 'slug',
63
-							'terms' => array(
64
-								'post-format-aside',
65
-								'post-format-audio',
66
-								'post-format-chat',
67
-								'post-format-gallery',
68
-								'post-format-image',
69
-								'post-format-link',
70
-								'post-format-quote',
71
-								'post-format-status',
72
-								'post-format-video',
73
-							),
74
-							'operator' => 'NOT IN',
75
-						),
76
-					),
77
-				);
78
-
79
-				$posts_query = new \WP_Query( $params );
80
-
81
-				if ( $posts_query->have_posts() ) {
82
-					$tab_post['post_type'] = 'post';
83
-					$tab_post['title'] = esc_html__( 'Posts', 'lsx-team' );
84
-					$tab_post['posts'] = $posts_query->posts;
85
-
86
-					if ( ! empty( $tab_post['posts'] ) ) {
87
-						$post_ids = join( ',', $tab_post['posts'] );
88
-						$tab_post['shortcode'] = '[lsx_posts columns="3" include="' . $post_ids . '"]';
89
-						$tabs[] = $tab_post;
90
-					}
91
-				}
92
-			}
93
-		}
94
-	}
95
-
96
-	// Tab Projects
97
-
98
-	$tab_project['post_type'] = 'project';
99
-	$tab_project['title'] = esc_html__( 'Projects', 'lsx-team' );
100
-	$tab_project['posts'] = get_post_meta( get_the_ID(), 'project_to_team', true );
101
-
102
-	if ( is_plugin_active( 'lsx-projects/lsx-projects.php' ) && ( ! empty( $tab_project['posts'] ) ) ) {
103
-		$post_ids = join( ',', $tab_project['posts'] );
104
-		$tab_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
105
-		$tabs[] = $tab_project;
106
-	}
107
-
108
-	// Tab Services
109
-
110
-	if ( is_plugin_active( 'lsx-services/lsx-services.php' ) ) {
111
-		$tab_service['post_type'] = 'service';
112
-		$tab_service['title'] = esc_html__( 'Services', 'lsx-team' );
113
-		$tab_service['posts'] = get_post_meta( get_the_ID(), 'service_to_team', true );
114
-
115
-		if ( ! empty( $tab_service['posts'] ) ) {
116
-			$post_ids = join( ',', $tab_service['posts'] );
117
-			$tab_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
118
-			$tabs[] = $tab_service;
119
-		}
120
-	}
121
-
122
-	// Tab Testimonials
123
-
124
-	$tab_testimonial['post_type'] = 'testimonial';
125
-	$tab_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-team' );
126
-	$tab_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_team', true );
127
-
128
-	if ( is_plugin_active( 'lsx-testimonials/lsx-testimonials.php' ) && ( ! empty( $tab_testimonial['posts'] ) ) ) {
129
-		if ( count( $tab_testimonial['posts'] ) <= 2 ) {
130
-			$columns = count( $tab_testimonial['posts'] );
131
-		} else {
132
-			$columns = 2;
133
-		}
134
-
135
-		$post_ids = join( ',', $tab_testimonial['posts'] );
136
-		$tab_testimonial['shortcode'] = '[lsx_testimonials columns="' . $columns . '" include="' . $post_ids . '" orderby="date" order="DESC" display="excerpt"]';
137
-		$tabs[] = $tab_testimonial;
138
-	}
8
+     global $lsx_team;
9
+
10
+     $thumbnail = $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-single' );
11
+
12
+     $job_title = get_post_meta( get_the_ID(), 'lsx_job_title', true );
13
+
14
+     $links = array(
15
+          'facebook'  => get_post_meta( get_the_ID(), 'lsx_facebook', true ),
16
+          'twitter'   => get_post_meta( get_the_ID(), 'lsx_twitter', true ),
17
+          'linkedin'  => get_post_meta( get_the_ID(), 'lsx_linkedin', true ),
18
+          'github'    => get_post_meta( get_the_ID(), 'lsx_github', true ),
19
+          'wordpress' => get_post_meta( get_the_ID(), 'lsx_wordpress', true ),
20
+     );
21
+
22
+     foreach ( $links as $service => $link ) {
23
+          if ( empty( $link ) ) {
24
+               unset( $links[ $service ] );
25
+          }
26
+     }
27
+
28
+     $email = get_post_meta( get_the_ID(), 'lsx_email_contact', true );
29
+     $phone = get_post_meta( get_the_ID(), 'lsx_tel', true );
30
+     $skype = get_post_meta( get_the_ID(), 'lsx_skype', true );
31
+
32
+     $phone_attr = $phone;
33
+     $phone_attr = str_replace( ' ', '', $phone_attr );
34
+     $phone_attr = str_replace( '+', '', $phone_attr );
35
+     $phone_attr = str_replace( '(', '', $phone_attr );
36
+     $phone_attr = str_replace( ')', '', $phone_attr );
37
+     $phone_attr = str_replace( '.', '', $phone_attr );
38
+
39
+     // Tabs
40
+
41
+     $tabs = array();
42
+
43
+     // Tab Posts
44
+
45
+     $site_user = get_post_meta( get_the_ID(), 'lsx_site_user', true );
46
+
47
+     if ( ! empty( $site_user ) ) {
48
+          if ( is_user_member_of_blog( $site_user ) ) {
49
+               $user_posts = count_user_posts( $site_user, 'post' );
50
+
51
+               if ( $user_posts > 0 ) {
52
+                    $params = array(
53
+                         'post_type' => 'post',
54
+                         'author' => $site_user,
55
+                         'posts_per_page' => 9,
56
+                         'order' => 'DESC',
57
+                         'orderby' => 'date',
58
+                         'fields' => 'ids',
59
+                         'tax_query' => array(
60
+                              array(
61
+                                   'taxonomy' => 'post_format',
62
+                                   'field' => 'slug',
63
+                                   'terms' => array(
64
+                                        'post-format-aside',
65
+                                        'post-format-audio',
66
+                                        'post-format-chat',
67
+                                        'post-format-gallery',
68
+                                        'post-format-image',
69
+                                        'post-format-link',
70
+                                        'post-format-quote',
71
+                                        'post-format-status',
72
+                                        'post-format-video',
73
+                                   ),
74
+                                   'operator' => 'NOT IN',
75
+                              ),
76
+                         ),
77
+                    );
78
+
79
+                    $posts_query = new \WP_Query( $params );
80
+
81
+                    if ( $posts_query->have_posts() ) {
82
+                         $tab_post['post_type'] = 'post';
83
+                         $tab_post['title'] = esc_html__( 'Posts', 'lsx-team' );
84
+                         $tab_post['posts'] = $posts_query->posts;
85
+
86
+                         if ( ! empty( $tab_post['posts'] ) ) {
87
+                              $post_ids = join( ',', $tab_post['posts'] );
88
+                              $tab_post['shortcode'] = '[lsx_posts columns="3" include="' . $post_ids . '"]';
89
+                              $tabs[] = $tab_post;
90
+                         }
91
+                    }
92
+               }
93
+          }
94
+     }
95
+
96
+     // Tab Projects
97
+
98
+     $tab_project['post_type'] = 'project';
99
+     $tab_project['title'] = esc_html__( 'Projects', 'lsx-team' );
100
+     $tab_project['posts'] = get_post_meta( get_the_ID(), 'project_to_team', true );
101
+
102
+     if ( is_plugin_active( 'lsx-projects/lsx-projects.php' ) && ( ! empty( $tab_project['posts'] ) ) ) {
103
+          $post_ids = join( ',', $tab_project['posts'] );
104
+          $tab_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
105
+          $tabs[] = $tab_project;
106
+     }
107
+
108
+     // Tab Services
109
+
110
+     if ( is_plugin_active( 'lsx-services/lsx-services.php' ) ) {
111
+          $tab_service['post_type'] = 'service';
112
+          $tab_service['title'] = esc_html__( 'Services', 'lsx-team' );
113
+          $tab_service['posts'] = get_post_meta( get_the_ID(), 'service_to_team', true );
114
+
115
+          if ( ! empty( $tab_service['posts'] ) ) {
116
+               $post_ids = join( ',', $tab_service['posts'] );
117
+               $tab_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
118
+               $tabs[] = $tab_service;
119
+          }
120
+     }
121
+
122
+     // Tab Testimonials
123
+
124
+     $tab_testimonial['post_type'] = 'testimonial';
125
+     $tab_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-team' );
126
+     $tab_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_team', true );
127
+
128
+     if ( is_plugin_active( 'lsx-testimonials/lsx-testimonials.php' ) && ( ! empty( $tab_testimonial['posts'] ) ) ) {
129
+          if ( count( $tab_testimonial['posts'] ) <= 2 ) {
130
+               $columns = count( $tab_testimonial['posts'] );
131
+          } else {
132
+               $columns = 2;
133
+          }
134
+
135
+          $post_ids = join( ',', $tab_testimonial['posts'] );
136
+          $tab_testimonial['shortcode'] = '[lsx_testimonials columns="' . $columns . '" include="' . $post_ids . '" orderby="date" order="DESC" display="excerpt"]';
137
+          $tabs[] = $tab_testimonial;
138
+     }
139 139
 ?>
140 140
 
141 141
 <?php lsx_entry_before(); ?>
Please login to merge, or discard this patch.
classes/class-lsx-team-admin.php 1 patch
Indentation   +442 added lines, -442 removed lines patch added patch discarded remove patch
@@ -11,448 +11,448 @@
 block discarded – undo
11 11
 
12 12
 class LSX_Team_Admin {
13 13
 
14
-	public function __construct() {
15
-		$this->load_classes();
16
-
17
-		add_action( 'init', array( $this, 'post_type_setup' ) );
18
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
19
-
20
-		add_action( 'cmb2_admin_init', array( $this, 'details_metabox' ) );
21
-		add_action( 'cmb2_admin_init', array( $this, 'projects_details_metabox' ) );
22
-		add_action( 'cmb2_admin_init', array( $this, 'services_details_metabox' ) );
23
-		add_action( 'cmb2_admin_init', array( $this, 'testimonials_details_metabox' ) );
24
-
25
-		add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
26
-
27
-		add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 );
28
-		add_filter( 'enter_title_here', array( $this, 'change_title_text' ) );
29
-	}
30
-
31
-	/**
32
-	 * Loads the admin subclasses
33
-	 */
34
-	private function load_classes() {
35
-		require_once LSX_TEAM_PATH . 'classes/admin/class-settings.php';
36
-		$this->settings = \lsx\team\classes\admin\Settings::get_instance();
37
-
38
-		require_once LSX_TEAM_PATH . 'classes/admin/class-settings-theme.php';
39
-		$this->settings_theme = \lsx\team\classes\admin\Settings_Theme::get_instance();
40
-	}
41
-
42
-	public function post_type_setup() {
43
-		$labels = array(
44
-			'name'               => esc_html_x( 'Team Members', 'post type general name', 'lsx-team' ),
45
-			'singular_name'      => esc_html_x( 'Team Member', 'post type singular name', 'lsx-team' ),
46
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-team' ),
47
-			'add_new_item'       => esc_html__( 'Add New Team Member', 'lsx-team' ),
48
-			'edit_item'          => esc_html__( 'Edit Team Member', 'lsx-team' ),
49
-			'new_item'           => esc_html__( 'New Team Member', 'lsx-team' ),
50
-			'all_items'          => esc_html__( 'All Team Members', 'lsx-team' ),
51
-			'view_item'          => esc_html__( 'View Team Member', 'lsx-team' ),
52
-			'search_items'       => esc_html__( 'Search Team Members', 'lsx-team' ),
53
-			'not_found'          => esc_html__( 'No team members found', 'lsx-team' ),
54
-			'not_found_in_trash' => esc_html__( 'No team members found in Trash', 'lsx-team' ),
55
-			'parent_item_colon'  => '',
56
-			'menu_name'          => esc_html_x( 'Team Members', 'admin menu', 'lsx-team' ),
57
-		);
58
-
59
-		$args = array(
60
-			'labels'             => $labels,
61
-			'public'             => true,
62
-			'publicly_queryable' => true,
63
-			'show_ui'            => true,
64
-			'show_in_menu'       => true,
65
-			'menu_icon'          => 'dashicons-groups',
66
-			'query_var'          => true,
67
-			'rewrite'            => array(
68
-				'slug' => 'team',
69
-			),
70
-			'capability_type'    => 'post',
71
-			'has_archive'        => 'team',
72
-			'hierarchical'       => false,
73
-			'menu_position'      => null,
74
-			'supports'           => array(
75
-				'title',
76
-				'editor',
77
-				'excerpt',
78
-				'thumbnail',
79
-				'custom-fields',
80
-			),
81
-			'show_in_rest'          => true,
82
-		);
83
-
84
-		register_post_type( 'team', $args );
85
-	}
86
-
87
-	public function taxonomy_setup() {
88
-		$labels = array(
89
-			'name'              => esc_html_x( 'Roles', 'taxonomy general name', 'lsx-team' ),
90
-			'singular_name'     => esc_html_x( 'Role', 'taxonomy singular name', 'lsx-team' ),
91
-			'search_items'      => esc_html__( 'Search Roles', 'lsx-team' ),
92
-			'all_items'         => esc_html__( 'All Roles', 'lsx-team' ),
93
-			'parent_item'       => esc_html__( 'Parent Role', 'lsx-team' ),
94
-			'parent_item_colon' => esc_html__( 'Parent Role:', 'lsx-team' ),
95
-			'edit_item'         => esc_html__( 'Edit Role', 'lsx-team' ),
96
-			'update_item'       => esc_html__( 'Update Role', 'lsx-team' ),
97
-			'add_new_item'      => esc_html__( 'Add New Role', 'lsx-team' ),
98
-			'new_item_name'     => esc_html__( 'New Role Name', 'lsx-team' ),
99
-			'menu_name'         => esc_html__( 'Roles', 'lsx-team' ),
100
-		);
101
-
102
-		$args = array(
103
-			'hierarchical'      => true,
104
-			'labels'            => $labels,
105
-			'show_ui'           => true,
106
-			'show_admin_column' => true,
107
-			'query_var'         => true,
108
-			'rewrite'           => array(
109
-				'slug' => 'team-role',
110
-			),
111
-			'show_in_rest'          => true,
112
-		);
113
-
114
-		register_taxonomy( 'team_role', array( 'team' ), $args );
115
-	}
116
-
117
-	/**
118
-	 * Define the metabox and field configurations.
119
-	 */
120
-	public function details_metabox() {
121
-
122
-		$prefix = 'lsx_';
123
-
124
-		$users = get_transient( 'lsx_team_users' );
125
-
126
-		if ( false === $users || '' === $users ) {
127
-			$users = get_users( array(
128
-				'role__in' => array( 'administrator', 'editor', 'author' ),
129
-			) );
130
-			set_transient( 'lsx_team_users', $users, 5 * 60 );
131
-		}
132
-
133
-		foreach ( $users as $user ) {
134
-			$user_array[] = array(
135
-				'name'  => $user->nice_name,
136
-				'value' => $user->ID,
137
-			);
138
-		}
139
-
140
-		$cmb = new_cmb2_box(
141
-			array(
142
-				'id'           => $prefix . '_team',
143
-				'title'        => esc_html__( 'Team Member Details', 'lsx-team' ),
144
-				'object_types' => 'team',
145
-				'context'      => 'normal',
146
-				'priority'     => 'low',
147
-				'show_names'   => true,
148
-			)
149
-		);
150
-
151
-		$cmb->add_field(
152
-			array(
153
-				'name'         => esc_html__( 'Featured:', 'lsx-team' ),
154
-				'id'           => $prefix . 'featured',
155
-				'type'         => 'checkbox',
156
-				'value'        => 1,
157
-				'default'      => 0,
158
-				'show_in_rest' => true,
159
-			)
160
-		);
161
-
162
-		$cmb->add_field(
163
-			array(
164
-				'name'         => esc_html__( 'Site User', 'lsx-team' ),
165
-				'id'           => $prefix . 'site_user',
166
-				'allow_none'   => true,
167
-				'type'         => 'select',
168
-				'options'      => $user_array,
169
-				'show_in_rest' => true,
170
-			)
171
-		);
172
-
173
-		$cmb->add_field(
174
-			array(
175
-				'name'         => esc_html__( 'Job Title:', 'lsx-team' ),
176
-				'id'           => $prefix . 'job_title',
177
-				'type'         => 'text',
178
-				'show_in_rest' => true,
179
-			)
180
-		);
181
-
182
-		$cmb->add_field(
183
-			array(
184
-				'name'         => esc_html__( 'Location:', 'lsx-team' ),
185
-				'id'           => $prefix . 'location',
186
-				'type'         => 'text',
187
-				'show_in_rest' => true,
188
-			)
189
-		);
190
-
191
-		$cmb->add_field(
192
-			array(
193
-				'name'         => esc_html__( 'Contact Email Address:', 'lsx-team' ),
194
-				'id'           => $prefix . 'email_contact',
195
-				'type'         => 'text',
196
-				'show_in_rest' => true,
197
-			)
198
-		);
199
-
200
-		$cmb->add_field(
201
-			array(
202
-				'name'         => esc_html__( 'Gravatar Email Address:', 'lsx-team' ),
203
-				'desc'         => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ),
204
-				'id'           => $prefix . 'email_gravatar',
205
-				'type'         => 'text',
206
-				'show_in_rest' => true,
207
-			)
208
-		);
209
-
210
-		$cmb->add_field(
211
-			array(
212
-				'name'         => esc_html__( 'Telephone Number:', 'lsx-team' ),
213
-				'id'           => $prefix . 'tel',
214
-				'type'         => 'text',
215
-				'show_in_rest' => true,
216
-			)
217
-		);
218
-
219
-		$cmb->add_field(
220
-			array(
221
-				'name'         => esc_html__( 'Skype Name:', 'lsx-team' ),
222
-				'id'           => $prefix . 'skype',
223
-				'type'         => 'text',
224
-				'show_in_rest' => true,
225
-			)
226
-		);
227
-
228
-		$cmb->add_field(
229
-			array(
230
-				'name'         => esc_html__( 'Facebook URL', 'lsx-team' ),
231
-				'id'           => $prefix . 'facebook',
232
-				'type'         => 'text_url',
233
-				'show_in_rest' => true,
234
-			)
235
-		);
236
-
237
-		$cmb->add_field(
238
-			array(
239
-				'name'         => esc_html__( 'Twitter URL', 'lsx-team' ),
240
-				'id'           => $prefix . 'twitter',
241
-				'type'         => 'text_url',
242
-				'show_in_rest' => true,
243
-			)
244
-		);
245
-
246
-		$cmb->add_field(
247
-			array(
248
-				'name'         => esc_html__( 'LinkedIn URL', 'lsx-team' ),
249
-				'id'           => $prefix . 'linkedin',
250
-				'type'         => 'text_url',
251
-				'show_in_rest' => true,
252
-			)
253
-		);
254
-
255
-		$cmb->add_field(
256
-			array(
257
-				'name'         => esc_html__( 'Github URL', 'lsx-team' ),
258
-				'id'           => $prefix . 'github',
259
-				'type'         => 'text_url',
260
-				'show_in_rest' => true,
261
-			)
262
-		);
263
-
264
-		$cmb->add_field(
265
-			array(
266
-				'name'         => esc_html__( 'WordPress URL', 'lsx-team' ),
267
-				'id'           => $prefix . 'wordpress',
268
-				'type'         => 'text_url',
269
-				'show_in_rest' => true,
270
-			)
271
-		);
272
-	}
273
-
274
-	/**
275
-	 * Define the metabox and field configurations.
276
-	 */
277
-	public function projects_details_metabox() {
278
-
279
-		if ( class_exists( 'LSX_Projects' ) ) {
280
-
281
-			$prefix = 'lsx_';
282
-
283
-			$cmb = new_cmb2_box(
284
-				array(
285
-					'id'           => $prefix . '_team',
286
-					'context'      => 'normal',
287
-					'priority'     => 'low',
288
-					'show_names'   => true,
289
-					'object_types' => array( 'team' ),
290
-				)
291
-			);
292
-			$cmb->add_field(
293
-				array(
294
-					'name'       => __( 'Projects:', 'lsx-team' ),
295
-					'id'         => 'project_to_team',
296
-					'type'       => 'post_search_ajax',
297
-					'limit'      => 15,
298
-					'sortable'   => true,
299
-					'query_args' => array(
300
-						'post_type'      => array( 'project' ),
301
-						'post_status'    => array( 'publish' ),
302
-						'posts_per_page' => -1,
303
-					),
304
-				)
305
-			);
306
-		}
307
-	}
308
-
309
-	/**
310
-	 * Define the metabox and field configurations.
311
-	 */
312
-	public function services_details_metabox() {
313
-
314
-		if ( class_exists( 'LSX_Services' ) ) {
315
-
316
-			$prefix = 'lsx_';
317
-
318
-			$cmb = new_cmb2_box(
319
-				array(
320
-					'id'           => $prefix . '_team',
321
-					'context'      => 'normal',
322
-					'priority'     => 'low',
323
-					'show_names'   => true,
324
-					'object_types' => array( 'team' ),
325
-				)
326
-			);
327
-			$cmb->add_field(
328
-				array(
329
-					'name'       => __( 'Services:', 'lsx-team' ),
330
-					'id'         => 'service_to_team',
331
-					'type'       => 'post_search_ajax',
332
-					'limit'      => 15,
333
-					'sortable'   => true,
334
-					'query_args' => array(
335
-						'post_type'      => array( 'service' ),
336
-						'post_status'    => array( 'publish' ),
337
-						'posts_per_page' => -1,
338
-					),
339
-				)
340
-			);
341
-		}
342
-	}
343
-
344
-	/**
345
-	 * Define the metabox and field configurations.
346
-	 */
347
-	public function testimonials_details_metabox() {
348
-
349
-		if ( class_exists( 'LSX_Testimonials' ) ) {
350
-
351
-			$prefix = 'lsx_';
352
-
353
-			$cmb = new_cmb2_box(
354
-				array(
355
-					'id'           => $prefix . '_team',
356
-					'context'      => 'normal',
357
-					'priority'     => 'low',
358
-					'show_names'   => true,
359
-					'object_types' => array( 'team' ),
360
-				)
361
-			);
362
-			$cmb->add_field(
363
-				array(
364
-					'name'       => __( 'Testimonials:', 'lsx-team' ),
365
-					'id'         => 'testimonial_to_team',
366
-					'type'       => 'post_search_ajax',
367
-					'limit'      => 15,
368
-					'sortable'   => true,
369
-					'query_args' => array(
370
-						'post_type'      => array( 'testimonial' ),
371
-						'post_status'    => array( 'publish' ),
372
-						'posts_per_page' => -1,
373
-					),
374
-				)
375
-			);
376
-		}
377
-
378
-	}
379
-
380
-	/**
381
-	 * Sets up the "post relations".
382
-	 */
383
-	public function post_relations( $post_id, $field, $value ) {
384
-		$connections = array(
385
-			'team_to_testimonial',
386
-			'testimonial_to_team',
387
-
388
-			'team_to_project',
389
-			'project_to_team',
390
-
391
-			'team_to_service',
392
-			'service_to_team',
393
-		);
394
-
395
-		if ( in_array( $field['id'], $connections ) ) {
396
-			$this->save_related_post( $connections, $post_id, $field, $value );
397
-		}
398
-	}
399
-
400
-	/**
401
-	 * Save the reverse post relation.
402
-	 */
403
-	public function save_related_post( $connections, $post_id, $field, $value ) {
404
-		$ids = explode( '_to_', $field['id'] );
405
-		$relation = $ids[1] . '_to_' . $ids[0];
406
-
407
-		if ( in_array( $relation, $connections ) ) {
408
-			$previous_values = get_post_meta( $post_id, $field['id'], false );
409
-
410
-			if ( ! empty( $previous_values ) ) {
411
-				foreach ( $previous_values as $v ) {
412
-					delete_post_meta( $v, $relation, $post_id );
413
-				}
414
-			}
415
-
416
-			if ( is_array( $value ) ) {
417
-				foreach ( $value as $v ) {
418
-					if ( ! empty( $v ) ) {
419
-						add_post_meta( $v, $relation, $post_id );
420
-					}
421
-				}
422
-			}
423
-		}
424
-	}
425
-
426
-	public function assets() {
427
-		//wp_enqueue_media();
428
-		wp_enqueue_script( 'media-upload' );
429
-		wp_enqueue_script( 'thickbox' );
430
-		wp_enqueue_style( 'thickbox' );
431
-
432
-		wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER );
433
-		wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER );
434
-	}
435
-
436
-	/**
437
-	 * Change the "Insert into Post" button text when media modal is used for feature images
438
-	 */
439
-	public function change_attachment_field_button( $html ) {
440
-		if ( isset( $_GET['feature_image_text_button'] ) ) {
441
-			$html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html );
442
-		}
443
-
444
-		return $html;
445
-	}
446
-
447
-	public function change_title_text( $title ) {
448
-		$screen = get_current_screen();
449
-
450
-		if ( 'team' === $screen->post_type ) {
451
-			$title = esc_attr__( 'Enter team member name', 'lsx-team' );
452
-		}
453
-
454
-		return $title;
455
-	}
14
+     public function __construct() {
15
+          $this->load_classes();
16
+
17
+          add_action( 'init', array( $this, 'post_type_setup' ) );
18
+          add_action( 'init', array( $this, 'taxonomy_setup' ) );
19
+
20
+          add_action( 'cmb2_admin_init', array( $this, 'details_metabox' ) );
21
+          add_action( 'cmb2_admin_init', array( $this, 'projects_details_metabox' ) );
22
+          add_action( 'cmb2_admin_init', array( $this, 'services_details_metabox' ) );
23
+          add_action( 'cmb2_admin_init', array( $this, 'testimonials_details_metabox' ) );
24
+
25
+          add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
26
+
27
+          add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 );
28
+          add_filter( 'enter_title_here', array( $this, 'change_title_text' ) );
29
+     }
30
+
31
+     /**
32
+      * Loads the admin subclasses
33
+      */
34
+     private function load_classes() {
35
+          require_once LSX_TEAM_PATH . 'classes/admin/class-settings.php';
36
+          $this->settings = \lsx\team\classes\admin\Settings::get_instance();
37
+
38
+          require_once LSX_TEAM_PATH . 'classes/admin/class-settings-theme.php';
39
+          $this->settings_theme = \lsx\team\classes\admin\Settings_Theme::get_instance();
40
+     }
41
+
42
+     public function post_type_setup() {
43
+          $labels = array(
44
+               'name'               => esc_html_x( 'Team Members', 'post type general name', 'lsx-team' ),
45
+               'singular_name'      => esc_html_x( 'Team Member', 'post type singular name', 'lsx-team' ),
46
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-team' ),
47
+               'add_new_item'       => esc_html__( 'Add New Team Member', 'lsx-team' ),
48
+               'edit_item'          => esc_html__( 'Edit Team Member', 'lsx-team' ),
49
+               'new_item'           => esc_html__( 'New Team Member', 'lsx-team' ),
50
+               'all_items'          => esc_html__( 'All Team Members', 'lsx-team' ),
51
+               'view_item'          => esc_html__( 'View Team Member', 'lsx-team' ),
52
+               'search_items'       => esc_html__( 'Search Team Members', 'lsx-team' ),
53
+               'not_found'          => esc_html__( 'No team members found', 'lsx-team' ),
54
+               'not_found_in_trash' => esc_html__( 'No team members found in Trash', 'lsx-team' ),
55
+               'parent_item_colon'  => '',
56
+               'menu_name'          => esc_html_x( 'Team Members', 'admin menu', 'lsx-team' ),
57
+          );
58
+
59
+          $args = array(
60
+               'labels'             => $labels,
61
+               'public'             => true,
62
+               'publicly_queryable' => true,
63
+               'show_ui'            => true,
64
+               'show_in_menu'       => true,
65
+               'menu_icon'          => 'dashicons-groups',
66
+               'query_var'          => true,
67
+               'rewrite'            => array(
68
+                    'slug' => 'team',
69
+               ),
70
+               'capability_type'    => 'post',
71
+               'has_archive'        => 'team',
72
+               'hierarchical'       => false,
73
+               'menu_position'      => null,
74
+               'supports'           => array(
75
+                    'title',
76
+                    'editor',
77
+                    'excerpt',
78
+                    'thumbnail',
79
+                    'custom-fields',
80
+               ),
81
+               'show_in_rest'          => true,
82
+          );
83
+
84
+          register_post_type( 'team', $args );
85
+     }
86
+
87
+     public function taxonomy_setup() {
88
+          $labels = array(
89
+               'name'              => esc_html_x( 'Roles', 'taxonomy general name', 'lsx-team' ),
90
+               'singular_name'     => esc_html_x( 'Role', 'taxonomy singular name', 'lsx-team' ),
91
+               'search_items'      => esc_html__( 'Search Roles', 'lsx-team' ),
92
+               'all_items'         => esc_html__( 'All Roles', 'lsx-team' ),
93
+               'parent_item'       => esc_html__( 'Parent Role', 'lsx-team' ),
94
+               'parent_item_colon' => esc_html__( 'Parent Role:', 'lsx-team' ),
95
+               'edit_item'         => esc_html__( 'Edit Role', 'lsx-team' ),
96
+               'update_item'       => esc_html__( 'Update Role', 'lsx-team' ),
97
+               'add_new_item'      => esc_html__( 'Add New Role', 'lsx-team' ),
98
+               'new_item_name'     => esc_html__( 'New Role Name', 'lsx-team' ),
99
+               'menu_name'         => esc_html__( 'Roles', 'lsx-team' ),
100
+          );
101
+
102
+          $args = array(
103
+               'hierarchical'      => true,
104
+               'labels'            => $labels,
105
+               'show_ui'           => true,
106
+               'show_admin_column' => true,
107
+               'query_var'         => true,
108
+               'rewrite'           => array(
109
+                    'slug' => 'team-role',
110
+               ),
111
+               'show_in_rest'          => true,
112
+          );
113
+
114
+          register_taxonomy( 'team_role', array( 'team' ), $args );
115
+     }
116
+
117
+     /**
118
+      * Define the metabox and field configurations.
119
+      */
120
+     public function details_metabox() {
121
+
122
+          $prefix = 'lsx_';
123
+
124
+          $users = get_transient( 'lsx_team_users' );
125
+
126
+          if ( false === $users || '' === $users ) {
127
+               $users = get_users( array(
128
+                    'role__in' => array( 'administrator', 'editor', 'author' ),
129
+               ) );
130
+               set_transient( 'lsx_team_users', $users, 5 * 60 );
131
+          }
132
+
133
+          foreach ( $users as $user ) {
134
+               $user_array[] = array(
135
+                    'name'  => $user->nice_name,
136
+                    'value' => $user->ID,
137
+               );
138
+          }
139
+
140
+          $cmb = new_cmb2_box(
141
+               array(
142
+                    'id'           => $prefix . '_team',
143
+                    'title'        => esc_html__( 'Team Member Details', 'lsx-team' ),
144
+                    'object_types' => 'team',
145
+                    'context'      => 'normal',
146
+                    'priority'     => 'low',
147
+                    'show_names'   => true,
148
+               )
149
+          );
150
+
151
+          $cmb->add_field(
152
+               array(
153
+                    'name'         => esc_html__( 'Featured:', 'lsx-team' ),
154
+                    'id'           => $prefix . 'featured',
155
+                    'type'         => 'checkbox',
156
+                    'value'        => 1,
157
+                    'default'      => 0,
158
+                    'show_in_rest' => true,
159
+               )
160
+          );
161
+
162
+          $cmb->add_field(
163
+               array(
164
+                    'name'         => esc_html__( 'Site User', 'lsx-team' ),
165
+                    'id'           => $prefix . 'site_user',
166
+                    'allow_none'   => true,
167
+                    'type'         => 'select',
168
+                    'options'      => $user_array,
169
+                    'show_in_rest' => true,
170
+               )
171
+          );
172
+
173
+          $cmb->add_field(
174
+               array(
175
+                    'name'         => esc_html__( 'Job Title:', 'lsx-team' ),
176
+                    'id'           => $prefix . 'job_title',
177
+                    'type'         => 'text',
178
+                    'show_in_rest' => true,
179
+               )
180
+          );
181
+
182
+          $cmb->add_field(
183
+               array(
184
+                    'name'         => esc_html__( 'Location:', 'lsx-team' ),
185
+                    'id'           => $prefix . 'location',
186
+                    'type'         => 'text',
187
+                    'show_in_rest' => true,
188
+               )
189
+          );
190
+
191
+          $cmb->add_field(
192
+               array(
193
+                    'name'         => esc_html__( 'Contact Email Address:', 'lsx-team' ),
194
+                    'id'           => $prefix . 'email_contact',
195
+                    'type'         => 'text',
196
+                    'show_in_rest' => true,
197
+               )
198
+          );
199
+
200
+          $cmb->add_field(
201
+               array(
202
+                    'name'         => esc_html__( 'Gravatar Email Address:', 'lsx-team' ),
203
+                    'desc'         => esc_html__( 'Used for Gravatar if a featured image is not set', 'lsx-team' ),
204
+                    'id'           => $prefix . 'email_gravatar',
205
+                    'type'         => 'text',
206
+                    'show_in_rest' => true,
207
+               )
208
+          );
209
+
210
+          $cmb->add_field(
211
+               array(
212
+                    'name'         => esc_html__( 'Telephone Number:', 'lsx-team' ),
213
+                    'id'           => $prefix . 'tel',
214
+                    'type'         => 'text',
215
+                    'show_in_rest' => true,
216
+               )
217
+          );
218
+
219
+          $cmb->add_field(
220
+               array(
221
+                    'name'         => esc_html__( 'Skype Name:', 'lsx-team' ),
222
+                    'id'           => $prefix . 'skype',
223
+                    'type'         => 'text',
224
+                    'show_in_rest' => true,
225
+               )
226
+          );
227
+
228
+          $cmb->add_field(
229
+               array(
230
+                    'name'         => esc_html__( 'Facebook URL', 'lsx-team' ),
231
+                    'id'           => $prefix . 'facebook',
232
+                    'type'         => 'text_url',
233
+                    'show_in_rest' => true,
234
+               )
235
+          );
236
+
237
+          $cmb->add_field(
238
+               array(
239
+                    'name'         => esc_html__( 'Twitter URL', 'lsx-team' ),
240
+                    'id'           => $prefix . 'twitter',
241
+                    'type'         => 'text_url',
242
+                    'show_in_rest' => true,
243
+               )
244
+          );
245
+
246
+          $cmb->add_field(
247
+               array(
248
+                    'name'         => esc_html__( 'LinkedIn URL', 'lsx-team' ),
249
+                    'id'           => $prefix . 'linkedin',
250
+                    'type'         => 'text_url',
251
+                    'show_in_rest' => true,
252
+               )
253
+          );
254
+
255
+          $cmb->add_field(
256
+               array(
257
+                    'name'         => esc_html__( 'Github URL', 'lsx-team' ),
258
+                    'id'           => $prefix . 'github',
259
+                    'type'         => 'text_url',
260
+                    'show_in_rest' => true,
261
+               )
262
+          );
263
+
264
+          $cmb->add_field(
265
+               array(
266
+                    'name'         => esc_html__( 'WordPress URL', 'lsx-team' ),
267
+                    'id'           => $prefix . 'wordpress',
268
+                    'type'         => 'text_url',
269
+                    'show_in_rest' => true,
270
+               )
271
+          );
272
+     }
273
+
274
+     /**
275
+      * Define the metabox and field configurations.
276
+      */
277
+     public function projects_details_metabox() {
278
+
279
+          if ( class_exists( 'LSX_Projects' ) ) {
280
+
281
+               $prefix = 'lsx_';
282
+
283
+               $cmb = new_cmb2_box(
284
+                    array(
285
+                         'id'           => $prefix . '_team',
286
+                         'context'      => 'normal',
287
+                         'priority'     => 'low',
288
+                         'show_names'   => true,
289
+                         'object_types' => array( 'team' ),
290
+                    )
291
+               );
292
+               $cmb->add_field(
293
+                    array(
294
+                         'name'       => __( 'Projects:', 'lsx-team' ),
295
+                         'id'         => 'project_to_team',
296
+                         'type'       => 'post_search_ajax',
297
+                         'limit'      => 15,
298
+                         'sortable'   => true,
299
+                         'query_args' => array(
300
+                              'post_type'      => array( 'project' ),
301
+                              'post_status'    => array( 'publish' ),
302
+                              'posts_per_page' => -1,
303
+                         ),
304
+                    )
305
+               );
306
+          }
307
+     }
308
+
309
+     /**
310
+      * Define the metabox and field configurations.
311
+      */
312
+     public function services_details_metabox() {
313
+
314
+          if ( class_exists( 'LSX_Services' ) ) {
315
+
316
+               $prefix = 'lsx_';
317
+
318
+               $cmb = new_cmb2_box(
319
+                    array(
320
+                         'id'           => $prefix . '_team',
321
+                         'context'      => 'normal',
322
+                         'priority'     => 'low',
323
+                         'show_names'   => true,
324
+                         'object_types' => array( 'team' ),
325
+                    )
326
+               );
327
+               $cmb->add_field(
328
+                    array(
329
+                         'name'       => __( 'Services:', 'lsx-team' ),
330
+                         'id'         => 'service_to_team',
331
+                         'type'       => 'post_search_ajax',
332
+                         'limit'      => 15,
333
+                         'sortable'   => true,
334
+                         'query_args' => array(
335
+                              'post_type'      => array( 'service' ),
336
+                              'post_status'    => array( 'publish' ),
337
+                              'posts_per_page' => -1,
338
+                         ),
339
+                    )
340
+               );
341
+          }
342
+     }
343
+
344
+     /**
345
+      * Define the metabox and field configurations.
346
+      */
347
+     public function testimonials_details_metabox() {
348
+
349
+          if ( class_exists( 'LSX_Testimonials' ) ) {
350
+
351
+               $prefix = 'lsx_';
352
+
353
+               $cmb = new_cmb2_box(
354
+                    array(
355
+                         'id'           => $prefix . '_team',
356
+                         'context'      => 'normal',
357
+                         'priority'     => 'low',
358
+                         'show_names'   => true,
359
+                         'object_types' => array( 'team' ),
360
+                    )
361
+               );
362
+               $cmb->add_field(
363
+                    array(
364
+                         'name'       => __( 'Testimonials:', 'lsx-team' ),
365
+                         'id'         => 'testimonial_to_team',
366
+                         'type'       => 'post_search_ajax',
367
+                         'limit'      => 15,
368
+                         'sortable'   => true,
369
+                         'query_args' => array(
370
+                              'post_type'      => array( 'testimonial' ),
371
+                              'post_status'    => array( 'publish' ),
372
+                              'posts_per_page' => -1,
373
+                         ),
374
+                    )
375
+               );
376
+          }
377
+
378
+     }
379
+
380
+     /**
381
+      * Sets up the "post relations".
382
+      */
383
+     public function post_relations( $post_id, $field, $value ) {
384
+          $connections = array(
385
+               'team_to_testimonial',
386
+               'testimonial_to_team',
387
+
388
+               'team_to_project',
389
+               'project_to_team',
390
+
391
+               'team_to_service',
392
+               'service_to_team',
393
+          );
394
+
395
+          if ( in_array( $field['id'], $connections ) ) {
396
+               $this->save_related_post( $connections, $post_id, $field, $value );
397
+          }
398
+     }
399
+
400
+     /**
401
+      * Save the reverse post relation.
402
+      */
403
+     public function save_related_post( $connections, $post_id, $field, $value ) {
404
+          $ids = explode( '_to_', $field['id'] );
405
+          $relation = $ids[1] . '_to_' . $ids[0];
406
+
407
+          if ( in_array( $relation, $connections ) ) {
408
+               $previous_values = get_post_meta( $post_id, $field['id'], false );
409
+
410
+               if ( ! empty( $previous_values ) ) {
411
+                    foreach ( $previous_values as $v ) {
412
+                         delete_post_meta( $v, $relation, $post_id );
413
+                    }
414
+               }
415
+
416
+               if ( is_array( $value ) ) {
417
+                    foreach ( $value as $v ) {
418
+                         if ( ! empty( $v ) ) {
419
+                              add_post_meta( $v, $relation, $post_id );
420
+                         }
421
+                    }
422
+               }
423
+          }
424
+     }
425
+
426
+     public function assets() {
427
+          //wp_enqueue_media();
428
+          wp_enqueue_script( 'media-upload' );
429
+          wp_enqueue_script( 'thickbox' );
430
+          wp_enqueue_style( 'thickbox' );
431
+
432
+          wp_enqueue_script( 'lsx-team-admin', LSX_TEAM_URL . 'assets/js/lsx-team-admin.min.js', array( 'jquery' ), LSX_TEAM_VER );
433
+          wp_enqueue_style( 'lsx-team-admin', LSX_TEAM_URL . 'assets/css/lsx-team-admin.css', array(), LSX_TEAM_VER );
434
+     }
435
+
436
+     /**
437
+      * Change the "Insert into Post" button text when media modal is used for feature images
438
+      */
439
+     public function change_attachment_field_button( $html ) {
440
+          if ( isset( $_GET['feature_image_text_button'] ) ) {
441
+               $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-team' ) ), $html );
442
+          }
443
+
444
+          return $html;
445
+     }
446
+
447
+     public function change_title_text( $title ) {
448
+          $screen = get_current_screen();
449
+
450
+          if ( 'team' === $screen->post_type ) {
451
+               $title = esc_attr__( 'Enter team member name', 'lsx-team' );
452
+          }
453
+
454
+          return $title;
455
+     }
456 456
 }
457 457
 
458 458
 $lsx_team_admin = new LSX_Team_Admin();
Please login to merge, or discard this patch.