Passed
Push — master ( a2b158...bbedc2 )
by Warwick
10:01 queued 05:57
created
templates/archive-projects.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -18,44 +18,44 @@  discard block
 block discarded – undo
18 18
 		<?php lsx_content_top(); ?>
19 19
 
20 20
 		<?php
21
-			$args = array(
22
-				'taxonomy'   => 'project-group',
23
-				'hide_empty' => false,
24
-			);
21
+               $args = array(
22
+                    'taxonomy'   => 'project-group',
23
+                    'hide_empty' => false,
24
+               );
25 25
 
26
-			$groups = get_terms( $args );
27
-			$group_selected = get_query_var( 'project-group' );
26
+               $groups = get_terms( $args );
27
+               $group_selected = get_query_var( 'project-group' );
28 28
 
29
-			if ( count( $groups ) > 0 ) :
30
-			?>
29
+               if ( count( $groups ) > 0 ) :
30
+               ?>
31 31
 
32 32
 			<ul class="nav nav-tabs lsx-projects-filter">
33 33
 				<?php
34
-					$group_selected_class = '';
34
+                         $group_selected_class = '';
35 35
 
36
-					if ( empty( $group_selected ) ) {
37
-						$group_selected_class = ' class="active"';
38
-					}
39
-				?>
36
+                         if ( empty( $group_selected ) ) {
37
+                              $group_selected_class = ' class="active"';
38
+                         }
39
+                    ?>
40 40
 
41 41
 				<li<?php echo wp_kses_post( $group_selected_class ); ?>><a href="<?php echo empty( $group_selected ) ? '#' : esc_url( get_post_type_archive_link( 'project' ) ); ?>" data-filter="*"><?php esc_html_e( 'All', 'lsx-projects' ); ?></a></li>
42 42
 
43 43
 				<?php foreach ( $groups as $group ) : ?>
44 44
 					<?php
45
-						$group_selected_class = '';
45
+                              $group_selected_class = '';
46 46
 
47
-						if ( (string) $group_selected === (string) $group->slug ) {
48
-							$group_selected_class = ' class="active"';
49
-						}
50
-					?>
47
+                              if ( (string) $group_selected === (string) $group->slug ) {
48
+                                   $group_selected_class = ' class="active"';
49
+                              }
50
+                         ?>
51 51
 
52 52
 					<li<?php echo wp_kses_post( $group_selected_class ); ?>><a href="<?php echo empty( $group_selected ) ? '#' : esc_url( get_term_link( $group ) ); ?>" data-filter=".filter-<?php echo esc_attr( $group->slug ); ?>"><?php echo esc_attr( $group->name ); ?></a></li>
53 53
 				<?php endforeach; ?>
54 54
 			</ul>
55 55
 
56 56
 			<?php
57
-			endif;
58
-		?>
57
+               endif;
58
+          ?>
59 59
 
60 60
 		<?php if ( have_posts() ) : ?>
61 61
 
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 				<div class="row row-flex lsx-projects-row"">
64 64
 
65 65
 					<?php
66
-						$count = 0;
66
+                              $count = 0;
67 67
 
68
-						while ( have_posts() ) {
69
-							the_post();
70
-							include( LSX_PROJECTS_PATH . '/templates/content-archive-projects.php' );
71
-						}
72
-					?>
68
+                              while ( have_posts() ) {
69
+                                   the_post();
70
+                                   include( LSX_PROJECTS_PATH . '/templates/content-archive-projects.php' );
71
+                              }
72
+                         ?>
73 73
 
74 74
 				</div>
75 75
 			</div>
Please login to merge, or discard this patch.
templates/content-archive-projects.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -5,24 +5,24 @@  discard block
 block discarded – undo
5 5
 ?>
6 6
 
7 7
 <?php
8
-	global $lsx_projects_frontend;
8
+     global $lsx_projects_frontend;
9 9
 
10
-	$groups = '';
11
-	$groups_class = '';
12
-	$terms = get_the_terms( get_the_ID(), 'project-group' );
10
+     $groups = '';
11
+     $groups_class = '';
12
+     $terms = get_the_terms( get_the_ID(), 'project-group' );
13 13
 
14
-	if ( $terms && ! is_wp_error( $terms ) ) {
15
-		$groups = array();
16
-		$groups_class = array();
14
+     if ( $terms && ! is_wp_error( $terms ) ) {
15
+          $groups = array();
16
+          $groups_class = array();
17 17
 
18
-		foreach ( $terms as $term ) {
19
-			$groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
20
-			$groups_class[] = 'filter-' . $term->slug;
21
-		}
18
+          foreach ( $terms as $term ) {
19
+               $groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
20
+               $groups_class[] = 'filter-' . $term->slug;
21
+          }
22 22
 
23
-		$groups = join( ', ', $groups );
24
-		$groups_class = join( ' ', $groups_class );
25
-	}
23
+          $groups = join( ', ', $groups );
24
+          $groups_class = join( ' ', $groups_class );
25
+     }
26 26
 ?>
27 27
 
28 28
 <div class="col-xs-12 col-sm-6 col-md-4 lsx-projects-column <?php echo esc_attr( $groups_class ); ?>">
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 		<?php endif; ?>
37 37
 
38 38
 		<?php
39
-		if ( empty( lsx_get_thumbnail( 'lsx-thumbnail-single' ) ) ) {
40
-			if ( ! empty( projects_get_option( 'projects_placeholder' ) ) ) {
41
-				echo wp_kses_post( '<img src="' . projects_get_option( 'projects_placeholder' ) . '" width="auto" alt="placeholder" />' );
42
-			}
43
-		}
44
-		?>
39
+          if ( empty( lsx_get_thumbnail( 'lsx-thumbnail-single' ) ) ) {
40
+               if ( ! empty( projects_get_option( 'projects_placeholder' ) ) ) {
41
+                    echo wp_kses_post( '<img src="' . projects_get_option( 'projects_placeholder' ) . '" width="auto" alt="placeholder" />' );
42
+               }
43
+          }
44
+          ?>
45 45
 
46 46
 		<h5 class="lsx-projects-title">
47 47
 			<?php if ( ! isset( $lsx_projects_frontend->options['display'] ) || ! isset( $lsx_projects_frontend->options['display']['team_disable_single'] ) ) : ?>
Please login to merge, or discard this patch.
includes/class-lsx-projects-scpo-engine.php 1 patch
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -13,277 +13,277 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class LSX_Projects_SCPO_Engine {
15 15
 
16
-	function __construct() {
17
-		if ( ! get_option( 'lsx_projects_scporder_install' ) ) {
18
-			$this->lsx_projects_scporder_install();
19
-		}
16
+     function __construct() {
17
+          if ( ! get_option( 'lsx_projects_scporder_install' ) ) {
18
+               $this->lsx_projects_scporder_install();
19
+          }
20 20
 
21
-		add_action( 'admin_init', array( $this, 'refresh' ) );
22
-		add_action( 'admin_init', array( $this, 'load_script_css' ) );
21
+          add_action( 'admin_init', array( $this, 'refresh' ) );
22
+          add_action( 'admin_init', array( $this, 'load_script_css' ) );
23 23
 
24
-		add_action( 'wp_ajax_update-menu-order', array( $this, 'update_menu_order' ) );
24
+          add_action( 'wp_ajax_update-menu-order', array( $this, 'update_menu_order' ) );
25 25
 
26
-		add_action( 'pre_get_posts', array( $this, 'lsx_projects_scporder_pre_get_posts' ) );
26
+          add_action( 'pre_get_posts', array( $this, 'lsx_projects_scporder_pre_get_posts' ) );
27 27
 
28
-		add_filter( 'get_previous_post_where', array( $this, 'lsx_projects_scporder_previous_post_where' ) );
29
-		add_filter( 'get_previous_post_sort', array( $this, 'lsx_projects_scporder_previous_post_sort' ) );
30
-		add_filter( 'get_next_post_where', array( $this, 'lsx_projects_scporder_next_post_where' ) );
31
-		add_filter( 'get_next_post_sort', array( $this, 'lsx_projects_scporder_next_post_sort' ) );
32
-	}
28
+          add_filter( 'get_previous_post_where', array( $this, 'lsx_projects_scporder_previous_post_where' ) );
29
+          add_filter( 'get_previous_post_sort', array( $this, 'lsx_projects_scporder_previous_post_sort' ) );
30
+          add_filter( 'get_next_post_where', array( $this, 'lsx_projects_scporder_next_post_where' ) );
31
+          add_filter( 'get_next_post_sort', array( $this, 'lsx_projects_scporder_next_post_sort' ) );
32
+     }
33 33
 
34
-	function lsx_projects_scporder_install() {
35
-		update_option( 'lsx_projects_scporder_install', 1 );
36
-	}
34
+     function lsx_projects_scporder_install() {
35
+          update_option( 'lsx_projects_scporder_install', 1 );
36
+     }
37 37
 
38
-	function _check_load_script_css() {
39
-		$active = false;
40
-		$objects = $this->get_lsx_projects_scporder_options_objects();
38
+     function _check_load_script_css() {
39
+          $active = false;
40
+          $objects = $this->get_lsx_projects_scporder_options_objects();
41 41
 
42
-		if ( empty( $objects ) ) {
43
-			return false;
44
-		}
42
+          if ( empty( $objects ) ) {
43
+               return false;
44
+          }
45 45
 
46
-		if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'action=edit' ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/post-new.php' ) ) {
47
-			return false;
48
-		}
46
+          if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'action=edit' ) || strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/post-new.php' ) ) {
47
+               return false;
48
+          }
49 49
 
50
-		if ( ! empty( $objects ) ) {
51
-			if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( wp_unslash( $_GET['post_type'] ) ), $objects ) ) { // if page or custom post types
52
-				$active = true;
53
-			}
50
+          if ( ! empty( $objects ) ) {
51
+               if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( wp_unslash( $_GET['post_type'] ) ), $objects ) ) { // if page or custom post types
52
+                    $active = true;
53
+               }
54 54
 
55
-			if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post
56
-				$active = true;
57
-			}
58
-		}
55
+               if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post
56
+                    $active = true;
57
+               }
58
+          }
59 59
 
60
-		return $active;
61
-	}
60
+          return $active;
61
+     }
62 62
 
63
-	function load_script_css() {
64
-		if ( $this->_check_load_script_css() ) {
65
-			wp_enqueue_script( 'scporderjs', LSX_PROJECTS_URL . 'assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true );
63
+     function load_script_css() {
64
+          if ( $this->_check_load_script_css() ) {
65
+               wp_enqueue_script( 'scporderjs', LSX_PROJECTS_URL . 'assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true );
66 66
 
67
-			$scporderjs_params = array(
68
-				'ajax_url' => admin_url( 'admin-ajax.php' ),
69
-				'ajax_nonce' => wp_create_nonce( 'scporder' ),
70
-			);
67
+               $scporderjs_params = array(
68
+                    'ajax_url' => admin_url( 'admin-ajax.php' ),
69
+                    'ajax_nonce' => wp_create_nonce( 'scporder' ),
70
+               );
71 71
 
72
-			wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params );
72
+               wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params );
73 73
 
74
-			wp_enqueue_style( 'scporder', LSX_PROJECTS_URL . 'assets/css/scporder.css', array(), null );
75
-		}
76
-	}
74
+               wp_enqueue_style( 'scporder', LSX_PROJECTS_URL . 'assets/css/scporder.css', array(), null );
75
+          }
76
+     }
77 77
 
78
-	function refresh() {
79
-		global $wpdb;
78
+     function refresh() {
79
+          global $wpdb;
80 80
 
81
-		$objects = $this->get_lsx_projects_scporder_options_objects();
81
+          $objects = $this->get_lsx_projects_scporder_options_objects();
82 82
 
83
-		if ( ! empty( $objects ) ) {
84
-			foreach ( $objects as $object => $object_data ) {
85
-				$result = $wpdb->get_results($wpdb->prepare("
83
+          if ( ! empty( $objects ) ) {
84
+               foreach ( $objects as $object => $object_data ) {
85
+                    $result = $wpdb->get_results($wpdb->prepare("
86 86
 					SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min
87 87
 					FROM $wpdb->posts
88 88
 					WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
89 89
 				", $object));
90 90
 
91
-				if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) {
92
-					continue;
93
-				}
91
+                    if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) {
92
+                         continue;
93
+                    }
94 94
 
95
-				$results = $wpdb->get_results( $wpdb->prepare("
95
+                    $results = $wpdb->get_results( $wpdb->prepare("
96 96
 					SELECT ID
97 97
 					FROM $wpdb->posts
98 98
 					WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
99 99
 					ORDER BY menu_order ASC
100 100
 				", $object ) );
101 101
 
102
-				foreach ( $results as $key => $result ) {
103
-					$wpdb->update(
104
-						$wpdb->posts,
105
-						array(
106
-							'menu_order' => $key + 1,
107
-						),
108
-						array(
109
-							'ID' => $result->ID,
110
-						)
111
-					);
112
-				}
113
-			}
114
-		}
115
-	}
102
+                    foreach ( $results as $key => $result ) {
103
+                         $wpdb->update(
104
+                              $wpdb->posts,
105
+                              array(
106
+                                   'menu_order' => $key + 1,
107
+                              ),
108
+                              array(
109
+                                   'ID' => $result->ID,
110
+                              )
111
+                         );
112
+                    }
113
+               }
114
+          }
115
+     }
116 116
 
117
-	function update_menu_order() {
118
-		check_ajax_referer( 'scporder', 'security' );
117
+     function update_menu_order() {
118
+          check_ajax_referer( 'scporder', 'security' );
119 119
 
120
-		global $wpdb;
120
+          global $wpdb;
121 121
 
122
-		parse_str( sanitize_text_field( wp_unslash( $_POST['order'] ) ), $data );
122
+          parse_str( sanitize_text_field( wp_unslash( $_POST['order'] ) ), $data );
123 123
 
124
-		if ( ! is_array( $data ) ) {
125
-			return false;
126
-		}
124
+          if ( ! is_array( $data ) ) {
125
+               return false;
126
+          }
127 127
 
128
-		$id_arr = array();
128
+          $id_arr = array();
129 129
 
130
-		foreach ( $data as $key => $values ) {
131
-			foreach ( $values as $position => $id ) {
132
-				$id_arr[] = $id;
133
-			}
134
-		}
130
+          foreach ( $data as $key => $values ) {
131
+               foreach ( $values as $position => $id ) {
132
+                    $id_arr[] = $id;
133
+               }
134
+          }
135 135
 
136
-		$menu_order_arr = array();
136
+          $menu_order_arr = array();
137 137
 
138
-		foreach ( $id_arr as $key => $id ) {
139
-			$results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = " . intval( $id ) );
138
+          foreach ( $id_arr as $key => $id ) {
139
+               $results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = " . intval( $id ) );
140 140
 
141
-			foreach ( $results as $result ) {
142
-				$menu_order_arr[] = $result->menu_order;
143
-			}
144
-		}
141
+               foreach ( $results as $result ) {
142
+                    $menu_order_arr[] = $result->menu_order;
143
+               }
144
+          }
145 145
 
146
-		sort( $menu_order_arr );
146
+          sort( $menu_order_arr );
147 147
 
148
-		foreach ( $data as $key => $values ) {
149
-			foreach ( $values as $position => $id ) {
150
-				$wpdb->update(
151
-					$wpdb->posts,
152
-					array(
153
-						'menu_order' => $menu_order_arr[ $position ],
154
-					),
155
-					array(
156
-						'ID' => intval( $id ),
157
-					)
158
-				);
159
-			}
160
-		}
161
-	}
162
-
163
-	function lsx_projects_scporder_previous_post_where( $where ) {
164
-		global $post;
165
-
166
-		$objects = $this->get_lsx_projects_scporder_options_objects();
167
-
168
-		if ( empty( $objects ) ) {
169
-			return $where;
170
-		}
171
-
172
-		if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
173
-			$current_menu_order = $post->menu_order;
174
-			$where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'";
175
-		}
176
-
177
-		return $where;
178
-	}
179
-
180
-	function lsx_projects_scporder_previous_post_sort( $orderby ) {
181
-		global $post;
182
-
183
-		$objects = $this->get_lsx_projects_scporder_options_objects();
184
-
185
-		if ( empty( $objects ) ) {
186
-			return $orderby;
187
-		}
188
-
189
-		if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
190
-			$orderby = 'ORDER BY p.menu_order ASC LIMIT 1';
191
-		}
192
-
193
-		return $orderby;
194
-	}
195
-
196
-	function lsx_projects_scporder_next_post_where( $where ) {
197
-		global $post;
198
-
199
-		$objects = $this->get_lsx_projects_scporder_options_objects();
200
-
201
-		if ( empty( $objects ) ) {
202
-			return $where;
203
-		}
204
-
205
-		if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
206
-			$current_menu_order = $post->menu_order;
207
-			$where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'";
208
-		}
209
-
210
-		return $where;
211
-	}
212
-
213
-	function lsx_projects_scporder_next_post_sort( $orderby ) {
214
-		global $post;
215
-
216
-		$objects = $this->get_lsx_projects_scporder_options_objects();
217
-
218
-		if ( empty( $objects ) ) {
219
-			return $orderby;
220
-		}
221
-
222
-		if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
223
-			$orderby = 'ORDER BY p.menu_order DESC LIMIT 1';
224
-		}
225
-
226
-		return $orderby;
227
-	}
228
-
229
-	function lsx_projects_scporder_pre_get_posts( $wp_query ) {
230
-		$objects = $this->get_lsx_projects_scporder_options_objects();
231
-
232
-		if ( empty( $objects ) ) {
233
-			return false;
234
-		}
235
-
236
-		if ( is_admin() ) {
237
-			if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) {
238
-				if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) {
239
-					$wp_query->set( 'orderby', 'menu_order' );
240
-					$wp_query->set( 'order', 'ASC' );
241
-				}
242
-			}
243
-		} else {
244
-			$active = false;
245
-
246
-			if ( isset( $wp_query->query['post_type'] ) ) {
247
-				if ( ! is_array( $wp_query->query['post_type'] ) ) {
248
-					if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) {
249
-						$active = true;
250
-					}
251
-				}
252
-			} else {
253
-				if ( array_key_exists( 'post', $objects ) ) {
254
-					$active = true;
255
-				}
256
-			}
257
-
258
-			if ( ! $active ) {
259
-				return false;
260
-			}
261
-
262
-			if ( isset( $wp_query->query['suppress_filters'] ) ) {
263
-				if ( $wp_query->get( 'orderby' ) == 'date' ) {
264
-					$wp_query->set( 'orderby', 'menu_order' );
265
-				}
266
-
267
-				if ( $wp_query->get( 'order' ) == 'DESC' ) {
268
-					$wp_query->set( 'order', 'ASC' );
269
-				}
270
-			} else {
271
-				if ( ! $wp_query->get( 'orderby' ) ) {
272
-					$wp_query->set( 'orderby', 'menu_order' );
273
-				}
274
-
275
-				if ( ! $wp_query->get( 'order' ) ) {
276
-					$wp_query->set( 'order', 'ASC' );
277
-				}
278
-			}
279
-		}
280
-	}
281
-
282
-	function get_lsx_projects_scporder_options_objects() {
283
-		return array(
284
-			'project' => esc_html_x( 'Project', 'post type singular name', 'lsx-project' ),
285
-		);
286
-	}
148
+          foreach ( $data as $key => $values ) {
149
+               foreach ( $values as $position => $id ) {
150
+                    $wpdb->update(
151
+                         $wpdb->posts,
152
+                         array(
153
+                              'menu_order' => $menu_order_arr[ $position ],
154
+                         ),
155
+                         array(
156
+                              'ID' => intval( $id ),
157
+                         )
158
+                    );
159
+               }
160
+          }
161
+     }
162
+
163
+     function lsx_projects_scporder_previous_post_where( $where ) {
164
+          global $post;
165
+
166
+          $objects = $this->get_lsx_projects_scporder_options_objects();
167
+
168
+          if ( empty( $objects ) ) {
169
+               return $where;
170
+          }
171
+
172
+          if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
173
+               $current_menu_order = $post->menu_order;
174
+               $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'";
175
+          }
176
+
177
+          return $where;
178
+     }
179
+
180
+     function lsx_projects_scporder_previous_post_sort( $orderby ) {
181
+          global $post;
182
+
183
+          $objects = $this->get_lsx_projects_scporder_options_objects();
184
+
185
+          if ( empty( $objects ) ) {
186
+               return $orderby;
187
+          }
188
+
189
+          if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
190
+               $orderby = 'ORDER BY p.menu_order ASC LIMIT 1';
191
+          }
192
+
193
+          return $orderby;
194
+     }
195
+
196
+     function lsx_projects_scporder_next_post_where( $where ) {
197
+          global $post;
198
+
199
+          $objects = $this->get_lsx_projects_scporder_options_objects();
200
+
201
+          if ( empty( $objects ) ) {
202
+               return $where;
203
+          }
204
+
205
+          if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
206
+               $current_menu_order = $post->menu_order;
207
+               $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'";
208
+          }
209
+
210
+          return $where;
211
+     }
212
+
213
+     function lsx_projects_scporder_next_post_sort( $orderby ) {
214
+          global $post;
215
+
216
+          $objects = $this->get_lsx_projects_scporder_options_objects();
217
+
218
+          if ( empty( $objects ) ) {
219
+               return $orderby;
220
+          }
221
+
222
+          if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) {
223
+               $orderby = 'ORDER BY p.menu_order DESC LIMIT 1';
224
+          }
225
+
226
+          return $orderby;
227
+     }
228
+
229
+     function lsx_projects_scporder_pre_get_posts( $wp_query ) {
230
+          $objects = $this->get_lsx_projects_scporder_options_objects();
231
+
232
+          if ( empty( $objects ) ) {
233
+               return false;
234
+          }
235
+
236
+          if ( is_admin() ) {
237
+               if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) {
238
+                    if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) {
239
+                         $wp_query->set( 'orderby', 'menu_order' );
240
+                         $wp_query->set( 'order', 'ASC' );
241
+                    }
242
+               }
243
+          } else {
244
+               $active = false;
245
+
246
+               if ( isset( $wp_query->query['post_type'] ) ) {
247
+                    if ( ! is_array( $wp_query->query['post_type'] ) ) {
248
+                         if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) {
249
+                              $active = true;
250
+                         }
251
+                    }
252
+               } else {
253
+                    if ( array_key_exists( 'post', $objects ) ) {
254
+                         $active = true;
255
+                    }
256
+               }
257
+
258
+               if ( ! $active ) {
259
+                    return false;
260
+               }
261
+
262
+               if ( isset( $wp_query->query['suppress_filters'] ) ) {
263
+                    if ( $wp_query->get( 'orderby' ) == 'date' ) {
264
+                         $wp_query->set( 'orderby', 'menu_order' );
265
+                    }
266
+
267
+                    if ( $wp_query->get( 'order' ) == 'DESC' ) {
268
+                         $wp_query->set( 'order', 'ASC' );
269
+                    }
270
+               } else {
271
+                    if ( ! $wp_query->get( 'orderby' ) ) {
272
+                         $wp_query->set( 'orderby', 'menu_order' );
273
+                    }
274
+
275
+                    if ( ! $wp_query->get( 'order' ) ) {
276
+                         $wp_query->set( 'order', 'ASC' );
277
+                    }
278
+               }
279
+          }
280
+     }
281
+
282
+     function get_lsx_projects_scporder_options_objects() {
283
+          return array(
284
+               'project' => esc_html_x( 'Project', 'post type singular name', 'lsx-project' ),
285
+          );
286
+     }
287 287
 
288 288
 }
289 289
 
@@ -293,23 +293,23 @@  discard block
 block discarded – undo
293 293
 register_uninstall_hook( __FILE__, 'lsx_projects_scporder_uninstall' );
294 294
 
295 295
 function lsx_projects_scporder_uninstall() {
296
-	global $wpdb;
296
+     global $wpdb;
297 297
 
298
-	if ( function_exists( 'is_multisite' ) && is_multisite() ) {
299
-		$curr_blog = $wpdb->blogid;
300
-		$blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
298
+     if ( function_exists( 'is_multisite' ) && is_multisite() ) {
299
+          $curr_blog = $wpdb->blogid;
300
+          $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
301 301
 
302
-		foreach ( $blogids as $blog_id ) {
303
-			switch_to_blog( $blog_id );
304
-			lsx_projects_scporder_uninstall_db();
305
-		}
302
+          foreach ( $blogids as $blog_id ) {
303
+               switch_to_blog( $blog_id );
304
+               lsx_projects_scporder_uninstall_db();
305
+          }
306 306
 
307
-		switch_to_blog( $curr_blog );
308
-	} else {
309
-		lsx_projects_scporder_uninstall_db();
310
-	}
307
+          switch_to_blog( $curr_blog );
308
+     } else {
309
+          lsx_projects_scporder_uninstall_db();
310
+     }
311 311
 }
312 312
 
313 313
 function lsx_projects_scporder_uninstall_db() {
314
-	delete_option( 'lsx_projects_scporder_install' );
314
+     delete_option( 'lsx_projects_scporder_install' );
315 315
 }
Please login to merge, or discard this patch.
classes/class-lsx-projects-core.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -7,87 +7,87 @@
 block discarded – undo
7 7
  */
8 8
 class LSX_Projects_Core {
9 9
 
10
-	/**
11
-	 * Holds class instance
12
-	 *
13
-	 * @since 1.0.0
14
-	 *
15
-	 * @var      object \lsx_projects\classes\Core()
16
-	 */
17
-	protected static $instance = null;
10
+     /**
11
+      * Holds class instance
12
+      *
13
+      * @since 1.0.0
14
+      *
15
+      * @var      object \lsx_projects\classes\Core()
16
+      */
17
+     protected static $instance = null;
18 18
 
19
-	/**
20
-	 * Holds class instance
21
-	 *
22
-	 * @since 1.0.0
23
-	 *
24
-	 * @var      object \MAG_CMB2_Field_Post_Search_Ajax()
25
-	 */
26
-	public $cmb2_post_search_ajax = false;
19
+     /**
20
+      * Holds class instance
21
+      *
22
+      * @since 1.0.0
23
+      *
24
+      * @var      object \MAG_CMB2_Field_Post_Search_Ajax()
25
+      */
26
+     public $cmb2_post_search_ajax = false;
27 27
 
28
-	/**
29
-	 * Contructor
30
-	 */
31
-	public function __construct() {
32
-		add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) );
33
-		$this->load_vendors();
34
-	}
28
+     /**
29
+      * Contructor
30
+      */
31
+     public function __construct() {
32
+          add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) );
33
+          $this->load_vendors();
34
+     }
35 35
 
36
-	/**
37
-	 * Return an instance of this class.
38
-	 *
39
-	 * @since 1.0.0
40
-	 *
41
-	 * @return    object \lsx_projects\classes\Core()    A single instance of this class.
42
-	 */
43
-	public static function get_instance() {
36
+     /**
37
+      * Return an instance of this class.
38
+      *
39
+      * @since 1.0.0
40
+      *
41
+      * @return    object \lsx_projects\classes\Core()    A single instance of this class.
42
+      */
43
+     public static function get_instance() {
44 44
 
45
-		// If the single instance hasn't been set, set it now.
46
-		if ( null === self::$instance ) {
47
-			self::$instance = new self();
48
-		}
45
+          // If the single instance hasn't been set, set it now.
46
+          if ( null === self::$instance ) {
47
+               self::$instance = new self();
48
+          }
49 49
 
50
-		return self::$instance;
50
+          return self::$instance;
51 51
 
52
-	}
52
+     }
53 53
 
54
-	/**
55
-	 * Loads the plugin functions.
56
-	 */
57
-	private function load_vendors() {
58
-		// Configure custom fields.
59
-		if ( ! class_exists( 'CMB2' ) ) {
60
-			require_once LSX_PROJECTS_PATH . 'vendor/CMB2/init.php';
61
-		}
62
-	}
54
+     /**
55
+      * Loads the plugin functions.
56
+      */
57
+     private function load_vendors() {
58
+          // Configure custom fields.
59
+          if ( ! class_exists( 'CMB2' ) ) {
60
+               require_once LSX_PROJECTS_PATH . 'vendor/CMB2/init.php';
61
+          }
62
+     }
63 63
 
64
-	/**
65
-	 * Returns the post types currently active
66
-	 *
67
-	 * @return void
68
-	 */
69
-	public function get_post_types() {
70
-		$post_types = apply_filters( 'lsx_projects_post_types', isset( $this->post_types ) );
71
-		foreach ( $post_types as $index => $post_type ) {
72
-			$is_disabled = \cmb2_get_option( 'lsx_projects_options', $post_type . '_disabled', false );
73
-			if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) {
74
-				unset( $post_types[ $index ] );
75
-			}
76
-		}
77
-		return $post_types;
78
-	}
64
+     /**
65
+      * Returns the post types currently active
66
+      *
67
+      * @return void
68
+      */
69
+     public function get_post_types() {
70
+          $post_types = apply_filters( 'lsx_projects_post_types', isset( $this->post_types ) );
71
+          foreach ( $post_types as $index => $post_type ) {
72
+               $is_disabled = \cmb2_get_option( 'lsx_projects_options', $post_type . '_disabled', false );
73
+               if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) {
74
+                    unset( $post_types[ $index ] );
75
+               }
76
+          }
77
+          return $post_types;
78
+     }
79 79
 
80
-	/**
81
-	 * Includes the Post Search Ajax if it is there.
82
-	 *
83
-	 * @return void
84
-	 */
85
-	public function cmb2_post_search_ajax() {
86
-		require_once LSX_PROJECTS_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php';
87
-		if ( method_exists( 'MAG_CMB2_Field_Post_Search_Ajax', 'get_instance' ) ) {
88
-			$this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance();
89
-		}
90
-	}
80
+     /**
81
+      * Includes the Post Search Ajax if it is there.
82
+      *
83
+      * @return void
84
+      */
85
+     public function cmb2_post_search_ajax() {
86
+          require_once LSX_PROJECTS_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php';
87
+          if ( method_exists( 'MAG_CMB2_Field_Post_Search_Ajax', 'get_instance' ) ) {
88
+               $this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance();
89
+          }
90
+     }
91 91
 }
92 92
 
93 93
 LSX_Projects_Core::get_instance();
Please login to merge, or discard this patch.
classes/class-lsx-projects-widget.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -10,173 +10,173 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class LSX_Projects_Widget extends WP_Widget {
12 12
 
13
-	public function __construct() {
14
-		$widget_ops = array(
15
-			'classname' => 'lsx-projects',
16
-		);
13
+     public function __construct() {
14
+          $widget_ops = array(
15
+               'classname' => 'lsx-projects',
16
+          );
17 17
 
18
-		parent::__construct( 'LSX_Projects_Widget', esc_html__( 'LSX Projects', 'lsx-projects' ), $widget_ops );
19
-	}
18
+          parent::__construct( 'LSX_Projects_Widget', esc_html__( 'LSX Projects', 'lsx-projects' ), $widget_ops );
19
+     }
20 20
 
21
-	function widget( $args, $instance ) {
22
-		extract( $args );
21
+     function widget( $args, $instance ) {
22
+          extract( $args );
23 23
 
24
-		$title = $instance['title'];
25
-		$title_link = $instance['title_link'];
26
-		$tagline = $instance['tagline'];
27
-		$columns = $instance['columns'];
28
-		$orderby = $instance['orderby'];
29
-		$order = $instance['order'];
30
-		$limit = $instance['limit'];
31
-		$include = $instance['include'];
32
-		$display = $instance['display'];
33
-		$size = $instance['size'];
34
-		$button_text = $instance['button_text'];
35
-		$responsive = $instance['responsive'];
36
-		$show_image = $instance['show_image'];
37
-		$carousel = $instance['carousel'];
38
-		$featured = $instance['featured'];
24
+          $title = $instance['title'];
25
+          $title_link = $instance['title_link'];
26
+          $tagline = $instance['tagline'];
27
+          $columns = $instance['columns'];
28
+          $orderby = $instance['orderby'];
29
+          $order = $instance['order'];
30
+          $limit = $instance['limit'];
31
+          $include = $instance['include'];
32
+          $display = $instance['display'];
33
+          $size = $instance['size'];
34
+          $button_text = $instance['button_text'];
35
+          $responsive = $instance['responsive'];
36
+          $show_image = $instance['show_image'];
37
+          $carousel = $instance['carousel'];
38
+          $featured = $instance['featured'];
39 39
 
40
-		// If limit not set, display 99 posts
41
-		if ( empty( $limit ) ) {
42
-			$limit = '99';
43
-		}
40
+          // If limit not set, display 99 posts
41
+          if ( empty( $limit ) ) {
42
+               $limit = '99';
43
+          }
44 44
 
45
-		// If specific posts included, display 99 posts
46
-		if ( ! empty( $include ) ) {
47
-			$limit = '99';
48
-		}
45
+          // If specific posts included, display 99 posts
46
+          if ( ! empty( $include ) ) {
47
+               $limit = '99';
48
+          }
49 49
 
50
-		if ( '1' == $responsive ) {
51
-			$responsive = 'true';
52
-		} else {
53
-			$responsive = 'false';
54
-		}
50
+          if ( '1' == $responsive ) {
51
+               $responsive = 'true';
52
+          } else {
53
+               $responsive = 'false';
54
+          }
55 55
 
56
-		if ( '1' == $show_image ) {
57
-			$show_image = 'true';
58
-		} else {
59
-			$show_image = 'false';
60
-		}
56
+          if ( '1' == $show_image ) {
57
+               $show_image = 'true';
58
+          } else {
59
+               $show_image = 'false';
60
+          }
61 61
 
62
-		if ( '1' == $carousel ) {
63
-			$carousel = 'true';
64
-		} else {
65
-			$carousel = 'false';
66
-		}
62
+          if ( '1' == $carousel ) {
63
+               $carousel = 'true';
64
+          } else {
65
+               $carousel = 'false';
66
+          }
67 67
 
68
-		if ( '1' == $featured ) {
69
-			$featured = 'true';
70
-		} else {
71
-			$featured = 'false';
72
-		}
68
+          if ( '1' == $featured ) {
69
+               $featured = 'true';
70
+          } else {
71
+               $featured = 'false';
72
+          }
73 73
 
74
-		if ( $title_link ) {
75
-			//$link_open = '<a href="' . $title_link . '">';
76
-			$link_open = '';
77
-			$link_btn_open = '<a href="' . $title_link . '" class="btn border-btn">';
78
-			//$link_close = '</a>';
79
-			$link_close = '';
80
-			$link_btn_close = '</a>';
81
-		} else {
82
-			$link_open = '';
83
-			$link_btn_open = '';
84
-			$link_close = '';
85
-			$link_btn_close = '';
86
-		}
74
+          if ( $title_link ) {
75
+               //$link_open = '<a href="' . $title_link . '">';
76
+               $link_open = '';
77
+               $link_btn_open = '<a href="' . $title_link . '" class="btn border-btn">';
78
+               //$link_close = '</a>';
79
+               $link_close = '';
80
+               $link_btn_close = '</a>';
81
+          } else {
82
+               $link_open = '';
83
+               $link_btn_open = '';
84
+               $link_close = '';
85
+               $link_btn_close = '';
86
+          }
87 87
 
88
-		echo wp_kses_post( $before_widget );
88
+          echo wp_kses_post( $before_widget );
89 89
 
90
-		if ( $title ) {
91
-			echo wp_kses_post( $before_title . $link_open . $title . $link_close . $after_title );
92
-		}
90
+          if ( $title ) {
91
+               echo wp_kses_post( $before_title . $link_open . $title . $link_close . $after_title );
92
+          }
93 93
 
94
-		if ( $tagline ) {
95
-			echo '<p class="tagline text-center">' . esc_html( $tagline ) . '</p>';
96
-		}
94
+          if ( $tagline ) {
95
+               echo '<p class="tagline text-center">' . esc_html( $tagline ) . '</p>';
96
+          }
97 97
 
98
-		if ( class_exists( 'LSX_Projects' ) ) {
99
-			lsx_projects( array(
100
-				'columns' => $columns,
101
-				'orderby' => $orderby,
102
-				'order' => $order,
103
-				'limit' => $limit,
104
-				'include' => $include,
105
-				'display' => $display,
106
-				'size' => $size,
107
-				'responsive' => $responsive,
108
-				'show_image' => $show_image,
109
-				'carousel' => $carousel,
110
-				'featured' => $featured,
111
-			) );
112
-		};
98
+          if ( class_exists( 'LSX_Projects' ) ) {
99
+               lsx_projects( array(
100
+                    'columns' => $columns,
101
+                    'orderby' => $orderby,
102
+                    'order' => $order,
103
+                    'limit' => $limit,
104
+                    'include' => $include,
105
+                    'display' => $display,
106
+                    'size' => $size,
107
+                    'responsive' => $responsive,
108
+                    'show_image' => $show_image,
109
+                    'carousel' => $carousel,
110
+                    'featured' => $featured,
111
+               ) );
112
+          };
113 113
 
114
-		if ( $button_text && $title_link ) {
115
-			echo wp_kses_post( '<p class="text-center lsx-projects-archive-link-wrap"><span class="lsx-projects-archive-link">' . $link_btn_open . $button_text . ' <i class="fa fa-angle-right"></i>' . $link_btn_close . '</span></p>' );
116
-		}
114
+          if ( $button_text && $title_link ) {
115
+               echo wp_kses_post( '<p class="text-center lsx-projects-archive-link-wrap"><span class="lsx-projects-archive-link">' . $link_btn_open . $button_text . ' <i class="fa fa-angle-right"></i>' . $link_btn_close . '</span></p>' );
116
+          }
117 117
 
118
-		echo wp_kses_post( $after_widget );
119
-	}
118
+          echo wp_kses_post( $after_widget );
119
+     }
120 120
 
121
-	function update( $new_instance, $old_instance ) {
122
-		$instance = $old_instance;
121
+     function update( $new_instance, $old_instance ) {
122
+          $instance = $old_instance;
123 123
 
124
-		$instance['title'] = wp_kses_post( force_balance_tags( $new_instance['title'] ) );
125
-		$instance['title_link'] = strip_tags( $new_instance['title_link'] );
126
-		$instance['tagline'] = wp_kses_post( force_balance_tags( $new_instance['tagline'] ) );
127
-		$instance['columns'] = strip_tags( $new_instance['columns'] );
128
-		$instance['orderby'] = strip_tags( $new_instance['orderby'] );
129
-		$instance['order'] = strip_tags( $new_instance['order'] );
130
-		$instance['limit'] = strip_tags( $new_instance['limit'] );
131
-		$instance['include'] = strip_tags( $new_instance['include'] );
132
-		$instance['display'] = strip_tags( $new_instance['display'] );
133
-		$instance['size'] = strip_tags( $new_instance['size'] );
134
-		$instance['button_text'] = strip_tags( $new_instance['button_text'] );
135
-		$instance['responsive'] = strip_tags( $new_instance['responsive'] );
136
-		$instance['show_image'] = strip_tags( $new_instance['show_image'] );
137
-		$instance['carousel'] = strip_tags( $new_instance['carousel'] );
138
-		$instance['featured'] = strip_tags( $new_instance['featured'] );
124
+          $instance['title'] = wp_kses_post( force_balance_tags( $new_instance['title'] ) );
125
+          $instance['title_link'] = strip_tags( $new_instance['title_link'] );
126
+          $instance['tagline'] = wp_kses_post( force_balance_tags( $new_instance['tagline'] ) );
127
+          $instance['columns'] = strip_tags( $new_instance['columns'] );
128
+          $instance['orderby'] = strip_tags( $new_instance['orderby'] );
129
+          $instance['order'] = strip_tags( $new_instance['order'] );
130
+          $instance['limit'] = strip_tags( $new_instance['limit'] );
131
+          $instance['include'] = strip_tags( $new_instance['include'] );
132
+          $instance['display'] = strip_tags( $new_instance['display'] );
133
+          $instance['size'] = strip_tags( $new_instance['size'] );
134
+          $instance['button_text'] = strip_tags( $new_instance['button_text'] );
135
+          $instance['responsive'] = strip_tags( $new_instance['responsive'] );
136
+          $instance['show_image'] = strip_tags( $new_instance['show_image'] );
137
+          $instance['carousel'] = strip_tags( $new_instance['carousel'] );
138
+          $instance['featured'] = strip_tags( $new_instance['featured'] );
139 139
 
140
-		return $instance;
141
-	}
140
+          return $instance;
141
+     }
142 142
 
143
-	function form( $instance ) {
144
-		$defaults = array(
145
-			'title' => 'Projects',
146
-			'title_link' => '',
147
-			'tagline' => '',
148
-			'columns' => '3',
149
-			'orderby' => 'name',
150
-			'order' => 'ASC',
151
-			'limit' => '',
152
-			'include' => '',
153
-			'display' => 'excerpt',
154
-			'size' => 'lsx-thumbnail-single',
155
-			'button_text' => '',
156
-			'responsive' => 1,
157
-			'show_image' => 1,
158
-			'carousel' => 1,
159
-			'featured' => 0,
160
-		);
143
+     function form( $instance ) {
144
+          $defaults = array(
145
+               'title' => 'Projects',
146
+               'title_link' => '',
147
+               'tagline' => '',
148
+               'columns' => '3',
149
+               'orderby' => 'name',
150
+               'order' => 'ASC',
151
+               'limit' => '',
152
+               'include' => '',
153
+               'display' => 'excerpt',
154
+               'size' => 'lsx-thumbnail-single',
155
+               'button_text' => '',
156
+               'responsive' => 1,
157
+               'show_image' => 1,
158
+               'carousel' => 1,
159
+               'featured' => 0,
160
+          );
161 161
 
162
-		$instance = wp_parse_args( (array) $instance, $defaults );
162
+          $instance = wp_parse_args( (array) $instance, $defaults );
163 163
 
164
-		$title          = esc_attr( $instance['title'] );
165
-		$title_link     = esc_attr( $instance['title_link'] );
166
-		$tagline        = esc_attr( $instance['tagline'] );
167
-		$columns        = esc_attr( $instance['columns'] );
168
-		$orderby        = esc_attr( $instance['orderby'] );
169
-		$order          = esc_attr( $instance['order'] );
170
-		$limit          = esc_attr( $instance['limit'] );
171
-		$include        = esc_attr( $instance['include'] );
172
-		$display        = esc_attr( $instance['display'] );
173
-		$size           = esc_attr( $instance['size'] );
174
-		$button_text    = esc_attr( $instance['button_text'] );
175
-		$responsive     = esc_attr( $instance['responsive'] );
176
-		$show_image     = esc_attr( $instance['show_image'] );
177
-		$carousel       = esc_attr( $instance['carousel'] );
178
-		$featured       = esc_attr( $instance['featured'] );
179
-		?>
164
+          $title          = esc_attr( $instance['title'] );
165
+          $title_link     = esc_attr( $instance['title_link'] );
166
+          $tagline        = esc_attr( $instance['tagline'] );
167
+          $columns        = esc_attr( $instance['columns'] );
168
+          $orderby        = esc_attr( $instance['orderby'] );
169
+          $order          = esc_attr( $instance['order'] );
170
+          $limit          = esc_attr( $instance['limit'] );
171
+          $include        = esc_attr( $instance['include'] );
172
+          $display        = esc_attr( $instance['display'] );
173
+          $size           = esc_attr( $instance['size'] );
174
+          $button_text    = esc_attr( $instance['button_text'] );
175
+          $responsive     = esc_attr( $instance['responsive'] );
176
+          $show_image     = esc_attr( $instance['show_image'] );
177
+          $carousel       = esc_attr( $instance['carousel'] );
178
+          $featured       = esc_attr( $instance['featured'] );
179
+          ?>
180 180
 		<p>
181 181
 			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'lsx-projects' ); ?></label>
182 182
 			<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
@@ -195,47 +195,47 @@  discard block
 block discarded – undo
195 195
 			<label for="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>"><?php esc_html_e( 'Columns:', 'lsx-projects' ); ?></label>
196 196
 			<select name="<?php echo esc_attr( $this->get_field_name( 'columns' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'columns' ) ); ?>" class="widefat">
197 197
 			<?php
198
-				$options = array( '1', '2', '3', '4' );
198
+                    $options = array( '1', '2', '3', '4' );
199 199
 
200
-				foreach ( $options as $option ) {
201
-					echo '<option value="' . esc_attr( lcfirst( $option ) ) . '" id="' . esc_attr( $option ) . '"', lcfirst( $option ) == $columns ? ' selected="selected"' : '', '>', esc_html( $option ), '</option>';
202
-				}
203
-			?>
200
+                    foreach ( $options as $option ) {
201
+                         echo '<option value="' . esc_attr( lcfirst( $option ) ) . '" id="' . esc_attr( $option ) . '"', lcfirst( $option ) == $columns ? ' selected="selected"' : '', '>', esc_html( $option ), '</option>';
202
+                    }
203
+               ?>
204 204
 			</select>
205 205
 		</p>
206 206
 		<p>
207 207
 			<label for="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>"><?php esc_html_e( 'Order By:', 'lsx-projects' ); ?></label>
208 208
 			<select name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'orderby' ) ); ?>" class="widefat">
209 209
 			<?php
210
-				$options = array(
211
-					esc_html__( 'None', 'lsx-projects' ) => 'none',
212
-					esc_html__( 'ID', 'lsx-projects' ) => 'ID',
213
-					esc_html__( 'Name', 'lsx-projects' ) => 'name',
214
-					esc_html__( 'Date', 'lsx-projects' ) => 'date',
215
-					esc_html__( 'Modified Date', 'lsx-projects' ) => 'modified',
216
-					esc_html__( 'Random', 'lsx-projects' ) => 'rand',
217
-					esc_html__( 'Menu (WP dashboard order)', 'lsx-projects' ) => 'menu_order',
218
-				);
210
+                    $options = array(
211
+                         esc_html__( 'None', 'lsx-projects' ) => 'none',
212
+                         esc_html__( 'ID', 'lsx-projects' ) => 'ID',
213
+                         esc_html__( 'Name', 'lsx-projects' ) => 'name',
214
+                         esc_html__( 'Date', 'lsx-projects' ) => 'date',
215
+                         esc_html__( 'Modified Date', 'lsx-projects' ) => 'modified',
216
+                         esc_html__( 'Random', 'lsx-projects' ) => 'rand',
217
+                         esc_html__( 'Menu (WP dashboard order)', 'lsx-projects' ) => 'menu_order',
218
+                    );
219 219
 
220
-				foreach ( $options as $name => $value ) {
221
-					echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $orderby == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>';
222
-				}
223
-			?>
220
+                    foreach ( $options as $name => $value ) {
221
+                         echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $orderby == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>';
222
+                    }
223
+               ?>
224 224
 			</select>
225 225
 		</p>
226 226
 		<p>
227 227
 			<label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php esc_html_e( 'Order:', 'lsx-projects' ); ?></label>
228 228
 			<select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>" class="widefat">
229 229
 			<?php
230
-				$options = array(
231
-					esc_html__( 'Ascending', 'lsx-projects' ) => 'ASC',
232
-					esc_html__( 'Descending', 'lsx-projects' ) => 'DESC',
233
-				);
230
+                    $options = array(
231
+                         esc_html__( 'Ascending', 'lsx-projects' ) => 'ASC',
232
+                         esc_html__( 'Descending', 'lsx-projects' ) => 'DESC',
233
+                    );
234 234
 
235
-				foreach ( $options as $name => $value ) {
236
-					echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $order == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>';
237
-				}
238
-			?>
235
+                    foreach ( $options as $name => $value ) {
236
+                         echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $order == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>';
237
+                    }
238
+               ?>
239 239
 			</select>
240 240
 		</p>
241 241
 		<p class="limit">
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
 			<label for="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>"><?php esc_html_e( 'Display:', 'lsx-projects' ); ?></label>
253 253
 			<select name="<?php echo esc_attr( $this->get_field_name( 'display' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'display' ) ); ?>" class="widefat">
254 254
 			<?php
255
-				$options = array(
256
-					esc_html__( 'Excerpt', 'lsx-projects' ) => 'excerpt',
257
-					esc_html__( 'Full Content', 'lsx-projects' ) => 'full',
258
-				);
255
+                    $options = array(
256
+                         esc_html__( 'Excerpt', 'lsx-projects' ) => 'excerpt',
257
+                         esc_html__( 'Full Content', 'lsx-projects' ) => 'full',
258
+                    );
259 259
 
260
-				foreach ( $options as $name => $value ) {
261
-					echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $display == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>';
262
-				}
263
-			?>
260
+                    foreach ( $options as $name => $value ) {
261
+                         echo '<option value="' . esc_attr( $value ) . '" id="' . esc_attr( $value ) . '"', $display == $value ? ' selected="selected"' : '', '>', esc_html( $name ), '</option>';
262
+                    }
263
+               ?>
264 264
 			</select>
265 265
 		</p>
266 266
 		<p>
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
 			<label for="<?php echo esc_attr( $this->get_field_id( 'featured' ) ); ?>"><?php esc_html_e( 'Featured posts', 'lsx-projects' ); ?></label>
290 290
 		</p>
291 291
 		<?php
292
-	}
292
+     }
293 293
 
294 294
 }
295 295
 
296 296
 function lsx_projects_register_widget() {
297
-	return register_widget( 'LSX_Projects_Widget' );
297
+     return register_widget( 'LSX_Projects_Widget' );
298 298
 }
299 299
 add_action( 'widgets_init', 'lsx_projects_register_widget' );
Please login to merge, or discard this patch.
classes/admin/class-settings-theme.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -11,186 +11,186 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class Settings_Theme {
13 13
 
14
-	/**
15
-	 * Holds class instance
16
-	 *
17
-	 * @since 1.0.0
18
-	 *
19
-	 * @var      object \lsx\projects\classes\admin\Settings_Theme()
20
-	 */
21
-	protected static $instance = null;
14
+     /**
15
+      * Holds class instance
16
+      *
17
+      * @since 1.0.0
18
+      *
19
+      * @var      object \lsx\projects\classes\admin\Settings_Theme()
20
+      */
21
+     protected static $instance = null;
22 22
 
23
-	/**
24
-	 * Will return true if this is the LSX projects settings page.
25
-	 *
26
-	 * @var array
27
-	 */
28
-	public $is_options_page = false;
23
+     /**
24
+      * Will return true if this is the LSX projects settings page.
25
+      *
26
+      * @var array
27
+      */
28
+     public $is_options_page = false;
29 29
 
30
-	/**
31
-	 * Holds the id and labels for the navigation.
32
-	 *
33
-	 * @var array
34
-	 */
35
-	public $navigation = array();
30
+     /**
31
+      * Holds the id and labels for the navigation.
32
+      *
33
+      * @var array
34
+      */
35
+     public $navigation = array();
36 36
 
37
-	/**
38
-	 * Contructor
39
-	 */
40
-	public function __construct() {
41
-		add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );
42
-		add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );
43
-		add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );
44
-		add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );
45
-		add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );
46
-		add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );
47
-		add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );
48
-		add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );
49
-	}
37
+     /**
38
+      * Contructor
39
+      */
40
+     public function __construct() {
41
+          add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );
42
+          add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );
43
+          add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );
44
+          add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );
45
+          add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );
46
+          add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );
47
+          add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );
48
+          add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );
49
+     }
50 50
 
51
-	/**
52
-	 * Return an instance of this class.
53
-	 *
54
-	 * @since 1.0.0
55
-	 *
56
-	 * @return    object \lsx\projects\classes\admin\Settings_Theme()    A single instance of this class.
57
-	 */
58
-	public static function get_instance() {
59
-		// If the single instance hasn't been set, set it now.
60
-		if ( null == self::$instance ) {
61
-			self::$instance = new self();
62
-		}
63
-		return self::$instance;
64
-	}
51
+     /**
52
+      * Return an instance of this class.
53
+      *
54
+      * @since 1.0.0
55
+      *
56
+      * @return    object \lsx\projects\classes\admin\Settings_Theme()    A single instance of this class.
57
+      */
58
+     public static function get_instance() {
59
+          // If the single instance hasn't been set, set it now.
60
+          if ( null == self::$instance ) {
61
+               self::$instance = new self();
62
+          }
63
+          return self::$instance;
64
+     }
65 65
 
66
-	/**
67
-	 * Disable CMB2 styles on front end forms.
68
-	 *
69
-	 * @return bool $enabled Whether to enable (enqueue) styles.
70
-	 */
71
-	public function disable_cmb2_styles( $enabled ) {
72
-		if ( is_admin() ) {
73
-			$current_screen = get_current_screen();
74
-			if ( is_object( $current_screen ) && 'project_page_lsx_projects_options' === $current_screen->id ) {
75
-				$enabled = false;
76
-			}
77
-		}
78
-		return $enabled;
79
-	}
66
+     /**
67
+      * Disable CMB2 styles on front end forms.
68
+      *
69
+      * @return bool $enabled Whether to enable (enqueue) styles.
70
+      */
71
+     public function disable_cmb2_styles( $enabled ) {
72
+          if ( is_admin() ) {
73
+               $current_screen = get_current_screen();
74
+               if ( is_object( $current_screen ) && 'project_page_lsx_projects_options' === $current_screen->id ) {
75
+                    $enabled = false;
76
+               }
77
+          }
78
+          return $enabled;
79
+     }
80 80
 
81
-	/**
82
-	 * Generates the tabbed navigation for the settings page.
83
-	 *
84
-	 * @param string $cmb_id
85
-	 * @param string $object_id
86
-	 * @param string $object_type
87
-	 * @param object $cmb2_obj
88
-	 * @return void
89
-	 */
90
-	public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
91
-		if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) {
92
-			$this->navigation      = array();
93
-			$this->is_options_page = true;
94
-			if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) {
95
-				foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) {
96
-					if ( 'title' === $field['type'] ) {
97
-						$this->navigation[ $field_index ] = $field['name'];
98
-					}
99
-				}
100
-			}
101
-			$this->output_navigation();
102
-		}
103
-	}
81
+     /**
82
+      * Generates the tabbed navigation for the settings page.
83
+      *
84
+      * @param string $cmb_id
85
+      * @param string $object_id
86
+      * @param string $object_type
87
+      * @param object $cmb2_obj
88
+      * @return void
89
+      */
90
+     public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
91
+          if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) {
92
+               $this->navigation      = array();
93
+               $this->is_options_page = true;
94
+               if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) {
95
+                    foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) {
96
+                         if ( 'title' === $field['type'] ) {
97
+                              $this->navigation[ $field_index ] = $field['name'];
98
+                         }
99
+                    }
100
+               }
101
+               $this->output_navigation();
102
+          }
103
+     }
104 104
 
105
-	/**
106
-	 * Outputs the WP style navigation for the Settings page.
107
-	 *
108
-	 * @return void
109
-	 */
110
-	public function output_navigation() {
111
-		if ( ! empty( $this->navigation ) ) {
112
-			?>
105
+     /**
106
+      * Outputs the WP style navigation for the Settings page.
107
+      *
108
+      * @return void
109
+      */
110
+     public function output_navigation() {
111
+          if ( ! empty( $this->navigation ) ) {
112
+               ?>
113 113
 			<div class="wp-filter hide-if-no-js">
114 114
 				<ul class="filter-links">
115 115
 					<?php
116
-					$first_tab    = true;
117
-					$total        = count( $this->navigation );
118
-					$count        = 0;
119
-					$separator    = ' |';
120
-					$selected_tab = '';
121
-					if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) {
122
-						$selected_tab  = sanitize_text_field( $_GET['cmb_tab'] );
123
-						$selected_tab  = 'settings_' . $selected_tab;
124
-					}
125
-					foreach ( $this->navigation as $key => $label ) {
126
-						$count++;
127
-						$current_css = '';
128
-						if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) {
129
-							$first_tab   = false;
130
-							$current_css = 'current';
131
-						}
132
-						if ( $count === $total ) {
133
-							$separator = '';
134
-						}
135
-						?>
116
+                         $first_tab    = true;
117
+                         $total        = count( $this->navigation );
118
+                         $count        = 0;
119
+                         $separator    = ' |';
120
+                         $selected_tab = '';
121
+                         if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) {
122
+                              $selected_tab  = sanitize_text_field( $_GET['cmb_tab'] );
123
+                              $selected_tab  = 'settings_' . $selected_tab;
124
+                         }
125
+                         foreach ( $this->navigation as $key => $label ) {
126
+                              $count++;
127
+                              $current_css = '';
128
+                              if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) {
129
+                                   $first_tab   = false;
130
+                                   $current_css = 'current';
131
+                              }
132
+                              if ( $count === $total ) {
133
+                                   $separator = '';
134
+                              }
135
+                              ?>
136 136
 							<li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li>
137 137
 						<?php
138
-					}
139
-					?>
138
+                         }
139
+                         ?>
140 140
 				</ul>
141 141
 			</div>
142 142
 			<?php
143
-		}
144
-	}
143
+          }
144
+     }
145 145
 
146
-	/**
147
-	 * Outputs the opening tab div.
148
-	 *
149
-	 * @param object $field CMB2_Field();
150
-	 * @return void
151
-	 */
152
-	public function output_tab_open_div( $field ) {
153
-		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) {
154
-			?>
146
+     /**
147
+      * Outputs the opening tab div.
148
+      *
149
+      * @param object $field CMB2_Field();
150
+      * @return void
151
+      */
152
+     public function output_tab_open_div( $field ) {
153
+          if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) {
154
+               ?>
155 155
 			<div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden">
156 156
 			<?php
157
-		}
158
-	}
157
+          }
158
+     }
159 159
 
160
-	/**
161
-	 * Outputs the opening closing div.
162
-	 *
163
-	 * @param object $field CMB2_Field();
164
-	 * @return void
165
-	 */
166
-	public function output_tab_closing_div( $field ) {
167
-		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) {
168
-			?>
160
+     /**
161
+      * Outputs the opening closing div.
162
+      *
163
+      * @param object $field CMB2_Field();
164
+      * @return void
165
+      */
166
+     public function output_tab_closing_div( $field ) {
167
+          if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) {
168
+               ?>
169 169
 			</div>
170 170
 			<?php
171
-		}
172
-	}
171
+          }
172
+     }
173 173
 
174
-	public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
175
-		return;
176
-	}
174
+     public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
175
+          return;
176
+     }
177 177
 
178
-	public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) {
179
-		return '';
180
-	}
178
+     public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) {
179
+          return '';
180
+     }
181 181
 
182
-	/**
183
-	 * Outputs the Script for the tabbed navigation.
184
-	 *
185
-	 * @param string $cmb_id
186
-	 * @param string $object_id
187
-	 * @param string $object_type
188
-	 * @param object $cmb2_obj
189
-	 * @return void
190
-	 */
191
-	public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
192
-		if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) {
193
-			?>
182
+     /**
183
+      * Outputs the Script for the tabbed navigation.
184
+      *
185
+      * @param string $cmb_id
186
+      * @param string $object_id
187
+      * @param string $object_type
188
+      * @param object $cmb2_obj
189
+      * @return void
190
+      */
191
+     public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
192
+          if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) {
193
+               ?>
194 194
 			<script>
195 195
 				var LSX_PROJECTS_CMB2 = Object.create( null );
196 196
 
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
 				} )( jQuery, window, document );
263 263
 			</script>
264 264
 			<?php
265
-		}
266
-	}
265
+          }
266
+     }
267 267
 
268
-	/**
269
-	 * This will add the tab selection to the url.
270
-	 *
271
-	 * @param string $url
272
-	 * @return void
273
-	 */
274
-	public function add_tab_argument( $url ) {
275
-		if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine
276
-			$tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine
277
-			$tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine
278
-			if ( 'single' !== $tab_selection ) {
279
-				$url = add_query_arg( 'cmb_tab', $tab_selection, $url );
280
-			} else {
281
-				$url = remove_query_arg( 'cmb_tab', $url );
282
-			}
283
-		}
284
-		return $url;
285
-	}
268
+     /**
269
+      * This will add the tab selection to the url.
270
+      *
271
+      * @param string $url
272
+      * @return void
273
+      */
274
+     public function add_tab_argument( $url ) {
275
+          if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine
276
+               $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine
277
+               $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine
278
+               if ( 'single' !== $tab_selection ) {
279
+                    $url = add_query_arg( 'cmb_tab', $tab_selection, $url );
280
+               } else {
281
+                    $url = remove_query_arg( 'cmb_tab', $url );
282
+               }
283
+          }
284
+          return $url;
285
+     }
286 286
 }
Please login to merge, or discard this patch.
classes/class-lsx-projects.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -10,169 +10,169 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class LSX_Projects {
12 12
 
13
-	public $columns, $responsive, $options;
14
-
15
-	public function __construct() {
16
-		$this->options = projects_get_options();
17
-
18
-		add_filter( 'lsx_banner_allowed_post_types', array( $this, 'lsx_banner_allowed_post_types' ) );
19
-		add_filter( 'lsx_banner_allowed_taxonomies', array( $this, 'lsx_banner_allowed_taxonomies' ) );
20
-	}
21
-
22
-	/**
23
-	 * Enable project custom post type on LSX Banners.
24
-	 */
25
-	public function lsx_banner_allowed_post_types( $post_types ) {
26
-		$post_types[] = 'project';
27
-		return $post_types;
28
-	}
29
-
30
-	/**
31
-	 * Enable project custom taxonomies on LSX Banners.
32
-	 */
33
-	public function lsx_banner_allowed_taxonomies( $taxonomies ) {
34
-		$taxonomies[] = 'project-group';
35
-		return $taxonomies;
36
-	}
37
-
38
-	/**
39
-	 * Returns the shortcode output markup
40
-	 */
41
-	public function output( $atts ) {
42
-		// @codingStandardsIgnoreLine
43
-		extract( shortcode_atts( array(
44
-			'columns' => 3,
45
-			'orderby' => 'name',
46
-			'order' => 'ASC',
47
-			'limit' => '-1',
48
-			'include' => '',
49
-			'display' => 'excerpt',
50
-			'size' => 'lsx-thumbnail-single',
51
-			'responsive' => 'true',
52
-			'show_image' => 'true',
53
-			'carousel' => 'true',
54
-			'featured' => 'false',
55
-		), $atts ) );
56
-
57
-		$output = '';
58
-
59
-		if ( 'true' === $responsive || true === $responsive ) {
60
-			$responsive = ' img-responsive';
61
-		} else {
62
-			$responsive = '';
63
-		}
64
-
65
-		$this->columns = $columns;
66
-		$this->responsive = $responsive;
67
-
68
-		if ( ! empty( $include ) ) {
69
-			$include = explode( ',', $include );
70
-
71
-			$args = array(
72
-				'post_type' => 'project',
73
-				'posts_per_page' => $limit,
74
-				'post__in' => $include,
75
-				'orderby' => 'post__in',
76
-				'order' => $order,
77
-			);
78
-		} else {
79
-			$args = array(
80
-				'post_type' => 'project',
81
-				'posts_per_page' => $limit,
82
-				'orderby' => $orderby,
83
-				'order' => $order,
84
-			);
85
-
86
-			if ( 'true' === $featured || true === $featured ) {
87
-				$args['meta_key'] = 'lsx_project_featured';
88
-				$args['meta_value'] = 1;
89
-			}
90
-		}
91
-
92
-		$projects = new \WP_Query( $args );
93
-
94
-		if ( $projects->have_posts() ) {
95
-			global $post;
96
-
97
-			$count = 0;
98
-			$count_global = 0;
99
-
100
-			if ( 'true' === $carousel || true === $carousel ) {
101
-				$output .= "<div id='lsx-projects-slider' class='lsx-projects-shortcode' data-slick='{\"slidesToShow\": $columns, \"slidesToScroll\": $columns }'>";
102
-			} else {
103
-				$output .= "<div class='lsx-projects-shortcode'><div class='row'>";
104
-			}
105
-
106
-			while ( $projects->have_posts() ) {
107
-				$projects->the_post();
108
-
109
-				// Count
110
-				$count++;
111
-				$count_global++;
112
-
113
-				// Content
114
-				if ( 'full' === $display ) {
115
-					$content = apply_filters( 'the_content', get_the_content() );
116
-					$content = str_replace( ']]>', ']]&gt;', $content );
117
-				} elseif ( 'excerpt' === $display ) {
118
-					$content = apply_filters( 'the_excerpt', get_the_excerpt() );
119
-				}
120
-
121
-				// Image
122
-				if ( 'true' === $show_image || true === $show_image ) {
123
-					if ( is_numeric( $size ) ) {
124
-						$thumb_size = array( $size, $size );
125
-					} else {
126
-						$thumb_size = $size;
127
-					}
128
-
129
-					if ( ! empty( get_the_post_thumbnail( $post->ID ) ) ) {
130
-						$image = get_the_post_thumbnail( $post->ID, $thumb_size, array(
131
-							'class' => $responsive,
132
-						) );
133
-					} else {
134
-						$image = '';
135
-					}
136
-
137
-					if ( empty( $image ) ) {
138
-						if ( ! empty( $this->options['display']['projects_placeholder'] ) ) {
139
-							$image = '<img class="' . $responsive . '" src="' . $this->options['display']['projects_placeholder'] . '" width="' . $size . '" alt="placeholder" />';
140
-						} else {
141
-							$image = '';
142
-						}
143
-					}
144
-				} else {
145
-					$image = '';
146
-				}
147
-
148
-				// Project groups
149
-				$groups = '';
150
-				$terms = get_the_terms( $post->ID, 'project-group' );
151
-
152
-				if ( $terms && ! is_wp_error( $terms ) ) {
153
-					$groups = array();
154
-
155
-					foreach ( $terms as $term ) {
156
-						$groups[] = $term->name;
157
-					}
158
-
159
-					$groups = join( ', ', $groups );
160
-				}
161
-
162
-				$project_groups = '' !== $groups ? "<p class='lsx-projects-groups'>$groups</p>" : '';
163
-
164
-				if ( 'true' === $carousel || true === $carousel ) {
165
-					$output .= "
13
+     public $columns, $responsive, $options;
14
+
15
+     public function __construct() {
16
+          $this->options = projects_get_options();
17
+
18
+          add_filter( 'lsx_banner_allowed_post_types', array( $this, 'lsx_banner_allowed_post_types' ) );
19
+          add_filter( 'lsx_banner_allowed_taxonomies', array( $this, 'lsx_banner_allowed_taxonomies' ) );
20
+     }
21
+
22
+     /**
23
+      * Enable project custom post type on LSX Banners.
24
+      */
25
+     public function lsx_banner_allowed_post_types( $post_types ) {
26
+          $post_types[] = 'project';
27
+          return $post_types;
28
+     }
29
+
30
+     /**
31
+      * Enable project custom taxonomies on LSX Banners.
32
+      */
33
+     public function lsx_banner_allowed_taxonomies( $taxonomies ) {
34
+          $taxonomies[] = 'project-group';
35
+          return $taxonomies;
36
+     }
37
+
38
+     /**
39
+      * Returns the shortcode output markup
40
+      */
41
+     public function output( $atts ) {
42
+          // @codingStandardsIgnoreLine
43
+          extract( shortcode_atts( array(
44
+               'columns' => 3,
45
+               'orderby' => 'name',
46
+               'order' => 'ASC',
47
+               'limit' => '-1',
48
+               'include' => '',
49
+               'display' => 'excerpt',
50
+               'size' => 'lsx-thumbnail-single',
51
+               'responsive' => 'true',
52
+               'show_image' => 'true',
53
+               'carousel' => 'true',
54
+               'featured' => 'false',
55
+          ), $atts ) );
56
+
57
+          $output = '';
58
+
59
+          if ( 'true' === $responsive || true === $responsive ) {
60
+               $responsive = ' img-responsive';
61
+          } else {
62
+               $responsive = '';
63
+          }
64
+
65
+          $this->columns = $columns;
66
+          $this->responsive = $responsive;
67
+
68
+          if ( ! empty( $include ) ) {
69
+               $include = explode( ',', $include );
70
+
71
+               $args = array(
72
+                    'post_type' => 'project',
73
+                    'posts_per_page' => $limit,
74
+                    'post__in' => $include,
75
+                    'orderby' => 'post__in',
76
+                    'order' => $order,
77
+               );
78
+          } else {
79
+               $args = array(
80
+                    'post_type' => 'project',
81
+                    'posts_per_page' => $limit,
82
+                    'orderby' => $orderby,
83
+                    'order' => $order,
84
+               );
85
+
86
+               if ( 'true' === $featured || true === $featured ) {
87
+                    $args['meta_key'] = 'lsx_project_featured';
88
+                    $args['meta_value'] = 1;
89
+               }
90
+          }
91
+
92
+          $projects = new \WP_Query( $args );
93
+
94
+          if ( $projects->have_posts() ) {
95
+               global $post;
96
+
97
+               $count = 0;
98
+               $count_global = 0;
99
+
100
+               if ( 'true' === $carousel || true === $carousel ) {
101
+                    $output .= "<div id='lsx-projects-slider' class='lsx-projects-shortcode' data-slick='{\"slidesToShow\": $columns, \"slidesToScroll\": $columns }'>";
102
+               } else {
103
+                    $output .= "<div class='lsx-projects-shortcode'><div class='row'>";
104
+               }
105
+
106
+               while ( $projects->have_posts() ) {
107
+                    $projects->the_post();
108
+
109
+                    // Count
110
+                    $count++;
111
+                    $count_global++;
112
+
113
+                    // Content
114
+                    if ( 'full' === $display ) {
115
+                         $content = apply_filters( 'the_content', get_the_content() );
116
+                         $content = str_replace( ']]>', ']]&gt;', $content );
117
+                    } elseif ( 'excerpt' === $display ) {
118
+                         $content = apply_filters( 'the_excerpt', get_the_excerpt() );
119
+                    }
120
+
121
+                    // Image
122
+                    if ( 'true' === $show_image || true === $show_image ) {
123
+                         if ( is_numeric( $size ) ) {
124
+                              $thumb_size = array( $size, $size );
125
+                         } else {
126
+                              $thumb_size = $size;
127
+                         }
128
+
129
+                         if ( ! empty( get_the_post_thumbnail( $post->ID ) ) ) {
130
+                              $image = get_the_post_thumbnail( $post->ID, $thumb_size, array(
131
+                                   'class' => $responsive,
132
+                              ) );
133
+                         } else {
134
+                              $image = '';
135
+                         }
136
+
137
+                         if ( empty( $image ) ) {
138
+                              if ( ! empty( $this->options['display']['projects_placeholder'] ) ) {
139
+                                   $image = '<img class="' . $responsive . '" src="' . $this->options['display']['projects_placeholder'] . '" width="' . $size . '" alt="placeholder" />';
140
+                              } else {
141
+                                   $image = '';
142
+                              }
143
+                         }
144
+                    } else {
145
+                         $image = '';
146
+                    }
147
+
148
+                    // Project groups
149
+                    $groups = '';
150
+                    $terms = get_the_terms( $post->ID, 'project-group' );
151
+
152
+                    if ( $terms && ! is_wp_error( $terms ) ) {
153
+                         $groups = array();
154
+
155
+                         foreach ( $terms as $term ) {
156
+                              $groups[] = $term->name;
157
+                         }
158
+
159
+                         $groups = join( ', ', $groups );
160
+                    }
161
+
162
+                    $project_groups = '' !== $groups ? "<p class='lsx-projects-groups'>$groups</p>" : '';
163
+
164
+                    if ( 'true' === $carousel || true === $carousel ) {
165
+                         $output .= "
166 166
 						<div class='lsx-projects-slot'>
167 167
 							" . ( ! empty( $image ) ? "<a href='" . get_permalink() . "'><figure class='lsx-projects-avatar'>$image</figure></a>" : '' ) . "
168 168
 							<h5 class='lsx-projects-title'><a href='" . get_permalink() . "'>" . apply_filters( 'the_title', $post->post_title ) . "</a></h5>
169 169
 							$project_groups
170 170
 							<div class='lsx-projects-content'><a href='" . get_permalink() . "' class='moretag'>" . esc_html__( 'View more', 'lsx-projects' ) . '</a></div>
171 171
 						</div>';
172
-				} elseif ( $columns >= 1 && $columns <= 4 ) {
173
-					$md_col_width = 12 / $columns;
172
+                    } elseif ( $columns >= 1 && $columns <= 4 ) {
173
+                         $md_col_width = 12 / $columns;
174 174
 
175
-					$output .= "
175
+                         $output .= "
176 176
 						<div class='col-xs-12 col-md-" . $md_col_width . "'>
177 177
 							<div class='lsx-projects-slot'>
178 178
 								" . ( ! empty( $image ) ? "<a href='" . get_permalink() . "'><figure class='lsx-projects-avatar'>$image</figure></a>" : '' ) . "
@@ -182,30 +182,30 @@  discard block
 block discarded – undo
182 182
 							</div>
183 183
 						</div>';
184 184
 
185
-					if ( $count == $columns && $projects->post_count > $count_global ) {
186
-						$output .= '</div>';
187
-						$output .= "<div class='row'>";
188
-						$count = 0;
189
-					}
190
-				} else {
191
-					$output .= "
185
+                         if ( $count == $columns && $projects->post_count > $count_global ) {
186
+                              $output .= '</div>';
187
+                              $output .= "<div class='row'>";
188
+                              $count = 0;
189
+                         }
190
+                    } else {
191
+                         $output .= "
192 192
 						<p class='bg-warning' style='padding: 20px;'>
193 193
 							" . esc_html__( 'Invalid number of columns set. LSX Projects supports 1 to 4 columns.', 'lsx-projects' ) . '
194 194
 						</p>';
195
-				}
195
+                    }
196 196
 
197
-				wp_reset_postdata();
198
-			}
197
+                    wp_reset_postdata();
198
+               }
199 199
 
200
-			if ( 'true' !== $carousel && true !== $carousel ) {
201
-				$output .= '</div>';
202
-			}
200
+               if ( 'true' !== $carousel && true !== $carousel ) {
201
+                    $output .= '</div>';
202
+               }
203 203
 
204
-			$output .= '</div>';
204
+               $output .= '</div>';
205 205
 
206
-			return $output;
207
-		}
208
-	}
206
+               return $output;
207
+          }
208
+     }
209 209
 
210 210
 }
211 211
 
Please login to merge, or discard this patch.
lsx-projects.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 // If this file is called directly, abort.
16 16
 if ( ! defined( 'WPINC' ) ) {
17
-	die;
17
+     die;
18 18
 }
19 19
 
20 20
 define( 'LSX_PROJECTS_PATH', plugin_dir_path( __FILE__ ) );
Please login to merge, or discard this patch.
classes/class-lsx-projects-admin.php 1 patch
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.