Passed
Push — add/43 ( 191a50...b7cbfe )
by Chris
03:54 queued 36s
created
includes/functions.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@  discard block
 block discarded – undo
13 13
  * Add our action to init to set up our vars first.
14 14
  */
15 15
 function lsx_projects_load_plugin_textdomain() {
16
-	load_plugin_textdomain( 'lsx-projects', false, basename( LSX_PROJECTS_PATH ) . '/languages' );
16
+	load_plugin_textdomain('lsx-projects', false, basename(LSX_PROJECTS_PATH) . '/languages');
17 17
 }
18
-add_action( 'init', 'lsx_projects_load_plugin_textdomain' );
18
+add_action('init', 'lsx_projects_load_plugin_textdomain');
19 19
 
20 20
 /**
21 21
  * Wraps the output class in a function to be called in templates
22 22
  */
23
-function lsx_projects( $args ) {
23
+function lsx_projects($args) {
24 24
 	$lsx_projects = new LSX_Projects;
25
-	echo wp_kses_post( $lsx_projects->output( $args ) );
25
+	echo wp_kses_post($lsx_projects->output($args));
26 26
 }
27 27
 
28 28
 /**
29 29
  * Shortcode
30 30
  */
31
-function lsx_projects_shortcode( $atts ) {
31
+function lsx_projects_shortcode($atts) {
32 32
 	$lsx_projects = new LSX_Projects;
33
-	return $lsx_projects->output( $atts );
33
+	return $lsx_projects->output($atts);
34 34
 }
35
-add_shortcode( 'lsx_projects', 'lsx_projects_shortcode' );
35
+add_shortcode('lsx_projects', 'lsx_projects_shortcode');
36 36
 
37 37
 /**
38 38
  * Wraps the output class in a function to be called in templates
39 39
  */
40 40
 function lsx_groups_list() {
41
-	do_action( 'lsx_groups_list' );
41
+	do_action('lsx_groups_list');
42 42
 }
43 43
 
44 44
 function lsx_child_group_list() {
45
-	do_action( 'lsx_child_group_list' );
45
+	do_action('lsx_child_group_list');
46 46
 }
47 47
 
48 48
 function lsx_projects_list() {
49
-	do_action( 'lsx_projects_list' );
49
+	do_action('lsx_projects_list');
50 50
 }
51 51
 
52 52
 function lsx_projects_sidebar() {
53
-	do_action( 'lsx_projects_sidebar' );
53
+	do_action('lsx_projects_sidebar');
54 54
 }
55 55
 
56 56
 function lsx_projects_single_tag() {
57
-	do_action( 'lsx_projects_single_tag' );
57
+	do_action('lsx_projects_single_tag');
58 58
 }
59 59
 
60 60
 /**
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function projects_get_options() {
68 68
 	$options = array();
69
-	if ( function_exists( 'tour_operator' ) ) {
70
-		$options = get_option( '_lsx-to_settings', false );
69
+	if (function_exists('tour_operator')) {
70
+		$options = get_option('_lsx-to_settings', false);
71 71
 	} else {
72
-		$options = get_option( '_lsx_settings', false );
72
+		$options = get_option('_lsx_settings', false);
73 73
 
74
-		if ( false === $options ) {
75
-			$options = get_option( '_lsx_lsx-settings', false );
74
+		if (false === $options) {
75
+			$options = get_option('_lsx_lsx-settings', false);
76 76
 		}
77 77
 	}
78 78
 
79 79
 	// If there are new CMB2 options available, then use those.
80
-	$new_options = get_option( 'lsx_projects_options', false );
81
-	if ( false !== $new_options ) {
80
+	$new_options = get_option('lsx_projects_options', false);
81
+	if (false !== $new_options) {
82 82
 		$options['display'] = $new_options;
83 83
 	}
84 84
 	return $options;
@@ -91,27 +91,27 @@  discard block
 block discarded – undo
91 91
  * @param  mixed  $default Optional default value
92 92
  * @return mixed           Option value
93 93
  */
94
-function projects_get_option( $key = '', $default = false ) {
94
+function projects_get_option($key = '', $default = false) {
95 95
 	$options = array();
96 96
 	$value   = $default;
97
-	if ( function_exists( 'tour_operator' ) ) {
98
-		$options = get_option( '_lsx-to_settings', false );
97
+	if (function_exists('tour_operator')) {
98
+		$options = get_option('_lsx-to_settings', false);
99 99
 	} else {
100
-		$options = get_option( '_lsx_settings', false );
100
+		$options = get_option('_lsx_settings', false);
101 101
 
102
-		if ( false === $options ) {
103
-			$options = get_option( '_lsx_lsx-settings', false );
102
+		if (false === $options) {
103
+			$options = get_option('_lsx_lsx-settings', false);
104 104
 		}
105 105
 	}
106 106
 
107 107
 	// If there are new CMB2 options available, then use those.
108
-	$new_options = get_option( 'lsx_projects_options', false );
109
-	if ( false !== $new_options ) {
108
+	$new_options = get_option('lsx_projects_options', false);
109
+	if (false !== $new_options) {
110 110
 		$options['display'] = $new_options;
111 111
 	}
112 112
 
113
-	if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) {
114
-		$value = $options['display'][ $key ];
113
+	if (isset($options['display']) && isset($options['display'][$key])) {
114
+		$value = $options['display'][$key];
115 115
 	}
116 116
 	return $value;
117 117
 }
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Add our action to init to set up our vars first.
14 14
  */
15 15
 function lsx_projects_load_plugin_textdomain() {
16
-	load_plugin_textdomain( 'lsx-projects', false, basename( LSX_PROJECTS_PATH ) . '/languages' );
16
+     load_plugin_textdomain( 'lsx-projects', false, basename( LSX_PROJECTS_PATH ) . '/languages' );
17 17
 }
18 18
 add_action( 'init', 'lsx_projects_load_plugin_textdomain' );
19 19
 
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
  * Wraps the output class in a function to be called in templates
22 22
  */
23 23
 function lsx_projects( $args ) {
24
-	$lsx_projects = new LSX_Projects;
25
-	echo wp_kses_post( $lsx_projects->output( $args ) );
24
+     $lsx_projects = new LSX_Projects;
25
+     echo wp_kses_post( $lsx_projects->output( $args ) );
26 26
 }
27 27
 
28 28
 /**
29 29
  * Shortcode
30 30
  */
31 31
 function lsx_projects_shortcode( $atts ) {
32
-	$lsx_projects = new LSX_Projects;
33
-	return $lsx_projects->output( $atts );
32
+     $lsx_projects = new LSX_Projects;
33
+     return $lsx_projects->output( $atts );
34 34
 }
35 35
 add_shortcode( 'lsx_projects', 'lsx_projects_shortcode' );
36 36
 
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
  * Wraps the output class in a function to be called in templates
39 39
  */
40 40
 function lsx_groups_list() {
41
-	do_action( 'lsx_groups_list' );
41
+     do_action( 'lsx_groups_list' );
42 42
 }
43 43
 
44 44
 function lsx_child_group_list() {
45
-	do_action( 'lsx_child_group_list' );
45
+     do_action( 'lsx_child_group_list' );
46 46
 }
47 47
 
48 48
 function lsx_projects_list() {
49
-	do_action( 'lsx_projects_list' );
49
+     do_action( 'lsx_projects_list' );
50 50
 }
51 51
 
52 52
 function lsx_projects_sidebar() {
53
-	do_action( 'lsx_projects_sidebar' );
53
+     do_action( 'lsx_projects_sidebar' );
54 54
 }
55 55
 
56 56
 function lsx_projects_single_tag() {
57
-	do_action( 'lsx_projects_single_tag' );
57
+     do_action( 'lsx_projects_single_tag' );
58 58
 }
59 59
 
60 60
 /**
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
  * @return mixed           Option value
66 66
  */
67 67
 function projects_get_options() {
68
-	$options = array();
69
-	if ( function_exists( 'tour_operator' ) ) {
70
-		$options = get_option( '_lsx-to_settings', false );
71
-	} else {
72
-		$options = get_option( '_lsx_settings', false );
68
+     $options = array();
69
+     if ( function_exists( 'tour_operator' ) ) {
70
+          $options = get_option( '_lsx-to_settings', false );
71
+     } else {
72
+          $options = get_option( '_lsx_settings', false );
73 73
 
74
-		if ( false === $options ) {
75
-			$options = get_option( '_lsx_lsx-settings', false );
76
-		}
77
-	}
74
+          if ( false === $options ) {
75
+               $options = get_option( '_lsx_lsx-settings', false );
76
+          }
77
+     }
78 78
 
79
-	// If there are new CMB2 options available, then use those.
80
-	$new_options = get_option( 'lsx_projects_options', false );
81
-	if ( false !== $new_options ) {
82
-		$options['display'] = $new_options;
83
-	}
84
-	return $options;
79
+     // If there are new CMB2 options available, then use those.
80
+     $new_options = get_option( 'lsx_projects_options', false );
81
+     if ( false !== $new_options ) {
82
+          $options['display'] = $new_options;
83
+     }
84
+     return $options;
85 85
 }
86 86
 
87 87
 /**
@@ -92,26 +92,26 @@  discard block
 block discarded – undo
92 92
  * @return mixed           Option value
93 93
  */
94 94
 function projects_get_option( $key = '', $default = false ) {
95
-	$options = array();
96
-	$value   = $default;
97
-	if ( function_exists( 'tour_operator' ) ) {
98
-		$options = get_option( '_lsx-to_settings', false );
99
-	} else {
100
-		$options = get_option( '_lsx_settings', false );
95
+     $options = array();
96
+     $value   = $default;
97
+     if ( function_exists( 'tour_operator' ) ) {
98
+          $options = get_option( '_lsx-to_settings', false );
99
+     } else {
100
+          $options = get_option( '_lsx_settings', false );
101 101
 
102
-		if ( false === $options ) {
103
-			$options = get_option( '_lsx_lsx-settings', false );
104
-		}
105
-	}
102
+          if ( false === $options ) {
103
+               $options = get_option( '_lsx_lsx-settings', false );
104
+          }
105
+     }
106 106
 
107
-	// If there are new CMB2 options available, then use those.
108
-	$new_options = get_option( 'lsx_projects_options', false );
109
-	if ( false !== $new_options ) {
110
-		$options['display'] = $new_options;
111
-	}
107
+     // If there are new CMB2 options available, then use those.
108
+     $new_options = get_option( 'lsx_projects_options', false );
109
+     if ( false !== $new_options ) {
110
+          $options['display'] = $new_options;
111
+     }
112 112
 
113
-	if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) {
114
-		$value = $options['display'][ $key ];
115
-	}
116
-	return $value;
113
+     if ( isset( $options['display'] ) && isset( $options['display'][ $key ] ) ) {
114
+          $value = $options['display'][ $key ];
115
+     }
116
+     return $value;
117 117
 }
Please login to merge, or discard this patch.
templates/content-archive-projects.php 3 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,53 +9,53 @@
 block discarded – undo
9 9
 
10 10
 	$groups = '';
11 11
 	$groups_class = '';
12
-	$terms = get_the_terms( get_the_ID(), 'project-group' );
12
+	$terms = get_the_terms(get_the_ID(), 'project-group');
13 13
 
14
-	if ( $terms && ! is_wp_error( $terms ) ) {
14
+	if ($terms && ! is_wp_error($terms)) {
15 15
 		$groups = array();
16 16
 		$groups_class = array();
17 17
 
18
-		foreach ( $terms as $term ) {
19
-			$groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
18
+		foreach ($terms as $term) {
19
+			$groups[] = '<a href="' . get_term_link($term) . '">' . $term->name . '</a>';
20 20
 			$groups_class[] = 'filter-' . $term->slug;
21 21
 		}
22 22
 
23
-		$groups = join( ', ', $groups );
24
-		$groups_class = join( ' ', $groups_class );
23
+		$groups = join(', ', $groups);
24
+		$groups_class = join(' ', $groups_class);
25 25
 	}
26 26
 ?>
27 27
 
28
-<div class="col-xs-12 col-sm-6 col-md-4 lsx-projects-column <?php echo esc_attr( $groups_class ); ?>">
28
+<div class="col-xs-12 col-sm-6 col-md-4 lsx-projects-column <?php echo esc_attr($groups_class); ?>">
29 29
 	<article class="lsx-projects-slot">
30
-		<?php if ( ! empty( lsx_get_thumbnail( 'lsx-thumbnail-single' ) ) ) : ?>
31
-			<?php if ( ! isset( $lsx_projects_frontend->options['display'] ) || ! isset( $lsx_projects_frontend->options['display']['team_disable_single'] ) ) : ?>
32
-				<a href="<?php the_permalink(); ?>"><figure class="lsx-projects-avatar"><?php lsx_thumbnail( 'lsx-thumbnail-single' ); ?></figure></a>
30
+		<?php if ( ! empty(lsx_get_thumbnail('lsx-thumbnail-single'))) : ?>
31
+			<?php if ( ! isset($lsx_projects_frontend->options['display']) || ! isset($lsx_projects_frontend->options['display']['team_disable_single'])) : ?>
32
+				<a href="<?php the_permalink(); ?>"><figure class="lsx-projects-avatar"><?php lsx_thumbnail('lsx-thumbnail-single'); ?></figure></a>
33 33
 			<?php else : ?>
34
-				<figure class="lsx-projects-avatar"><?php lsx_thumbnail( 'lsx-thumbnail-single' ); ?></figure>
34
+				<figure class="lsx-projects-avatar"><?php lsx_thumbnail('lsx-thumbnail-single'); ?></figure>
35 35
 			<?php endif; ?>
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" />' );
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 42
 			}
43 43
 		}
44 44
 		?>
45 45
 
46 46
 		<h5 class="lsx-projects-title">
47
-			<?php if ( ! isset( $lsx_projects_frontend->options['display'] ) || ! isset( $lsx_projects_frontend->options['display']['team_disable_single'] ) ) : ?>
47
+			<?php if ( ! isset($lsx_projects_frontend->options['display']) || ! isset($lsx_projects_frontend->options['display']['team_disable_single'])) : ?>
48 48
 				<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
49 49
 			<?php else : ?>
50 50
 				<?php the_title(); ?>
51 51
 			<?php endif; ?>
52 52
 		</h5>
53 53
 
54
-		<?php if ( ! empty( $groups ) ) : ?>
55
-			<p class="lsx-projects-groups"><?php echo wp_kses_post( $groups ); ?></p>
54
+		<?php if ( ! empty($groups)) : ?>
55
+			<p class="lsx-projects-groups"><?php echo wp_kses_post($groups); ?></p>
56 56
 		<?php endif; ?>
57 57
 
58 58
 		<!--<div class="lsx-projects-content"><?php the_excerpt(); ?></div>-->
59
-		<div class="lsx-projects-content"><a href="<?php the_permalink(); ?>" class="moretag"><?php esc_html_e( 'View more', 'lsx-projects' ); ?></a></div>
59
+		<div class="lsx-projects-content"><a href="<?php the_permalink(); ?>" class="moretag"><?php esc_html_e('View more', 'lsx-projects'); ?></a></div>
60 60
 	</article>
61 61
 </div>
Please login to merge, or discard this 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.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,11 @@  discard block
 block discarded – undo
30 30
 		<?php if ( ! empty( lsx_get_thumbnail( 'lsx-thumbnail-single' ) ) ) : ?>
31 31
 			<?php if ( ! isset( $lsx_projects_frontend->options['display'] ) || ! isset( $lsx_projects_frontend->options['display']['team_disable_single'] ) ) : ?>
32 32
 				<a href="<?php the_permalink(); ?>"><figure class="lsx-projects-avatar"><?php lsx_thumbnail( 'lsx-thumbnail-single' ); ?></figure></a>
33
-			<?php else : ?>
34
-				<figure class="lsx-projects-avatar"><?php lsx_thumbnail( 'lsx-thumbnail-single' ); ?></figure>
33
+			<?php else {
34
+     : ?>
35
+				<figure class="lsx-projects-avatar"><?php lsx_thumbnail( 'lsx-thumbnail-single' );
36
+}
37
+?></figure>
35 38
 			<?php endif; ?>
36 39
 		<?php endif; ?>
37 40
 
@@ -46,8 +49,11 @@  discard block
 block discarded – undo
46 49
 		<h5 class="lsx-projects-title">
47 50
 			<?php if ( ! isset( $lsx_projects_frontend->options['display'] ) || ! isset( $lsx_projects_frontend->options['display']['team_disable_single'] ) ) : ?>
48 51
 				<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
49
-			<?php else : ?>
50
-				<?php the_title(); ?>
52
+			<?php else {
53
+     : ?>
54
+				<?php the_title();
55
+}
56
+?>
51 57
 			<?php endif; ?>
52 58
 		</h5>
53 59
 
Please login to merge, or discard this patch.
classes/class-lsx-projects-core.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * Contructor
30 30
 	 */
31 31
 	public function __construct() {
32
-		add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) );
32
+		add_action('init', array($this, 'cmb2_post_search_ajax'));
33 33
 		$this->load_vendors();
34 34
 	}
35 35
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	public static function get_instance() {
44 44
 
45 45
 		// If the single instance hasn't been set, set it now.
46
-		if ( null === self::$instance ) {
46
+		if (null === self::$instance) {
47 47
 			self::$instance = new self();
48 48
 		}
49 49
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	private function load_vendors() {
58 58
 		// Configure custom fields.
59
-		if ( ! class_exists( 'CMB2' ) ) {
59
+		if ( ! class_exists('CMB2')) {
60 60
 			require_once LSX_PROJECTS_PATH . 'vendor/CMB2/init.php';
61 61
 		}
62 62
 	}
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 	 * @return void
68 68
 	 */
69 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 ] );
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 75
 			}
76 76
 		}
77 77
 		return $post_types;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function cmb2_post_search_ajax() {
86 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' ) ) {
87
+		if (method_exists('MAG_CMB2_Field_Post_Search_Ajax', 'get_instance')) {
88 88
 			$this->cmb2_post_search_ajax = \MAG_CMB2_Field_Post_Search_Ajax::get_instance();
89 89
 		}
90 90
 	}
Please login to merge, or discard this 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-admin.php 2 patches
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@  discard block
 block discarded – undo
13 13
 	public function __construct() {
14 14
 		$this->load_classes();
15 15
 
16
-		add_action( 'init', array( $this, 'post_type_setup' ) );
17
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
18
-		add_action( 'init', array( $this, 'taxonomy_project_type_setup' ) );
19
-		add_action( 'init', array( $this, 'taxonomy_project_tag_setup' ) );
20
-		add_filter( 'cmb2_admin_init', array( $this, 'field_setup' ) );
21
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_services_metaboxes' ) );
22
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_testimonials_metaboxes' ) );
23
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_team_metaboxes' ) );
24
-		add_filter( 'cmb2_admin_init', array( $this, 'projects_woocommerce_metaboxes' ) );
25
-		add_filter( 'cmb2_admin_init', array( $this, 'project_field_setup_product' ) );
26
-		add_action( 'cmb_save_custom', array( $this, 'post_relations' ), 3, 20 );
27
-		add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
28
-
29
-		add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 );
30
-		add_filter( 'enter_title_here', array( $this, 'change_title_text' ) );
16
+		add_action('init', array($this, 'post_type_setup'));
17
+		add_action('init', array($this, 'taxonomy_setup'));
18
+		add_action('init', array($this, 'taxonomy_project_type_setup'));
19
+		add_action('init', array($this, 'taxonomy_project_tag_setup'));
20
+		add_filter('cmb2_admin_init', array($this, 'field_setup'));
21
+		add_filter('cmb2_admin_init', array($this, 'projects_services_metaboxes'));
22
+		add_filter('cmb2_admin_init', array($this, 'projects_testimonials_metaboxes'));
23
+		add_filter('cmb2_admin_init', array($this, 'projects_team_metaboxes'));
24
+		add_filter('cmb2_admin_init', array($this, 'projects_woocommerce_metaboxes'));
25
+		add_filter('cmb2_admin_init', array($this, 'project_field_setup_product'));
26
+		add_action('cmb_save_custom', array($this, 'post_relations'), 3, 20);
27
+		add_action('admin_enqueue_scripts', array($this, 'assets'));
28
+
29
+		add_filter('type_url_form_media', array($this, 'change_attachment_field_button'), 20, 1);
30
+		add_filter('enter_title_here', array($this, 'change_title_text'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function post_type_setup() {
48 48
 		$labels = array(
49
-			'name'               => esc_html_x( 'Projects', 'post type general name', 'lsx-projects' ),
50
-			'singular_name'      => esc_html_x( 'Project', 'post type singular name', 'lsx-projects' ),
51
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-projects' ),
52
-			'add_new_item'       => esc_html__( 'Add New Project', 'lsx-projects' ),
53
-			'edit_item'          => esc_html__( 'Edit Project', 'lsx-projects' ),
54
-			'new_item'           => esc_html__( 'New Project', 'lsx-projects' ),
55
-			'all_items'          => esc_html__( 'All Projects', 'lsx-projects' ),
56
-			'view_item'          => esc_html__( 'View Project', 'lsx-projects' ),
57
-			'search_items'       => esc_html__( 'Search Projects', 'lsx-projects' ),
58
-			'not_found'          => esc_html__( 'No projects found', 'lsx-projects' ),
59
-			'not_found_in_trash' => esc_html__( 'No projects found in Trash', 'lsx-projects' ),
49
+			'name'               => esc_html_x('Projects', 'post type general name', 'lsx-projects'),
50
+			'singular_name'      => esc_html_x('Project', 'post type singular name', 'lsx-projects'),
51
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-projects'),
52
+			'add_new_item'       => esc_html__('Add New Project', 'lsx-projects'),
53
+			'edit_item'          => esc_html__('Edit Project', 'lsx-projects'),
54
+			'new_item'           => esc_html__('New Project', 'lsx-projects'),
55
+			'all_items'          => esc_html__('All Projects', 'lsx-projects'),
56
+			'view_item'          => esc_html__('View Project', 'lsx-projects'),
57
+			'search_items'       => esc_html__('Search Projects', 'lsx-projects'),
58
+			'not_found'          => esc_html__('No projects found', 'lsx-projects'),
59
+			'not_found_in_trash' => esc_html__('No projects found in Trash', 'lsx-projects'),
60 60
 			'parent_item_colon'  => '',
61
-			'menu_name'          => esc_html_x( 'Projects', 'admin menu', 'lsx-projects' ),
61
+			'menu_name'          => esc_html_x('Projects', 'admin menu', 'lsx-projects'),
62 62
 		);
63 63
 
64 64
 		$args = array(
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 				'excerpt',
84 84
 			),
85 85
 			'show_in_rest'       => true,
86
-			'supports'           => array( 'editor', 'title', 'excerpt', 'thumbnail' ),
86
+			'supports'           => array('editor', 'title', 'excerpt', 'thumbnail'),
87 87
 		);
88 88
 
89
-		register_post_type( 'project', $args );
89
+		register_post_type('project', $args);
90 90
 	}
91 91
 
92 92
 	/**
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function taxonomy_setup() {
96 96
 		$labels = array(
97
-			'name'              => esc_html_x( 'Project Groups', 'taxonomy general name', 'lsx-projects' ),
98
-			'singular_name'     => esc_html_x( 'Group', 'taxonomy singular name', 'lsx-projects' ),
99
-			'search_items'      => esc_html__( 'Search Groups', 'lsx-projects' ),
100
-			'all_items'         => esc_html__( 'All Groups', 'lsx-projects' ),
101
-			'parent_item'       => esc_html__( 'Parent Group', 'lsx-projects' ),
102
-			'parent_item_colon' => esc_html__( 'Parent Group:', 'lsx-projects' ),
103
-			'edit_item'         => esc_html__( 'Edit Group', 'lsx-projects' ),
104
-			'update_item'       => esc_html__( 'Update Group', 'lsx-projects' ),
105
-			'add_new_item'      => esc_html__( 'Add New Group', 'lsx-projects' ),
106
-			'new_item_name'     => esc_html__( 'New Group Name', 'lsx-projects' ),
107
-			'menu_name'         => esc_html__( 'Groups', 'lsx-projects' ),
97
+			'name'              => esc_html_x('Project Groups', 'taxonomy general name', 'lsx-projects'),
98
+			'singular_name'     => esc_html_x('Group', 'taxonomy singular name', 'lsx-projects'),
99
+			'search_items'      => esc_html__('Search Groups', 'lsx-projects'),
100
+			'all_items'         => esc_html__('All Groups', 'lsx-projects'),
101
+			'parent_item'       => esc_html__('Parent Group', 'lsx-projects'),
102
+			'parent_item_colon' => esc_html__('Parent Group:', 'lsx-projects'),
103
+			'edit_item'         => esc_html__('Edit Group', 'lsx-projects'),
104
+			'update_item'       => esc_html__('Update Group', 'lsx-projects'),
105
+			'add_new_item'      => esc_html__('Add New Group', 'lsx-projects'),
106
+			'new_item_name'     => esc_html__('New Group Name', 'lsx-projects'),
107
+			'menu_name'         => esc_html__('Groups', 'lsx-projects'),
108 108
 		);
109 109
 
110 110
 		$args = array(
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			),
119 119
 		);
120 120
 
121
-		register_taxonomy( 'project-group', array( 'project' ), $args );
121
+		register_taxonomy('project-group', array('project'), $args);
122 122
 	}
123 123
 
124 124
 	/**
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function taxonomy_project_type_setup() {
128 128
 		$labels = array(
129
-			'name'              => esc_html_x( 'Project Types', 'taxonomy general name', 'lsx-projects' ),
130
-			'singular_name'     => esc_html_x( 'Type', 'taxonomy singular name', 'lsx-projects' ),
131
-			'search_items'      => esc_html__( 'Search Types', 'lsx-projects' ),
132
-			'all_items'         => esc_html__( 'All Types', 'lsx-projects' ),
133
-			'parent_item'       => esc_html__( 'Parent Type', 'lsx-projects' ),
134
-			'parent_item_colon' => esc_html__( 'Parent Type:', 'lsx-projects' ),
135
-			'edit_item'         => esc_html__( 'Edit Type', 'lsx-projects' ),
136
-			'update_item'       => esc_html__( 'Update Type', 'lsx-projects' ),
137
-			'add_new_item'      => esc_html__( 'Add New Type', 'lsx-projects' ),
138
-			'new_item_name'     => esc_html__( 'New Type Name', 'lsx-projects' ),
139
-			'menu_name'         => esc_html__( 'Types', 'lsx-projects' ),
129
+			'name'              => esc_html_x('Project Types', 'taxonomy general name', 'lsx-projects'),
130
+			'singular_name'     => esc_html_x('Type', 'taxonomy singular name', 'lsx-projects'),
131
+			'search_items'      => esc_html__('Search Types', 'lsx-projects'),
132
+			'all_items'         => esc_html__('All Types', 'lsx-projects'),
133
+			'parent_item'       => esc_html__('Parent Type', 'lsx-projects'),
134
+			'parent_item_colon' => esc_html__('Parent Type:', 'lsx-projects'),
135
+			'edit_item'         => esc_html__('Edit Type', 'lsx-projects'),
136
+			'update_item'       => esc_html__('Update Type', 'lsx-projects'),
137
+			'add_new_item'      => esc_html__('Add New Type', 'lsx-projects'),
138
+			'new_item_name'     => esc_html__('New Type Name', 'lsx-projects'),
139
+			'menu_name'         => esc_html__('Types', 'lsx-projects'),
140 140
 		);
141 141
 
142 142
 		$args = array(
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 			'show_in_rest'      => true,
152 152
 		);
153 153
 
154
-		register_taxonomy( 'project-type', array( 'project' ), $args );
154
+		register_taxonomy('project-type', array('project'), $args);
155 155
 	}
156 156
 
157 157
 	/**
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function taxonomy_project_tag_setup() {
161 161
 		$labels = array(
162
-			'name'              => esc_html_x( 'Project Tags', 'taxonomy general name', 'lsx-projects' ),
163
-			'singular_name'     => esc_html_x( 'Tag', 'taxonomy singular name', 'lsx-projects' ),
164
-			'search_items'      => esc_html__( 'Search Tags', 'lsx-projects' ),
165
-			'all_items'         => esc_html__( 'All Tags', 'lsx-projects' ),
166
-			'parent_item'       => esc_html__( 'Parent Tag', 'lsx-projects' ),
167
-			'parent_item_colon' => esc_html__( 'Parent Tag:', 'lsx-projects' ),
168
-			'edit_item'         => esc_html__( 'Edit Tag', 'lsx-projects' ),
169
-			'update_item'       => esc_html__( 'Update Tag', 'lsx-projects' ),
170
-			'add_new_item'      => esc_html__( 'Add New Tag', 'lsx-projects' ),
171
-			'new_item_name'     => esc_html__( 'New Tag Name', 'lsx-projects' ),
172
-			'menu_name'         => esc_html__( 'Tags', 'lsx-projects' ),
162
+			'name'              => esc_html_x('Project Tags', 'taxonomy general name', 'lsx-projects'),
163
+			'singular_name'     => esc_html_x('Tag', 'taxonomy singular name', 'lsx-projects'),
164
+			'search_items'      => esc_html__('Search Tags', 'lsx-projects'),
165
+			'all_items'         => esc_html__('All Tags', 'lsx-projects'),
166
+			'parent_item'       => esc_html__('Parent Tag', 'lsx-projects'),
167
+			'parent_item_colon' => esc_html__('Parent Tag:', 'lsx-projects'),
168
+			'edit_item'         => esc_html__('Edit Tag', 'lsx-projects'),
169
+			'update_item'       => esc_html__('Update Tag', 'lsx-projects'),
170
+			'add_new_item'      => esc_html__('Add New Tag', 'lsx-projects'),
171
+			'new_item_name'     => esc_html__('New Tag Name', 'lsx-projects'),
172
+			'menu_name'         => esc_html__('Tags', 'lsx-projects'),
173 173
 		);
174 174
 
175 175
 		$args = array(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			'show_in_rest'      => true,
185 185
 		);
186 186
 
187
-		register_taxonomy( 'project-tag', array( 'project' ), $args );
187
+		register_taxonomy('project-tag', array('project'), $args);
188 188
 	}
189 189
 
190 190
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		$cmb = new_cmb2_box(
197 197
 			array(
198 198
 				'id'           => $prefix . '_project',
199
-				'title'        => __( 'General', 'lsx-projects' ),
199
+				'title'        => __('General', 'lsx-projects'),
200 200
 				'object_types' => 'project',
201 201
 				'context'      => 'normal',
202 202
 				'priority'     => 'low',
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 		$cmb->add_field(
208 208
 			array(
209
-				'name'         => esc_html__( 'Featured:', 'lsx-projects' ),
209
+				'name'         => esc_html__('Featured:', 'lsx-projects'),
210 210
 				'id'           => $prefix . 'featured',
211 211
 				'type'         => 'checkbox',
212 212
 				'value'        => 1,
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$cmb->add_field(
219 219
 			array(
220
-				'name'         => esc_html__( 'Client:', 'lsx-projects' ),
220
+				'name'         => esc_html__('Client:', 'lsx-projects'),
221 221
 				'id'           => $prefix . 'client',
222 222
 				'type'         => 'text',
223 223
 				'show_in_rest' => true,
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 
227 227
 		$cmb->add_field(
228 228
 			array(
229
-				'name'         => esc_html__( 'Client logo:', 'lsx-projects' ),
229
+				'name'         => esc_html__('Client logo:', 'lsx-projects'),
230 230
 				'id'           => $prefix . 'client_logo',
231 231
 				'type'         => 'file',
232
-				'desc'         => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ),
232
+				'desc'         => esc_html__('Recommended image size: 320 x 50~60', 'lsx-projects'),
233 233
 				'options'      => array(
234 234
 					'url' => false, // Hide the text input for the url.
235 235
 				),
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 		$cmb->add_field(
244 244
 			array(
245
-				'name'         => esc_html__( 'URL for the finished project:', 'lsx-projects' ),
245
+				'name'         => esc_html__('URL for the finished project:', 'lsx-projects'),
246 246
 				'id'           => $prefix . 'url',
247 247
 				'type'         => 'text',
248 248
 				'show_in_rest' => true,
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
 
269 269
 		$cmb->add_field(
270 270
 			array(
271
-				'name'         => esc_html__( 'Services related to this project:', 'lsx-projects' ),
271
+				'name'         => esc_html__('Services related to this project:', 'lsx-projects'),
272 272
 				'id'           => 'page_to_project',
273 273
 				'type'         => 'post_search_ajax',
274 274
 				'show_in_rest' => true,
275 275
 				'limit'        => 15,
276 276
 				'sortable'     => true,
277 277
 				'query_args'   => array(
278
-					'post_type'      => array( 'project' ),
279
-					'post_status'    => array( 'publish' ),
278
+					'post_type'      => array('project'),
279
+					'post_status'    => array('publish'),
280 280
 					'nopagin'        => true,
281 281
 					'posts_per_page' => '50',
282 282
 					'orderby'        => 'title',
@@ -302,18 +302,18 @@  discard block
 block discarded – undo
302 302
 			)
303 303
 		);
304 304
 
305
-		if ( class_exists( 'LSX_Testimonials' ) ) {
305
+		if (class_exists('LSX_Testimonials')) {
306 306
 			$cmb->add_field(
307 307
 				array(
308
-					'name'         => esc_html__( 'Testimonials related to this project:', 'lsx-projects' ),
308
+					'name'         => esc_html__('Testimonials related to this project:', 'lsx-projects'),
309 309
 					'id'           => 'testimonial_to_project',
310 310
 					'type'         => 'post_search_ajax',
311 311
 					'show_in_rest' => true,
312 312
 					'limit'        => 15,
313 313
 					'sortable'     => true,
314 314
 					'query_args'   => array(
315
-						'post_type'      => array( 'testimonial' ),
316
-						'post_status'    => array( 'publish' ),
315
+						'post_type'      => array('testimonial'),
316
+						'post_status'    => array('publish'),
317 317
 						'nopagin'        => true,
318 318
 						'posts_per_page' => '50',
319 319
 						'orderby'        => 'title',
@@ -340,18 +340,18 @@  discard block
 block discarded – undo
340 340
 			)
341 341
 		);
342 342
 
343
-		if ( class_exists( 'LSX_Team' ) ) {
343
+		if (class_exists('LSX_Team')) {
344 344
 			$cmb->add_field(
345 345
 				array(
346
-					'name'         => esc_html__( 'Team members involved with this project:', 'lsx-projects' ),
346
+					'name'         => esc_html__('Team members involved with this project:', 'lsx-projects'),
347 347
 					'id'           => 'team_to_project',
348 348
 					'type'         => 'post_search_ajax',
349 349
 					'show_in_rest' => true,
350 350
 					'limit'        => 15,
351 351
 					'sortable'     => true,
352 352
 					'query_args'   => array(
353
-						'post_type'      => array( 'team' ),
354
-						'post_status'    => array( 'publish' ),
353
+						'post_type'      => array('team'),
354
+						'post_status'    => array('publish'),
355 355
 						'nopagin'        => true,
356 356
 						'posts_per_page' => '50',
357 357
 						'orderby'        => 'title',
@@ -378,18 +378,18 @@  discard block
 block discarded – undo
378 378
 			)
379 379
 		);
380 380
 
381
-		if ( class_exists( 'woocommerce' ) ) {
381
+		if (class_exists('woocommerce')) {
382 382
 			$cmb->add_field(
383 383
 				array(
384
-					'name'         => esc_html__( 'Products used for this project:', 'lsx-projects' ),
384
+					'name'         => esc_html__('Products used for this project:', 'lsx-projects'),
385 385
 					'id'           => 'product_to_project',
386 386
 					'type'         => 'post_search_ajax',
387 387
 					'show_in_rest' => true,
388 388
 					'limit'        => 15,
389 389
 					'sortable'     => true,
390 390
 					'query_args'   => array(
391
-						'post_type'      => array( 'product' ),
392
-						'post_status'    => array( 'publish' ),
391
+						'post_type'      => array('product'),
392
+						'post_status'    => array('publish'),
393 393
 						'nopagin'        => true,
394 394
 						'posts_per_page' => '50',
395 395
 						'orderby'        => 'title',
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		$cmb = new_cmb2_box(
410 410
 			array(
411 411
 				'id'           => $prefix . '_project',
412
-				'title'        => __( 'General', 'lsx-projects' ),
412
+				'title'        => __('General', 'lsx-projects'),
413 413
 				'object_types' => 'project',
414 414
 				'context'      => 'normal',
415 415
 				'priority'     => 'low',
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
 				'id'      => $prefix . '_alt_products',
423 423
 				'type'    => 'group',
424 424
 				'options' => array(
425
-					'group_title'   => __( 'Alternative Products', 'lsx-projects' ),
426
-					'add_button'    => __( 'Add Product', 'lsx-projects' ),
427
-					'remove_button' => __( 'Remove Product', 'lsx-projects' ),
425
+					'group_title'   => __('Alternative Products', 'lsx-projects'),
426
+					'add_button'    => __('Add Product', 'lsx-projects'),
427
+					'remove_button' => __('Remove Product', 'lsx-projects'),
428 428
 					'sortable'      => true,
429 429
 				),
430 430
 				'classes' => 'lsx-admin-row',
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		$cmb->add_group_field(
435 435
 			$tip_group,
436 436
 			array(
437
-				'name'         => esc_html__( 'Alt Product Name:', 'lsx-projects' ),
437
+				'name'         => esc_html__('Alt Product Name:', 'lsx-projects'),
438 438
 				'id'           => $prefix . 'alt_product_title',
439 439
 				'type'         => 'text',
440 440
 				'show_in_rest' => true,
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 		$cmb->add_group_field(
445 445
 			$tip_group,
446 446
 			array(
447
-				'name'         => esc_html__( 'Alt Product Link:', 'lsx-projects' ),
447
+				'name'         => esc_html__('Alt Product Link:', 'lsx-projects'),
448 448
 				'id'           => $prefix . 'alt_product_link',
449 449
 				'type'         => 'text',
450 450
 				'show_in_rest' => true,
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
 		$cmb->add_group_field(
455 455
 			$tip_group,
456 456
 			array(
457
-				'name'         => esc_html__( 'Alt Product Image:', 'lsx-projects' ),
457
+				'name'         => esc_html__('Alt Product Image:', 'lsx-projects'),
458 458
 				'id'           => $prefix . 'alt_product_image',
459 459
 				'type'         => 'file',
460
-				'desc'         => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ),
460
+				'desc'         => esc_html__('Recommended image size: 320 x 50~60', 'lsx-projects'),
461 461
 				'options'      => array(
462 462
 					'url' => false, // Hide the text input for the url.
463 463
 				),
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	/**
473 473
 	 * Sets up the "post relations".
474 474
 	 */
475
-	public function post_relations( $post_id, $field, $value ) {
475
+	public function post_relations($post_id, $field, $value) {
476 476
 		$connections = array(
477 477
 			// 'project_to_project',
478 478
 
@@ -489,31 +489,31 @@  discard block
 block discarded – undo
489 489
 			'team_to_project',
490 490
 		);
491 491
 
492
-		if ( in_array( $field['id'], $connections ) ) {
493
-			$this->save_related_post( $connections, $post_id, $field, $value );
492
+		if (in_array($field['id'], $connections)) {
493
+			$this->save_related_post($connections, $post_id, $field, $value);
494 494
 		}
495 495
 	}
496 496
 
497 497
 	/**
498 498
 	 * Save the reverse post relation.
499 499
 	 */
500
-	public function save_related_post( $connections, $post_id, $field, $value ) {
501
-		$ids = explode( '_to_', $field['id'] );
500
+	public function save_related_post($connections, $post_id, $field, $value) {
501
+		$ids = explode('_to_', $field['id']);
502 502
 		$relation = $ids[1] . '_to_' . $ids[0];
503 503
 
504
-		if ( in_array( $relation, $connections ) ) {
505
-			$previous_values = get_post_meta( $post_id, $field['id'], false );
504
+		if (in_array($relation, $connections)) {
505
+			$previous_values = get_post_meta($post_id, $field['id'], false);
506 506
 
507
-			if ( ! empty( $previous_values ) ) {
508
-				foreach ( $previous_values as $v ) {
509
-					delete_post_meta( $v, $relation, $post_id );
507
+			if ( ! empty($previous_values)) {
508
+				foreach ($previous_values as $v) {
509
+					delete_post_meta($v, $relation, $post_id);
510 510
 				}
511 511
 			}
512 512
 
513
-			if ( is_array( $value ) ) {
514
-				foreach ( $value as $v ) {
515
-					if ( ! empty( $v ) ) {
516
-						add_post_meta( $v, $relation, $post_id );
513
+			if (is_array($value)) {
514
+				foreach ($value as $v) {
515
+					if ( ! empty($v)) {
516
+						add_post_meta($v, $relation, $post_id);
517 517
 					}
518 518
 				}
519 519
 			}
@@ -522,30 +522,30 @@  discard block
 block discarded – undo
522 522
 
523 523
 	public function assets() {
524 524
 		//wp_enqueue_media();
525
-		wp_enqueue_script( 'media-upload' );
526
-		wp_enqueue_script( 'thickbox' );
527
-		wp_enqueue_style( 'thickbox' );
525
+		wp_enqueue_script('media-upload');
526
+		wp_enqueue_script('thickbox');
527
+		wp_enqueue_style('thickbox');
528 528
 
529
-		wp_enqueue_script( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array( 'jquery' ), LSX_PROJECTS_VER, true );
530
-		wp_enqueue_style( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER );
529
+		wp_enqueue_script('lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array('jquery'), LSX_PROJECTS_VER, true);
530
+		wp_enqueue_style('lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER);
531 531
 	}
532 532
 
533 533
 	/**
534 534
 	 * Change the "Insert into Post" button text when media modal is used for feature images
535 535
 	 */
536
-	public function change_attachment_field_button( $html ) {
537
-		if ( isset( $_GET['feature_image_text_button'] ) ) {
538
-			$html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-projects' ) ), $html );
536
+	public function change_attachment_field_button($html) {
537
+		if (isset($_GET['feature_image_text_button'])) {
538
+			$html = str_replace('value="Insert into Post"', sprintf('value="%s"', esc_html__('Select featured image', 'lsx-projects')), $html);
539 539
 		}
540 540
 
541 541
 		return $html;
542 542
 	}
543 543
 
544
-	public function change_title_text( $title ) {
544
+	public function change_title_text($title) {
545 545
 		$screen = get_current_screen();
546 546
 
547
-		if ( 'project' === $screen->post_type ) {
548
-			$title = esc_attr__( 'Enter project title', 'lsx-projects' );
547
+		if ('project' === $screen->post_type) {
548
+			$title = esc_attr__('Enter project title', 'lsx-projects');
549 549
 		}
550 550
 
551 551
 		return $title;
Please login to merge, or discard this patch.
Indentation   +540 added lines, -540 removed lines patch added patch discarded remove patch
@@ -10,546 +10,546 @@
 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
-		$cmb->add_group_field(
455
-			$tip_group,
456
-			array(
457
-				'name'         => esc_html__( 'Alt Product Image:', 'lsx-projects' ),
458
-				'id'           => $prefix . 'alt_product_image',
459
-				'type'         => 'file',
460
-				'desc'         => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ),
461
-				'options'      => array(
462
-					'url' => false, // Hide the text input for the url.
463
-				),
464
-				'text'         => array(
465
-					'add_upload_file_text' => 'Choose Image',
466
-				),
467
-				'show_in_rest' => true,
468
-			)
469
-		);
470
-	}
471
-
472
-	/**
473
-	 * Sets up the "post relations".
474
-	 */
475
-	public function post_relations( $post_id, $field, $value ) {
476
-		$connections = array(
477
-			// 'project_to_project',
478
-
479
-			'page_to_project',
480
-			'project_to_page',
481
-
482
-			'project_to_service',
483
-			'service_to_project',
484
-
485
-			'project_to_testimonial',
486
-			'testimonial_to_project',
487
-
488
-			'project_to_team',
489
-			'team_to_project',
490
-		);
491
-
492
-		if ( in_array( $field['id'], $connections ) ) {
493
-			$this->save_related_post( $connections, $post_id, $field, $value );
494
-		}
495
-	}
496
-
497
-	/**
498
-	 * Save the reverse post relation.
499
-	 */
500
-	public function save_related_post( $connections, $post_id, $field, $value ) {
501
-		$ids = explode( '_to_', $field['id'] );
502
-		$relation = $ids[1] . '_to_' . $ids[0];
503
-
504
-		if ( in_array( $relation, $connections ) ) {
505
-			$previous_values = get_post_meta( $post_id, $field['id'], false );
506
-
507
-			if ( ! empty( $previous_values ) ) {
508
-				foreach ( $previous_values as $v ) {
509
-					delete_post_meta( $v, $relation, $post_id );
510
-				}
511
-			}
512
-
513
-			if ( is_array( $value ) ) {
514
-				foreach ( $value as $v ) {
515
-					if ( ! empty( $v ) ) {
516
-						add_post_meta( $v, $relation, $post_id );
517
-					}
518
-				}
519
-			}
520
-		}
521
-	}
522
-
523
-	public function assets() {
524
-		//wp_enqueue_media();
525
-		wp_enqueue_script( 'media-upload' );
526
-		wp_enqueue_script( 'thickbox' );
527
-		wp_enqueue_style( 'thickbox' );
528
-
529
-		wp_enqueue_script( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array( 'jquery' ), LSX_PROJECTS_VER, true );
530
-		wp_enqueue_style( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER );
531
-	}
532
-
533
-	/**
534
-	 * Change the "Insert into Post" button text when media modal is used for feature images
535
-	 */
536
-	public function change_attachment_field_button( $html ) {
537
-		if ( isset( $_GET['feature_image_text_button'] ) ) {
538
-			$html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-projects' ) ), $html );
539
-		}
540
-
541
-		return $html;
542
-	}
543
-
544
-	public function change_title_text( $title ) {
545
-		$screen = get_current_screen();
546
-
547
-		if ( 'project' === $screen->post_type ) {
548
-			$title = esc_attr__( 'Enter project title', 'lsx-projects' );
549
-		}
550
-
551
-		return $title;
552
-	}
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
+          $cmb->add_group_field(
455
+               $tip_group,
456
+               array(
457
+                    'name'         => esc_html__( 'Alt Product Image:', 'lsx-projects' ),
458
+                    'id'           => $prefix . 'alt_product_image',
459
+                    'type'         => 'file',
460
+                    'desc'         => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ),
461
+                    'options'      => array(
462
+                         'url' => false, // Hide the text input for the url.
463
+                    ),
464
+                    'text'         => array(
465
+                         'add_upload_file_text' => 'Choose Image',
466
+                    ),
467
+                    'show_in_rest' => true,
468
+               )
469
+          );
470
+     }
471
+
472
+     /**
473
+      * Sets up the "post relations".
474
+      */
475
+     public function post_relations( $post_id, $field, $value ) {
476
+          $connections = array(
477
+               // 'project_to_project',
478
+
479
+               'page_to_project',
480
+               'project_to_page',
481
+
482
+               'project_to_service',
483
+               'service_to_project',
484
+
485
+               'project_to_testimonial',
486
+               'testimonial_to_project',
487
+
488
+               'project_to_team',
489
+               'team_to_project',
490
+          );
491
+
492
+          if ( in_array( $field['id'], $connections ) ) {
493
+               $this->save_related_post( $connections, $post_id, $field, $value );
494
+          }
495
+     }
496
+
497
+     /**
498
+      * Save the reverse post relation.
499
+      */
500
+     public function save_related_post( $connections, $post_id, $field, $value ) {
501
+          $ids = explode( '_to_', $field['id'] );
502
+          $relation = $ids[1] . '_to_' . $ids[0];
503
+
504
+          if ( in_array( $relation, $connections ) ) {
505
+               $previous_values = get_post_meta( $post_id, $field['id'], false );
506
+
507
+               if ( ! empty( $previous_values ) ) {
508
+                    foreach ( $previous_values as $v ) {
509
+                         delete_post_meta( $v, $relation, $post_id );
510
+                    }
511
+               }
512
+
513
+               if ( is_array( $value ) ) {
514
+                    foreach ( $value as $v ) {
515
+                         if ( ! empty( $v ) ) {
516
+                              add_post_meta( $v, $relation, $post_id );
517
+                         }
518
+                    }
519
+               }
520
+          }
521
+     }
522
+
523
+     public function assets() {
524
+          //wp_enqueue_media();
525
+          wp_enqueue_script( 'media-upload' );
526
+          wp_enqueue_script( 'thickbox' );
527
+          wp_enqueue_style( 'thickbox' );
528
+
529
+          wp_enqueue_script( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array( 'jquery' ), LSX_PROJECTS_VER, true );
530
+          wp_enqueue_style( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER );
531
+     }
532
+
533
+     /**
534
+      * Change the "Insert into Post" button text when media modal is used for feature images
535
+      */
536
+     public function change_attachment_field_button( $html ) {
537
+          if ( isset( $_GET['feature_image_text_button'] ) ) {
538
+               $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-projects' ) ), $html );
539
+          }
540
+
541
+          return $html;
542
+     }
543
+
544
+     public function change_title_text( $title ) {
545
+          $screen = get_current_screen();
546
+
547
+          if ( 'project' === $screen->post_type ) {
548
+               $title = esc_attr__( 'Enter project title', 'lsx-projects' );
549
+          }
550
+
551
+          return $title;
552
+     }
553 553
 }
554 554
 
555 555
 $lsx_projects_admin = new LSX_Projects_Admin();
Please login to merge, or discard this patch.
templates/content-single-projects.php 2 patches
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -5,37 +5,37 @@  discard block
 block discarded – undo
5 5
 ?>
6 6
 
7 7
 <?php
8
-	$client = get_post_meta( get_the_ID(), 'lsx_project_client', true );
9
-	$client_logo = get_post_meta( get_the_ID(), 'lsx_project_client_logo', true );
10
-	$url = get_post_meta( get_the_ID(), 'lsx_project_url', true );
8
+	$client = get_post_meta(get_the_ID(), 'lsx_project_client', true);
9
+	$client_logo = get_post_meta(get_the_ID(), 'lsx_project_client_logo', true);
10
+	$url = get_post_meta(get_the_ID(), 'lsx_project_url', true);
11 11
 
12 12
 	global $lsx_projects;
13 13
 
14 14
 	$button_label = '';
15 15
 	$button_cf_id = '';
16 16
 
17
-	if ( ! empty( projects_get_option( 'projects_modal_enable' ) ) ) {
18
-		if ( ! empty( projects_get_option( 'projects_modal_cta_label' ) ) && ! empty( projects_get_option( 'projects_modal_form_id' ) ) ) {
19
-			$button_label = projects_get_option( 'projects_modal_cta_label' );
20
-			$button_cf_id = projects_get_option( 'projects_modal_form_id' );
17
+	if ( ! empty(projects_get_option('projects_modal_enable'))) {
18
+		if ( ! empty(projects_get_option('projects_modal_cta_label')) && ! empty(projects_get_option('projects_modal_form_id'))) {
19
+			$button_label = projects_get_option('projects_modal_cta_label');
20
+			$button_cf_id = projects_get_option('projects_modal_form_id');
21 21
 		}
22 22
 	}
23 23
 
24
-	if ( ! empty( $client_logo ) ) {
24
+	if ( ! empty($client_logo)) {
25 25
 		$client_logo = '<img src="' . $client_logo . '">';
26 26
 	}
27 27
 
28 28
 	$groups = '';
29
-	$terms = get_the_terms( get_the_ID(), 'project-group' );
29
+	$terms = get_the_terms(get_the_ID(), 'project-group');
30 30
 
31
-	if ( $terms && ! is_wp_error( $terms ) ) {
31
+	if ($terms && ! is_wp_error($terms)) {
32 32
 		$groups = array();
33 33
 
34
-		foreach ( $terms as $term ) {
35
-			$groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
34
+		foreach ($terms as $term) {
35
+			$groups[] = '<a href="' . get_term_link($term) . '">' . $term->name . '</a>';
36 36
 		}
37 37
 
38
-		$groups = join( ', ', $groups );
38
+		$groups = join(', ', $groups);
39 39
 	}
40 40
 
41 41
 	// Connections
@@ -44,22 +44,22 @@  discard block
 block discarded – undo
44 44
 
45 45
 	// Connection Projects
46 46
 
47
-	if ( $terms && ! is_wp_error( $terms ) ) {
47
+	if ($terms && ! is_wp_error($terms)) {
48 48
 		$groups_ = array();
49 49
 
50
-		foreach ( $terms as $term ) {
50
+		foreach ($terms as $term) {
51 51
 			$groups_[] = $term->term_id;
52 52
 		}
53 53
 
54
-		if ( count( $groups_ ) > 0 ) {
54
+		if (count($groups_) > 0) {
55 55
 			$connection_project['post_type'] = 'project';
56
-			$connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' );
56
+			$connection_project['title'] = esc_html__('Related Projects', 'lsx-projects');
57 57
 			//$connection_project['posts'] = get_post_meta( get_the_ID(), 'project_to_project', false );
58 58
 			$connection_project['posts'] = array();
59 59
 
60 60
 			$args = array(
61 61
 				'post_type'              => 'project',
62
-				'post__not_in'           => array( get_the_ID() ),
62
+				'post__not_in'           => array(get_the_ID()),
63 63
 				'no_found_rows'          => true,
64 64
 				'ignore_sticky_posts'    => 1,
65 65
 				'update_post_meta_cache' => false,
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
 				),
72 72
 			);
73 73
 
74
-			$projects_ = new \WP_Query( $args );
74
+			$projects_ = new \WP_Query($args);
75 75
 
76
-			if ( $projects_->have_posts() ) {
77
-				while ( $projects_->have_posts() ) {
76
+			if ($projects_->have_posts()) {
77
+				while ($projects_->have_posts()) {
78 78
 					$projects_->the_post();
79 79
 					$connection_project['posts'][] = get_the_ID();
80 80
 					wp_reset_postdata();
81 81
 				}
82 82
 			}
83 83
 
84
-			if ( ! empty( $connection_project['posts'] ) ) {
85
-				$post_ids = join( ',', $connection_project['posts'] );
84
+			if ( ! empty($connection_project['posts'])) {
85
+				$post_ids = join(',', $connection_project['posts']);
86 86
 				$connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
87 87
 				$connections[] = $connection_project;
88 88
 			}
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 
92 92
 	// Connection Products
93 93
 
94
-	if ( class_exists( 'WooCommerce' ) ) {
94
+	if (class_exists('WooCommerce')) {
95 95
 		$connection_product['post_type'] = 'product';
96
-		$connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>';
97
-		$connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false );
96
+		$connection_product['title'] = esc_html__('Related Products', 'lsx-projects') . ' <small>' . esc_html__('Products used to build this project', 'lsx-projects') . '</small>';
97
+		$connection_product['posts'] = get_post_meta(get_the_ID(), 'product_to_project', false);
98 98
 
99
-		if ( ! empty( $connection_product['posts'] ) ) {
99
+		if ( ! empty($connection_product['posts'])) {
100 100
 			$connection_product['small_list_html'] = '';
101 101
 
102 102
 			$args = array(
@@ -109,19 +109,19 @@  discard block
 block discarded – undo
109 109
 				'update_post_meta_cache' => false,
110 110
 			);
111 111
 
112
-			$connection_product['posts_obj'] = new \WP_Query( $args );
112
+			$connection_product['posts_obj'] = new \WP_Query($args);
113 113
 
114
-			if ( $connection_product['posts_obj']->have_posts() ) {
114
+			if ($connection_product['posts_obj']->have_posts()) {
115 115
 				$connection_product['small_list_html'] = array();
116 116
 
117
-				while ( $connection_product['posts_obj']->have_posts() ) {
117
+				while ($connection_product['posts_obj']->have_posts()) {
118 118
 					$connection_product['posts_obj']->the_post();
119
-					$connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
119
+					$connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title('', '', false) . '</a>';
120 120
 					wp_reset_postdata();
121 121
 				}
122 122
 
123 123
 				$connection_product['posts_obj']->rewind_posts();
124
-				$connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] );
124
+				$connection_product['small_list_html'] = join(', ', $connection_product['small_list_html']);
125 125
 			}
126 126
 
127 127
 			$connections[] = $connection_product;
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 
133 133
 	$connection_service['post_type'] = 'page';
134 134
 	// $connection_service['title'] = esc_html__( 'Services', 'lsx-projects' );
135
-	$connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false );
135
+	$connection_service['pages'] = get_post_meta(get_the_ID(), 'page_to_project', false);
136 136
 
137
-	if ( ! empty( $connection_service['pages'] ) ) {
138
-		$post_ids = join( ',', $connection_service['pages'] );
137
+	if ( ! empty($connection_service['pages'])) {
138
+		$post_ids = join(',', $connection_service['pages']);
139 139
 		//$connection_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
140 140
 		$connection_service['small_list_html'] = '';
141 141
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 			'update_post_meta_cache' => false,
150 150
 		);
151 151
 
152
-		$services_ = new \WP_Query( $args );
152
+		$services_ = new \WP_Query($args);
153 153
 
154
-		if ( $services_->have_posts() ) {
154
+		if ($services_->have_posts()) {
155 155
 			$connection_service['small_list_html'] = array();
156 156
 
157
-			while ( $services_->have_posts() ) {
157
+			while ($services_->have_posts()) {
158 158
 				$services_->the_post();
159
-				$connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
159
+				$connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title('', '', false) . '</a>';
160 160
 				wp_reset_postdata();
161 161
 			}
162 162
 
163
-			$connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] );
163
+			$connection_service['small_list_html'] = join(', ', $connection_service['small_list_html']);
164 164
 		}
165 165
 
166 166
 		$connections[] = $connection_service;
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 
171 171
 	$connection_testimonial['post_type'] = 'testimonial';
172 172
 	// $connection_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-projects' );
173
-	$connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false );
173
+	$connection_testimonial['posts'] = get_post_meta(get_the_ID(), 'testimonial_to_project', false);
174 174
 
175
-	if ( ! empty( $connection_testimonial['posts'] ) ) {
176
-		$post_ids = join( ',', $connection_testimonial['posts'][0] );
175
+	if ( ! empty($connection_testimonial['posts'])) {
176
+		$post_ids = join(',', $connection_testimonial['posts'][0]);
177 177
 		$connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]';
178 178
 		$connections[] = $connection_testimonial;
179 179
 	}
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 
183 183
 	$connection_team['post_type'] = 'team';
184 184
 	// $connection_team['title'] = esc_html__( 'Team', 'lsx-projects' );
185
-	$connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false );
185
+	$connection_team['posts'] = get_post_meta(get_the_ID(), 'team_to_project', false);
186 186
 
187
-	if ( ! empty( $connection_team['posts'] ) ) {
188
-		$post_ids = join( ',', $connection_team['posts'][0] );
187
+	if ( ! empty($connection_team['posts'])) {
188
+		$post_ids = join(',', $connection_team['posts'][0]);
189 189
 		$connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]';
190 190
 		$connection_team['small_list_html'] = '';
191 191
 
@@ -199,19 +199,19 @@  discard block
 block discarded – undo
199 199
 			'update_post_meta_cache' => false,
200 200
 		);
201 201
 
202
-		$team_ = new \WP_Query( $args );
202
+		$team_ = new \WP_Query($args);
203 203
 
204
-		if ( $team_->have_posts() ) {
204
+		if ($team_->have_posts()) {
205 205
 			global $lsx_team;
206 206
 			$connection_team['small_list_html'] = array();
207 207
 
208
-			while ( $team_->have_posts() ) {
208
+			while ($team_->have_posts()) {
209 209
 				$team_->the_post();
210
-				$connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>';
210
+				$connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail(get_the_ID(), 'lsx-team-archive') . '</a>';
211 211
 				wp_reset_postdata();
212 212
 			}
213 213
 
214
-			$connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] );
214
+			$connection_team['small_list_html'] = join(' ', $connection_team['small_list_html']);
215 215
 		}
216 216
 
217 217
 		$connections[] = $connection_team;
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
 		<div class="col-xs-12 col-sm-7 col-md-8">
229 229
 			<div class="entry-content"><?php the_content(); ?></div>
230 230
 
231
-			<?php if ( count( $connections ) > 0 ) : ?>
232
-				<?php foreach ( $connections as $i => $connection ) : ?>
231
+			<?php if (count($connections) > 0) : ?>
232
+				<?php foreach ($connections as $i => $connection) : ?>
233 233
 					<?php
234
-						if ( 'testimonial' === $connection['post_type'] ) {
234
+						if ('testimonial' === $connection['post_type']) {
235 235
 							echo '<div class="tab-pane-fake">';
236
-							echo do_shortcode( $connection['shortcode'] );
236
+							echo do_shortcode($connection['shortcode']);
237 237
 							echo '</div>';
238 238
 						}
239 239
 					?>
@@ -244,83 +244,83 @@  discard block
 block discarded – undo
244 244
 		<div class="col-xs-12 col-sm-5 col-md-4">
245 245
 			<div class="entry-fixed-sidebar-wrapper">
246 246
 				<div class="entry-fixed-sidebar">
247
-					<?php if ( ! empty( $client_logo ) ) : ?>
248
-						<div class="entry-meta-single"><?php echo wp_kses_post( $client_logo ); ?></div>
249
-					<?php elseif ( ! empty( $client ) ) : ?>
250
-						<div class="entry-meta-single"><?php echo esc_html( $client ); ?></div>
247
+					<?php if ( ! empty($client_logo)) : ?>
248
+						<div class="entry-meta-single"><?php echo wp_kses_post($client_logo); ?></div>
249
+					<?php elseif ( ! empty($client)) : ?>
250
+						<div class="entry-meta-single"><?php echo esc_html($client); ?></div>
251 251
 					<?php endif; ?>
252 252
 
253
-					<?php if ( ! empty( $groups ) ) : ?>
254
-						<div class="entry-meta-key"><?php esc_html_e( 'Industry:', 'lsx-projects' ); ?></div>
255
-						<div class="entry-meta-value"><?php echo wp_kses_post( $groups ); ?></div>
253
+					<?php if ( ! empty($groups)) : ?>
254
+						<div class="entry-meta-key"><?php esc_html_e('Industry:', 'lsx-projects'); ?></div>
255
+						<div class="entry-meta-value"><?php echo wp_kses_post($groups); ?></div>
256 256
 					<?php endif; ?>
257 257
 
258
-					<?php if ( ! empty( $connection_service['small_list_html'] ) ) : ?>
259
-						<div class="entry-meta-key"><?php esc_html_e( 'Services:', 'lsx-projects' ); ?></div>
260
-						<div class="entry-meta-value"><?php echo wp_kses_post( $connection_service['small_list_html'] ); ?></div>
258
+					<?php if ( ! empty($connection_service['small_list_html'])) : ?>
259
+						<div class="entry-meta-key"><?php esc_html_e('Services:', 'lsx-projects'); ?></div>
260
+						<div class="entry-meta-value"><?php echo wp_kses_post($connection_service['small_list_html']); ?></div>
261 261
 					<?php endif; ?>
262 262
 
263
-					<?php if ( ! empty( $connection_product['small_list_html'] ) ) : ?>
263
+					<?php if ( ! empty($connection_product['small_list_html'])) : ?>
264 264
 						<!--
265
-						<div class="entry-meta-key"><?php esc_html_e( 'Products used:', 'lsx-projects' ); ?></div>
266
-						<div class="entry-meta-value"><?php echo wp_kses_post( $connection_product['small_list_html'] ); ?></div>
265
+						<div class="entry-meta-key"><?php esc_html_e('Products used:', 'lsx-projects'); ?></div>
266
+						<div class="entry-meta-value"><?php echo wp_kses_post($connection_product['small_list_html']); ?></div>
267 267
 						-->
268 268
 					<?php endif; ?>
269 269
 
270
-					<?php if ( ! empty( $connection_team['small_list_html'] ) ) : ?>
271
-						<div class="entry-meta-key"><?php esc_html_e( 'Team members involved:', 'lsx-projects' ); ?></div>
272
-						<div class="entry-meta-value entry-meta-value-team"><?php echo wp_kses_post( $connection_team['small_list_html'] ); ?></div>
270
+					<?php if ( ! empty($connection_team['small_list_html'])) : ?>
271
+						<div class="entry-meta-key"><?php esc_html_e('Team members involved:', 'lsx-projects'); ?></div>
272
+						<div class="entry-meta-value entry-meta-value-team"><?php echo wp_kses_post($connection_team['small_list_html']); ?></div>
273 273
 					<?php endif; ?>
274 274
 
275
-					<?php if ( ! empty( $url ) ) : ?>
276
-						<div class="entry-meta-single"><a href="<?php echo esc_url( $url ); ?>" target="_blank" rel="nofollow" class="btn btn-block secondary-btn"><?php esc_html_e( 'See website', 'lsx-projects' ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
275
+					<?php if ( ! empty($url)) : ?>
276
+						<div class="entry-meta-single"><a href="<?php echo esc_url($url); ?>" target="_blank" rel="nofollow" class="btn btn-block secondary-btn"><?php esc_html_e('See website', 'lsx-projects'); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
277 277
 					<?php endif; ?>
278 278
 
279
-					<?php if ( ! empty( $button_label ) ) : ?>
280
-						<div class="entry-meta-single"><a href="#lsx-project-contact" data-toggle="modal" class="btn btn-block cta-btn"><?php echo esc_html( $button_label ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
279
+					<?php if ( ! empty($button_label)) : ?>
280
+						<div class="entry-meta-single"><a href="#lsx-project-contact" data-toggle="modal" class="btn btn-block cta-btn"><?php echo esc_html($button_label); ?> <i class="fa fa-angle-right" aria-hidden="true"></i></a></div>
281 281
 					<?php endif; ?>
282 282
 				</div>
283 283
 			</div>
284 284
 		</div>
285 285
 	</div>
286 286
 
287
-	<?php if ( count( $connections ) > 0 ) : ?>
288
-		<?php foreach ( $connections as $i => $connection ) : ?>
287
+	<?php if (count($connections) > 0) : ?>
288
+		<?php foreach ($connections as $i => $connection) : ?>
289 289
 			<?php
290 290
 				// Team is now visible on detail box
291 291
 				// Services is now visible on detail box
292 292
 				// Testimonials is now visible below the content
293
-				if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) {
293
+				if (in_array($connection['post_type'], array('team', 'testimonial', 'service'))) {
294 294
 					continue;
295 295
 				}
296 296
 			?>
297
-			<?php if ( 'page' !== $connection['post_type'] ) { ?>
297
+			<?php if ('page' !== $connection['post_type']) { ?>
298 298
 				<div class="lsx-projects-section lsx-full-width">
299 299
 					<div class="row">
300 300
 						<div class="col-xs-12">
301
-							<h3 class="lsx-title"><?php echo wp_kses_post( $connection['title'] ); ?></h3>
301
+							<h3 class="lsx-title"><?php echo wp_kses_post($connection['title']); ?></h3>
302 302
 
303 303
 							<?php
304
-								if ( 'product' === $connection['post_type'] ) {
304
+								if ('product' === $connection['post_type']) {
305 305
 
306
-									if ( $connection_product['posts_obj']->have_posts() ) {
306
+									if ($connection_product['posts_obj']->have_posts()) {
307 307
 										// @codingStandardsIgnoreLine
308
-										echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
308
+										echo apply_filters('woocommerce_before_widget_product_list', '<ul class="product_list_widget">');
309 309
 
310
-										while ( $connection_product['posts_obj']->have_posts() ) {
310
+										while ($connection_product['posts_obj']->have_posts()) {
311 311
 											$connection_product['posts_obj']->the_post();
312
-											wc_get_template( 'content-widget-product.php', array(
312
+											wc_get_template('content-widget-product.php', array(
313 313
 												'show_rating' => false,
314
-											) );
314
+											));
315 315
 
316 316
 											wp_reset_postdata();
317 317
 										}
318 318
 
319 319
 										// @codingStandardsIgnoreLine
320
-										echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
320
+										echo apply_filters('woocommerce_after_widget_product_list', '</ul>');
321 321
 									}
322 322
 								} else {
323
-									echo do_shortcode( $connection['shortcode'] );
323
+									echo do_shortcode($connection['shortcode']);
324 324
 								}
325 325
 							?>
326 326
 						</div>
@@ -335,17 +335,17 @@  discard block
 block discarded – undo
335 335
 	<?php
336 336
 	// Connection Alt Produtcs
337 337
 
338
-	$connection_alt_product['posts'] = get_post_meta( get_the_ID(), 'lsx_project__alt_products', false );
338
+	$connection_alt_product['posts'] = get_post_meta(get_the_ID(), 'lsx_project__alt_products', false);
339 339
 
340
-	if ( ! empty( $connection_alt_product['posts'] ) ) {
340
+	if ( ! empty($connection_alt_product['posts'])) {
341 341
 		?>
342 342
 		<div class="lsx-projects-section lsx-full-width">
343 343
 			<div class="row">
344 344
 				<div class="col-xs-12">
345
-					<h3 class="lsx-title"><?php echo esc_html__( 'Related Products', 'lsx-projects' ); ?></h3>
345
+					<h3 class="lsx-title"><?php echo esc_html__('Related Products', 'lsx-projects'); ?></h3>
346 346
 					<div id="lsx-alt-products-slider" class="lsx-alt-products lsx-projects-shortcode slick-slider" data-slick="{'slidesToShow': 3, 'slidesToScroll': 3 }">
347 347
 					<?php
348
-					foreach ( $connection_alt_product['posts'][0] as $alt_post ) {
348
+					foreach ($connection_alt_product['posts'][0] as $alt_post) {
349 349
 						$alt_post_name    = $alt_post['lsx_project_alt_product_title'];
350 350
 						$alt_post_link    = $alt_post['lsx_project_alt_product_link'];
351 351
 						$alt_post_img_id  = $alt_post['lsx_project_alt_product_image_id'];
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 						<div class="lsx-projects-slot">
356 356
 							<a href="<?php echo $alt_post_link; ?>">
357 357
 								<figure class="lsx-projects-avatar">
358
-									<img src="<?php echo esc_url( $alt_post_img_url ); ?>" alt="<?php echo esc_html( $alt_post_name ); ?>">
358
+									<img src="<?php echo esc_url($alt_post_img_url); ?>" alt="<?php echo esc_html($alt_post_name); ?>">
359 359
 								</figure>
360 360
 							</a>
361 361
 							<h5 class="lsx-projects-title">
362
-								<a href="<?php echo esc_url( $alt_post_link ); ?>">
363
-									<?php echo esc_html( $alt_post_name ); ?>
362
+								<a href="<?php echo esc_url($alt_post_link); ?>">
363
+									<?php echo esc_html($alt_post_name); ?>
364 364
 								</a>
365 365
 							</h5>
366 366
 							<div class="lsx-projects-content">
367
-								<a class="moretag" href="<?php echo esc_url( $alt_post_link ); ?>">
368
-									<?php echo esc_html__( 'View more', 'lsx-projects' ); ?>
367
+								<a class="moretag" href="<?php echo esc_url($alt_post_link); ?>">
368
+									<?php echo esc_html__('View more', 'lsx-projects'); ?>
369 369
 								</a>
370 370
 							</div>
371 371
 						</div>
Please login to merge, or discard this patch.
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -5,217 +5,217 @@  discard block
 block discarded – undo
5 5
 ?>
6 6
 
7 7
 <?php
8
-	$client = get_post_meta( get_the_ID(), 'lsx_project_client', true );
9
-	$client_logo = get_post_meta( get_the_ID(), 'lsx_project_client_logo', true );
10
-	$url = get_post_meta( get_the_ID(), 'lsx_project_url', true );
11
-
12
-	global $lsx_projects;
13
-
14
-	$button_label = '';
15
-	$button_cf_id = '';
16
-
17
-	if ( ! empty( projects_get_option( 'projects_modal_enable' ) ) ) {
18
-		if ( ! empty( projects_get_option( 'projects_modal_cta_label' ) ) && ! empty( projects_get_option( 'projects_modal_form_id' ) ) ) {
19
-			$button_label = projects_get_option( 'projects_modal_cta_label' );
20
-			$button_cf_id = projects_get_option( 'projects_modal_form_id' );
21
-		}
22
-	}
23
-
24
-	if ( ! empty( $client_logo ) ) {
25
-		$client_logo = '<img src="' . $client_logo . '">';
26
-	}
27
-
28
-	$groups = '';
29
-	$terms = get_the_terms( get_the_ID(), 'project-group' );
30
-
31
-	if ( $terms && ! is_wp_error( $terms ) ) {
32
-		$groups = array();
33
-
34
-		foreach ( $terms as $term ) {
35
-			$groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
36
-		}
37
-
38
-		$groups = join( ', ', $groups );
39
-	}
40
-
41
-	// Connections
42
-
43
-	$connections = array();
44
-
45
-	// Connection Projects
46
-
47
-	if ( $terms && ! is_wp_error( $terms ) ) {
48
-		$groups_ = array();
49
-
50
-		foreach ( $terms as $term ) {
51
-			$groups_[] = $term->term_id;
52
-		}
53
-
54
-		if ( count( $groups_ ) > 0 ) {
55
-			$connection_project['post_type'] = 'project';
56
-			$connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' );
57
-			//$connection_project['posts'] = get_post_meta( get_the_ID(), 'project_to_project', false );
58
-			$connection_project['posts'] = array();
59
-
60
-			$args = array(
61
-				'post_type'              => 'project',
62
-				'post__not_in'           => array( get_the_ID() ),
63
-				'no_found_rows'          => true,
64
-				'ignore_sticky_posts'    => 1,
65
-				'update_post_meta_cache' => false,
66
-				'tax_query' => array(
67
-					array(
68
-						'taxonomy' => 'project-group',
69
-						'terms'    => $groups_,
70
-					),
71
-				),
72
-			);
73
-
74
-			$projects_ = new \WP_Query( $args );
75
-
76
-			if ( $projects_->have_posts() ) {
77
-				while ( $projects_->have_posts() ) {
78
-					$projects_->the_post();
79
-					$connection_project['posts'][] = get_the_ID();
80
-					wp_reset_postdata();
81
-				}
82
-			}
83
-
84
-			if ( ! empty( $connection_project['posts'] ) ) {
85
-				$post_ids = join( ',', $connection_project['posts'] );
86
-				$connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
87
-				$connections[] = $connection_project;
88
-			}
89
-		}
90
-	}
91
-
92
-	// Connection Products
93
-
94
-	if ( class_exists( 'WooCommerce' ) ) {
95
-		$connection_product['post_type'] = 'product';
96
-		$connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>';
97
-		$connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false );
98
-
99
-		if ( ! empty( $connection_product['posts'] ) ) {
100
-			$connection_product['small_list_html'] = '';
101
-
102
-			$args = array(
103
-				'post_type'              => 'product',
104
-				'post__in'               => $connection_product['posts'][0],
105
-				'orderby'                => 'post__in',
106
-				'no_found_rows'          => true,
107
-				'ignore_sticky_posts'    => 1,
108
-				'update_post_term_cache' => false,
109
-				'update_post_meta_cache' => false,
110
-			);
111
-
112
-			$connection_product['posts_obj'] = new \WP_Query( $args );
113
-
114
-			if ( $connection_product['posts_obj']->have_posts() ) {
115
-				$connection_product['small_list_html'] = array();
116
-
117
-				while ( $connection_product['posts_obj']->have_posts() ) {
118
-					$connection_product['posts_obj']->the_post();
119
-					$connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
120
-					wp_reset_postdata();
121
-				}
122
-
123
-				$connection_product['posts_obj']->rewind_posts();
124
-				$connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] );
125
-			}
126
-
127
-			$connections[] = $connection_product;
128
-		}
129
-	}
130
-
131
-	// Connection Services
132
-
133
-	$connection_service['post_type'] = 'page';
134
-	// $connection_service['title'] = esc_html__( 'Services', 'lsx-projects' );
135
-	$connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false );
136
-
137
-	if ( ! empty( $connection_service['pages'] ) ) {
138
-		$post_ids = join( ',', $connection_service['pages'] );
139
-		//$connection_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
140
-		$connection_service['small_list_html'] = '';
141
-
142
-		$args = array(
143
-			'post_type'              => 'page',
144
-			'post__in'               => $connection_service['pages'],
145
-			'orderby'                => 'post__in',
146
-			'no_found_rows'          => true,
147
-			'ignore_sticky_posts'    => 1,
148
-			'update_post_term_cache' => false,
149
-			'update_post_meta_cache' => false,
150
-		);
151
-
152
-		$services_ = new \WP_Query( $args );
153
-
154
-		if ( $services_->have_posts() ) {
155
-			$connection_service['small_list_html'] = array();
156
-
157
-			while ( $services_->have_posts() ) {
158
-				$services_->the_post();
159
-				$connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
160
-				wp_reset_postdata();
161
-			}
162
-
163
-			$connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] );
164
-		}
165
-
166
-		$connections[] = $connection_service;
167
-	}
168
-
169
-	// Connection Testimonials
170
-
171
-	$connection_testimonial['post_type'] = 'testimonial';
172
-	// $connection_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-projects' );
173
-	$connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false );
174
-
175
-	if ( ! empty( $connection_testimonial['posts'] ) ) {
176
-		$post_ids = join( ',', $connection_testimonial['posts'][0] );
177
-		$connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]';
178
-		$connections[] = $connection_testimonial;
179
-	}
180
-
181
-	// Connection Team
182
-
183
-	$connection_team['post_type'] = 'team';
184
-	// $connection_team['title'] = esc_html__( 'Team', 'lsx-projects' );
185
-	$connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false );
186
-
187
-	if ( ! empty( $connection_team['posts'] ) ) {
188
-		$post_ids = join( ',', $connection_team['posts'][0] );
189
-		$connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]';
190
-		$connection_team['small_list_html'] = '';
191
-
192
-		$args = array(
193
-			'post_type'              => 'team',
194
-			'post__in'               => $connection_team['posts'][0],
195
-			'orderby'                => 'post__in',
196
-			'no_found_rows'          => true,
197
-			'ignore_sticky_posts'    => 1,
198
-			'update_post_term_cache' => false,
199
-			'update_post_meta_cache' => false,
200
-		);
201
-
202
-		$team_ = new \WP_Query( $args );
203
-
204
-		if ( $team_->have_posts() ) {
205
-			global $lsx_team;
206
-			$connection_team['small_list_html'] = array();
207
-
208
-			while ( $team_->have_posts() ) {
209
-				$team_->the_post();
210
-				$connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>';
211
-				wp_reset_postdata();
212
-			}
213
-
214
-			$connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] );
215
-		}
216
-
217
-		$connections[] = $connection_team;
218
-	}
8
+     $client = get_post_meta( get_the_ID(), 'lsx_project_client', true );
9
+     $client_logo = get_post_meta( get_the_ID(), 'lsx_project_client_logo', true );
10
+     $url = get_post_meta( get_the_ID(), 'lsx_project_url', true );
11
+
12
+     global $lsx_projects;
13
+
14
+     $button_label = '';
15
+     $button_cf_id = '';
16
+
17
+     if ( ! empty( projects_get_option( 'projects_modal_enable' ) ) ) {
18
+          if ( ! empty( projects_get_option( 'projects_modal_cta_label' ) ) && ! empty( projects_get_option( 'projects_modal_form_id' ) ) ) {
19
+               $button_label = projects_get_option( 'projects_modal_cta_label' );
20
+               $button_cf_id = projects_get_option( 'projects_modal_form_id' );
21
+          }
22
+     }
23
+
24
+     if ( ! empty( $client_logo ) ) {
25
+          $client_logo = '<img src="' . $client_logo . '">';
26
+     }
27
+
28
+     $groups = '';
29
+     $terms = get_the_terms( get_the_ID(), 'project-group' );
30
+
31
+     if ( $terms && ! is_wp_error( $terms ) ) {
32
+          $groups = array();
33
+
34
+          foreach ( $terms as $term ) {
35
+               $groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>';
36
+          }
37
+
38
+          $groups = join( ', ', $groups );
39
+     }
40
+
41
+     // Connections
42
+
43
+     $connections = array();
44
+
45
+     // Connection Projects
46
+
47
+     if ( $terms && ! is_wp_error( $terms ) ) {
48
+          $groups_ = array();
49
+
50
+          foreach ( $terms as $term ) {
51
+               $groups_[] = $term->term_id;
52
+          }
53
+
54
+          if ( count( $groups_ ) > 0 ) {
55
+               $connection_project['post_type'] = 'project';
56
+               $connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' );
57
+               //$connection_project['posts'] = get_post_meta( get_the_ID(), 'project_to_project', false );
58
+               $connection_project['posts'] = array();
59
+
60
+               $args = array(
61
+                    'post_type'              => 'project',
62
+                    'post__not_in'           => array( get_the_ID() ),
63
+                    'no_found_rows'          => true,
64
+                    'ignore_sticky_posts'    => 1,
65
+                    'update_post_meta_cache' => false,
66
+                    'tax_query' => array(
67
+                         array(
68
+                              'taxonomy' => 'project-group',
69
+                              'terms'    => $groups_,
70
+                         ),
71
+                    ),
72
+               );
73
+
74
+               $projects_ = new \WP_Query( $args );
75
+
76
+               if ( $projects_->have_posts() ) {
77
+                    while ( $projects_->have_posts() ) {
78
+                         $projects_->the_post();
79
+                         $connection_project['posts'][] = get_the_ID();
80
+                         wp_reset_postdata();
81
+                    }
82
+               }
83
+
84
+               if ( ! empty( $connection_project['posts'] ) ) {
85
+                    $post_ids = join( ',', $connection_project['posts'] );
86
+                    $connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]';
87
+                    $connections[] = $connection_project;
88
+               }
89
+          }
90
+     }
91
+
92
+     // Connection Products
93
+
94
+     if ( class_exists( 'WooCommerce' ) ) {
95
+          $connection_product['post_type'] = 'product';
96
+          $connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>';
97
+          $connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false );
98
+
99
+          if ( ! empty( $connection_product['posts'] ) ) {
100
+               $connection_product['small_list_html'] = '';
101
+
102
+               $args = array(
103
+                    'post_type'              => 'product',
104
+                    'post__in'               => $connection_product['posts'][0],
105
+                    'orderby'                => 'post__in',
106
+                    'no_found_rows'          => true,
107
+                    'ignore_sticky_posts'    => 1,
108
+                    'update_post_term_cache' => false,
109
+                    'update_post_meta_cache' => false,
110
+               );
111
+
112
+               $connection_product['posts_obj'] = new \WP_Query( $args );
113
+
114
+               if ( $connection_product['posts_obj']->have_posts() ) {
115
+                    $connection_product['small_list_html'] = array();
116
+
117
+                    while ( $connection_product['posts_obj']->have_posts() ) {
118
+                         $connection_product['posts_obj']->the_post();
119
+                         $connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
120
+                         wp_reset_postdata();
121
+                    }
122
+
123
+                    $connection_product['posts_obj']->rewind_posts();
124
+                    $connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] );
125
+               }
126
+
127
+               $connections[] = $connection_product;
128
+          }
129
+     }
130
+
131
+     // Connection Services
132
+
133
+     $connection_service['post_type'] = 'page';
134
+     // $connection_service['title'] = esc_html__( 'Services', 'lsx-projects' );
135
+     $connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false );
136
+
137
+     if ( ! empty( $connection_service['pages'] ) ) {
138
+          $post_ids = join( ',', $connection_service['pages'] );
139
+          //$connection_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]';
140
+          $connection_service['small_list_html'] = '';
141
+
142
+          $args = array(
143
+               'post_type'              => 'page',
144
+               'post__in'               => $connection_service['pages'],
145
+               'orderby'                => 'post__in',
146
+               'no_found_rows'          => true,
147
+               'ignore_sticky_posts'    => 1,
148
+               'update_post_term_cache' => false,
149
+               'update_post_meta_cache' => false,
150
+          );
151
+
152
+          $services_ = new \WP_Query( $args );
153
+
154
+          if ( $services_->have_posts() ) {
155
+               $connection_service['small_list_html'] = array();
156
+
157
+               while ( $services_->have_posts() ) {
158
+                    $services_->the_post();
159
+                    $connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>';
160
+                    wp_reset_postdata();
161
+               }
162
+
163
+               $connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] );
164
+          }
165
+
166
+          $connections[] = $connection_service;
167
+     }
168
+
169
+     // Connection Testimonials
170
+
171
+     $connection_testimonial['post_type'] = 'testimonial';
172
+     // $connection_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-projects' );
173
+     $connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false );
174
+
175
+     if ( ! empty( $connection_testimonial['posts'] ) ) {
176
+          $post_ids = join( ',', $connection_testimonial['posts'][0] );
177
+          $connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]';
178
+          $connections[] = $connection_testimonial;
179
+     }
180
+
181
+     // Connection Team
182
+
183
+     $connection_team['post_type'] = 'team';
184
+     // $connection_team['title'] = esc_html__( 'Team', 'lsx-projects' );
185
+     $connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false );
186
+
187
+     if ( ! empty( $connection_team['posts'] ) ) {
188
+          $post_ids = join( ',', $connection_team['posts'][0] );
189
+          $connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]';
190
+          $connection_team['small_list_html'] = '';
191
+
192
+          $args = array(
193
+               'post_type'              => 'team',
194
+               'post__in'               => $connection_team['posts'][0],
195
+               'orderby'                => 'post__in',
196
+               'no_found_rows'          => true,
197
+               'ignore_sticky_posts'    => 1,
198
+               'update_post_term_cache' => false,
199
+               'update_post_meta_cache' => false,
200
+          );
201
+
202
+          $team_ = new \WP_Query( $args );
203
+
204
+          if ( $team_->have_posts() ) {
205
+               global $lsx_team;
206
+               $connection_team['small_list_html'] = array();
207
+
208
+               while ( $team_->have_posts() ) {
209
+                    $team_->the_post();
210
+                    $connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>';
211
+                    wp_reset_postdata();
212
+               }
213
+
214
+               $connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] );
215
+          }
216
+
217
+          $connections[] = $connection_team;
218
+     }
219 219
 ?>
220 220
 
221 221
 <?php lsx_entry_before(); ?>
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 			<?php if ( count( $connections ) > 0 ) : ?>
232 232
 				<?php foreach ( $connections as $i => $connection ) : ?>
233 233
 					<?php
234
-						if ( 'testimonial' === $connection['post_type'] ) {
235
-							echo '<div class="tab-pane-fake">';
236
-							echo do_shortcode( $connection['shortcode'] );
237
-							echo '</div>';
238
-						}
239
-					?>
234
+                              if ( 'testimonial' === $connection['post_type'] ) {
235
+                                   echo '<div class="tab-pane-fake">';
236
+                                   echo do_shortcode( $connection['shortcode'] );
237
+                                   echo '</div>';
238
+                              }
239
+                         ?>
240 240
 				<?php endforeach; ?>
241 241
 			<?php endif; ?>
242 242
 		</div>
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
 	<?php if ( count( $connections ) > 0 ) : ?>
288 288
 		<?php foreach ( $connections as $i => $connection ) : ?>
289 289
 			<?php
290
-				// Team is now visible on detail box
291
-				// Services is now visible on detail box
292
-				// Testimonials is now visible below the content
293
-				if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) {
294
-					continue;
295
-				}
296
-			?>
290
+                    // Team is now visible on detail box
291
+                    // Services is now visible on detail box
292
+                    // Testimonials is now visible below the content
293
+                    if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) {
294
+                         continue;
295
+                    }
296
+               ?>
297 297
 			<?php if ( 'page' !== $connection['post_type'] ) { ?>
298 298
 				<div class="lsx-projects-section lsx-full-width">
299 299
 					<div class="row">
@@ -301,57 +301,57 @@  discard block
 block discarded – undo
301 301
 							<h3 class="lsx-title"><?php echo wp_kses_post( $connection['title'] ); ?></h3>
302 302
 
303 303
 							<?php
304
-								if ( 'product' === $connection['post_type'] ) {
305
-
306
-									if ( $connection_product['posts_obj']->have_posts() ) {
307
-										// @codingStandardsIgnoreLine
308
-										echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
309
-
310
-										while ( $connection_product['posts_obj']->have_posts() ) {
311
-											$connection_product['posts_obj']->the_post();
312
-											wc_get_template( 'content-widget-product.php', array(
313
-												'show_rating' => false,
314
-											) );
315
-
316
-											wp_reset_postdata();
317
-										}
318
-
319
-										// @codingStandardsIgnoreLine
320
-										echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
321
-									}
322
-								} else {
323
-									echo do_shortcode( $connection['shortcode'] );
324
-								}
325
-							?>
304
+                                        if ( 'product' === $connection['post_type'] ) {
305
+
306
+                                             if ( $connection_product['posts_obj']->have_posts() ) {
307
+                                                  // @codingStandardsIgnoreLine
308
+                                                  echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
309
+
310
+                                                  while ( $connection_product['posts_obj']->have_posts() ) {
311
+                                                       $connection_product['posts_obj']->the_post();
312
+                                                       wc_get_template( 'content-widget-product.php', array(
313
+                                                            'show_rating' => false,
314
+                                                       ) );
315
+
316
+                                                       wp_reset_postdata();
317
+                                                  }
318
+
319
+                                                  // @codingStandardsIgnoreLine
320
+                                                  echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
321
+                                             }
322
+                                        } else {
323
+                                             echo do_shortcode( $connection['shortcode'] );
324
+                                        }
325
+                                   ?>
326 326
 						</div>
327 327
 					</div>
328 328
 				</div>
329 329
 			<?php
330
-			}
331
-		?>
330
+               }
331
+          ?>
332 332
 		<?php endforeach; ?>
333 333
 	<?php endif; ?>
334 334
 
335 335
 	<?php
336
-	// Connection Alt Produtcs
336
+     // Connection Alt Produtcs
337 337
 
338
-	$connection_alt_product['posts'] = get_post_meta( get_the_ID(), 'lsx_project__alt_products', false );
338
+     $connection_alt_product['posts'] = get_post_meta( get_the_ID(), 'lsx_project__alt_products', false );
339 339
 
340
-	if ( ! empty( $connection_alt_product['posts'] ) ) {
341
-		?>
340
+     if ( ! empty( $connection_alt_product['posts'] ) ) {
341
+          ?>
342 342
 		<div class="lsx-projects-section lsx-full-width">
343 343
 			<div class="row">
344 344
 				<div class="col-xs-12">
345 345
 					<h3 class="lsx-title"><?php echo esc_html__( 'Related Products', 'lsx-projects' ); ?></h3>
346 346
 					<div id="lsx-alt-products-slider" class="lsx-alt-products lsx-projects-shortcode slick-slider" data-slick="{'slidesToShow': 3, 'slidesToScroll': 3 }">
347 347
 					<?php
348
-					foreach ( $connection_alt_product['posts'][0] as $alt_post ) {
349
-						$alt_post_name    = $alt_post['lsx_project_alt_product_title'];
350
-						$alt_post_link    = $alt_post['lsx_project_alt_product_link'];
351
-						$alt_post_img_id  = $alt_post['lsx_project_alt_product_image_id'];
352
-						$alt_post_img_url = $alt_post['lsx_project_alt_product_image'];
348
+                         foreach ( $connection_alt_product['posts'][0] as $alt_post ) {
349
+                              $alt_post_name    = $alt_post['lsx_project_alt_product_title'];
350
+                              $alt_post_link    = $alt_post['lsx_project_alt_product_link'];
351
+                              $alt_post_img_id  = $alt_post['lsx_project_alt_product_image_id'];
352
+                              $alt_post_img_url = $alt_post['lsx_project_alt_product_image'];
353 353
 
354
-						?>
354
+                              ?>
355 355
 						<div class="lsx-projects-slot">
356 356
 							<a href="<?php echo $alt_post_link; ?>">
357 357
 								<figure class="lsx-projects-avatar">
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 							</div>
371 371
 						</div>
372 372
 						<?php
373
-					}
374
-					?>
373
+                         }
374
+                         ?>
375 375
 					</div>
376 376
 				</div>
377 377
 			</div>
Please login to merge, or discard this patch.