Passed
Push — master ( 294a1f...bd0a4e )
by Virginia
03:23
created
templates/content-single-projects.php 2 patches
Indentation   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -5,230 +5,230 @@  discard block
 block discarded – undo
5 5
 ?>
6 6
 
7 7
 <?php
8
-	$client = get_post_meta( get_the_ID(), 'lsx_project_client', true );
9
-	$client_logo = get_post_meta( get_the_ID(), 'lsx_project_client_logo', true );
10
-	$url = get_post_meta( get_the_ID(), 'lsx_project_url', true );
11
-
12
-	global $lsx_projects;
13
-
14
-	$button_label = '';
15
-	$button_cf_id = '';
16
-
17
-	if ( ! empty( projects_get_option( 'projects_modal_enable' ) ) ) {
18
-		if ( ! empty( projects_get_option( 'projects_modal_cta_label' ) ) && ! empty( projects_get_option( 'projects_modal_form_id' ) ) ) {
19
-			$button_label = projects_get_option( 'projects_modal_cta_label' );
20
-			$button_cf_id = projects_get_option( 'projects_modal_form_id' );
21
-		}
22
-	}
23
-
24
-	if ( ! empty( $client_logo ) ) {
25
-		$client_logo = '<img src="' . $client_logo . '">';
26
-	}
27
-
28
-	$groups = '';
29
-	$terms  = get_the_terms( get_the_ID(), 'project-group' );
30
-
31
-	if ( $terms && ! is_wp_error( $terms ) ) {
32
-		$groups = array();
33
-
34
-		foreach ( $terms as $term ) {
35
-			$groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
36
-		}
37
-
38
-		$groups = join( ', ', $groups );
39
-	}
40
-
41
-	$product_groups = '';
42
-	$product_terms = get_post_meta( get_the_ID(), 'lsx_project__alt_products', false );
43
-
44
-	if ( $product_terms && ! is_wp_error( $product_terms ) ) {
45
-		$product_groups = array();
46
-		foreach ( $product_terms[0] as $product_term ) {
47
-			$product_groups[] = '<a href="' . $product_term['lsx_project_alt_product_link'] . '">' . $product_term['lsx_project_alt_product_title'] . '</a>';
48
-		}
49
-
50
-		$product_groups = join( ', ', $product_groups );
51
-	}
52
-
53
-
54
-	// Connections
55
-
56
-	$connections = array();
57
-
58
-	// Connection Projects
59
-
60
-	if ( $terms && ! is_wp_error( $terms ) ) {
61
-		$groups_ = array();
62
-
63
-		foreach ( $terms as $term ) {
64
-			$groups_[] = $term->term_id;
65
-		}
66
-
67
-		if ( count( $groups_ ) > 0 ) {
68
-			$connection_project['post_type'] = 'project';
69
-			$connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' );
70
-			//$connection_project['posts'] = get_post_meta( get_the_ID(), 'project_to_project', false );
71
-			$connection_project['posts'] = array();
72
-
73
-			$args = array(
74
-				'post_type'              => 'project',
75
-				'post__not_in'           => array( get_the_ID() ),
76
-				'no_found_rows'          => true,
77
-				'ignore_sticky_posts'    => 1,
78
-				'update_post_meta_cache' => false,
79
-				'tax_query' => array(
80
-					array(
81
-						'taxonomy' => 'project-group',
82
-						'terms'    => $groups_,
83
-					),
84
-				),
85
-			);
86
-
87
-			$projects_ = new \WP_Query( $args );
88
-
89
-			if ( $projects_->have_posts() ) {
90
-				while ( $projects_->have_posts() ) {
91
-					$projects_->the_post();
92
-					$connection_project['posts'][] = get_the_ID();
93
-					wp_reset_postdata();
94
-				}
95
-			}
96
-
97
-			if ( ! empty( $connection_project['posts'] ) ) {
98
-				$post_ids = join( ',', $connection_project['posts'] );
99
-				$connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
100
-				$connections[] = $connection_project;
101
-			}
102
-		}
103
-	}
104
-
105
-	// Connection Products
106
-
107
-	if ( class_exists( 'WooCommerce' ) ) {
108
-		$connection_product['post_type'] = 'product';
109
-		$connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>';
110
-		$connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false );
111
-
112
-		if ( ! empty( $connection_product['posts'] ) ) {
113
-			$connection_product['small_list_html'] = '';
114
-
115
-			$args = array(
116
-				'post_type'              => 'product',
117
-				'post__in'               => $connection_product['posts'][0],
118
-				'orderby'                => 'post__in',
119
-				'no_found_rows'          => true,
120
-				'ignore_sticky_posts'    => 1,
121
-				'update_post_term_cache' => false,
122
-				'update_post_meta_cache' => false,
123
-			);
124
-
125
-			$connection_product['posts_obj'] = new \WP_Query( $args );
126
-
127
-			if ( $connection_product['posts_obj']->have_posts() ) {
128
-				$connection_product['small_list_html'] = array();
129
-
130
-				while ( $connection_product['posts_obj']->have_posts() ) {
131
-					$connection_product['posts_obj']->the_post();
132
-					$connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
133
-					wp_reset_postdata();
134
-				}
135
-
136
-				$connection_product['posts_obj']->rewind_posts();
137
-				$connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] );
138
-			}
139
-
140
-			$connections[] = $connection_product;
141
-		}
142
-	}
143
-
144
-	// Connection Services
145
-
146
-	$connection_service['post_type'] = 'page';
147
-	// $connection_service['title'] = esc_html__( 'Services', 'lsx-projects' );
148
-	$connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false );
149
-
150
-	if ( ! empty( $connection_service['pages'] ) ) {
151
-		$post_ids = join( ',', $connection_service['pages'] );
152
-		//$connection_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
153
-		$connection_service['small_list_html'] = '';
154
-
155
-		$args = array(
156
-			'post_type'              => 'page',
157
-			'post__in'               => $connection_service['pages'],
158
-			'orderby'                => 'post__in',
159
-			'no_found_rows'          => true,
160
-			'ignore_sticky_posts'    => 1,
161
-			'update_post_term_cache' => false,
162
-			'update_post_meta_cache' => false,
163
-		);
164
-
165
-		$services_ = new \WP_Query( $args );
166
-
167
-		if ( $services_->have_posts() ) {
168
-			$connection_service['small_list_html'] = array();
169
-
170
-			while ( $services_->have_posts() ) {
171
-				$services_->the_post();
172
-				$connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
173
-				wp_reset_postdata();
174
-			}
175
-
176
-			$connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] );
177
-		}
178
-
179
-		$connections[] = $connection_service;
180
-	}
181
-
182
-	// Connection Testimonials
183
-
184
-	$connection_testimonial['post_type'] = 'testimonial';
185
-	// $connection_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-projects' );
186
-	$connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false );
187
-
188
-	if ( ! empty( $connection_testimonial['posts'] ) ) {
189
-		$post_ids = join( ',', $connection_testimonial['posts'][0] );
190
-		$connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]';
191
-		$connections[] = $connection_testimonial;
192
-	}
193
-
194
-	// Connection Team
195
-
196
-	$connection_team['post_type'] = 'team';
197
-	// $connection_team['title'] = esc_html__( 'Team', 'lsx-projects' );
198
-	$connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false );
199
-
200
-	if ( ! empty( $connection_team['posts'] ) ) {
201
-		$post_ids = join( ',', $connection_team['posts'][0] );
202
-		$connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]';
203
-		$connection_team['small_list_html'] = '';
204
-
205
-		$args = array(
206
-			'post_type'              => 'team',
207
-			'post__in'               => $connection_team['posts'][0],
208
-			'orderby'                => 'post__in',
209
-			'no_found_rows'          => true,
210
-			'ignore_sticky_posts'    => 1,
211
-			'update_post_term_cache' => false,
212
-			'update_post_meta_cache' => false,
213
-		);
214
-
215
-		$team_ = new \WP_Query( $args );
216
-
217
-		if ( $team_->have_posts() ) {
218
-			global $lsx_team;
219
-			$connection_team['small_list_html'] = array();
220
-
221
-			while ( $team_->have_posts() ) {
222
-				$team_->the_post();
223
-				$connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>';
224
-				wp_reset_postdata();
225
-			}
226
-
227
-			$connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] );
228
-		}
229
-
230
-		$connections[] = $connection_team;
231
-	}
8
+     $client = get_post_meta( get_the_ID(), 'lsx_project_client', true );
9
+     $client_logo = get_post_meta( get_the_ID(), 'lsx_project_client_logo', true );
10
+     $url = get_post_meta( get_the_ID(), 'lsx_project_url', true );
11
+
12
+     global $lsx_projects;
13
+
14
+     $button_label = '';
15
+     $button_cf_id = '';
16
+
17
+     if ( ! empty( projects_get_option( 'projects_modal_enable' ) ) ) {
18
+          if ( ! empty( projects_get_option( 'projects_modal_cta_label' ) ) && ! empty( projects_get_option( 'projects_modal_form_id' ) ) ) {
19
+               $button_label = projects_get_option( 'projects_modal_cta_label' );
20
+               $button_cf_id = projects_get_option( 'projects_modal_form_id' );
21
+          }
22
+     }
23
+
24
+     if ( ! empty( $client_logo ) ) {
25
+          $client_logo = '<img src="' . $client_logo . '">';
26
+     }
27
+
28
+     $groups = '';
29
+     $terms  = get_the_terms( get_the_ID(), 'project-group' );
30
+
31
+     if ( $terms && ! is_wp_error( $terms ) ) {
32
+          $groups = array();
33
+
34
+          foreach ( $terms as $term ) {
35
+               $groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
36
+          }
37
+
38
+          $groups = join( ', ', $groups );
39
+     }
40
+
41
+     $product_groups = '';
42
+     $product_terms = get_post_meta( get_the_ID(), 'lsx_project__alt_products', false );
43
+
44
+     if ( $product_terms && ! is_wp_error( $product_terms ) ) {
45
+          $product_groups = array();
46
+          foreach ( $product_terms[0] as $product_term ) {
47
+               $product_groups[] = '<a href="' . $product_term['lsx_project_alt_product_link'] . '">' . $product_term['lsx_project_alt_product_title'] . '</a>';
48
+          }
49
+
50
+          $product_groups = join( ', ', $product_groups );
51
+     }
52
+
53
+
54
+     // Connections
55
+
56
+     $connections = array();
57
+
58
+     // Connection Projects
59
+
60
+     if ( $terms && ! is_wp_error( $terms ) ) {
61
+          $groups_ = array();
62
+
63
+          foreach ( $terms as $term ) {
64
+               $groups_[] = $term->term_id;
65
+          }
66
+
67
+          if ( count( $groups_ ) > 0 ) {
68
+               $connection_project['post_type'] = 'project';
69
+               $connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' );
70
+               //$connection_project['posts'] = get_post_meta( get_the_ID(), 'project_to_project', false );
71
+               $connection_project['posts'] = array();
72
+
73
+               $args = array(
74
+                    'post_type'              => 'project',
75
+                    'post__not_in'           => array( get_the_ID() ),
76
+                    'no_found_rows'          => true,
77
+                    'ignore_sticky_posts'    => 1,
78
+                    'update_post_meta_cache' => false,
79
+                    'tax_query' => array(
80
+                         array(
81
+                              'taxonomy' => 'project-group',
82
+                              'terms'    => $groups_,
83
+                         ),
84
+                    ),
85
+               );
86
+
87
+               $projects_ = new \WP_Query( $args );
88
+
89
+               if ( $projects_->have_posts() ) {
90
+                    while ( $projects_->have_posts() ) {
91
+                         $projects_->the_post();
92
+                         $connection_project['posts'][] = get_the_ID();
93
+                         wp_reset_postdata();
94
+                    }
95
+               }
96
+
97
+               if ( ! empty( $connection_project['posts'] ) ) {
98
+                    $post_ids = join( ',', $connection_project['posts'] );
99
+                    $connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
100
+                    $connections[] = $connection_project;
101
+               }
102
+          }
103
+     }
104
+
105
+     // Connection Products
106
+
107
+     if ( class_exists( 'WooCommerce' ) ) {
108
+          $connection_product['post_type'] = 'product';
109
+          $connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>';
110
+          $connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false );
111
+
112
+          if ( ! empty( $connection_product['posts'] ) ) {
113
+               $connection_product['small_list_html'] = '';
114
+
115
+               $args = array(
116
+                    'post_type'              => 'product',
117
+                    'post__in'               => $connection_product['posts'][0],
118
+                    'orderby'                => 'post__in',
119
+                    'no_found_rows'          => true,
120
+                    'ignore_sticky_posts'    => 1,
121
+                    'update_post_term_cache' => false,
122
+                    'update_post_meta_cache' => false,
123
+               );
124
+
125
+               $connection_product['posts_obj'] = new \WP_Query( $args );
126
+
127
+               if ( $connection_product['posts_obj']->have_posts() ) {
128
+                    $connection_product['small_list_html'] = array();
129
+
130
+                    while ( $connection_product['posts_obj']->have_posts() ) {
131
+                         $connection_product['posts_obj']->the_post();
132
+                         $connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
133
+                         wp_reset_postdata();
134
+                    }
135
+
136
+                    $connection_product['posts_obj']->rewind_posts();
137
+                    $connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] );
138
+               }
139
+
140
+               $connections[] = $connection_product;
141
+          }
142
+     }
143
+
144
+     // Connection Services
145
+
146
+     $connection_service['post_type'] = 'page';
147
+     // $connection_service['title'] = esc_html__( 'Services', 'lsx-projects' );
148
+     $connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false );
149
+
150
+     if ( ! empty( $connection_service['pages'] ) ) {
151
+          $post_ids = join( ',', $connection_service['pages'] );
152
+          //$connection_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
153
+          $connection_service['small_list_html'] = '';
154
+
155
+          $args = array(
156
+               'post_type'              => 'page',
157
+               'post__in'               => $connection_service['pages'],
158
+               'orderby'                => 'post__in',
159
+               'no_found_rows'          => true,
160
+               'ignore_sticky_posts'    => 1,
161
+               'update_post_term_cache' => false,
162
+               'update_post_meta_cache' => false,
163
+          );
164
+
165
+          $services_ = new \WP_Query( $args );
166
+
167
+          if ( $services_->have_posts() ) {
168
+               $connection_service['small_list_html'] = array();
169
+
170
+               while ( $services_->have_posts() ) {
171
+                    $services_->the_post();
172
+                    $connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
173
+                    wp_reset_postdata();
174
+               }
175
+
176
+               $connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] );
177
+          }
178
+
179
+          $connections[] = $connection_service;
180
+     }
181
+
182
+     // Connection Testimonials
183
+
184
+     $connection_testimonial['post_type'] = 'testimonial';
185
+     // $connection_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-projects' );
186
+     $connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false );
187
+
188
+     if ( ! empty( $connection_testimonial['posts'] ) ) {
189
+          $post_ids = join( ',', $connection_testimonial['posts'][0] );
190
+          $connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]';
191
+          $connections[] = $connection_testimonial;
192
+     }
193
+
194
+     // Connection Team
195
+
196
+     $connection_team['post_type'] = 'team';
197
+     // $connection_team['title'] = esc_html__( 'Team', 'lsx-projects' );
198
+     $connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false );
199
+
200
+     if ( ! empty( $connection_team['posts'] ) ) {
201
+          $post_ids = join( ',', $connection_team['posts'][0] );
202
+          $connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]';
203
+          $connection_team['small_list_html'] = '';
204
+
205
+          $args = array(
206
+               'post_type'              => 'team',
207
+               'post__in'               => $connection_team['posts'][0],
208
+               'orderby'                => 'post__in',
209
+               'no_found_rows'          => true,
210
+               'ignore_sticky_posts'    => 1,
211
+               'update_post_term_cache' => false,
212
+               'update_post_meta_cache' => false,
213
+          );
214
+
215
+          $team_ = new \WP_Query( $args );
216
+
217
+          if ( $team_->have_posts() ) {
218
+               global $lsx_team;
219
+               $connection_team['small_list_html'] = array();
220
+
221
+               while ( $team_->have_posts() ) {
222
+                    $team_->the_post();
223
+                    $connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>';
224
+                    wp_reset_postdata();
225
+               }
226
+
227
+               $connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] );
228
+          }
229
+
230
+          $connections[] = $connection_team;
231
+     }
232 232
 ?>
233 233
 
234 234
 <?php lsx_entry_before(); ?>
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 			<?php if ( count( $connections ) > 0 ) : ?>
245 245
 				<?php foreach ( $connections as $i => $connection ) : ?>
246 246
 					<?php
247
-						if ( 'testimonial' === $connection['post_type'] ) {
248
-							echo '<div class="tab-pane-fake">';
249
-							echo do_shortcode( $connection['shortcode'] );
250
-							echo '</div>';
251
-						}
252
-					?>
247
+                              if ( 'testimonial' === $connection['post_type'] ) {
248
+                                   echo '<div class="tab-pane-fake">';
249
+                                   echo do_shortcode( $connection['shortcode'] );
250
+                                   echo '</div>';
251
+                              }
252
+                         ?>
253 253
 				<?php endforeach; ?>
254 254
 			<?php endif; ?>
255 255
 		</div>
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 	<?php if ( count( $connections ) > 0 ) : ?>
306 306
 		<?php foreach ( $connections as $i => $connection ) : ?>
307 307
 			<?php
308
-				// Team is now visible on detail box
309
-				// Services is now visible on detail box
310
-				// Testimonials is now visible below the content
311
-				if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) {
312
-					continue;
313
-				}
314
-			?>
308
+                    // Team is now visible on detail box
309
+                    // Services is now visible on detail box
310
+                    // Testimonials is now visible below the content
311
+                    if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) {
312
+                         continue;
313
+                    }
314
+               ?>
315 315
 			<?php if ( 'page' !== $connection['post_type'] ) { ?>
316 316
 				<div class="lsx-projects-section lsx-full-width">
317 317
 					<div class="row">
@@ -319,34 +319,34 @@  discard block
 block discarded – undo
319 319
 							<h3 class="lsx-title"><?php echo wp_kses_post( $connection['title'] ); ?></h3>
320 320
 
321 321
 							<?php
322
-								if ( 'product' === $connection['post_type'] ) {
323
-
324
-									if ( $connection_product['posts_obj']->have_posts() ) {
325
-										// @codingStandardsIgnoreLine
326
-										echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
327
-
328
-										while ( $connection_product['posts_obj']->have_posts() ) {
329
-											$connection_product['posts_obj']->the_post();
330
-											wc_get_template( 'content-widget-product.php', array(
331
-												'show_rating' => false,
332
-											) );
333
-
334
-											wp_reset_postdata();
335
-										}
336
-
337
-										// @codingStandardsIgnoreLine
338
-										echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
339
-									}
340
-								} else {
341
-									echo do_shortcode( $connection['shortcode'] );
342
-								}
343
-							?>
322
+                                        if ( 'product' === $connection['post_type'] ) {
323
+
324
+                                             if ( $connection_product['posts_obj']->have_posts() ) {
325
+                                                  // @codingStandardsIgnoreLine
326
+                                                  echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
327
+
328
+                                                  while ( $connection_product['posts_obj']->have_posts() ) {
329
+                                                       $connection_product['posts_obj']->the_post();
330
+                                                       wc_get_template( 'content-widget-product.php', array(
331
+                                                            'show_rating' => false,
332
+                                                       ) );
333
+
334
+                                                       wp_reset_postdata();
335
+                                                  }
336
+
337
+                                                  // @codingStandardsIgnoreLine
338
+                                                  echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
339
+                                             }
340
+                                        } else {
341
+                                             echo do_shortcode( $connection['shortcode'] );
342
+                                        }
343
+                                   ?>
344 344
 						</div>
345 345
 					</div>
346 346
 				</div>
347 347
 			<?php
348
-			}
349
-		?>
348
+               }
349
+          ?>
350 350
 		<?php endforeach; ?>
351 351
 	<?php endif; ?>
352 352
 
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -5,49 +5,49 @@  discard block
 block discarded – undo
5 5
 ?>
6 6
 
7 7
 <?php
8
-	$client = get_post_meta( get_the_ID(), 'lsx_project_client', true );
9
-	$client_logo = get_post_meta( get_the_ID(), 'lsx_project_client_logo', true );
10
-	$url = get_post_meta( get_the_ID(), 'lsx_project_url', true );
8
+	$client = get_post_meta(get_the_ID(), 'lsx_project_client', true);
9
+	$client_logo = get_post_meta(get_the_ID(), 'lsx_project_client_logo', true);
10
+	$url = get_post_meta(get_the_ID(), 'lsx_project_url', true);
11 11
 
12 12
 	global $lsx_projects;
13 13
 
14 14
 	$button_label = '';
15 15
 	$button_cf_id = '';
16 16
 
17
-	if ( ! empty( projects_get_option( 'projects_modal_enable' ) ) ) {
18
-		if ( ! empty( projects_get_option( 'projects_modal_cta_label' ) ) && ! empty( projects_get_option( 'projects_modal_form_id' ) ) ) {
19
-			$button_label = projects_get_option( 'projects_modal_cta_label' );
20
-			$button_cf_id = projects_get_option( 'projects_modal_form_id' );
17
+	if ( ! empty(projects_get_option('projects_modal_enable'))) {
18
+		if ( ! empty(projects_get_option('projects_modal_cta_label')) && ! empty(projects_get_option('projects_modal_form_id'))) {
19
+			$button_label = projects_get_option('projects_modal_cta_label');
20
+			$button_cf_id = projects_get_option('projects_modal_form_id');
21 21
 		}
22 22
 	}
23 23
 
24
-	if ( ! empty( $client_logo ) ) {
24
+	if ( ! empty($client_logo)) {
25 25
 		$client_logo = '<img src="' . $client_logo . '">';
26 26
 	}
27 27
 
28 28
 	$groups = '';
29
-	$terms  = get_the_terms( get_the_ID(), 'project-group' );
29
+	$terms  = get_the_terms(get_the_ID(), 'project-group');
30 30
 
31
-	if ( $terms && ! is_wp_error( $terms ) ) {
31
+	if ($terms && ! is_wp_error($terms)) {
32 32
 		$groups = array();
33 33
 
34
-		foreach ( $terms as $term ) {
35
-			$groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
34
+		foreach ($terms as $term) {
35
+			$groups[] = '<a href="' . get_term_link($term) . '">' . $term->name . '</a>';
36 36
 		}
37 37
 
38
-		$groups = join( ', ', $groups );
38
+		$groups = join(', ', $groups);
39 39
 	}
40 40
 
41 41
 	$product_groups = '';
42
-	$product_terms = get_post_meta( get_the_ID(), 'lsx_project__alt_products', false );
42
+	$product_terms = get_post_meta(get_the_ID(), 'lsx_project__alt_products', false);
43 43
 
44
-	if ( $product_terms && ! is_wp_error( $product_terms ) ) {
44
+	if ($product_terms && ! is_wp_error($product_terms)) {
45 45
 		$product_groups = array();
46
-		foreach ( $product_terms[0] as $product_term ) {
46
+		foreach ($product_terms[0] as $product_term) {
47 47
 			$product_groups[] = '<a href="' . $product_term['lsx_project_alt_product_link'] . '">' . $product_term['lsx_project_alt_product_title'] . '</a>';
48 48
 		}
49 49
 
50
-		$product_groups = join( ', ', $product_groups );
50
+		$product_groups = join(', ', $product_groups);
51 51
 	}
52 52
 
53 53
 
@@ -57,22 +57,22 @@  discard block
 block discarded – undo
57 57
 
58 58
 	// Connection Projects
59 59
 
60
-	if ( $terms && ! is_wp_error( $terms ) ) {
60
+	if ($terms && ! is_wp_error($terms)) {
61 61
 		$groups_ = array();
62 62
 
63
-		foreach ( $terms as $term ) {
63
+		foreach ($terms as $term) {
64 64
 			$groups_[] = $term->term_id;
65 65
 		}
66 66
 
67
-		if ( count( $groups_ ) > 0 ) {
67
+		if (count($groups_) > 0) {
68 68
 			$connection_project['post_type'] = 'project';
69
-			$connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' );
69
+			$connection_project['title'] = esc_html__('Related Projects', 'lsx-projects');
70 70
 			//$connection_project['posts'] = get_post_meta( get_the_ID(), 'project_to_project', false );
71 71
 			$connection_project['posts'] = array();
72 72
 
73 73
 			$args = array(
74 74
 				'post_type'              => 'project',
75
-				'post__not_in'           => array( get_the_ID() ),
75
+				'post__not_in'           => array(get_the_ID()),
76 76
 				'no_found_rows'          => true,
77 77
 				'ignore_sticky_posts'    => 1,
78 78
 				'update_post_meta_cache' => false,
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 				),
85 85
 			);
86 86
 
87
-			$projects_ = new \WP_Query( $args );
87
+			$projects_ = new \WP_Query($args);
88 88
 
89
-			if ( $projects_->have_posts() ) {
90
-				while ( $projects_->have_posts() ) {
89
+			if ($projects_->have_posts()) {
90
+				while ($projects_->have_posts()) {
91 91
 					$projects_->the_post();
92 92
 					$connection_project['posts'][] = get_the_ID();
93 93
 					wp_reset_postdata();
94 94
 				}
95 95
 			}
96 96
 
97
-			if ( ! empty( $connection_project['posts'] ) ) {
98
-				$post_ids = join( ',', $connection_project['posts'] );
97
+			if ( ! empty($connection_project['posts'])) {
98
+				$post_ids = join(',', $connection_project['posts']);
99 99
 				$connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
100 100
 				$connections[] = $connection_project;
101 101
 			}
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 
105 105
 	// Connection Products
106 106
 
107
-	if ( class_exists( 'WooCommerce' ) ) {
107
+	if (class_exists('WooCommerce')) {
108 108
 		$connection_product['post_type'] = 'product';
109
-		$connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>';
110
-		$connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false );
109
+		$connection_product['title'] = esc_html__('Related Products', 'lsx-projects') . ' <small>' . esc_html__('Products used to build this project', 'lsx-projects') . '</small>';
110
+		$connection_product['posts'] = get_post_meta(get_the_ID(), 'product_to_project', false);
111 111
 
112
-		if ( ! empty( $connection_product['posts'] ) ) {
112
+		if ( ! empty($connection_product['posts'])) {
113 113
 			$connection_product['small_list_html'] = '';
114 114
 
115 115
 			$args = array(
@@ -122,19 +122,19 @@  discard block
 block discarded – undo
122 122
 				'update_post_meta_cache' => false,
123 123
 			);
124 124
 
125
-			$connection_product['posts_obj'] = new \WP_Query( $args );
125
+			$connection_product['posts_obj'] = new \WP_Query($args);
126 126
 
127
-			if ( $connection_product['posts_obj']->have_posts() ) {
127
+			if ($connection_product['posts_obj']->have_posts()) {
128 128
 				$connection_product['small_list_html'] = array();
129 129
 
130
-				while ( $connection_product['posts_obj']->have_posts() ) {
130
+				while ($connection_product['posts_obj']->have_posts()) {
131 131
 					$connection_product['posts_obj']->the_post();
132
-					$connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
132
+					$connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title('', '', false) . '</a>';
133 133
 					wp_reset_postdata();
134 134
 				}
135 135
 
136 136
 				$connection_product['posts_obj']->rewind_posts();
137
-				$connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] );
137
+				$connection_product['small_list_html'] = join(', ', $connection_product['small_list_html']);
138 138
 			}
139 139
 
140 140
 			$connections[] = $connection_product;
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 
146 146
 	$connection_service['post_type'] = 'page';
147 147
 	// $connection_service['title'] = esc_html__( 'Services', 'lsx-projects' );
148
-	$connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false );
148
+	$connection_service['pages'] = get_post_meta(get_the_ID(), 'page_to_project', false);
149 149
 
150
-	if ( ! empty( $connection_service['pages'] ) ) {
151
-		$post_ids = join( ',', $connection_service['pages'] );
150
+	if ( ! empty($connection_service['pages'])) {
151
+		$post_ids = join(',', $connection_service['pages']);
152 152
 		//$connection_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
153 153
 		$connection_service['small_list_html'] = '';
154 154
 
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 			'update_post_meta_cache' => false,
163 163
 		);
164 164
 
165
-		$services_ = new \WP_Query( $args );
165
+		$services_ = new \WP_Query($args);
166 166
 
167
-		if ( $services_->have_posts() ) {
167
+		if ($services_->have_posts()) {
168 168
 			$connection_service['small_list_html'] = array();
169 169
 
170
-			while ( $services_->have_posts() ) {
170
+			while ($services_->have_posts()) {
171 171
 				$services_->the_post();
172
-				$connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
172
+				$connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title('', '', false) . '</a>';
173 173
 				wp_reset_postdata();
174 174
 			}
175 175
 
176
-			$connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] );
176
+			$connection_service['small_list_html'] = join(', ', $connection_service['small_list_html']);
177 177
 		}
178 178
 
179 179
 		$connections[] = $connection_service;
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 
184 184
 	$connection_testimonial['post_type'] = 'testimonial';
185 185
 	// $connection_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-projects' );
186
-	$connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false );
186
+	$connection_testimonial['posts'] = get_post_meta(get_the_ID(), 'testimonial_to_project', false);
187 187
 
188
-	if ( ! empty( $connection_testimonial['posts'] ) ) {
189
-		$post_ids = join( ',', $connection_testimonial['posts'][0] );
188
+	if ( ! empty($connection_testimonial['posts'])) {
189
+		$post_ids = join(',', $connection_testimonial['posts'][0]);
190 190
 		$connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]';
191 191
 		$connections[] = $connection_testimonial;
192 192
 	}
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 
196 196
 	$connection_team['post_type'] = 'team';
197 197
 	// $connection_team['title'] = esc_html__( 'Team', 'lsx-projects' );
198
-	$connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false );
198
+	$connection_team['posts'] = get_post_meta(get_the_ID(), 'team_to_project', false);
199 199
 
200
-	if ( ! empty( $connection_team['posts'] ) ) {
201
-		$post_ids = join( ',', $connection_team['posts'][0] );
200
+	if ( ! empty($connection_team['posts'])) {
201
+		$post_ids = join(',', $connection_team['posts'][0]);
202 202
 		$connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]';
203 203
 		$connection_team['small_list_html'] = '';
204 204
 
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 			'update_post_meta_cache' => false,
213 213
 		);
214 214
 
215
-		$team_ = new \WP_Query( $args );
215
+		$team_ = new \WP_Query($args);
216 216
 
217
-		if ( $team_->have_posts() ) {
217
+		if ($team_->have_posts()) {
218 218
 			global $lsx_team;
219 219
 			$connection_team['small_list_html'] = array();
220 220
 
221
-			while ( $team_->have_posts() ) {
221
+			while ($team_->have_posts()) {
222 222
 				$team_->the_post();
223
-				$connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>';
223
+				$connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail(get_the_ID(), 'lsx-team-archive') . '</a>';
224 224
 				wp_reset_postdata();
225 225
 			}
226 226
 
227
-			$connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] );
227
+			$connection_team['small_list_html'] = join(' ', $connection_team['small_list_html']);
228 228
 		}
229 229
 
230 230
 		$connections[] = $connection_team;
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 		<div class="col-xs-12 col-sm-7 col-md-8">
242 242
 			<div class="entry-content"><?php the_content(); ?></div>
243 243
 
244
-			<?php if ( count( $connections ) > 0 ) : ?>
245
-				<?php foreach ( $connections as $i => $connection ) : ?>
244
+			<?php if (count($connections) > 0) : ?>
245
+				<?php foreach ($connections as $i => $connection) : ?>
246 246
 					<?php
247
-						if ( 'testimonial' === $connection['post_type'] ) {
247
+						if ('testimonial' === $connection['post_type']) {
248 248
 							echo '<div class="tab-pane-fake">';
249
-							echo do_shortcode( $connection['shortcode'] );
249
+							echo do_shortcode($connection['shortcode']);
250 250
 							echo '</div>';
251 251
 						}
252 252
 					?>
@@ -257,88 +257,88 @@  discard block
 block discarded – undo
257 257
 		<div class="col-xs-12 col-sm-5 col-md-4">
258 258
 			<div class="entry-fixed-sidebar-wrapper">
259 259
 				<div class="entry-fixed-sidebar">
260
-					<?php if ( ! empty( $client_logo ) ) : ?>
261
-						<div class="entry-meta-single"><?php echo wp_kses_post( $client_logo ); ?></div>
262
-					<?php elseif ( ! empty( $client ) ) : ?>
263
-						<div class="entry-meta-single"><?php echo esc_html( $client ); ?></div>
260
+					<?php if ( ! empty($client_logo)) : ?>
261
+						<div class="entry-meta-single"><?php echo wp_kses_post($client_logo); ?></div>
262
+					<?php elseif ( ! empty($client)) : ?>
263
+						<div class="entry-meta-single"><?php echo esc_html($client); ?></div>
264 264
 					<?php endif; ?>
265 265
 
266
-					<?php if ( ! empty( $groups ) ) : ?>
267
-						<div class="entry-meta-key"><?php esc_html_e( 'Industry:', 'lsx-projects' ); ?></div>
268
-						<div class="entry-meta-value"><?php echo wp_kses_post( $groups ); ?></div>
266
+					<?php if ( ! empty($groups)) : ?>
267
+						<div class="entry-meta-key"><?php esc_html_e('Industry:', 'lsx-projects'); ?></div>
268
+						<div class="entry-meta-value"><?php echo wp_kses_post($groups); ?></div>
269 269
 					<?php endif; ?>
270 270
 
271
-					<?php if ( ! empty( $product_groups ) ) : ?>
272
-						<div class="entry-meta-key"><?php esc_html_e( 'Products:', 'lsx-projects' ); ?></div>
273
-						<div class="entry-meta-value"><?php echo wp_kses_post( $product_groups ); ?></div>
271
+					<?php if ( ! empty($product_groups)) : ?>
272
+						<div class="entry-meta-key"><?php esc_html_e('Products:', 'lsx-projects'); ?></div>
273
+						<div class="entry-meta-value"><?php echo wp_kses_post($product_groups); ?></div>
274 274
 					<?php endif; ?>
275 275
 
276
-					<?php if ( ! empty( $connection_service['small_list_html'] ) ) : ?>
277
-						<div class="entry-meta-key"><?php esc_html_e( 'Services:', 'lsx-projects' ); ?></div>
278
-						<div class="entry-meta-value"><?php echo wp_kses_post( $connection_service['small_list_html'] ); ?></div>
276
+					<?php if ( ! empty($connection_service['small_list_html'])) : ?>
277
+						<div class="entry-meta-key"><?php esc_html_e('Services:', 'lsx-projects'); ?></div>
278
+						<div class="entry-meta-value"><?php echo wp_kses_post($connection_service['small_list_html']); ?></div>
279 279
 					<?php endif; ?>
280 280
 
281
-					<?php if ( ! empty( $connection_product['small_list_html'] ) ) : ?>
281
+					<?php if ( ! empty($connection_product['small_list_html'])) : ?>
282 282
 						<!--
283
-						<div class="entry-meta-key"><?php esc_html_e( 'Products used:', 'lsx-projects' ); ?></div>
284
-						<div class="entry-meta-value"><?php echo wp_kses_post( $connection_product['small_list_html'] ); ?></div>
283
+						<div class="entry-meta-key"><?php esc_html_e('Products used:', 'lsx-projects'); ?></div>
284
+						<div class="entry-meta-value"><?php echo wp_kses_post($connection_product['small_list_html']); ?></div>
285 285
 						-->
286 286
 					<?php endif; ?>
287 287
 
288
-					<?php if ( ! empty( $connection_team['small_list_html'] ) ) : ?>
289
-						<div class="entry-meta-key"><?php esc_html_e( 'Team members involved:', 'lsx-projects' ); ?></div>
290
-						<div class="entry-meta-value entry-meta-value-team"><?php echo wp_kses_post( $connection_team['small_list_html'] ); ?></div>
288
+					<?php if ( ! empty($connection_team['small_list_html'])) : ?>
289
+						<div class="entry-meta-key"><?php esc_html_e('Team members involved:', 'lsx-projects'); ?></div>
290
+						<div class="entry-meta-value entry-meta-value-team"><?php echo wp_kses_post($connection_team['small_list_html']); ?></div>
291 291
 					<?php endif; ?>
292 292
 
293
-					<?php if ( ! empty( $url ) ) : ?>
294
-						<div class="entry-meta-single"><a href="<?php echo esc_url( $url ); ?>" target="_blank" rel="nofollow" class="btn btn-block secondary-btn"><?php esc_html_e( 'See website', 'lsx-projects' ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
293
+					<?php if ( ! empty($url)) : ?>
294
+						<div class="entry-meta-single"><a href="<?php echo esc_url($url); ?>" target="_blank" rel="nofollow" class="btn btn-block secondary-btn"><?php esc_html_e('See website', 'lsx-projects'); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
295 295
 					<?php endif; ?>
296 296
 
297
-					<?php if ( ! empty( $button_label ) ) : ?>
298
-						<div class="entry-meta-single"><a href="#lsx-project-contact" data-toggle="modal" class="btn btn-block cta-btn"><?php echo esc_html( $button_label ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
297
+					<?php if ( ! empty($button_label)) : ?>
298
+						<div class="entry-meta-single"><a href="#lsx-project-contact" data-toggle="modal" class="btn btn-block cta-btn"><?php echo esc_html($button_label); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
299 299
 					<?php endif; ?>
300 300
 				</div>
301 301
 			</div>
302 302
 		</div>
303 303
 	</div>
304 304
 
305
-	<?php if ( count( $connections ) > 0 ) : ?>
306
-		<?php foreach ( $connections as $i => $connection ) : ?>
305
+	<?php if (count($connections) > 0) : ?>
306
+		<?php foreach ($connections as $i => $connection) : ?>
307 307
 			<?php
308 308
 				// Team is now visible on detail box
309 309
 				// Services is now visible on detail box
310 310
 				// Testimonials is now visible below the content
311
-				if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) {
311
+				if (in_array($connection['post_type'], array('team', 'testimonial', 'service'))) {
312 312
 					continue;
313 313
 				}
314 314
 			?>
315
-			<?php if ( 'page' !== $connection['post_type'] ) { ?>
315
+			<?php if ('page' !== $connection['post_type']) { ?>
316 316
 				<div class="lsx-projects-section lsx-full-width">
317 317
 					<div class="row">
318 318
 						<div class="col-xs-12">
319
-							<h3 class="lsx-title"><?php echo wp_kses_post( $connection['title'] ); ?></h3>
319
+							<h3 class="lsx-title"><?php echo wp_kses_post($connection['title']); ?></h3>
320 320
 
321 321
 							<?php
322
-								if ( 'product' === $connection['post_type'] ) {
322
+								if ('product' === $connection['post_type']) {
323 323
 
324
-									if ( $connection_product['posts_obj']->have_posts() ) {
324
+									if ($connection_product['posts_obj']->have_posts()) {
325 325
 										// @codingStandardsIgnoreLine
326
-										echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
326
+										echo apply_filters('woocommerce_before_widget_product_list', '<ul class="product_list_widget">');
327 327
 
328
-										while ( $connection_product['posts_obj']->have_posts() ) {
328
+										while ($connection_product['posts_obj']->have_posts()) {
329 329
 											$connection_product['posts_obj']->the_post();
330
-											wc_get_template( 'content-widget-product.php', array(
330
+											wc_get_template('content-widget-product.php', array(
331 331
 												'show_rating' => false,
332
-											) );
332
+											));
333 333
 
334 334
 											wp_reset_postdata();
335 335
 										}
336 336
 
337 337
 										// @codingStandardsIgnoreLine
338
-										echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
338
+										echo apply_filters('woocommerce_after_widget_product_list', '</ul>');
339 339
 									}
340 340
 								} else {
341
-									echo do_shortcode( $connection['shortcode'] );
341
+									echo do_shortcode($connection['shortcode']);
342 342
 								}
343 343
 							?>
344 344
 						</div>
Please login to merge, or discard this patch.
classes/class-lsx-projects-admin.php 2 patches
Indentation   +524 added lines, -524 removed lines patch added patch discarded remove patch
@@ -10,530 +10,530 @@
 block discarded – undo
10 10
  */
11 11
 class LSX_Projects_Admin {
12 12
 
13
-	public function __construct() {
14
-		$this->load_classes();
15
-
16
-		add_action( 'init', array( $this, 'post_type_setup' ) );
17
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
18
-		add_action( 'init', array( $this, 'taxonomy_project_type_setup' ) );
19
-		add_action( 'init', array( $this, 'taxonomy_project_tag_setup' ) );
20
-		add_filter( 'cmb2_admin_init', array( $this, 'field_setup' ) );
21
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_services_metaboxes' ) );
22
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_testimonials_metaboxes' ) );
23
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_team_metaboxes' ) );
24
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_woocommerce_metaboxes' ) );
25
-		add_filter( 'cmb2_admin_init', array( $this, 'project_field_setup_product' ) );
26
-		add_action( 'cmb_save_custom', array( $this, 'post_relations' ), 3, 20 );
27
-		add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
28
-
29
-		add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 );
30
-		add_filter( 'enter_title_here', array( $this, 'change_title_text' ) );
31
-	}
32
-
33
-	/**
34
-	 * Loads the admin subclasses
35
-	 */
36
-	private function load_classes() {
37
-		require_once LSX_PROJECTS_PATH . 'classes/admin/class-settings.php';
38
-		$this->settings = \lsx\projects\classes\admin\Settings::get_instance();
39
-
40
-		require_once LSX_PROJECTS_PATH . 'classes/admin/class-settings-theme.php';
41
-		$this->settings_theme = \lsx\projects\classes\admin\Settings_Theme::get_instance();
42
-	}
43
-
44
-	/**
45
-	 * Register the Project and Product Tag post type
46
-	 */
47
-	public function post_type_setup() {
48
-		$labels = array(
49
-			'name'               => esc_html_x( 'Projects', 'post type general name', 'lsx-projects' ),
50
-			'singular_name'      => esc_html_x( 'Project', 'post type singular name', 'lsx-projects' ),
51
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-projects' ),
52
-			'add_new_item'       => esc_html__( 'Add New Project', 'lsx-projects' ),
53
-			'edit_item'          => esc_html__( 'Edit Project', 'lsx-projects' ),
54
-			'new_item'           => esc_html__( 'New Project', 'lsx-projects' ),
55
-			'all_items'          => esc_html__( 'All Projects', 'lsx-projects' ),
56
-			'view_item'          => esc_html__( 'View Project', 'lsx-projects' ),
57
-			'search_items'       => esc_html__( 'Search Projects', 'lsx-projects' ),
58
-			'not_found'          => esc_html__( 'No projects found', 'lsx-projects' ),
59
-			'not_found_in_trash' => esc_html__( 'No projects found in Trash', 'lsx-projects' ),
60
-			'parent_item_colon'  => '',
61
-			'menu_name'          => esc_html_x( 'Projects', 'admin menu', 'lsx-projects' ),
62
-		);
63
-
64
-		$args = array(
65
-			'labels'             => $labels,
66
-			'public'             => true,
67
-			'publicly_queryable' => true,
68
-			'show_ui'            => true,
69
-			'show_in_menu'       => true,
70
-			'menu_icon'          => 'dashicons-portfolio',
71
-			'query_var'          => true,
72
-			'rewrite'            => array(
73
-				'slug' => 'portfolio',
74
-			),
75
-			'capability_type'    => 'post',
76
-			'has_archive'        => 'portfolio',
77
-			'hierarchical'       => false,
78
-			'menu_position'      => null,
79
-			'supports'           => array(
80
-				'title',
81
-				'editor',
82
-				'thumbnail',
83
-				'excerpt',
84
-			),
85
-			'show_in_rest'       => true,
86
-			'supports'           => array( 'editor', 'title', 'excerpt', 'thumbnail' ),
87
-		);
88
-
89
-		register_post_type( 'project', $args );
90
-	}
91
-
92
-	/**
93
-	 * Register the Group taxonomy
94
-	 */
95
-	public function taxonomy_setup() {
96
-		$labels = array(
97
-			'name'              => esc_html_x( 'Project Groups', 'taxonomy general name', 'lsx-projects' ),
98
-			'singular_name'     => esc_html_x( 'Group', 'taxonomy singular name', 'lsx-projects' ),
99
-			'search_items'      => esc_html__( 'Search Groups', 'lsx-projects' ),
100
-			'all_items'         => esc_html__( 'All Groups', 'lsx-projects' ),
101
-			'parent_item'       => esc_html__( 'Parent Group', 'lsx-projects' ),
102
-			'parent_item_colon' => esc_html__( 'Parent Group:', 'lsx-projects' ),
103
-			'edit_item'         => esc_html__( 'Edit Group', 'lsx-projects' ),
104
-			'update_item'       => esc_html__( 'Update Group', 'lsx-projects' ),
105
-			'add_new_item'      => esc_html__( 'Add New Group', 'lsx-projects' ),
106
-			'new_item_name'     => esc_html__( 'New Group Name', 'lsx-projects' ),
107
-			'menu_name'         => esc_html__( 'Groups', 'lsx-projects' ),
108
-		);
109
-
110
-		$args = array(
111
-			'hierarchical'      => true,
112
-			'labels'            => $labels,
113
-			'show_ui'           => true,
114
-			'show_admin_column' => true,
115
-			'query_var'         => true,
116
-			'rewrite'           => array(
117
-				'slug' => 'portfolio-group',
118
-			),
119
-		);
120
-
121
-		register_taxonomy( 'project-group', array( 'project' ), $args );
122
-	}
123
-
124
-	/**
125
-	 * Register the Type taxonomy
126
-	 */
127
-	public function taxonomy_project_type_setup() {
128
-		$labels = array(
129
-			'name'              => esc_html_x( 'Project Types', 'taxonomy general name', 'lsx-projects' ),
130
-			'singular_name'     => esc_html_x( 'Type', 'taxonomy singular name', 'lsx-projects' ),
131
-			'search_items'      => esc_html__( 'Search Types', 'lsx-projects' ),
132
-			'all_items'         => esc_html__( 'All Types', 'lsx-projects' ),
133
-			'parent_item'       => esc_html__( 'Parent Type', 'lsx-projects' ),
134
-			'parent_item_colon' => esc_html__( 'Parent Type:', 'lsx-projects' ),
135
-			'edit_item'         => esc_html__( 'Edit Type', 'lsx-projects' ),
136
-			'update_item'       => esc_html__( 'Update Type', 'lsx-projects' ),
137
-			'add_new_item'      => esc_html__( 'Add New Type', 'lsx-projects' ),
138
-			'new_item_name'     => esc_html__( 'New Type Name', 'lsx-projects' ),
139
-			'menu_name'         => esc_html__( 'Types', 'lsx-projects' ),
140
-		);
141
-
142
-		$args = array(
143
-			'hierarchical'      => true,
144
-			'labels'            => $labels,
145
-			'show_ui'           => true,
146
-			'show_admin_column' => true,
147
-			'query_var'         => true,
148
-			'rewrite'           => array(
149
-				'slug' => 'project-type',
150
-			),
151
-			'show_in_rest'      => true,
152
-		);
153
-
154
-		register_taxonomy( 'project-type', array( 'project' ), $args );
155
-	}
156
-
157
-	/**
158
-	 * Register the Tag taxonomy
159
-	 */
160
-	public function taxonomy_project_tag_setup() {
161
-		$labels = array(
162
-			'name'              => esc_html_x( 'Project Tags', 'taxonomy general name', 'lsx-projects' ),
163
-			'singular_name'     => esc_html_x( 'Tag', 'taxonomy singular name', 'lsx-projects' ),
164
-			'search_items'      => esc_html__( 'Search Tags', 'lsx-projects' ),
165
-			'all_items'         => esc_html__( 'All Tags', 'lsx-projects' ),
166
-			'parent_item'       => esc_html__( 'Parent Tag', 'lsx-projects' ),
167
-			'parent_item_colon' => esc_html__( 'Parent Tag:', 'lsx-projects' ),
168
-			'edit_item'         => esc_html__( 'Edit Tag', 'lsx-projects' ),
169
-			'update_item'       => esc_html__( 'Update Tag', 'lsx-projects' ),
170
-			'add_new_item'      => esc_html__( 'Add New Tag', 'lsx-projects' ),
171
-			'new_item_name'     => esc_html__( 'New Tag Name', 'lsx-projects' ),
172
-			'menu_name'         => esc_html__( 'Tags', 'lsx-projects' ),
173
-		);
174
-
175
-		$args = array(
176
-			'hierarchical'      => true,
177
-			'labels'            => $labels,
178
-			'show_ui'           => true,
179
-			'show_admin_column' => true,
180
-			'query_var'         => true,
181
-			'rewrite'           => array(
182
-				'slug' => 'project-tag',
183
-			),
184
-			'show_in_rest'      => true,
185
-		);
186
-
187
-		register_taxonomy( 'project-tag', array( 'project' ), $args );
188
-	}
189
-
190
-	/**
191
-	 * Add metabox with custom fields to the Project post type
192
-	 */
193
-	public function field_setup() {
194
-		$prefix = 'lsx_project_';
195
-
196
-		$cmb = new_cmb2_box(
197
-			array(
198
-				'id'           => $prefix . '_project',
199
-				'title'        => __( 'General', 'lsx-projects' ),
200
-				'object_types' => 'project',
201
-				'context'      => 'normal',
202
-				'priority'     => 'low',
203
-				'show_names'   => true,
204
-			)
205
-		);
206
-
207
-		$cmb->add_field(
208
-			array(
209
-				'name'         => esc_html__( 'Featured:', 'lsx-projects' ),
210
-				'id'           => $prefix . 'featured',
211
-				'type'         => 'checkbox',
212
-				'value'        => 1,
213
-				'default'      => 0,
214
-				'show_in_rest' => true,
215
-			)
216
-		);
217
-
218
-		$cmb->add_field(
219
-			array(
220
-				'name'         => esc_html__( 'Client:', 'lsx-projects' ),
221
-				'id'           => $prefix . 'client',
222
-				'type'         => 'text',
223
-				'show_in_rest' => true,
224
-			)
225
-		);
226
-
227
-		$cmb->add_field(
228
-			array(
229
-				'name'         => esc_html__( 'Client logo:', 'lsx-projects' ),
230
-				'id'           => $prefix . 'client_logo',
231
-				'type'         => 'file',
232
-				'desc'         => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ),
233
-				'options'      => array(
234
-					'url' => false, // Hide the text input for the url.
235
-				),
236
-				'text'         => array(
237
-					'add_upload_file_text' => 'Choose Image',
238
-				),
239
-				'show_in_rest' => true,
240
-			)
241
-		);
242
-
243
-		$cmb->add_field(
244
-			array(
245
-				'name'         => esc_html__( 'URL for the finished project:', 'lsx-projects' ),
246
-				'id'           => $prefix . 'url',
247
-				'type'         => 'text',
248
-				'show_in_rest' => true,
249
-			)
250
-		);
251
-	}
252
-
253
-	/**
254
-	 * Project Services Metaboxes.
255
-	 */
256
-	public function projects_services_metaboxes() {
257
-		$prefix = 'lsx_project_';
258
-
259
-		$cmb = new_cmb2_box(
260
-			array(
261
-				'id'           => $prefix . '_project',
262
-				'object_types' => 'projects',
263
-				'context'      => 'normal',
264
-				'priority'     => 'low',
265
-				'show_names'   => true,
266
-			)
267
-		);
268
-
269
-		$cmb->add_field(
270
-			array(
271
-				'name'         => esc_html__( 'Services related to this project:', 'lsx-projects' ),
272
-				'id'           => 'page_to_project',
273
-				'type'         => 'post_search_ajax',
274
-				'show_in_rest' => true,
275
-				'limit'        => 15,
276
-				'sortable'     => true,
277
-				'query_args'   => array(
278
-					'post_type'      => array( 'project' ),
279
-					'post_status'    => array( 'publish' ),
280
-					'nopagin'        => true,
281
-					'posts_per_page' => '50',
282
-					'orderby'        => 'title',
283
-					'order'          => 'ASC',
284
-				),
285
-			)
286
-		);
287
-	}
288
-
289
-	/**
290
-	 * Project Testimonials Metaboxes.
291
-	 */
292
-	public function projects_testimonials_metaboxes() {
293
-		$prefix = 'lsx_project_';
294
-
295
-		$cmb = new_cmb2_box(
296
-			array(
297
-				'id'           => $prefix . '_project',
298
-				'object_types' => 'projects',
299
-				'context'      => 'normal',
300
-				'priority'     => 'low',
301
-				'show_names'   => true,
302
-			)
303
-		);
304
-
305
-		if ( class_exists( 'LSX_Testimonials' ) ) {
306
-			$cmb->add_field(
307
-				array(
308
-					'name'         => esc_html__( 'Testimonials related to this project:', 'lsx-projects' ),
309
-					'id'           => 'testimonial_to_project',
310
-					'type'         => 'post_search_ajax',
311
-					'show_in_rest' => true,
312
-					'limit'        => 15,
313
-					'sortable'     => true,
314
-					'query_args'   => array(
315
-						'post_type'      => array( 'testimonial' ),
316
-						'post_status'    => array( 'publish' ),
317
-						'nopagin'        => true,
318
-						'posts_per_page' => '50',
319
-						'orderby'        => 'title',
320
-						'order'          => 'ASC',
321
-					),
322
-				)
323
-			);
324
-		}
325
-	}
326
-
327
-	/**
328
-	 * Project Team Metaboxes.
329
-	 */
330
-	public function projects_team_metaboxes() {
331
-		$prefix = 'lsx_project_';
332
-
333
-		$cmb = new_cmb2_box(
334
-			array(
335
-				'id'           => $prefix . '_project',
336
-				'object_types' => 'project',
337
-				'context'      => 'normal',
338
-				'priority'     => 'low',
339
-				'show_names'   => true,
340
-			)
341
-		);
342
-
343
-		if ( class_exists( 'LSX_Team' ) ) {
344
-			$cmb->add_field(
345
-				array(
346
-					'name'         => esc_html__( 'Team members involved with this project:', 'lsx-projects' ),
347
-					'id'           => 'team_to_project',
348
-					'type'         => 'post_search_ajax',
349
-					'show_in_rest' => true,
350
-					'limit'        => 15,
351
-					'sortable'     => true,
352
-					'query_args'   => array(
353
-						'post_type'      => array( 'team' ),
354
-						'post_status'    => array( 'publish' ),
355
-						'nopagin'        => true,
356
-						'posts_per_page' => '50',
357
-						'orderby'        => 'title',
358
-						'order'          => 'ASC',
359
-					),
360
-				)
361
-			);
362
-		}
363
-	}
364
-
365
-	/**
366
-	 * Project Woocommerce Metaboxes.
367
-	 */
368
-	public function projects_woocommerce_metaboxes() {
369
-		$prefix = 'lsx_project_';
370
-
371
-		$cmb = new_cmb2_box(
372
-			array(
373
-				'id'           => $prefix . '_project',
374
-				'object_types' => 'projects',
375
-				'context'      => 'normal',
376
-				'priority'     => 'low',
377
-				'show_names'   => true,
378
-			)
379
-		);
380
-
381
-		if ( class_exists( 'woocommerce' ) ) {
382
-			$cmb->add_field(
383
-				array(
384
-					'name'         => esc_html__( 'Products used for this project:', 'lsx-projects' ),
385
-					'id'           => 'product_to_project',
386
-					'type'         => 'post_search_ajax',
387
-					'show_in_rest' => true,
388
-					'limit'        => 15,
389
-					'sortable'     => true,
390
-					'query_args'   => array(
391
-						'post_type'      => array( 'product' ),
392
-						'post_status'    => array( 'publish' ),
393
-						'nopagin'        => true,
394
-						'posts_per_page' => '50',
395
-						'orderby'        => 'title',
396
-						'order'          => 'ASC',
397
-					),
398
-				)
399
-			);
400
-		}
401
-	}
402
-
403
-	/**
404
-	 * Add Alt Product metabox with custom fields to the Project post type
405
-	 */
406
-	public function project_field_setup_product() {
407
-		$prefix = 'lsx_project_';
408
-
409
-		$cmb = new_cmb2_box(
410
-			array(
411
-				'id'           => $prefix . '_project',
412
-				'title'        => __( 'General', 'lsx-projects' ),
413
-				'object_types' => 'project',
414
-				'context'      => 'normal',
415
-				'priority'     => 'low',
416
-				'show_names'   => true,
417
-			)
418
-		);
419
-
420
-		$tip_group = $cmb->add_field(
421
-			array(
422
-				'id'      => $prefix . '_alt_products',
423
-				'type'    => 'group',
424
-				'options' => array(
425
-					'group_title'   => __( 'Alternative Products', 'lsx-projects' ),
426
-					'add_button'    => __( 'Add Product', 'lsx-projects' ),
427
-					'remove_button' => __( 'Remove Product', 'lsx-projects' ),
428
-					'sortable'      => true,
429
-				),
430
-				'classes' => 'lsx-admin-row',
431
-			)
432
-		);
433
-
434
-		$cmb->add_group_field(
435
-			$tip_group,
436
-			array(
437
-				'name'         => esc_html__( 'Alt Product Name:', 'lsx-projects' ),
438
-				'id'           => $prefix . 'alt_product_title',
439
-				'type'         => 'text',
440
-				'show_in_rest' => true,
441
-			)
442
-		);
443
-
444
-		$cmb->add_group_field(
445
-			$tip_group,
446
-			array(
447
-				'name'         => esc_html__( 'Alt Product Link:', 'lsx-projects' ),
448
-				'id'           => $prefix . 'alt_product_link',
449
-				'type'         => 'text',
450
-				'show_in_rest' => true,
451
-			)
452
-		);
453
-
454
-	}
455
-
456
-	/**
457
-	 * Sets up the "post relations".
458
-	 */
459
-	public function post_relations( $post_id, $field, $value ) {
460
-		$connections = array(
461
-			// 'project_to_project',
462
-
463
-			'page_to_project',
464
-			'project_to_page',
465
-
466
-			'project_to_service',
467
-			'service_to_project',
468
-
469
-			'project_to_testimonial',
470
-			'testimonial_to_project',
471
-
472
-			'project_to_team',
473
-			'team_to_project',
474
-		);
475
-
476
-		if ( in_array( $field['id'], $connections ) ) {
477
-			$this->save_related_post( $connections, $post_id, $field, $value );
478
-		}
479
-	}
480
-
481
-	/**
482
-	 * Save the reverse post relation.
483
-	 */
484
-	public function save_related_post( $connections, $post_id, $field, $value ) {
485
-		$ids = explode( '_to_', $field['id'] );
486
-		$relation = $ids[1] . '_to_' . $ids[0];
487
-
488
-		if ( in_array( $relation, $connections ) ) {
489
-			$previous_values = get_post_meta( $post_id, $field['id'], false );
490
-
491
-			if ( ! empty( $previous_values ) ) {
492
-				foreach ( $previous_values as $v ) {
493
-					delete_post_meta( $v, $relation, $post_id );
494
-				}
495
-			}
496
-
497
-			if ( is_array( $value ) ) {
498
-				foreach ( $value as $v ) {
499
-					if ( ! empty( $v ) ) {
500
-						add_post_meta( $v, $relation, $post_id );
501
-					}
502
-				}
503
-			}
504
-		}
505
-	}
506
-
507
-	public function assets() {
508
-		//wp_enqueue_media();
509
-		wp_enqueue_script( 'media-upload' );
510
-		wp_enqueue_script( 'thickbox' );
511
-		wp_enqueue_style( 'thickbox' );
512
-
513
-		wp_enqueue_script( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array( 'jquery' ), LSX_PROJECTS_VER, true );
514
-		wp_enqueue_style( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER );
515
-	}
516
-
517
-	/**
518
-	 * Change the "Insert into Post" button text when media modal is used for feature images
519
-	 */
520
-	public function change_attachment_field_button( $html ) {
521
-		if ( isset( $_GET['feature_image_text_button'] ) ) {
522
-			$html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-projects' ) ), $html );
523
-		}
524
-
525
-		return $html;
526
-	}
527
-
528
-	public function change_title_text( $title ) {
529
-		$screen = get_current_screen();
530
-
531
-		if ( 'project' === $screen->post_type ) {
532
-			$title = esc_attr__( 'Enter project title', 'lsx-projects' );
533
-		}
534
-
535
-		return $title;
536
-	}
13
+     public function __construct() {
14
+          $this->load_classes();
15
+
16
+          add_action( 'init', array( $this, 'post_type_setup' ) );
17
+          add_action( 'init', array( $this, 'taxonomy_setup' ) );
18
+          add_action( 'init', array( $this, 'taxonomy_project_type_setup' ) );
19
+          add_action( 'init', array( $this, 'taxonomy_project_tag_setup' ) );
20
+          add_filter( 'cmb2_admin_init', array( $this, 'field_setup' ) );
21
+          add_filter( 'cmb2_admin_init', array( $this, 'projects_services_metaboxes' ) );
22
+          add_filter( 'cmb2_admin_init', array( $this, 'projects_testimonials_metaboxes' ) );
23
+          add_filter( 'cmb2_admin_init', array( $this, 'projects_team_metaboxes' ) );
24
+          add_filter( 'cmb2_admin_init', array( $this, 'projects_woocommerce_metaboxes' ) );
25
+          add_filter( 'cmb2_admin_init', array( $this, 'project_field_setup_product' ) );
26
+          add_action( 'cmb_save_custom', array( $this, 'post_relations' ), 3, 20 );
27
+          add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
28
+
29
+          add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 );
30
+          add_filter( 'enter_title_here', array( $this, 'change_title_text' ) );
31
+     }
32
+
33
+     /**
34
+      * Loads the admin subclasses
35
+      */
36
+     private function load_classes() {
37
+          require_once LSX_PROJECTS_PATH . 'classes/admin/class-settings.php';
38
+          $this->settings = \lsx\projects\classes\admin\Settings::get_instance();
39
+
40
+          require_once LSX_PROJECTS_PATH . 'classes/admin/class-settings-theme.php';
41
+          $this->settings_theme = \lsx\projects\classes\admin\Settings_Theme::get_instance();
42
+     }
43
+
44
+     /**
45
+      * Register the Project and Product Tag post type
46
+      */
47
+     public function post_type_setup() {
48
+          $labels = array(
49
+               'name'               => esc_html_x( 'Projects', 'post type general name', 'lsx-projects' ),
50
+               'singular_name'      => esc_html_x( 'Project', 'post type singular name', 'lsx-projects' ),
51
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-projects' ),
52
+               'add_new_item'       => esc_html__( 'Add New Project', 'lsx-projects' ),
53
+               'edit_item'          => esc_html__( 'Edit Project', 'lsx-projects' ),
54
+               'new_item'           => esc_html__( 'New Project', 'lsx-projects' ),
55
+               'all_items'          => esc_html__( 'All Projects', 'lsx-projects' ),
56
+               'view_item'          => esc_html__( 'View Project', 'lsx-projects' ),
57
+               'search_items'       => esc_html__( 'Search Projects', 'lsx-projects' ),
58
+               'not_found'          => esc_html__( 'No projects found', 'lsx-projects' ),
59
+               'not_found_in_trash' => esc_html__( 'No projects found in Trash', 'lsx-projects' ),
60
+               'parent_item_colon'  => '',
61
+               'menu_name'          => esc_html_x( 'Projects', 'admin menu', 'lsx-projects' ),
62
+          );
63
+
64
+          $args = array(
65
+               'labels'             => $labels,
66
+               'public'             => true,
67
+               'publicly_queryable' => true,
68
+               'show_ui'            => true,
69
+               'show_in_menu'       => true,
70
+               'menu_icon'          => 'dashicons-portfolio',
71
+               'query_var'          => true,
72
+               'rewrite'            => array(
73
+                    'slug' => 'portfolio',
74
+               ),
75
+               'capability_type'    => 'post',
76
+               'has_archive'        => 'portfolio',
77
+               'hierarchical'       => false,
78
+               'menu_position'      => null,
79
+               'supports'           => array(
80
+                    'title',
81
+                    'editor',
82
+                    'thumbnail',
83
+                    'excerpt',
84
+               ),
85
+               'show_in_rest'       => true,
86
+               'supports'           => array( 'editor', 'title', 'excerpt', 'thumbnail' ),
87
+          );
88
+
89
+          register_post_type( 'project', $args );
90
+     }
91
+
92
+     /**
93
+      * Register the Group taxonomy
94
+      */
95
+     public function taxonomy_setup() {
96
+          $labels = array(
97
+               'name'              => esc_html_x( 'Project Groups', 'taxonomy general name', 'lsx-projects' ),
98
+               'singular_name'     => esc_html_x( 'Group', 'taxonomy singular name', 'lsx-projects' ),
99
+               'search_items'      => esc_html__( 'Search Groups', 'lsx-projects' ),
100
+               'all_items'         => esc_html__( 'All Groups', 'lsx-projects' ),
101
+               'parent_item'       => esc_html__( 'Parent Group', 'lsx-projects' ),
102
+               'parent_item_colon' => esc_html__( 'Parent Group:', 'lsx-projects' ),
103
+               'edit_item'         => esc_html__( 'Edit Group', 'lsx-projects' ),
104
+               'update_item'       => esc_html__( 'Update Group', 'lsx-projects' ),
105
+               'add_new_item'      => esc_html__( 'Add New Group', 'lsx-projects' ),
106
+               'new_item_name'     => esc_html__( 'New Group Name', 'lsx-projects' ),
107
+               'menu_name'         => esc_html__( 'Groups', 'lsx-projects' ),
108
+          );
109
+
110
+          $args = array(
111
+               'hierarchical'      => true,
112
+               'labels'            => $labels,
113
+               'show_ui'           => true,
114
+               'show_admin_column' => true,
115
+               'query_var'         => true,
116
+               'rewrite'           => array(
117
+                    'slug' => 'portfolio-group',
118
+               ),
119
+          );
120
+
121
+          register_taxonomy( 'project-group', array( 'project' ), $args );
122
+     }
123
+
124
+     /**
125
+      * Register the Type taxonomy
126
+      */
127
+     public function taxonomy_project_type_setup() {
128
+          $labels = array(
129
+               'name'              => esc_html_x( 'Project Types', 'taxonomy general name', 'lsx-projects' ),
130
+               'singular_name'     => esc_html_x( 'Type', 'taxonomy singular name', 'lsx-projects' ),
131
+               'search_items'      => esc_html__( 'Search Types', 'lsx-projects' ),
132
+               'all_items'         => esc_html__( 'All Types', 'lsx-projects' ),
133
+               'parent_item'       => esc_html__( 'Parent Type', 'lsx-projects' ),
134
+               'parent_item_colon' => esc_html__( 'Parent Type:', 'lsx-projects' ),
135
+               'edit_item'         => esc_html__( 'Edit Type', 'lsx-projects' ),
136
+               'update_item'       => esc_html__( 'Update Type', 'lsx-projects' ),
137
+               'add_new_item'      => esc_html__( 'Add New Type', 'lsx-projects' ),
138
+               'new_item_name'     => esc_html__( 'New Type Name', 'lsx-projects' ),
139
+               'menu_name'         => esc_html__( 'Types', 'lsx-projects' ),
140
+          );
141
+
142
+          $args = array(
143
+               'hierarchical'      => true,
144
+               'labels'            => $labels,
145
+               'show_ui'           => true,
146
+               'show_admin_column' => true,
147
+               'query_var'         => true,
148
+               'rewrite'           => array(
149
+                    'slug' => 'project-type',
150
+               ),
151
+               'show_in_rest'      => true,
152
+          );
153
+
154
+          register_taxonomy( 'project-type', array( 'project' ), $args );
155
+     }
156
+
157
+     /**
158
+      * Register the Tag taxonomy
159
+      */
160
+     public function taxonomy_project_tag_setup() {
161
+          $labels = array(
162
+               'name'              => esc_html_x( 'Project Tags', 'taxonomy general name', 'lsx-projects' ),
163
+               'singular_name'     => esc_html_x( 'Tag', 'taxonomy singular name', 'lsx-projects' ),
164
+               'search_items'      => esc_html__( 'Search Tags', 'lsx-projects' ),
165
+               'all_items'         => esc_html__( 'All Tags', 'lsx-projects' ),
166
+               'parent_item'       => esc_html__( 'Parent Tag', 'lsx-projects' ),
167
+               'parent_item_colon' => esc_html__( 'Parent Tag:', 'lsx-projects' ),
168
+               'edit_item'         => esc_html__( 'Edit Tag', 'lsx-projects' ),
169
+               'update_item'       => esc_html__( 'Update Tag', 'lsx-projects' ),
170
+               'add_new_item'      => esc_html__( 'Add New Tag', 'lsx-projects' ),
171
+               'new_item_name'     => esc_html__( 'New Tag Name', 'lsx-projects' ),
172
+               'menu_name'         => esc_html__( 'Tags', 'lsx-projects' ),
173
+          );
174
+
175
+          $args = array(
176
+               'hierarchical'      => true,
177
+               'labels'            => $labels,
178
+               'show_ui'           => true,
179
+               'show_admin_column' => true,
180
+               'query_var'         => true,
181
+               'rewrite'           => array(
182
+                    'slug' => 'project-tag',
183
+               ),
184
+               'show_in_rest'      => true,
185
+          );
186
+
187
+          register_taxonomy( 'project-tag', array( 'project' ), $args );
188
+     }
189
+
190
+     /**
191
+      * Add metabox with custom fields to the Project post type
192
+      */
193
+     public function field_setup() {
194
+          $prefix = 'lsx_project_';
195
+
196
+          $cmb = new_cmb2_box(
197
+               array(
198
+                    'id'           => $prefix . '_project',
199
+                    'title'        => __( 'General', 'lsx-projects' ),
200
+                    'object_types' => 'project',
201
+                    'context'      => 'normal',
202
+                    'priority'     => 'low',
203
+                    'show_names'   => true,
204
+               )
205
+          );
206
+
207
+          $cmb->add_field(
208
+               array(
209
+                    'name'         => esc_html__( 'Featured:', 'lsx-projects' ),
210
+                    'id'           => $prefix . 'featured',
211
+                    'type'         => 'checkbox',
212
+                    'value'        => 1,
213
+                    'default'      => 0,
214
+                    'show_in_rest' => true,
215
+               )
216
+          );
217
+
218
+          $cmb->add_field(
219
+               array(
220
+                    'name'         => esc_html__( 'Client:', 'lsx-projects' ),
221
+                    'id'           => $prefix . 'client',
222
+                    'type'         => 'text',
223
+                    'show_in_rest' => true,
224
+               )
225
+          );
226
+
227
+          $cmb->add_field(
228
+               array(
229
+                    'name'         => esc_html__( 'Client logo:', 'lsx-projects' ),
230
+                    'id'           => $prefix . 'client_logo',
231
+                    'type'         => 'file',
232
+                    'desc'         => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ),
233
+                    'options'      => array(
234
+                         'url' => false, // Hide the text input for the url.
235
+                    ),
236
+                    'text'         => array(
237
+                         'add_upload_file_text' => 'Choose Image',
238
+                    ),
239
+                    'show_in_rest' => true,
240
+               )
241
+          );
242
+
243
+          $cmb->add_field(
244
+               array(
245
+                    'name'         => esc_html__( 'URL for the finished project:', 'lsx-projects' ),
246
+                    'id'           => $prefix . 'url',
247
+                    'type'         => 'text',
248
+                    'show_in_rest' => true,
249
+               )
250
+          );
251
+     }
252
+
253
+     /**
254
+      * Project Services Metaboxes.
255
+      */
256
+     public function projects_services_metaboxes() {
257
+          $prefix = 'lsx_project_';
258
+
259
+          $cmb = new_cmb2_box(
260
+               array(
261
+                    'id'           => $prefix . '_project',
262
+                    'object_types' => 'projects',
263
+                    'context'      => 'normal',
264
+                    'priority'     => 'low',
265
+                    'show_names'   => true,
266
+               )
267
+          );
268
+
269
+          $cmb->add_field(
270
+               array(
271
+                    'name'         => esc_html__( 'Services related to this project:', 'lsx-projects' ),
272
+                    'id'           => 'page_to_project',
273
+                    'type'         => 'post_search_ajax',
274
+                    'show_in_rest' => true,
275
+                    'limit'        => 15,
276
+                    'sortable'     => true,
277
+                    'query_args'   => array(
278
+                         'post_type'      => array( 'project' ),
279
+                         'post_status'    => array( 'publish' ),
280
+                         'nopagin'        => true,
281
+                         'posts_per_page' => '50',
282
+                         'orderby'        => 'title',
283
+                         'order'          => 'ASC',
284
+                    ),
285
+               )
286
+          );
287
+     }
288
+
289
+     /**
290
+      * Project Testimonials Metaboxes.
291
+      */
292
+     public function projects_testimonials_metaboxes() {
293
+          $prefix = 'lsx_project_';
294
+
295
+          $cmb = new_cmb2_box(
296
+               array(
297
+                    'id'           => $prefix . '_project',
298
+                    'object_types' => 'projects',
299
+                    'context'      => 'normal',
300
+                    'priority'     => 'low',
301
+                    'show_names'   => true,
302
+               )
303
+          );
304
+
305
+          if ( class_exists( 'LSX_Testimonials' ) ) {
306
+               $cmb->add_field(
307
+                    array(
308
+                         'name'         => esc_html__( 'Testimonials related to this project:', 'lsx-projects' ),
309
+                         'id'           => 'testimonial_to_project',
310
+                         'type'         => 'post_search_ajax',
311
+                         'show_in_rest' => true,
312
+                         'limit'        => 15,
313
+                         'sortable'     => true,
314
+                         'query_args'   => array(
315
+                              'post_type'      => array( 'testimonial' ),
316
+                              'post_status'    => array( 'publish' ),
317
+                              'nopagin'        => true,
318
+                              'posts_per_page' => '50',
319
+                              'orderby'        => 'title',
320
+                              'order'          => 'ASC',
321
+                         ),
322
+                    )
323
+               );
324
+          }
325
+     }
326
+
327
+     /**
328
+      * Project Team Metaboxes.
329
+      */
330
+     public function projects_team_metaboxes() {
331
+          $prefix = 'lsx_project_';
332
+
333
+          $cmb = new_cmb2_box(
334
+               array(
335
+                    'id'           => $prefix . '_project',
336
+                    'object_types' => 'project',
337
+                    'context'      => 'normal',
338
+                    'priority'     => 'low',
339
+                    'show_names'   => true,
340
+               )
341
+          );
342
+
343
+          if ( class_exists( 'LSX_Team' ) ) {
344
+               $cmb->add_field(
345
+                    array(
346
+                         'name'         => esc_html__( 'Team members involved with this project:', 'lsx-projects' ),
347
+                         'id'           => 'team_to_project',
348
+                         'type'         => 'post_search_ajax',
349
+                         'show_in_rest' => true,
350
+                         'limit'        => 15,
351
+                         'sortable'     => true,
352
+                         'query_args'   => array(
353
+                              'post_type'      => array( 'team' ),
354
+                              'post_status'    => array( 'publish' ),
355
+                              'nopagin'        => true,
356
+                              'posts_per_page' => '50',
357
+                              'orderby'        => 'title',
358
+                              'order'          => 'ASC',
359
+                         ),
360
+                    )
361
+               );
362
+          }
363
+     }
364
+
365
+     /**
366
+      * Project Woocommerce Metaboxes.
367
+      */
368
+     public function projects_woocommerce_metaboxes() {
369
+          $prefix = 'lsx_project_';
370
+
371
+          $cmb = new_cmb2_box(
372
+               array(
373
+                    'id'           => $prefix . '_project',
374
+                    'object_types' => 'projects',
375
+                    'context'      => 'normal',
376
+                    'priority'     => 'low',
377
+                    'show_names'   => true,
378
+               )
379
+          );
380
+
381
+          if ( class_exists( 'woocommerce' ) ) {
382
+               $cmb->add_field(
383
+                    array(
384
+                         'name'         => esc_html__( 'Products used for this project:', 'lsx-projects' ),
385
+                         'id'           => 'product_to_project',
386
+                         'type'         => 'post_search_ajax',
387
+                         'show_in_rest' => true,
388
+                         'limit'        => 15,
389
+                         'sortable'     => true,
390
+                         'query_args'   => array(
391
+                              'post_type'      => array( 'product' ),
392
+                              'post_status'    => array( 'publish' ),
393
+                              'nopagin'        => true,
394
+                              'posts_per_page' => '50',
395
+                              'orderby'        => 'title',
396
+                              'order'          => 'ASC',
397
+                         ),
398
+                    )
399
+               );
400
+          }
401
+     }
402
+
403
+     /**
404
+      * Add Alt Product metabox with custom fields to the Project post type
405
+      */
406
+     public function project_field_setup_product() {
407
+          $prefix = 'lsx_project_';
408
+
409
+          $cmb = new_cmb2_box(
410
+               array(
411
+                    'id'           => $prefix . '_project',
412
+                    'title'        => __( 'General', 'lsx-projects' ),
413
+                    'object_types' => 'project',
414
+                    'context'      => 'normal',
415
+                    'priority'     => 'low',
416
+                    'show_names'   => true,
417
+               )
418
+          );
419
+
420
+          $tip_group = $cmb->add_field(
421
+               array(
422
+                    'id'      => $prefix . '_alt_products',
423
+                    'type'    => 'group',
424
+                    'options' => array(
425
+                         'group_title'   => __( 'Alternative Products', 'lsx-projects' ),
426
+                         'add_button'    => __( 'Add Product', 'lsx-projects' ),
427
+                         'remove_button' => __( 'Remove Product', 'lsx-projects' ),
428
+                         'sortable'      => true,
429
+                    ),
430
+                    'classes' => 'lsx-admin-row',
431
+               )
432
+          );
433
+
434
+          $cmb->add_group_field(
435
+               $tip_group,
436
+               array(
437
+                    'name'         => esc_html__( 'Alt Product Name:', 'lsx-projects' ),
438
+                    'id'           => $prefix . 'alt_product_title',
439
+                    'type'         => 'text',
440
+                    'show_in_rest' => true,
441
+               )
442
+          );
443
+
444
+          $cmb->add_group_field(
445
+               $tip_group,
446
+               array(
447
+                    'name'         => esc_html__( 'Alt Product Link:', 'lsx-projects' ),
448
+                    'id'           => $prefix . 'alt_product_link',
449
+                    'type'         => 'text',
450
+                    'show_in_rest' => true,
451
+               )
452
+          );
453
+
454
+     }
455
+
456
+     /**
457
+      * Sets up the "post relations".
458
+      */
459
+     public function post_relations( $post_id, $field, $value ) {
460
+          $connections = array(
461
+               // 'project_to_project',
462
+
463
+               'page_to_project',
464
+               'project_to_page',
465
+
466
+               'project_to_service',
467
+               'service_to_project',
468
+
469
+               'project_to_testimonial',
470
+               'testimonial_to_project',
471
+
472
+               'project_to_team',
473
+               'team_to_project',
474
+          );
475
+
476
+          if ( in_array( $field['id'], $connections ) ) {
477
+               $this->save_related_post( $connections, $post_id, $field, $value );
478
+          }
479
+     }
480
+
481
+     /**
482
+      * Save the reverse post relation.
483
+      */
484
+     public function save_related_post( $connections, $post_id, $field, $value ) {
485
+          $ids = explode( '_to_', $field['id'] );
486
+          $relation = $ids[1] . '_to_' . $ids[0];
487
+
488
+          if ( in_array( $relation, $connections ) ) {
489
+               $previous_values = get_post_meta( $post_id, $field['id'], false );
490
+
491
+               if ( ! empty( $previous_values ) ) {
492
+                    foreach ( $previous_values as $v ) {
493
+                         delete_post_meta( $v, $relation, $post_id );
494
+                    }
495
+               }
496
+
497
+               if ( is_array( $value ) ) {
498
+                    foreach ( $value as $v ) {
499
+                         if ( ! empty( $v ) ) {
500
+                              add_post_meta( $v, $relation, $post_id );
501
+                         }
502
+                    }
503
+               }
504
+          }
505
+     }
506
+
507
+     public function assets() {
508
+          //wp_enqueue_media();
509
+          wp_enqueue_script( 'media-upload' );
510
+          wp_enqueue_script( 'thickbox' );
511
+          wp_enqueue_style( 'thickbox' );
512
+
513
+          wp_enqueue_script( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array( 'jquery' ), LSX_PROJECTS_VER, true );
514
+          wp_enqueue_style( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER );
515
+     }
516
+
517
+     /**
518
+      * Change the "Insert into Post" button text when media modal is used for feature images
519
+      */
520
+     public function change_attachment_field_button( $html ) {
521
+          if ( isset( $_GET['feature_image_text_button'] ) ) {
522
+               $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-projects' ) ), $html );
523
+          }
524
+
525
+          return $html;
526
+     }
527
+
528
+     public function change_title_text( $title ) {
529
+          $screen = get_current_screen();
530
+
531
+          if ( 'project' === $screen->post_type ) {
532
+               $title = esc_attr__( 'Enter project title', 'lsx-projects' );
533
+          }
534
+
535
+          return $title;
536
+     }
537 537
 }
538 538
 
539 539
 $lsx_projects_admin = new LSX_Projects_Admin();
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@  discard block
 block discarded – undo
13 13
 	public function __construct() {
14 14
 		$this->load_classes();
15 15
 
16
-		add_action( 'init', array( $this, 'post_type_setup' ) );
17
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
18
-		add_action( 'init', array( $this, 'taxonomy_project_type_setup' ) );
19
-		add_action( 'init', array( $this, 'taxonomy_project_tag_setup' ) );
20
-		add_filter( 'cmb2_admin_init', array( $this, 'field_setup' ) );
21
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_services_metaboxes' ) );
22
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_testimonials_metaboxes' ) );
23
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_team_metaboxes' ) );
24
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_woocommerce_metaboxes' ) );
25
-		add_filter( 'cmb2_admin_init', array( $this, 'project_field_setup_product' ) );
26
-		add_action( 'cmb_save_custom', array( $this, 'post_relations' ), 3, 20 );
27
-		add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
28
-
29
-		add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 );
30
-		add_filter( 'enter_title_here', array( $this, 'change_title_text' ) );
16
+		add_action('init', array($this, 'post_type_setup'));
17
+		add_action('init', array($this, 'taxonomy_setup'));
18
+		add_action('init', array($this, 'taxonomy_project_type_setup'));
19
+		add_action('init', array($this, 'taxonomy_project_tag_setup'));
20
+		add_filter('cmb2_admin_init', array($this, 'field_setup'));
21
+		add_filter('cmb2_admin_init', array($this, 'projects_services_metaboxes'));
22
+		add_filter('cmb2_admin_init', array($this, 'projects_testimonials_metaboxes'));
23
+		add_filter('cmb2_admin_init', array($this, 'projects_team_metaboxes'));
24
+		add_filter('cmb2_admin_init', array($this, 'projects_woocommerce_metaboxes'));
25
+		add_filter('cmb2_admin_init', array($this, 'project_field_setup_product'));
26
+		add_action('cmb_save_custom', array($this, 'post_relations'), 3, 20);
27
+		add_action('admin_enqueue_scripts', array($this, 'assets'));
28
+
29
+		add_filter('type_url_form_media', array($this, 'change_attachment_field_button'), 20, 1);
30
+		add_filter('enter_title_here', array($this, 'change_title_text'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function post_type_setup() {
48 48
 		$labels = array(
49
-			'name'               => esc_html_x( 'Projects', 'post type general name', 'lsx-projects' ),
50
-			'singular_name'      => esc_html_x( 'Project', 'post type singular name', 'lsx-projects' ),
51
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-projects' ),
52
-			'add_new_item'       => esc_html__( 'Add New Project', 'lsx-projects' ),
53
-			'edit_item'          => esc_html__( 'Edit Project', 'lsx-projects' ),
54
-			'new_item'           => esc_html__( 'New Project', 'lsx-projects' ),
55
-			'all_items'          => esc_html__( 'All Projects', 'lsx-projects' ),
56
-			'view_item'          => esc_html__( 'View Project', 'lsx-projects' ),
57
-			'search_items'       => esc_html__( 'Search Projects', 'lsx-projects' ),
58
-			'not_found'          => esc_html__( 'No projects found', 'lsx-projects' ),
59
-			'not_found_in_trash' => esc_html__( 'No projects found in Trash', 'lsx-projects' ),
49
+			'name'               => esc_html_x('Projects', 'post type general name', 'lsx-projects'),
50
+			'singular_name'      => esc_html_x('Project', 'post type singular name', 'lsx-projects'),
51
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-projects'),
52
+			'add_new_item'       => esc_html__('Add New Project', 'lsx-projects'),
53
+			'edit_item'          => esc_html__('Edit Project', 'lsx-projects'),
54
+			'new_item'           => esc_html__('New Project', 'lsx-projects'),
55
+			'all_items'          => esc_html__('All Projects', 'lsx-projects'),
56
+			'view_item'          => esc_html__('View Project', 'lsx-projects'),
57
+			'search_items'       => esc_html__('Search Projects', 'lsx-projects'),
58
+			'not_found'          => esc_html__('No projects found', 'lsx-projects'),
59
+			'not_found_in_trash' => esc_html__('No projects found in Trash', 'lsx-projects'),
60 60
 			'parent_item_colon'  => '',
61
-			'menu_name'          => esc_html_x( 'Projects', 'admin menu', 'lsx-projects' ),
61
+			'menu_name'          => esc_html_x('Projects', 'admin menu', 'lsx-projects'),
62 62
 		);
63 63
 
64 64
 		$args = array(
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 				'excerpt',
84 84
 			),
85 85
 			'show_in_rest'       => true,
86
-			'supports'           => array( 'editor', 'title', 'excerpt', 'thumbnail' ),
86
+			'supports'           => array('editor', 'title', 'excerpt', 'thumbnail'),
87 87
 		);
88 88
 
89
-		register_post_type( 'project', $args );
89
+		register_post_type('project', $args);
90 90
 	}
91 91
 
92 92
 	/**
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function taxonomy_setup() {
96 96
 		$labels = array(
97
-			'name'              => esc_html_x( 'Project Groups', 'taxonomy general name', 'lsx-projects' ),
98
-			'singular_name'     => esc_html_x( 'Group', 'taxonomy singular name', 'lsx-projects' ),
99
-			'search_items'      => esc_html__( 'Search Groups', 'lsx-projects' ),
100
-			'all_items'         => esc_html__( 'All Groups', 'lsx-projects' ),
101
-			'parent_item'       => esc_html__( 'Parent Group', 'lsx-projects' ),
102
-			'parent_item_colon' => esc_html__( 'Parent Group:', 'lsx-projects' ),
103
-			'edit_item'         => esc_html__( 'Edit Group', 'lsx-projects' ),
104
-			'update_item'       => esc_html__( 'Update Group', 'lsx-projects' ),
105
-			'add_new_item'      => esc_html__( 'Add New Group', 'lsx-projects' ),
106
-			'new_item_name'     => esc_html__( 'New Group Name', 'lsx-projects' ),
107
-			'menu_name'         => esc_html__( 'Groups', 'lsx-projects' ),
97
+			'name'              => esc_html_x('Project Groups', 'taxonomy general name', 'lsx-projects'),
98
+			'singular_name'     => esc_html_x('Group', 'taxonomy singular name', 'lsx-projects'),
99
+			'search_items'      => esc_html__('Search Groups', 'lsx-projects'),
100
+			'all_items'         => esc_html__('All Groups', 'lsx-projects'),
101
+			'parent_item'       => esc_html__('Parent Group', 'lsx-projects'),
102
+			'parent_item_colon' => esc_html__('Parent Group:', 'lsx-projects'),
103
+			'edit_item'         => esc_html__('Edit Group', 'lsx-projects'),
104
+			'update_item'       => esc_html__('Update Group', 'lsx-projects'),
105
+			'add_new_item'      => esc_html__('Add New Group', 'lsx-projects'),
106
+			'new_item_name'     => esc_html__('New Group Name', 'lsx-projects'),
107
+			'menu_name'         => esc_html__('Groups', 'lsx-projects'),
108 108
 		);
109 109
 
110 110
 		$args = array(
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			),
119 119
 		);
120 120
 
121
-		register_taxonomy( 'project-group', array( 'project' ), $args );
121
+		register_taxonomy('project-group', array('project'), $args);
122 122
 	}
123 123
 
124 124
 	/**
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function taxonomy_project_type_setup() {
128 128
 		$labels = array(
129
-			'name'              => esc_html_x( 'Project Types', 'taxonomy general name', 'lsx-projects' ),
130
-			'singular_name'     => esc_html_x( 'Type', 'taxonomy singular name', 'lsx-projects' ),
131
-			'search_items'      => esc_html__( 'Search Types', 'lsx-projects' ),
132
-			'all_items'         => esc_html__( 'All Types', 'lsx-projects' ),
133
-			'parent_item'       => esc_html__( 'Parent Type', 'lsx-projects' ),
134
-			'parent_item_colon' => esc_html__( 'Parent Type:', 'lsx-projects' ),
135
-			'edit_item'         => esc_html__( 'Edit Type', 'lsx-projects' ),
136
-			'update_item'       => esc_html__( 'Update Type', 'lsx-projects' ),
137
-			'add_new_item'      => esc_html__( 'Add New Type', 'lsx-projects' ),
138
-			'new_item_name'     => esc_html__( 'New Type Name', 'lsx-projects' ),
139
-			'menu_name'         => esc_html__( 'Types', 'lsx-projects' ),
129
+			'name'              => esc_html_x('Project Types', 'taxonomy general name', 'lsx-projects'),
130
+			'singular_name'     => esc_html_x('Type', 'taxonomy singular name', 'lsx-projects'),
131
+			'search_items'      => esc_html__('Search Types', 'lsx-projects'),
132
+			'all_items'         => esc_html__('All Types', 'lsx-projects'),
133
+			'parent_item'       => esc_html__('Parent Type', 'lsx-projects'),
134
+			'parent_item_colon' => esc_html__('Parent Type:', 'lsx-projects'),
135
+			'edit_item'         => esc_html__('Edit Type', 'lsx-projects'),
136
+			'update_item'       => esc_html__('Update Type', 'lsx-projects'),
137
+			'add_new_item'      => esc_html__('Add New Type', 'lsx-projects'),
138
+			'new_item_name'     => esc_html__('New Type Name', 'lsx-projects'),
139
+			'menu_name'         => esc_html__('Types', 'lsx-projects'),
140 140
 		);
141 141
 
142 142
 		$args = array(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 			'show_in_rest'      => true,
152 152
 		);
153 153
 
154
-		register_taxonomy( 'project-type', array( 'project' ), $args );
154
+		register_taxonomy('project-type', array('project'), $args);
155 155
 	}
156 156
 
157 157
 	/**
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function taxonomy_project_tag_setup() {
161 161
 		$labels = array(
162
-			'name'              => esc_html_x( 'Project Tags', 'taxonomy general name', 'lsx-projects' ),
163
-			'singular_name'     => esc_html_x( 'Tag', 'taxonomy singular name', 'lsx-projects' ),
164
-			'search_items'      => esc_html__( 'Search Tags', 'lsx-projects' ),
165
-			'all_items'         => esc_html__( 'All Tags', 'lsx-projects' ),
166
-			'parent_item'       => esc_html__( 'Parent Tag', 'lsx-projects' ),
167
-			'parent_item_colon' => esc_html__( 'Parent Tag:', 'lsx-projects' ),
168
-			'edit_item'         => esc_html__( 'Edit Tag', 'lsx-projects' ),
169
-			'update_item'       => esc_html__( 'Update Tag', 'lsx-projects' ),
170
-			'add_new_item'      => esc_html__( 'Add New Tag', 'lsx-projects' ),
171
-			'new_item_name'     => esc_html__( 'New Tag Name', 'lsx-projects' ),
172
-			'menu_name'         => esc_html__( 'Tags', 'lsx-projects' ),
162
+			'name'              => esc_html_x('Project Tags', 'taxonomy general name', 'lsx-projects'),
163
+			'singular_name'     => esc_html_x('Tag', 'taxonomy singular name', 'lsx-projects'),
164
+			'search_items'      => esc_html__('Search Tags', 'lsx-projects'),
165
+			'all_items'         => esc_html__('All Tags', 'lsx-projects'),
166
+			'parent_item'       => esc_html__('Parent Tag', 'lsx-projects'),
167
+			'parent_item_colon' => esc_html__('Parent Tag:', 'lsx-projects'),
168
+			'edit_item'         => esc_html__('Edit Tag', 'lsx-projects'),
169
+			'update_item'       => esc_html__('Update Tag', 'lsx-projects'),
170
+			'add_new_item'      => esc_html__('Add New Tag', 'lsx-projects'),
171
+			'new_item_name'     => esc_html__('New Tag Name', 'lsx-projects'),
172
+			'menu_name'         => esc_html__('Tags', 'lsx-projects'),
173 173
 		);
174 174
 
175 175
 		$args = array(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			'show_in_rest'      => true,
185 185
 		);
186 186
 
187
-		register_taxonomy( 'project-tag', array( 'project' ), $args );
187
+		register_taxonomy('project-tag', array('project'), $args);
188 188
 	}
189 189
 
190 190
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		$cmb = new_cmb2_box(
197 197
 			array(
198 198
 				'id'           => $prefix . '_project',
199
-				'title'        => __( 'General', 'lsx-projects' ),
199
+				'title'        => __('General', 'lsx-projects'),
200 200
 				'object_types' => 'project',
201 201
 				'context'      => 'normal',
202 202
 				'priority'     => 'low',
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 		$cmb->add_field(
208 208
 			array(
209
-				'name'         => esc_html__( 'Featured:', 'lsx-projects' ),
209
+				'name'         => esc_html__('Featured:', 'lsx-projects'),
210 210
 				'id'           => $prefix . 'featured',
211 211
 				'type'         => 'checkbox',
212 212
 				'value'        => 1,
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$cmb->add_field(
219 219
 			array(
220
-				'name'         => esc_html__( 'Client:', 'lsx-projects' ),
220
+				'name'         => esc_html__('Client:', 'lsx-projects'),
221 221
 				'id'           => $prefix . 'client',
222 222
 				'type'         => 'text',
223 223
 				'show_in_rest' => true,
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 
227 227
 		$cmb->add_field(
228 228
 			array(
229
-				'name'         => esc_html__( 'Client logo:', 'lsx-projects' ),
229
+				'name'         => esc_html__('Client logo:', 'lsx-projects'),
230 230
 				'id'           => $prefix . 'client_logo',
231 231
 				'type'         => 'file',
232
-				'desc'         => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ),
232
+				'desc'         => esc_html__('Recommended image size: 320 x 50~60', 'lsx-projects'),
233 233
 				'options'      => array(
234 234
 					'url' => false, // Hide the text input for the url.
235 235
 				),
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 		$cmb->add_field(
244 244
 			array(
245
-				'name'         => esc_html__( 'URL for the finished project:', 'lsx-projects' ),
245
+				'name'         => esc_html__('URL for the finished project:', 'lsx-projects'),
246 246
 				'id'           => $prefix . 'url',
247 247
 				'type'         => 'text',
248 248
 				'show_in_rest' => true,
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
 
269 269
 		$cmb->add_field(
270 270
 			array(
271
-				'name'         => esc_html__( 'Services related to this project:', 'lsx-projects' ),
271
+				'name'         => esc_html__('Services related to this project:', 'lsx-projects'),
272 272
 				'id'           => 'page_to_project',
273 273
 				'type'         => 'post_search_ajax',
274 274
 				'show_in_rest' => true,
275 275
 				'limit'        => 15,
276 276
 				'sortable'     => true,
277 277
 				'query_args'   => array(
278
-					'post_type'      => array( 'project' ),
279
-					'post_status'    => array( 'publish' ),
278
+					'post_type'      => array('project'),
279
+					'post_status'    => array('publish'),
280 280
 					'nopagin'        => true,
281 281
 					'posts_per_page' => '50',
282 282
 					'orderby'        => 'title',
@@ -302,18 +302,18 @@  discard block
 block discarded – undo
302 302
 			)
303 303
 		);
304 304
 
305
-		if ( class_exists( 'LSX_Testimonials' ) ) {
305
+		if (class_exists('LSX_Testimonials')) {
306 306
 			$cmb->add_field(
307 307
 				array(
308
-					'name'         => esc_html__( 'Testimonials related to this project:', 'lsx-projects' ),
308
+					'name'         => esc_html__('Testimonials related to this project:', 'lsx-projects'),
309 309
 					'id'           => 'testimonial_to_project',
310 310
 					'type'         => 'post_search_ajax',
311 311
 					'show_in_rest' => true,
312 312
 					'limit'        => 15,
313 313
 					'sortable'     => true,
314 314
 					'query_args'   => array(
315
-						'post_type'      => array( 'testimonial' ),
316
-						'post_status'    => array( 'publish' ),
315
+						'post_type'      => array('testimonial'),
316
+						'post_status'    => array('publish'),
317 317
 						'nopagin'        => true,
318 318
 						'posts_per_page' => '50',
319 319
 						'orderby'        => 'title',
@@ -340,18 +340,18 @@  discard block
 block discarded – undo
340 340
 			)
341 341
 		);
342 342
 
343
-		if ( class_exists( 'LSX_Team' ) ) {
343
+		if (class_exists('LSX_Team')) {
344 344
 			$cmb->add_field(
345 345
 				array(
346
-					'name'         => esc_html__( 'Team members involved with this project:', 'lsx-projects' ),
346
+					'name'         => esc_html__('Team members involved with this project:', 'lsx-projects'),
347 347
 					'id'           => 'team_to_project',
348 348
 					'type'         => 'post_search_ajax',
349 349
 					'show_in_rest' => true,
350 350
 					'limit'        => 15,
351 351
 					'sortable'     => true,
352 352
 					'query_args'   => array(
353
-						'post_type'      => array( 'team' ),
354
-						'post_status'    => array( 'publish' ),
353
+						'post_type'      => array('team'),
354
+						'post_status'    => array('publish'),
355 355
 						'nopagin'        => true,
356 356
 						'posts_per_page' => '50',
357 357
 						'orderby'        => 'title',
@@ -378,18 +378,18 @@  discard block
 block discarded – undo
378 378
 			)
379 379
 		);
380 380
 
381
-		if ( class_exists( 'woocommerce' ) ) {
381
+		if (class_exists('woocommerce')) {
382 382
 			$cmb->add_field(
383 383
 				array(
384
-					'name'         => esc_html__( 'Products used for this project:', 'lsx-projects' ),
384
+					'name'         => esc_html__('Products used for this project:', 'lsx-projects'),
385 385
 					'id'           => 'product_to_project',
386 386
 					'type'         => 'post_search_ajax',
387 387
 					'show_in_rest' => true,
388 388
 					'limit'        => 15,
389 389
 					'sortable'     => true,
390 390
 					'query_args'   => array(
391
-						'post_type'      => array( 'product' ),
392
-						'post_status'    => array( 'publish' ),
391
+						'post_type'      => array('product'),
392
+						'post_status'    => array('publish'),
393 393
 						'nopagin'        => true,
394 394
 						'posts_per_page' => '50',
395 395
 						'orderby'        => 'title',
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		$cmb = new_cmb2_box(
410 410
 			array(
411 411
 				'id'           => $prefix . '_project',
412
-				'title'        => __( 'General', 'lsx-projects' ),
412
+				'title'        => __('General', 'lsx-projects'),
413 413
 				'object_types' => 'project',
414 414
 				'context'      => 'normal',
415 415
 				'priority'     => 'low',
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
 				'id'      => $prefix . '_alt_products',
423 423
 				'type'    => 'group',
424 424
 				'options' => array(
425
-					'group_title'   => __( 'Alternative Products', 'lsx-projects' ),
426
-					'add_button'    => __( 'Add Product', 'lsx-projects' ),
427
-					'remove_button' => __( 'Remove Product', 'lsx-projects' ),
425
+					'group_title'   => __('Alternative Products', 'lsx-projects'),
426
+					'add_button'    => __('Add Product', 'lsx-projects'),
427
+					'remove_button' => __('Remove Product', 'lsx-projects'),
428 428
 					'sortable'      => true,
429 429
 				),
430 430
 				'classes' => 'lsx-admin-row',
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$cmb->add_group_field(
435 435
 			$tip_group,
436 436
 			array(
437
-				'name'         => esc_html__( 'Alt Product Name:', 'lsx-projects' ),
437
+				'name'         => esc_html__('Alt Product Name:', 'lsx-projects'),
438 438
 				'id'           => $prefix . 'alt_product_title',
439 439
 				'type'         => 'text',
440 440
 				'show_in_rest' => true,
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 		$cmb->add_group_field(
445 445
 			$tip_group,
446 446
 			array(
447
-				'name'         => esc_html__( 'Alt Product Link:', 'lsx-projects' ),
447
+				'name'         => esc_html__('Alt Product Link:', 'lsx-projects'),
448 448
 				'id'           => $prefix . 'alt_product_link',
449 449
 				'type'         => 'text',
450 450
 				'show_in_rest' => true,
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	/**
457 457
 	 * Sets up the "post relations".
458 458
 	 */
459
-	public function post_relations( $post_id, $field, $value ) {
459
+	public function post_relations($post_id, $field, $value) {
460 460
 		$connections = array(
461 461
 			// 'project_to_project',
462 462
 
@@ -473,31 +473,31 @@  discard block
 block discarded – undo
473 473
 			'team_to_project',
474 474
 		);
475 475
 
476
-		if ( in_array( $field['id'], $connections ) ) {
477
-			$this->save_related_post( $connections, $post_id, $field, $value );
476
+		if (in_array($field['id'], $connections)) {
477
+			$this->save_related_post($connections, $post_id, $field, $value);
478 478
 		}
479 479
 	}
480 480
 
481 481
 	/**
482 482
 	 * Save the reverse post relation.
483 483
 	 */
484
-	public function save_related_post( $connections, $post_id, $field, $value ) {
485
-		$ids = explode( '_to_', $field['id'] );
484
+	public function save_related_post($connections, $post_id, $field, $value) {
485
+		$ids = explode('_to_', $field['id']);
486 486
 		$relation = $ids[1] . '_to_' . $ids[0];
487 487
 
488
-		if ( in_array( $relation, $connections ) ) {
489
-			$previous_values = get_post_meta( $post_id, $field['id'], false );
488
+		if (in_array($relation, $connections)) {
489
+			$previous_values = get_post_meta($post_id, $field['id'], false);
490 490
 
491
-			if ( ! empty( $previous_values ) ) {
492
-				foreach ( $previous_values as $v ) {
493
-					delete_post_meta( $v, $relation, $post_id );
491
+			if ( ! empty($previous_values)) {
492
+				foreach ($previous_values as $v) {
493
+					delete_post_meta($v, $relation, $post_id);
494 494
 				}
495 495
 			}
496 496
 
497
-			if ( is_array( $value ) ) {
498
-				foreach ( $value as $v ) {
499
-					if ( ! empty( $v ) ) {
500
-						add_post_meta( $v, $relation, $post_id );
497
+			if (is_array($value)) {
498
+				foreach ($value as $v) {
499
+					if ( ! empty($v)) {
500
+						add_post_meta($v, $relation, $post_id);
501 501
 					}
502 502
 				}
503 503
 			}
@@ -506,30 +506,30 @@  discard block
 block discarded – undo
506 506
 
507 507
 	public function assets() {
508 508
 		//wp_enqueue_media();
509
-		wp_enqueue_script( 'media-upload' );
510
-		wp_enqueue_script( 'thickbox' );
511
-		wp_enqueue_style( 'thickbox' );
509
+		wp_enqueue_script('media-upload');
510
+		wp_enqueue_script('thickbox');
511
+		wp_enqueue_style('thickbox');
512 512
 
513
-		wp_enqueue_script( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array( 'jquery' ), LSX_PROJECTS_VER, true );
514
-		wp_enqueue_style( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER );
513
+		wp_enqueue_script('lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array('jquery'), LSX_PROJECTS_VER, true);
514
+		wp_enqueue_style('lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER);
515 515
 	}
516 516
 
517 517
 	/**
518 518
 	 * Change the "Insert into Post" button text when media modal is used for feature images
519 519
 	 */
520
-	public function change_attachment_field_button( $html ) {
521
-		if ( isset( $_GET['feature_image_text_button'] ) ) {
522
-			$html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-projects' ) ), $html );
520
+	public function change_attachment_field_button($html) {
521
+		if (isset($_GET['feature_image_text_button'])) {
522
+			$html = str_replace('value="Insert into Post"', sprintf('value="%s"', esc_html__('Select featured image', 'lsx-projects')), $html);
523 523
 		}
524 524
 
525 525
 		return $html;
526 526
 	}
527 527
 
528
-	public function change_title_text( $title ) {
528
+	public function change_title_text($title) {
529 529
 		$screen = get_current_screen();
530 530
 
531
-		if ( 'project' === $screen->post_type ) {
532
-			$title = esc_attr__( 'Enter project title', 'lsx-projects' );
531
+		if ('project' === $screen->post_type) {
532
+			$title = esc_attr__('Enter project title', 'lsx-projects');
533 533
 		}
534 534
 
535 535
 		return $title;
Please login to merge, or discard this patch.
classes/admin/class-settings.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -9,168 +9,168 @@
 block discarded – undo
9 9
 
10 10
 class Settings {
11 11
 
12
-	/**
13
-	 * Holds class instance
14
-	 *
15
-	 * @since 1.0.0
16
-	 *
17
-	 * @var      object \lsx_projects\classes\admin\Settings()
18
-	 */
19
-	protected static $instance = null;
20
-
21
-	/**
22
-	 * Option key, and option page slug
23
-	 *
24
-	 * @var string
25
-	 */
26
-	protected $screen_id = 'lsx_projects_settings';
27
-
28
-	/**
29
-	 * Contructor
30
-	 */
31
-	public function __construct() {
32
-		add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
33
-		add_action( 'lsx_projects_settings_page', array( $this, 'general_settings' ), 1, 1 );
34
-		add_action( 'lsx_projects_settings_page', array( $this, 'contact_modal_settings' ), 1, 1 );
35
-	}
36
-
37
-	/**
38
-	 * Return an instance of this class.
39
-	 *
40
-	 * @since 1.0.0
41
-	 *
42
-	 * @return    object Settings()    A single instance of this class.
43
-	 */
44
-	public static function get_instance() {
45
-		// If the single instance hasn't been set, set it now.
46
-		if ( null === self::$instance ) {
47
-			self::$instance = new self();
48
-		}
49
-		return self::$instance;
50
-	}
51
-
52
-	/**
53
-	 * Hook in and register a submenu options page for the Page post-type menu.
54
-	 */
55
-	public function register_settings_page() {
56
-		$cmb = new_cmb2_box(
57
-			array(
58
-				'id'           => $this->screen_id,
59
-				'title'        => esc_html__( 'Settings', 'lsx-projects' ),
60
-				'object_types' => array( 'options-page' ),
61
-				'option_key'   => 'lsx_projects_options', // The option key and admin menu page slug.
62
-				'parent_slug'  => 'edit.php?post_type=project', // Make options page a submenu item of the themes menu.
63
-				'capability'   => 'manage_options', // Cap required to view options-page.
64
-			)
65
-		);
66
-		do_action( 'lsx_projects_settings_page', $cmb );
67
-	}
68
-
69
-	/**
70
-	 * Registers the general settings.
71
-	 *
72
-	 * @param object $cmb new_cmb2_box().
73
-	 * @return void
74
-	 */
75
-	public function general_settings( $cmb ) {
76
-		$cmb->add_field(
77
-			array(
78
-				'id'      => 'settings_general_title',
79
-				'type'    => 'title',
80
-				'name'    => __( 'General', 'lsx-projects' ),
81
-				'default' => __( 'General', 'lsx-projects' ),
82
-			)
83
-		);
84
-		$cmb->add_field(
85
-			array(
86
-				'name'        => __( 'Disable Single Posts', 'lsx-projects' ),
87
-				'id'          => 'projects_disable_single',
88
-				'type'        => 'checkbox',
89
-				'value'       => 1,
90
-				'default'     => 0,
91
-				'description' => __( 'Disable Single Posts.', 'lsx-projects' ),
92
-			)
93
-		);
94
-
95
-		$cmb->add_field(
96
-			array(
97
-				'name'    => 'Placeholder',
98
-				'desc'    => __( 'Choose Image.', 'lsx-projects' ),
99
-				'id'      => 'projects_placeholder',
100
-				'type'    => 'file',
101
-				'options' => array(
102
-					'url' => false, // Hide the text input for the url.
103
-				),
104
-				'text'    => array(
105
-					'add_upload_file_text' => 'Choose Image',
106
-				),
107
-			)
108
-		);
109
-
110
-		$cmb->add_field(
111
-			array(
112
-				'id'   => 'settings_general_closing',
113
-				'type' => 'tab_closing',
114
-			)
115
-		);
116
-	}
117
-
118
-	/**
119
-	 * Registers the Contact modal settings.
120
-	 *
121
-	 * @param object $cmb new_cmb2_box().
122
-	 * @return void
123
-	 */
124
-	public function contact_modal_settings( $cmb ) {
125
-		$cmb->add_field(
126
-			array(
127
-				'id'   => 'settings_contact_modal_title',
128
-				'type' => 'title',
129
-				'name' => __( 'Contact modal', 'lsx-projects' ),
130
-				'description' => __( 'Displays contact modal on project single if there is a linked Caldera or WPform.', 'lsx-projects' ),
131
-			)
132
-		);
133
-		$cmb->add_field(
134
-			array(
135
-				'name'        => __( 'Enable contact modal', 'lsx-projects' ),
136
-				'id'          => 'projects_modal_enable',
137
-				'type'        => 'checkbox',
138
-				'value'       => 1,
139
-				'default'     => 0,
140
-				'description' => __( 'Displays contact modal on project single.', 'lsx-projects' ),
141
-			)
142
-		);
143
-
144
-		$cmb->add_field(
145
-			array(
146
-				'name' => __( 'Button label', 'lsx-projects' ),
147
-				'id'   => 'projects_modal_cta_label',
148
-				'type' => 'text',
149
-			)
150
-		);
151
-
152
-		$cmb->add_field(
153
-			array(
154
-				'name' => __( 'Caldera Form ID (if enabled)', 'lsx-projects' ),
155
-				'id'   => 'projects_modal_form_id',
156
-				'type' => 'text',
157
-			)
158
-		);
159
-
160
-		$cmb->add_field(
161
-			array(
162
-				'name' => __( 'WPForm ID (if enabled)', 'lsx-projects' ),
163
-				'id'   => 'projects_wpform_modal_form_id',
164
-				'type' => 'text',
165
-			)
166
-		);
167
-
168
-		$cmb->add_field(
169
-			array(
170
-				'id'   => 'settings_contact_modal_closing',
171
-				'type' => 'tab_closing',
172
-			)
173
-		);
174
-	}
12
+     /**
13
+      * Holds class instance
14
+      *
15
+      * @since 1.0.0
16
+      *
17
+      * @var      object \lsx_projects\classes\admin\Settings()
18
+      */
19
+     protected static $instance = null;
20
+
21
+     /**
22
+      * Option key, and option page slug
23
+      *
24
+      * @var string
25
+      */
26
+     protected $screen_id = 'lsx_projects_settings';
27
+
28
+     /**
29
+      * Contructor
30
+      */
31
+     public function __construct() {
32
+          add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
33
+          add_action( 'lsx_projects_settings_page', array( $this, 'general_settings' ), 1, 1 );
34
+          add_action( 'lsx_projects_settings_page', array( $this, 'contact_modal_settings' ), 1, 1 );
35
+     }
36
+
37
+     /**
38
+      * Return an instance of this class.
39
+      *
40
+      * @since 1.0.0
41
+      *
42
+      * @return    object Settings()    A single instance of this class.
43
+      */
44
+     public static function get_instance() {
45
+          // If the single instance hasn't been set, set it now.
46
+          if ( null === self::$instance ) {
47
+               self::$instance = new self();
48
+          }
49
+          return self::$instance;
50
+     }
51
+
52
+     /**
53
+      * Hook in and register a submenu options page for the Page post-type menu.
54
+      */
55
+     public function register_settings_page() {
56
+          $cmb = new_cmb2_box(
57
+               array(
58
+                    'id'           => $this->screen_id,
59
+                    'title'        => esc_html__( 'Settings', 'lsx-projects' ),
60
+                    'object_types' => array( 'options-page' ),
61
+                    'option_key'   => 'lsx_projects_options', // The option key and admin menu page slug.
62
+                    'parent_slug'  => 'edit.php?post_type=project', // Make options page a submenu item of the themes menu.
63
+                    'capability'   => 'manage_options', // Cap required to view options-page.
64
+               )
65
+          );
66
+          do_action( 'lsx_projects_settings_page', $cmb );
67
+     }
68
+
69
+     /**
70
+      * Registers the general settings.
71
+      *
72
+      * @param object $cmb new_cmb2_box().
73
+      * @return void
74
+      */
75
+     public function general_settings( $cmb ) {
76
+          $cmb->add_field(
77
+               array(
78
+                    'id'      => 'settings_general_title',
79
+                    'type'    => 'title',
80
+                    'name'    => __( 'General', 'lsx-projects' ),
81
+                    'default' => __( 'General', 'lsx-projects' ),
82
+               )
83
+          );
84
+          $cmb->add_field(
85
+               array(
86
+                    'name'        => __( 'Disable Single Posts', 'lsx-projects' ),
87
+                    'id'          => 'projects_disable_single',
88
+                    'type'        => 'checkbox',
89
+                    'value'       => 1,
90
+                    'default'     => 0,
91
+                    'description' => __( 'Disable Single Posts.', 'lsx-projects' ),
92
+               )
93
+          );
94
+
95
+          $cmb->add_field(
96
+               array(
97
+                    'name'    => 'Placeholder',
98
+                    'desc'    => __( 'Choose Image.', 'lsx-projects' ),
99
+                    'id'      => 'projects_placeholder',
100
+                    'type'    => 'file',
101
+                    'options' => array(
102
+                         'url' => false, // Hide the text input for the url.
103
+                    ),
104
+                    'text'    => array(
105
+                         'add_upload_file_text' => 'Choose Image',
106
+                    ),
107
+               )
108
+          );
109
+
110
+          $cmb->add_field(
111
+               array(
112
+                    'id'   => 'settings_general_closing',
113
+                    'type' => 'tab_closing',
114
+               )
115
+          );
116
+     }
117
+
118
+     /**
119
+      * Registers the Contact modal settings.
120
+      *
121
+      * @param object $cmb new_cmb2_box().
122
+      * @return void
123
+      */
124
+     public function contact_modal_settings( $cmb ) {
125
+          $cmb->add_field(
126
+               array(
127
+                    'id'   => 'settings_contact_modal_title',
128
+                    'type' => 'title',
129
+                    'name' => __( 'Contact modal', 'lsx-projects' ),
130
+                    'description' => __( 'Displays contact modal on project single if there is a linked Caldera or WPform.', 'lsx-projects' ),
131
+               )
132
+          );
133
+          $cmb->add_field(
134
+               array(
135
+                    'name'        => __( 'Enable contact modal', 'lsx-projects' ),
136
+                    'id'          => 'projects_modal_enable',
137
+                    'type'        => 'checkbox',
138
+                    'value'       => 1,
139
+                    'default'     => 0,
140
+                    'description' => __( 'Displays contact modal on project single.', 'lsx-projects' ),
141
+               )
142
+          );
143
+
144
+          $cmb->add_field(
145
+               array(
146
+                    'name' => __( 'Button label', 'lsx-projects' ),
147
+                    'id'   => 'projects_modal_cta_label',
148
+                    'type' => 'text',
149
+               )
150
+          );
151
+
152
+          $cmb->add_field(
153
+               array(
154
+                    'name' => __( 'Caldera Form ID (if enabled)', 'lsx-projects' ),
155
+                    'id'   => 'projects_modal_form_id',
156
+                    'type' => 'text',
157
+               )
158
+          );
159
+
160
+          $cmb->add_field(
161
+               array(
162
+                    'name' => __( 'WPForm ID (if enabled)', 'lsx-projects' ),
163
+                    'id'   => 'projects_wpform_modal_form_id',
164
+                    'type' => 'text',
165
+               )
166
+          );
167
+
168
+          $cmb->add_field(
169
+               array(
170
+                    'id'   => 'settings_contact_modal_closing',
171
+                    'type' => 'tab_closing',
172
+               )
173
+          );
174
+     }
175 175
 
176 176
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * Contructor
30 30
 	 */
31 31
 	public function __construct() {
32
-		add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
33
-		add_action( 'lsx_projects_settings_page', array( $this, 'general_settings' ), 1, 1 );
34
-		add_action( 'lsx_projects_settings_page', array( $this, 'contact_modal_settings' ), 1, 1 );
32
+		add_action('cmb2_admin_init', array($this, 'register_settings_page'));
33
+		add_action('lsx_projects_settings_page', array($this, 'general_settings'), 1, 1);
34
+		add_action('lsx_projects_settings_page', array($this, 'contact_modal_settings'), 1, 1);
35 35
 	}
36 36
 
37 37
 	/**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static function get_instance() {
45 45
 		// If the single instance hasn't been set, set it now.
46
-		if ( null === self::$instance ) {
46
+		if (null === self::$instance) {
47 47
 			self::$instance = new self();
48 48
 		}
49 49
 		return self::$instance;
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 		$cmb = new_cmb2_box(
57 57
 			array(
58 58
 				'id'           => $this->screen_id,
59
-				'title'        => esc_html__( 'Settings', 'lsx-projects' ),
60
-				'object_types' => array( 'options-page' ),
59
+				'title'        => esc_html__('Settings', 'lsx-projects'),
60
+				'object_types' => array('options-page'),
61 61
 				'option_key'   => 'lsx_projects_options', // The option key and admin menu page slug.
62 62
 				'parent_slug'  => 'edit.php?post_type=project', // Make options page a submenu item of the themes menu.
63 63
 				'capability'   => 'manage_options', // Cap required to view options-page.
64 64
 			)
65 65
 		);
66
-		do_action( 'lsx_projects_settings_page', $cmb );
66
+		do_action('lsx_projects_settings_page', $cmb);
67 67
 	}
68 68
 
69 69
 	/**
@@ -72,30 +72,30 @@  discard block
 block discarded – undo
72 72
 	 * @param object $cmb new_cmb2_box().
73 73
 	 * @return void
74 74
 	 */
75
-	public function general_settings( $cmb ) {
75
+	public function general_settings($cmb) {
76 76
 		$cmb->add_field(
77 77
 			array(
78 78
 				'id'      => 'settings_general_title',
79 79
 				'type'    => 'title',
80
-				'name'    => __( 'General', 'lsx-projects' ),
81
-				'default' => __( 'General', 'lsx-projects' ),
80
+				'name'    => __('General', 'lsx-projects'),
81
+				'default' => __('General', 'lsx-projects'),
82 82
 			)
83 83
 		);
84 84
 		$cmb->add_field(
85 85
 			array(
86
-				'name'        => __( 'Disable Single Posts', 'lsx-projects' ),
86
+				'name'        => __('Disable Single Posts', 'lsx-projects'),
87 87
 				'id'          => 'projects_disable_single',
88 88
 				'type'        => 'checkbox',
89 89
 				'value'       => 1,
90 90
 				'default'     => 0,
91
-				'description' => __( 'Disable Single Posts.', 'lsx-projects' ),
91
+				'description' => __('Disable Single Posts.', 'lsx-projects'),
92 92
 			)
93 93
 		);
94 94
 
95 95
 		$cmb->add_field(
96 96
 			array(
97 97
 				'name'    => 'Placeholder',
98
-				'desc'    => __( 'Choose Image.', 'lsx-projects' ),
98
+				'desc'    => __('Choose Image.', 'lsx-projects'),
99 99
 				'id'      => 'projects_placeholder',
100 100
 				'type'    => 'file',
101 101
 				'options' => array(
@@ -121,29 +121,29 @@  discard block
 block discarded – undo
121 121
 	 * @param object $cmb new_cmb2_box().
122 122
 	 * @return void
123 123
 	 */
124
-	public function contact_modal_settings( $cmb ) {
124
+	public function contact_modal_settings($cmb) {
125 125
 		$cmb->add_field(
126 126
 			array(
127 127
 				'id'   => 'settings_contact_modal_title',
128 128
 				'type' => 'title',
129
-				'name' => __( 'Contact modal', 'lsx-projects' ),
130
-				'description' => __( 'Displays contact modal on project single if there is a linked Caldera or WPform.', 'lsx-projects' ),
129
+				'name' => __('Contact modal', 'lsx-projects'),
130
+				'description' => __('Displays contact modal on project single if there is a linked Caldera or WPform.', 'lsx-projects'),
131 131
 			)
132 132
 		);
133 133
 		$cmb->add_field(
134 134
 			array(
135
-				'name'        => __( 'Enable contact modal', 'lsx-projects' ),
135
+				'name'        => __('Enable contact modal', 'lsx-projects'),
136 136
 				'id'          => 'projects_modal_enable',
137 137
 				'type'        => 'checkbox',
138 138
 				'value'       => 1,
139 139
 				'default'     => 0,
140
-				'description' => __( 'Displays contact modal on project single.', 'lsx-projects' ),
140
+				'description' => __('Displays contact modal on project single.', 'lsx-projects'),
141 141
 			)
142 142
 		);
143 143
 
144 144
 		$cmb->add_field(
145 145
 			array(
146
-				'name' => __( 'Button label', 'lsx-projects' ),
146
+				'name' => __('Button label', 'lsx-projects'),
147 147
 				'id'   => 'projects_modal_cta_label',
148 148
 				'type' => 'text',
149 149
 			)
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 		$cmb->add_field(
153 153
 			array(
154
-				'name' => __( 'Caldera Form ID (if enabled)', 'lsx-projects' ),
154
+				'name' => __('Caldera Form ID (if enabled)', 'lsx-projects'),
155 155
 				'id'   => 'projects_modal_form_id',
156 156
 				'type' => 'text',
157 157
 			)
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 		$cmb->add_field(
161 161
 			array(
162
-				'name' => __( 'WPForm ID (if enabled)', 'lsx-projects' ),
162
+				'name' => __('WPForm ID (if enabled)', 'lsx-projects'),
163 163
 				'id'   => 'projects_wpform_modal_form_id',
164 164
 				'type' => 'text',
165 165
 			)
Please login to merge, or discard this patch.
classes/class-lsx-projects-frontend.php 2 patches
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -10,115 +10,115 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class LSX_Projects_Frontend {
12 12
 
13
-	public function __construct() {
14
-		$this->options = projects_get_options();
15
-
16
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 );
17
-		add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
18
-		add_filter( 'template_include', array( $this, 'single_template_include' ), 99 );
19
-		add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 );
20
-
21
-		if ( ! empty( $this->options['display']['projects_disable_single'] ) ) {
22
-			add_action( 'template_redirect', array( $this, 'disable_single' ) );
23
-		}
24
-
25
-		if ( is_admin() ) {
26
-			add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 );
27
-		}
28
-
29
-		add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 );
30
-
31
-		add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) );
32
-		add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) );
33
-		add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) );
34
-
35
-		add_filter( 'pre_get_posts', array( $this, 'posts_per_page' ) );
36
-		add_action( 'wp_footer', array( $this, 'add_form_modal' ) );
37
-	}
38
-
39
-	public function enqueue_scripts() {
40
-		$has_slick = wp_script_is( 'slick', 'queue' );
41
-
42
-		if ( ! $has_slick ) {
43
-			wp_enqueue_style( 'slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null );
44
-			wp_enqueue_script( 'slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
45
-		}
46
-
47
-		$has_scrolltofixed = wp_script_is( 'scrolltofixed', 'queue' );
48
-
49
-		if ( ! $has_scrolltofixed ) {
50
-			wp_enqueue_script( 'scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
51
-		}
52
-
53
-		$has_isotope = wp_script_is( 'isotope', 'queue' );
54
-
55
-		if ( ! $has_isotope ) {
56
-			wp_enqueue_script( 'isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
57
-		}
58
-
59
-		wp_enqueue_script( 'lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array( 'jquery', 'slick', 'scrolltofixed', 'isotope' ), LSX_PROJECTS_VER, true );
60
-
61
-		$params = apply_filters( 'lsx_projects_js_params', array(
62
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
63
-		));
64
-
65
-		wp_localize_script( 'lsx-projects', 'lsx_customizer_params', $params );
66
-
67
-		wp_enqueue_style( 'lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER );
68
-		wp_style_add_data( 'lsx-projects', 'rtl', 'replace' );
69
-	}
70
-
71
-	/**
72
-	 * Allow data params for Slick slider addon.
73
-	 */
74
-	public function wp_kses_allowed_html( $allowedtags, $context ) {
75
-		$allowedtags['div']['data-slick'] = true;
76
-		return $allowedtags;
77
-	}
78
-
79
-	/**
80
-	 * Single template.
81
-	 */
82
-	public function single_template_include( $template ) {
83
-		if ( is_main_query() && is_singular( 'project' ) ) {
84
-			if ( empty( locate_template( array( 'single-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/single-projects.php' ) ) {
85
-				$template = LSX_PROJECTS_PATH . 'templates/single-projects.php';
86
-			}
87
-		}
88
-
89
-		return $template;
90
-	}
91
-
92
-	/**
93
-	 * Archive template.
94
-	 */
95
-	public function archive_template_include( $template ) {
96
-		if ( is_main_query() && ( is_post_type_archive( 'project' ) || is_tax( 'project-group' ) ) ) {
97
-			if ( empty( locate_template( array( 'archive-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/archive-projects.php' ) ) {
98
-				$template = LSX_PROJECTS_PATH . 'templates/archive-projects.php';
99
-			}
100
-		}
101
-
102
-		return $template;
103
-	}
104
-
105
-	/**
106
-	 * Removes access to single project member posts.
107
-	 */
108
-	public function disable_single() {
109
-		$queried_post_type = get_query_var( 'post_type' );
110
-
111
-		if ( is_single() && 'project' === $queried_post_type ) {
112
-			wp_redirect( home_url(), 301 );
113
-			exit;
114
-		}
115
-	}
116
-
117
-	/**
118
-	 * Handle body colours that might be change by LSX Customiser
119
-	 */
120
-	public function customizer_body_colours_handler( $css, $colors ) {
121
-		$css .= '
13
+     public function __construct() {
14
+          $this->options = projects_get_options();
15
+
16
+          add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 );
17
+          add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
18
+          add_filter( 'template_include', array( $this, 'single_template_include' ), 99 );
19
+          add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 );
20
+
21
+          if ( ! empty( $this->options['display']['projects_disable_single'] ) ) {
22
+               add_action( 'template_redirect', array( $this, 'disable_single' ) );
23
+          }
24
+
25
+          if ( is_admin() ) {
26
+               add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 );
27
+          }
28
+
29
+          add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 );
30
+
31
+          add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) );
32
+          add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) );
33
+          add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) );
34
+
35
+          add_filter( 'pre_get_posts', array( $this, 'posts_per_page' ) );
36
+          add_action( 'wp_footer', array( $this, 'add_form_modal' ) );
37
+     }
38
+
39
+     public function enqueue_scripts() {
40
+          $has_slick = wp_script_is( 'slick', 'queue' );
41
+
42
+          if ( ! $has_slick ) {
43
+               wp_enqueue_style( 'slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null );
44
+               wp_enqueue_script( 'slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
45
+          }
46
+
47
+          $has_scrolltofixed = wp_script_is( 'scrolltofixed', 'queue' );
48
+
49
+          if ( ! $has_scrolltofixed ) {
50
+               wp_enqueue_script( 'scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
51
+          }
52
+
53
+          $has_isotope = wp_script_is( 'isotope', 'queue' );
54
+
55
+          if ( ! $has_isotope ) {
56
+               wp_enqueue_script( 'isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
57
+          }
58
+
59
+          wp_enqueue_script( 'lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array( 'jquery', 'slick', 'scrolltofixed', 'isotope' ), LSX_PROJECTS_VER, true );
60
+
61
+          $params = apply_filters( 'lsx_projects_js_params', array(
62
+               'ajax_url' => admin_url( 'admin-ajax.php' ),
63
+          ));
64
+
65
+          wp_localize_script( 'lsx-projects', 'lsx_customizer_params', $params );
66
+
67
+          wp_enqueue_style( 'lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER );
68
+          wp_style_add_data( 'lsx-projects', 'rtl', 'replace' );
69
+     }
70
+
71
+     /**
72
+      * Allow data params for Slick slider addon.
73
+      */
74
+     public function wp_kses_allowed_html( $allowedtags, $context ) {
75
+          $allowedtags['div']['data-slick'] = true;
76
+          return $allowedtags;
77
+     }
78
+
79
+     /**
80
+      * Single template.
81
+      */
82
+     public function single_template_include( $template ) {
83
+          if ( is_main_query() && is_singular( 'project' ) ) {
84
+               if ( empty( locate_template( array( 'single-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/single-projects.php' ) ) {
85
+                    $template = LSX_PROJECTS_PATH . 'templates/single-projects.php';
86
+               }
87
+          }
88
+
89
+          return $template;
90
+     }
91
+
92
+     /**
93
+      * Archive template.
94
+      */
95
+     public function archive_template_include( $template ) {
96
+          if ( is_main_query() && ( is_post_type_archive( 'project' ) || is_tax( 'project-group' ) ) ) {
97
+               if ( empty( locate_template( array( 'archive-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/archive-projects.php' ) ) {
98
+                    $template = LSX_PROJECTS_PATH . 'templates/archive-projects.php';
99
+               }
100
+          }
101
+
102
+          return $template;
103
+     }
104
+
105
+     /**
106
+      * Removes access to single project member posts.
107
+      */
108
+     public function disable_single() {
109
+          $queried_post_type = get_query_var( 'post_type' );
110
+
111
+          if ( is_single() && 'project' === $queried_post_type ) {
112
+               wp_redirect( home_url(), 301 );
113
+               exit;
114
+          }
115
+     }
116
+
117
+     /**
118
+      * Handle body colours that might be change by LSX Customiser
119
+      */
120
+     public function customizer_body_colours_handler( $css, $colors ) {
121
+          $css .= '
122 122
 			@import "' . LSX_PROJECTS_PATH . '/assets/css/scss/customizer-projects-body-colours";
123 123
 
124 124
 			/**
@@ -134,104 +134,104 @@  discard block
 block discarded – undo
134 134
 			);
135 135
 		';
136 136
 
137
-		return $css;
138
-	}
139
-
140
-	/**
141
-	 * Change the LSX Banners title for project archive.
142
-	 */
143
-	public function lsx_banner_archive_title( $title ) {
144
-		if ( is_main_query() && is_post_type_archive( 'project' ) ) {
145
-			$title = '<h1 class="page-title">' . esc_html__( 'Portfolio', 'lsx-projects' ) . '</h1>';
146
-		}
147
-
148
-		if ( is_main_query() && is_tax( 'project-group' ) ) {
149
-			$tax = get_queried_object();
150
-			$title = '<h1 class="page-title">' . esc_html__( 'Project Type', 'lsx-projects' ) . ': ' . apply_filters( 'the_title', $tax->name ) . '</h1>';
151
-		}
152
-
153
-		return $title;
154
-	}
155
-
156
-	/**
157
-	 * Remove the "continue reading" when the single is disabled.
158
-	 */
159
-	public function change_excerpt_more( $excerpt_more ) {
160
-		global $post;
161
-
162
-		if ( 'project' === $post->post_type ) {
163
-			if ( ! empty( $this->options['display']['projects_disable_single'] ) ) {
164
-				$excerpt_more = '';
165
-			}
166
-		}
167
-
168
-		return $excerpt_more;
169
-	}
170
-
171
-	/**
172
-	 * Change the word count when crop the content to excerpt (homepage widget).
173
-	 */
174
-	public function change_excerpt_length( $excerpt_word_count ) {
175
-		global $post;
176
-
177
-		if ( is_front_page() && 'project' === $post->post_type ) {
178
-			$excerpt_word_count = 20;
179
-		}
180
-
181
-		if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) {
182
-			$excerpt_word_count = 20;
183
-		}
184
-
185
-		return $excerpt_word_count;
186
-	}
187
-
188
-	/**
189
-	 * Change the allowed tags crop the content to excerpt (homepage widget).
190
-	 */
191
-	public function change_excerpt_strip_tags( $allowed_tags ) {
192
-		global $post;
193
-
194
-		if ( is_front_page() && 'project' === $post->post_type ) {
195
-			$allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
196
-		}
197
-
198
-		if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) {
199
-			$allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
200
-		}
201
-
202
-		return $allowed_tags;
203
-	}
204
-
205
-	/**
206
-	 * Change posts per page counter for archive.
207
-	 */
208
-	public function posts_per_page( $query ) {
209
-		if ( ! is_admin() && $query->is_main_query() ) {
210
-			if ( $query->is_post_type_archive( 'project' ) || $query->is_tax( 'project-group' ) ) {
211
-				$query->set( 'posts_per_page', -1 );
212
-			}
213
-		}
214
-
215
-		return $query;
216
-	}
217
-
218
-	/**
219
-	 * Add form modal
220
-	 */
221
-	public function add_form_modal() {
222
-
223
-		if ( empty( $this->options['display']['projects_modal_enable'] ) ) {
224
-			return '';
225
-		}
226
-
227
-		if ( empty( $this->options['display']['projects_modal_cta_label'] ) || empty( $this->options['display']['projects_modal_form_id'] ) || empty( $this->options['display']['projects_wpform_modal_form_id'] ) ) {
228
-			return '';
229
-		}
230
-
231
-		if ( ! is_singular( 'project' ) ) {
232
-			return '';
233
-		}
234
-		?>
137
+          return $css;
138
+     }
139
+
140
+     /**
141
+      * Change the LSX Banners title for project archive.
142
+      */
143
+     public function lsx_banner_archive_title( $title ) {
144
+          if ( is_main_query() && is_post_type_archive( 'project' ) ) {
145
+               $title = '<h1 class="page-title">' . esc_html__( 'Portfolio', 'lsx-projects' ) . '</h1>';
146
+          }
147
+
148
+          if ( is_main_query() && is_tax( 'project-group' ) ) {
149
+               $tax = get_queried_object();
150
+               $title = '<h1 class="page-title">' . esc_html__( 'Project Type', 'lsx-projects' ) . ': ' . apply_filters( 'the_title', $tax->name ) . '</h1>';
151
+          }
152
+
153
+          return $title;
154
+     }
155
+
156
+     /**
157
+      * Remove the "continue reading" when the single is disabled.
158
+      */
159
+     public function change_excerpt_more( $excerpt_more ) {
160
+          global $post;
161
+
162
+          if ( 'project' === $post->post_type ) {
163
+               if ( ! empty( $this->options['display']['projects_disable_single'] ) ) {
164
+                    $excerpt_more = '';
165
+               }
166
+          }
167
+
168
+          return $excerpt_more;
169
+     }
170
+
171
+     /**
172
+      * Change the word count when crop the content to excerpt (homepage widget).
173
+      */
174
+     public function change_excerpt_length( $excerpt_word_count ) {
175
+          global $post;
176
+
177
+          if ( is_front_page() && 'project' === $post->post_type ) {
178
+               $excerpt_word_count = 20;
179
+          }
180
+
181
+          if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) {
182
+               $excerpt_word_count = 20;
183
+          }
184
+
185
+          return $excerpt_word_count;
186
+     }
187
+
188
+     /**
189
+      * Change the allowed tags crop the content to excerpt (homepage widget).
190
+      */
191
+     public function change_excerpt_strip_tags( $allowed_tags ) {
192
+          global $post;
193
+
194
+          if ( is_front_page() && 'project' === $post->post_type ) {
195
+               $allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
196
+          }
197
+
198
+          if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) {
199
+               $allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
200
+          }
201
+
202
+          return $allowed_tags;
203
+     }
204
+
205
+     /**
206
+      * Change posts per page counter for archive.
207
+      */
208
+     public function posts_per_page( $query ) {
209
+          if ( ! is_admin() && $query->is_main_query() ) {
210
+               if ( $query->is_post_type_archive( 'project' ) || $query->is_tax( 'project-group' ) ) {
211
+                    $query->set( 'posts_per_page', -1 );
212
+               }
213
+          }
214
+
215
+          return $query;
216
+     }
217
+
218
+     /**
219
+      * Add form modal
220
+      */
221
+     public function add_form_modal() {
222
+
223
+          if ( empty( $this->options['display']['projects_modal_enable'] ) ) {
224
+               return '';
225
+          }
226
+
227
+          if ( empty( $this->options['display']['projects_modal_cta_label'] ) || empty( $this->options['display']['projects_modal_form_id'] ) || empty( $this->options['display']['projects_wpform_modal_form_id'] ) ) {
228
+               return '';
229
+          }
230
+
231
+          if ( ! is_singular( 'project' ) ) {
232
+               return '';
233
+          }
234
+          ?>
235 235
 		<div class="lsx-modal modal fade" id="lsx-project-contact" role="dialog">
236 236
 			<div class="modal-dialog">
237 237
 				<div class="modal-content">
@@ -243,17 +243,17 @@  discard block
 block discarded – undo
243 243
 
244 244
 					<div class="modal-body">
245 245
 						<?php
246
-						if ( ! empty( $this->options['display']['projects_modal_form_id'] ) ) {
247
-							echo do_shortcode( '[caldera_form id="' . $this->options['display']['projects_modal_form_id'] . '"]' );
248
-						} elseif ( ! empty( $this->options['display']['projects_wpform_modal_form_id'] ) ) {
249
-							echo do_shortcode( '[wpforms id="' . $this->options['display']['projects_wpform_modal_form_id'] . '"]' );
250
-						} ?>
246
+                              if ( ! empty( $this->options['display']['projects_modal_form_id'] ) ) {
247
+                                   echo do_shortcode( '[caldera_form id="' . $this->options['display']['projects_modal_form_id'] . '"]' );
248
+                              } elseif ( ! empty( $this->options['display']['projects_wpform_modal_form_id'] ) ) {
249
+                                   echo do_shortcode( '[wpforms id="' . $this->options['display']['projects_wpform_modal_form_id'] . '"]' );
250
+                              } ?>
251 251
 					</div>
252 252
 				</div>
253 253
 			</div>
254 254
 		</div>
255 255
 		<?php
256
-	}
256
+     }
257 257
 
258 258
 }
259 259
 
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -13,65 +13,65 @@  discard block
 block discarded – undo
13 13
 	public function __construct() {
14 14
 		$this->options = projects_get_options();
15 15
 
16
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 );
17
-		add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
18
-		add_filter( 'template_include', array( $this, 'single_template_include' ), 99 );
19
-		add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 );
16
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5);
17
+		add_filter('wp_kses_allowed_html', array($this, 'wp_kses_allowed_html'), 10, 2);
18
+		add_filter('template_include', array($this, 'single_template_include'), 99);
19
+		add_filter('template_include', array($this, 'archive_template_include'), 99);
20 20
 
21
-		if ( ! empty( $this->options['display']['projects_disable_single'] ) ) {
22
-			add_action( 'template_redirect', array( $this, 'disable_single' ) );
21
+		if ( ! empty($this->options['display']['projects_disable_single'])) {
22
+			add_action('template_redirect', array($this, 'disable_single'));
23 23
 		}
24 24
 
25
-		if ( is_admin() ) {
26
-			add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 );
25
+		if (is_admin()) {
26
+			add_filter('lsx_customizer_colour_selectors_body', array($this, 'customizer_body_colours_handler'), 15, 2);
27 27
 		}
28 28
 
29
-		add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 );
29
+		add_filter('lsx_banner_title', array($this, 'lsx_banner_archive_title'), 15);
30 30
 
31
-		add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) );
32
-		add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) );
33
-		add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) );
31
+		add_filter('excerpt_more_p', array($this, 'change_excerpt_more'));
32
+		add_filter('excerpt_length', array($this, 'change_excerpt_length'));
33
+		add_filter('excerpt_strip_tags', array($this, 'change_excerpt_strip_tags'));
34 34
 
35
-		add_filter( 'pre_get_posts', array( $this, 'posts_per_page' ) );
36
-		add_action( 'wp_footer', array( $this, 'add_form_modal' ) );
35
+		add_filter('pre_get_posts', array($this, 'posts_per_page'));
36
+		add_action('wp_footer', array($this, 'add_form_modal'));
37 37
 	}
38 38
 
39 39
 	public function enqueue_scripts() {
40
-		$has_slick = wp_script_is( 'slick', 'queue' );
40
+		$has_slick = wp_script_is('slick', 'queue');
41 41
 
42
-		if ( ! $has_slick ) {
43
-			wp_enqueue_style( 'slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null );
44
-			wp_enqueue_script( 'slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
42
+		if ( ! $has_slick) {
43
+			wp_enqueue_style('slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null);
44
+			wp_enqueue_script('slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array('jquery'), null, LSX_PROJECTS_VER, true);
45 45
 		}
46 46
 
47
-		$has_scrolltofixed = wp_script_is( 'scrolltofixed', 'queue' );
47
+		$has_scrolltofixed = wp_script_is('scrolltofixed', 'queue');
48 48
 
49
-		if ( ! $has_scrolltofixed ) {
50
-			wp_enqueue_script( 'scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
49
+		if ( ! $has_scrolltofixed) {
50
+			wp_enqueue_script('scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array('jquery'), null, LSX_PROJECTS_VER, true);
51 51
 		}
52 52
 
53
-		$has_isotope = wp_script_is( 'isotope', 'queue' );
53
+		$has_isotope = wp_script_is('isotope', 'queue');
54 54
 
55
-		if ( ! $has_isotope ) {
56
-			wp_enqueue_script( 'isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true );
55
+		if ( ! $has_isotope) {
56
+			wp_enqueue_script('isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array('jquery'), null, LSX_PROJECTS_VER, true);
57 57
 		}
58 58
 
59
-		wp_enqueue_script( 'lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array( 'jquery', 'slick', 'scrolltofixed', 'isotope' ), LSX_PROJECTS_VER, true );
59
+		wp_enqueue_script('lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array('jquery', 'slick', 'scrolltofixed', 'isotope'), LSX_PROJECTS_VER, true);
60 60
 
61
-		$params = apply_filters( 'lsx_projects_js_params', array(
62
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
61
+		$params = apply_filters('lsx_projects_js_params', array(
62
+			'ajax_url' => admin_url('admin-ajax.php'),
63 63
 		));
64 64
 
65
-		wp_localize_script( 'lsx-projects', 'lsx_customizer_params', $params );
65
+		wp_localize_script('lsx-projects', 'lsx_customizer_params', $params);
66 66
 
67
-		wp_enqueue_style( 'lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER );
68
-		wp_style_add_data( 'lsx-projects', 'rtl', 'replace' );
67
+		wp_enqueue_style('lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER);
68
+		wp_style_add_data('lsx-projects', 'rtl', 'replace');
69 69
 	}
70 70
 
71 71
 	/**
72 72
 	 * Allow data params for Slick slider addon.
73 73
 	 */
74
-	public function wp_kses_allowed_html( $allowedtags, $context ) {
74
+	public function wp_kses_allowed_html($allowedtags, $context) {
75 75
 		$allowedtags['div']['data-slick'] = true;
76 76
 		return $allowedtags;
77 77
 	}
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	/**
80 80
 	 * Single template.
81 81
 	 */
82
-	public function single_template_include( $template ) {
83
-		if ( is_main_query() && is_singular( 'project' ) ) {
84
-			if ( empty( locate_template( array( 'single-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/single-projects.php' ) ) {
82
+	public function single_template_include($template) {
83
+		if (is_main_query() && is_singular('project')) {
84
+			if (empty(locate_template(array('single-projects.php'))) && file_exists(LSX_PROJECTS_PATH . 'templates/single-projects.php')) {
85 85
 				$template = LSX_PROJECTS_PATH . 'templates/single-projects.php';
86 86
 			}
87 87
 		}
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 	/**
93 93
 	 * Archive template.
94 94
 	 */
95
-	public function archive_template_include( $template ) {
96
-		if ( is_main_query() && ( is_post_type_archive( 'project' ) || is_tax( 'project-group' ) ) ) {
97
-			if ( empty( locate_template( array( 'archive-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/archive-projects.php' ) ) {
95
+	public function archive_template_include($template) {
96
+		if (is_main_query() && (is_post_type_archive('project') || is_tax('project-group'))) {
97
+			if (empty(locate_template(array('archive-projects.php'))) && file_exists(LSX_PROJECTS_PATH . 'templates/archive-projects.php')) {
98 98
 				$template = LSX_PROJECTS_PATH . 'templates/archive-projects.php';
99 99
 			}
100 100
 		}
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	 * Removes access to single project member posts.
107 107
 	 */
108 108
 	public function disable_single() {
109
-		$queried_post_type = get_query_var( 'post_type' );
109
+		$queried_post_type = get_query_var('post_type');
110 110
 
111
-		if ( is_single() && 'project' === $queried_post_type ) {
112
-			wp_redirect( home_url(), 301 );
111
+		if (is_single() && 'project' === $queried_post_type) {
112
+			wp_redirect(home_url(), 301);
113 113
 			exit;
114 114
 		}
115 115
 	}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	/**
118 118
 	 * Handle body colours that might be change by LSX Customiser
119 119
 	 */
120
-	public function customizer_body_colours_handler( $css, $colors ) {
120
+	public function customizer_body_colours_handler($css, $colors) {
121 121
 		$css .= '
122 122
 			@import "' . LSX_PROJECTS_PATH . '/assets/css/scss/customizer-projects-body-colours";
123 123
 
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
 	/**
141 141
 	 * Change the LSX Banners title for project archive.
142 142
 	 */
143
-	public function lsx_banner_archive_title( $title ) {
144
-		if ( is_main_query() && is_post_type_archive( 'project' ) ) {
145
-			$title = '<h1 class="page-title">' . esc_html__( 'Portfolio', 'lsx-projects' ) . '</h1>';
143
+	public function lsx_banner_archive_title($title) {
144
+		if (is_main_query() && is_post_type_archive('project')) {
145
+			$title = '<h1 class="page-title">' . esc_html__('Portfolio', 'lsx-projects') . '</h1>';
146 146
 		}
147 147
 
148
-		if ( is_main_query() && is_tax( 'project-group' ) ) {
148
+		if (is_main_query() && is_tax('project-group')) {
149 149
 			$tax = get_queried_object();
150
-			$title = '<h1 class="page-title">' . esc_html__( 'Project Type', 'lsx-projects' ) . ': ' . apply_filters( 'the_title', $tax->name ) . '</h1>';
150
+			$title = '<h1 class="page-title">' . esc_html__('Project Type', 'lsx-projects') . ': ' . apply_filters('the_title', $tax->name) . '</h1>';
151 151
 		}
152 152
 
153 153
 		return $title;
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	/**
157 157
 	 * Remove the "continue reading" when the single is disabled.
158 158
 	 */
159
-	public function change_excerpt_more( $excerpt_more ) {
159
+	public function change_excerpt_more($excerpt_more) {
160 160
 		global $post;
161 161
 
162
-		if ( 'project' === $post->post_type ) {
163
-			if ( ! empty( $this->options['display']['projects_disable_single'] ) ) {
162
+		if ('project' === $post->post_type) {
163
+			if ( ! empty($this->options['display']['projects_disable_single'])) {
164 164
 				$excerpt_more = '';
165 165
 			}
166 166
 		}
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 	/**
172 172
 	 * Change the word count when crop the content to excerpt (homepage widget).
173 173
 	 */
174
-	public function change_excerpt_length( $excerpt_word_count ) {
174
+	public function change_excerpt_length($excerpt_word_count) {
175 175
 		global $post;
176 176
 
177
-		if ( is_front_page() && 'project' === $post->post_type ) {
177
+		if (is_front_page() && 'project' === $post->post_type) {
178 178
 			$excerpt_word_count = 20;
179 179
 		}
180 180
 
181
-		if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) {
181
+		if (is_singular('project') && ('team' === $post->post_type || 'testimonial' === $post->post_type)) {
182 182
 			$excerpt_word_count = 20;
183 183
 		}
184 184
 
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	/**
189 189
 	 * Change the allowed tags crop the content to excerpt (homepage widget).
190 190
 	 */
191
-	public function change_excerpt_strip_tags( $allowed_tags ) {
191
+	public function change_excerpt_strip_tags($allowed_tags) {
192 192
 		global $post;
193 193
 
194
-		if ( is_front_page() && 'project' === $post->post_type ) {
194
+		if (is_front_page() && 'project' === $post->post_type) {
195 195
 			$allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
196 196
 		}
197 197
 
198
-		if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) {
198
+		if (is_singular('project') && ('team' === $post->post_type || 'testimonial' === $post->post_type)) {
199 199
 			$allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>';
200 200
 		}
201 201
 
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 	/**
206 206
 	 * Change posts per page counter for archive.
207 207
 	 */
208
-	public function posts_per_page( $query ) {
209
-		if ( ! is_admin() && $query->is_main_query() ) {
210
-			if ( $query->is_post_type_archive( 'project' ) || $query->is_tax( 'project-group' ) ) {
211
-				$query->set( 'posts_per_page', -1 );
208
+	public function posts_per_page($query) {
209
+		if ( ! is_admin() && $query->is_main_query()) {
210
+			if ($query->is_post_type_archive('project') || $query->is_tax('project-group')) {
211
+				$query->set('posts_per_page', -1);
212 212
 			}
213 213
 		}
214 214
 
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	public function add_form_modal() {
222 222
 
223
-		if ( empty( $this->options['display']['projects_modal_enable'] ) ) {
223
+		if (empty($this->options['display']['projects_modal_enable'])) {
224 224
 			return '';
225 225
 		}
226 226
 
227
-		if ( empty( $this->options['display']['projects_modal_cta_label'] ) || empty( $this->options['display']['projects_modal_form_id'] ) || empty( $this->options['display']['projects_wpform_modal_form_id'] ) ) {
227
+		if (empty($this->options['display']['projects_modal_cta_label']) || empty($this->options['display']['projects_modal_form_id']) || empty($this->options['display']['projects_wpform_modal_form_id'])) {
228 228
 			return '';
229 229
 		}
230 230
 
231
-		if ( ! is_singular( 'project' ) ) {
231
+		if ( ! is_singular('project')) {
232 232
 			return '';
233 233
 		}
234 234
 		?>
@@ -238,15 +238,15 @@  discard block
 block discarded – undo
238 238
 					<button type="button" class="close" data-dismiss="modal">&times;</button>
239 239
 
240 240
 					<div class="modal-header">
241
-						<h4 class="modal-title"><?php echo esc_html( $this->options['display']['projects_modal_cta_label'] ); ?></h4>
241
+						<h4 class="modal-title"><?php echo esc_html($this->options['display']['projects_modal_cta_label']); ?></h4>
242 242
 					</div>
243 243
 
244 244
 					<div class="modal-body">
245 245
 						<?php
246
-						if ( ! empty( $this->options['display']['projects_modal_form_id'] ) ) {
247
-							echo do_shortcode( '[caldera_form id="' . $this->options['display']['projects_modal_form_id'] . '"]' );
248
-						} elseif ( ! empty( $this->options['display']['projects_wpform_modal_form_id'] ) ) {
249
-							echo do_shortcode( '[wpforms id="' . $this->options['display']['projects_wpform_modal_form_id'] . '"]' );
246
+						if ( ! empty($this->options['display']['projects_modal_form_id'])) {
247
+							echo do_shortcode('[caldera_form id="' . $this->options['display']['projects_modal_form_id'] . '"]');
248
+						} elseif ( ! empty($this->options['display']['projects_wpform_modal_form_id'])) {
249
+							echo do_shortcode('[wpforms id="' . $this->options['display']['projects_wpform_modal_form_id'] . '"]');
250 250
 						} ?>
251 251
 					</div>
252 252
 				</div>
Please login to merge, or discard this patch.
includes/functions.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Add our action to init to set up our vars first.
14 14
  */
15 15
 function lsx_projects_load_plugin_textdomain() {
16
-	load_plugin_textdomain( 'lsx-projects', false, basename( LSX_PROJECTS_PATH ) . '/languages' );
16
+     load_plugin_textdomain( 'lsx-projects', false, basename( LSX_PROJECTS_PATH ) . '/languages' );
17 17
 }
18 18
 add_action( 'init', 'lsx_projects_load_plugin_textdomain' );
19 19
 
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
  * Wraps the output class in a function to be called in templates
22 22
  */
23 23
 function lsx_projects( $args ) {
24
-	$lsx_projects = new LSX_Projects;
25
-	echo wp_kses_post( $lsx_projects->output( $args ) );
24
+     $lsx_projects = new LSX_Projects;
25
+     echo wp_kses_post( $lsx_projects->output( $args ) );
26 26
 }
27 27
 
28 28
 /**
29 29
  * Shortcode
30 30
  */
31 31
 function lsx_projects_shortcode( $atts ) {
32
-	$lsx_projects = new LSX_Projects;
33
-	return $lsx_projects->output( $atts );
32
+     $lsx_projects = new LSX_Projects;
33
+     return $lsx_projects->output( $atts );
34 34
 }
35 35
 add_shortcode( 'lsx_projects', 'lsx_projects_shortcode' );
36 36
 
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
  * Wraps the output class in a function to be called in templates
39 39
  */
40 40
 function lsx_groups_list() {
41
-	do_action( 'lsx_groups_list' );
41
+     do_action( 'lsx_groups_list' );
42 42
 }
43 43
 
44 44
 function lsx_child_group_list() {
45
-	do_action( 'lsx_child_group_list' );
45
+     do_action( 'lsx_child_group_list' );
46 46
 }
47 47
 
48 48
 function lsx_projects_list() {
49
-	do_action( 'lsx_projects_list' );
49
+     do_action( 'lsx_projects_list' );
50 50
 }
51 51
 
52 52
 function lsx_projects_sidebar() {
53
-	do_action( 'lsx_projects_sidebar' );
53
+     do_action( 'lsx_projects_sidebar' );
54 54
 }
55 55
 
56 56
 function lsx_projects_single_tag() {
57
-	do_action( 'lsx_projects_single_tag' );
57
+     do_action( 'lsx_projects_single_tag' );
58 58
 }
59 59
 
60 60
 /**
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
  * @return mixed           Option value
66 66
  */
67 67
 function projects_get_options() {
68
-	$options = array();
69
-	if ( function_exists( 'tour_operator' ) ) {
70
-		$options = get_option( '_lsx-to_settings', false );
71
-	} else {
72
-		$options = get_option( '_lsx_settings', false );
73
-
74
-		if ( false === $options ) {
75
-			$options = get_option( '_lsx_lsx-settings', false );
76
-		}
77
-	}
78
-
79
-	// If there are new CMB2 options available, then use those.
80
-	$new_options = get_option( 'lsx_projects_options', false );
81
-	if ( false !== $new_options ) {
82
-		$options['display'] = $new_options;
83
-	}
84
-	return $options;
68
+     $options = array();
69
+     if ( function_exists( 'tour_operator' ) ) {
70
+          $options = get_option( '_lsx-to_settings', false );
71
+     } else {
72
+          $options = get_option( '_lsx_settings', false );
73
+
74
+          if ( false === $options ) {
75
+               $options = get_option( '_lsx_lsx-settings', false );
76
+          }
77
+     }
78
+
79
+     // If there are new CMB2 options available, then use those.
80
+     $new_options = get_option( 'lsx_projects_options', false );
81
+     if ( false !== $new_options ) {
82
+          $options['display'] = $new_options;
83
+     }
84
+     return $options;
85 85
 }
86 86
 
87 87
 /**
@@ -92,28 +92,28 @@  discard block
 block discarded – undo
92 92
  * @return mixed           Option value
93 93
  */
94 94
 function projects_get_option( $key = '', $default = false ) {
95
-	$options = array();
96
-	$value   = $default;
97
-	if ( function_exists( 'tour_operator' ) ) {
98
-		$options = get_option( '_lsx-to_settings', false );
99
-	} else {
100
-		$options = get_option( '_lsx_settings', false );
101
-
102
-		if ( false === $options ) {
103
-			$options = get_option( '_lsx_lsx-settings', false );
104
-		}
105
-	}
106
-
107
-	// If there are new CMB2 options available, then use those.
108
-	$new_options = get_option( 'lsx_projects_options', false );
109
-	if ( false !== $new_options ) {
110
-		$options['display'] = $new_options;
111
-	}
112
-
113
-	if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) {
114
-		$value = $options['display'][ $key ];
115
-	}
116
-	return $value;
95
+     $options = array();
96
+     $value   = $default;
97
+     if ( function_exists( 'tour_operator' ) ) {
98
+          $options = get_option( '_lsx-to_settings', false );
99
+     } else {
100
+          $options = get_option( '_lsx_settings', false );
101
+
102
+          if ( false === $options ) {
103
+               $options = get_option( '_lsx_lsx-settings', false );
104
+          }
105
+     }
106
+
107
+     // If there are new CMB2 options available, then use those.
108
+     $new_options = get_option( 'lsx_projects_options', false );
109
+     if ( false !== $new_options ) {
110
+          $options['display'] = $new_options;
111
+     }
112
+
113
+     if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) {
114
+          $value = $options['display'][ $key ];
115
+     }
116
+     return $value;
117 117
 }
118 118
 
119 119
 
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
  * @return void
125 125
  */
126 126
 function portfolio_modify_archive_title( $title ) {
127
-	if ( ! is_post_type_archive( 'project' ) ) {
128
-		return $title;
129
-	}
130
-	$title = __( 'Portfolio', 'lsx' );
131
-	return $title;
127
+     if ( ! is_post_type_archive( 'project' ) ) {
128
+          return $title;
129
+     }
130
+     $title = __( 'Portfolio', 'lsx' );
131
+     return $title;
132 132
 }
133 133
 add_filter( 'get_the_archive_title', 'portfolio_modify_archive_title', 10, 1 );
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@  discard block
 block discarded – undo
13 13
  * Add our action to init to set up our vars first.
14 14
  */
15 15
 function lsx_projects_load_plugin_textdomain() {
16
-	load_plugin_textdomain( 'lsx-projects', false, basename( LSX_PROJECTS_PATH ) . '/languages' );
16
+	load_plugin_textdomain('lsx-projects', false, basename(LSX_PROJECTS_PATH) . '/languages');
17 17
 }
18
-add_action( 'init', 'lsx_projects_load_plugin_textdomain' );
18
+add_action('init', 'lsx_projects_load_plugin_textdomain');
19 19
 
20 20
 /**
21 21
  * Wraps the output class in a function to be called in templates
22 22
  */
23
-function lsx_projects( $args ) {
23
+function lsx_projects($args) {
24 24
 	$lsx_projects = new LSX_Projects;
25
-	echo wp_kses_post( $lsx_projects->output( $args ) );
25
+	echo wp_kses_post($lsx_projects->output($args));
26 26
 }
27 27
 
28 28
 /**
29 29
  * Shortcode
30 30
  */
31
-function lsx_projects_shortcode( $atts ) {
31
+function lsx_projects_shortcode($atts) {
32 32
 	$lsx_projects = new LSX_Projects;
33
-	return $lsx_projects->output( $atts );
33
+	return $lsx_projects->output($atts);
34 34
 }
35
-add_shortcode( 'lsx_projects', 'lsx_projects_shortcode' );
35
+add_shortcode('lsx_projects', 'lsx_projects_shortcode');
36 36
 
37 37
 /**
38 38
  * Wraps the output class in a function to be called in templates
39 39
  */
40 40
 function lsx_groups_list() {
41
-	do_action( 'lsx_groups_list' );
41
+	do_action('lsx_groups_list');
42 42
 }
43 43
 
44 44
 function lsx_child_group_list() {
45
-	do_action( 'lsx_child_group_list' );
45
+	do_action('lsx_child_group_list');
46 46
 }
47 47
 
48 48
 function lsx_projects_list() {
49
-	do_action( 'lsx_projects_list' );
49
+	do_action('lsx_projects_list');
50 50
 }
51 51
 
52 52
 function lsx_projects_sidebar() {
53
-	do_action( 'lsx_projects_sidebar' );
53
+	do_action('lsx_projects_sidebar');
54 54
 }
55 55
 
56 56
 function lsx_projects_single_tag() {
57
-	do_action( 'lsx_projects_single_tag' );
57
+	do_action('lsx_projects_single_tag');
58 58
 }
59 59
 
60 60
 /**
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function projects_get_options() {
68 68
 	$options = array();
69
-	if ( function_exists( 'tour_operator' ) ) {
70
-		$options = get_option( '_lsx-to_settings', false );
69
+	if (function_exists('tour_operator')) {
70
+		$options = get_option('_lsx-to_settings', false);
71 71
 	} else {
72
-		$options = get_option( '_lsx_settings', false );
72
+		$options = get_option('_lsx_settings', false);
73 73
 
74
-		if ( false === $options ) {
75
-			$options = get_option( '_lsx_lsx-settings', false );
74
+		if (false === $options) {
75
+			$options = get_option('_lsx_lsx-settings', false);
76 76
 		}
77 77
 	}
78 78
 
79 79
 	// If there are new CMB2 options available, then use those.
80
-	$new_options = get_option( 'lsx_projects_options', false );
81
-	if ( false !== $new_options ) {
80
+	$new_options = get_option('lsx_projects_options', false);
81
+	if (false !== $new_options) {
82 82
 		$options['display'] = $new_options;
83 83
 	}
84 84
 	return $options;
@@ -91,27 +91,27 @@  discard block
 block discarded – undo
91 91
  * @param  mixed  $default Optional default value
92 92
  * @return mixed           Option value
93 93
  */
94
-function projects_get_option( $key = '', $default = false ) {
94
+function projects_get_option($key = '', $default = false) {
95 95
 	$options = array();
96 96
 	$value   = $default;
97
-	if ( function_exists( 'tour_operator' ) ) {
98
-		$options = get_option( '_lsx-to_settings', false );
97
+	if (function_exists('tour_operator')) {
98
+		$options = get_option('_lsx-to_settings', false);
99 99
 	} else {
100
-		$options = get_option( '_lsx_settings', false );
100
+		$options = get_option('_lsx_settings', false);
101 101
 
102
-		if ( false === $options ) {
103
-			$options = get_option( '_lsx_lsx-settings', false );
102
+		if (false === $options) {
103
+			$options = get_option('_lsx_lsx-settings', false);
104 104
 		}
105 105
 	}
106 106
 
107 107
 	// If there are new CMB2 options available, then use those.
108
-	$new_options = get_option( 'lsx_projects_options', false );
109
-	if ( false !== $new_options ) {
108
+	$new_options = get_option('lsx_projects_options', false);
109
+	if (false !== $new_options) {
110 110
 		$options['display'] = $new_options;
111 111
 	}
112 112
 
113
-	if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) {
114
-		$value = $options['display'][ $key ];
113
+	if (isset($options['display']) && isset($options['display'][$key])) {
114
+		$value = $options['display'][$key];
115 115
 	}
116 116
 	return $value;
117 117
 }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
  * @param [type] $title
124 124
  * @return void
125 125
  */
126
-function portfolio_modify_archive_title( $title ) {
127
-	if ( ! is_post_type_archive( 'project' ) ) {
126
+function portfolio_modify_archive_title($title) {
127
+	if ( ! is_post_type_archive('project')) {
128 128
 		return $title;
129 129
 	}
130
-	$title = __( 'Portfolio', 'lsx' );
130
+	$title = __('Portfolio', 'lsx');
131 131
 	return $title;
132 132
 }
133
-add_filter( 'get_the_archive_title', 'portfolio_modify_archive_title', 10, 1 );
133
+add_filter('get_the_archive_title', 'portfolio_modify_archive_title', 10, 1);
Please login to merge, or discard this patch.