@@ -13,65 +13,65 @@ discard block |
||
13 | 13 | public function __construct() { |
14 | 14 | $this->options = projects_get_options(); |
15 | 15 | |
16 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 ); |
|
17 | - add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 ); |
|
18 | - add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
19 | - add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
16 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5); |
|
17 | + add_filter('wp_kses_allowed_html', array($this, 'wp_kses_allowed_html'), 10, 2); |
|
18 | + add_filter('template_include', array($this, 'single_template_include'), 99); |
|
19 | + add_filter('template_include', array($this, 'archive_template_include'), 99); |
|
20 | 20 | |
21 | - if ( ! empty( $this->options['display']['projects_disable_single'] ) ) { |
|
22 | - add_action( 'template_redirect', array( $this, 'disable_single' ) ); |
|
21 | + if ( ! empty($this->options['display']['projects_disable_single'])) { |
|
22 | + add_action('template_redirect', array($this, 'disable_single')); |
|
23 | 23 | } |
24 | 24 | |
25 | - if ( is_admin() ) { |
|
26 | - add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
25 | + if (is_admin()) { |
|
26 | + add_filter('lsx_customizer_colour_selectors_body', array($this, 'customizer_body_colours_handler'), 15, 2); |
|
27 | 27 | } |
28 | 28 | |
29 | - add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 ); |
|
29 | + add_filter('lsx_banner_title', array($this, 'lsx_banner_archive_title'), 15); |
|
30 | 30 | |
31 | - add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) ); |
|
32 | - add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) ); |
|
33 | - add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) ); |
|
31 | + add_filter('excerpt_more_p', array($this, 'change_excerpt_more')); |
|
32 | + add_filter('excerpt_length', array($this, 'change_excerpt_length')); |
|
33 | + add_filter('excerpt_strip_tags', array($this, 'change_excerpt_strip_tags')); |
|
34 | 34 | |
35 | - add_filter( 'pre_get_posts', array( $this, 'posts_per_page' ) ); |
|
36 | - add_action( 'wp_footer', array( $this, 'add_form_modal' ) ); |
|
35 | + add_filter('pre_get_posts', array($this, 'posts_per_page')); |
|
36 | + add_action('wp_footer', array($this, 'add_form_modal')); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function enqueue_scripts() { |
40 | - $has_slick = wp_script_is( 'slick', 'queue' ); |
|
40 | + $has_slick = wp_script_is('slick', 'queue'); |
|
41 | 41 | |
42 | - if ( ! $has_slick ) { |
|
43 | - wp_enqueue_style( 'slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null ); |
|
44 | - wp_enqueue_script( 'slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true ); |
|
42 | + if ( ! $has_slick) { |
|
43 | + wp_enqueue_style('slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null); |
|
44 | + wp_enqueue_script('slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array('jquery'), null, LSX_PROJECTS_VER, true); |
|
45 | 45 | } |
46 | 46 | |
47 | - $has_scrolltofixed = wp_script_is( 'scrolltofixed', 'queue' ); |
|
47 | + $has_scrolltofixed = wp_script_is('scrolltofixed', 'queue'); |
|
48 | 48 | |
49 | - if ( ! $has_scrolltofixed ) { |
|
50 | - wp_enqueue_script( 'scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true ); |
|
49 | + if ( ! $has_scrolltofixed) { |
|
50 | + wp_enqueue_script('scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array('jquery'), null, LSX_PROJECTS_VER, true); |
|
51 | 51 | } |
52 | 52 | |
53 | - $has_isotope = wp_script_is( 'isotope', 'queue' ); |
|
53 | + $has_isotope = wp_script_is('isotope', 'queue'); |
|
54 | 54 | |
55 | - if ( ! $has_isotope ) { |
|
56 | - wp_enqueue_script( 'isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true ); |
|
55 | + if ( ! $has_isotope) { |
|
56 | + wp_enqueue_script('isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array('jquery'), null, LSX_PROJECTS_VER, true); |
|
57 | 57 | } |
58 | 58 | |
59 | - wp_enqueue_script( 'lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array( 'jquery', 'slick', 'scrolltofixed', 'isotope' ), LSX_PROJECTS_VER, true ); |
|
59 | + wp_enqueue_script('lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array('jquery', 'slick', 'scrolltofixed', 'isotope'), LSX_PROJECTS_VER, true); |
|
60 | 60 | |
61 | - $params = apply_filters( 'lsx_projects_js_params', array( |
|
62 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
61 | + $params = apply_filters('lsx_projects_js_params', array( |
|
62 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
63 | 63 | )); |
64 | 64 | |
65 | - wp_localize_script( 'lsx-projects', 'lsx_customizer_params', $params ); |
|
65 | + wp_localize_script('lsx-projects', 'lsx_customizer_params', $params); |
|
66 | 66 | |
67 | - wp_enqueue_style( 'lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER ); |
|
68 | - wp_style_add_data( 'lsx-projects', 'rtl', 'replace' ); |
|
67 | + wp_enqueue_style('lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER); |
|
68 | + wp_style_add_data('lsx-projects', 'rtl', 'replace'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Allow data params for Slick slider addon. |
73 | 73 | */ |
74 | - public function wp_kses_allowed_html( $allowedtags, $context ) { |
|
74 | + public function wp_kses_allowed_html($allowedtags, $context) { |
|
75 | 75 | $allowedtags['div']['data-slick'] = true; |
76 | 76 | return $allowedtags; |
77 | 77 | } |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * Single template. |
81 | 81 | */ |
82 | - public function single_template_include( $template ) { |
|
83 | - if ( is_main_query() && is_singular( 'project' ) ) { |
|
84 | - if ( empty( locate_template( array( 'single-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/single-projects.php' ) ) { |
|
82 | + public function single_template_include($template) { |
|
83 | + if (is_main_query() && is_singular('project')) { |
|
84 | + if (empty(locate_template(array('single-projects.php'))) && file_exists(LSX_PROJECTS_PATH . 'templates/single-projects.php')) { |
|
85 | 85 | $template = LSX_PROJECTS_PATH . 'templates/single-projects.php'; |
86 | 86 | } |
87 | 87 | } |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * Archive template. |
94 | 94 | */ |
95 | - public function archive_template_include( $template ) { |
|
96 | - if ( is_main_query() && ( is_post_type_archive( 'project' ) || is_tax( 'project-group' ) ) ) { |
|
97 | - if ( empty( locate_template( array( 'archive-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/archive-projects.php' ) ) { |
|
95 | + public function archive_template_include($template) { |
|
96 | + if (is_main_query() && (is_post_type_archive('project') || is_tax('project-group'))) { |
|
97 | + if (empty(locate_template(array('archive-projects.php'))) && file_exists(LSX_PROJECTS_PATH . 'templates/archive-projects.php')) { |
|
98 | 98 | $template = LSX_PROJECTS_PATH . 'templates/archive-projects.php'; |
99 | 99 | } |
100 | 100 | } |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * Removes access to single project member posts. |
107 | 107 | */ |
108 | 108 | public function disable_single() { |
109 | - $queried_post_type = get_query_var( 'post_type' ); |
|
109 | + $queried_post_type = get_query_var('post_type'); |
|
110 | 110 | |
111 | - if ( is_single() && 'project' === $queried_post_type ) { |
|
112 | - wp_redirect( home_url(), 301 ); |
|
111 | + if (is_single() && 'project' === $queried_post_type) { |
|
112 | + wp_redirect(home_url(), 301); |
|
113 | 113 | exit; |
114 | 114 | } |
115 | 115 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | /** |
118 | 118 | * Handle body colours that might be change by LSX Customiser |
119 | 119 | */ |
120 | - public function customizer_body_colours_handler( $css, $colors ) { |
|
120 | + public function customizer_body_colours_handler($css, $colors) { |
|
121 | 121 | $css .= ' |
122 | 122 | @import "' . LSX_PROJECTS_PATH . '/assets/css/scss/customizer-projects-body-colours"; |
123 | 123 | |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Change the LSX Banners title for project archive. |
142 | 142 | */ |
143 | - public function lsx_banner_archive_title( $title ) { |
|
144 | - if ( is_main_query() && is_post_type_archive( 'project' ) ) { |
|
145 | - $title = '<h1 class="page-title">' . esc_html__( 'Portfolio', 'lsx-projects' ) . '</h1>'; |
|
143 | + public function lsx_banner_archive_title($title) { |
|
144 | + if (is_main_query() && is_post_type_archive('project')) { |
|
145 | + $title = '<h1 class="page-title">' . esc_html__('Portfolio', 'lsx-projects') . '</h1>'; |
|
146 | 146 | } |
147 | 147 | |
148 | - if ( is_main_query() && is_tax( 'project-group' ) ) { |
|
148 | + if (is_main_query() && is_tax('project-group')) { |
|
149 | 149 | $tax = get_queried_object(); |
150 | - $title = '<h1 class="page-title">' . esc_html__( 'Project Type', 'lsx-projects' ) . ': ' . apply_filters( 'the_title', $tax->name ) . '</h1>'; |
|
150 | + $title = '<h1 class="page-title">' . esc_html__('Project Type', 'lsx-projects') . ': ' . apply_filters('the_title', $tax->name) . '</h1>'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $title; |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * Remove the "continue reading" when the single is disabled. |
158 | 158 | */ |
159 | - public function change_excerpt_more( $excerpt_more ) { |
|
159 | + public function change_excerpt_more($excerpt_more) { |
|
160 | 160 | global $post; |
161 | 161 | |
162 | - if ( 'project' === $post->post_type ) { |
|
163 | - if ( ! empty( $this->options['display']['projects_disable_single'] ) ) { |
|
162 | + if ('project' === $post->post_type) { |
|
163 | + if ( ! empty($this->options['display']['projects_disable_single'])) { |
|
164 | 164 | $excerpt_more = ''; |
165 | 165 | } |
166 | 166 | } |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * Change the word count when crop the content to excerpt (homepage widget). |
173 | 173 | */ |
174 | - public function change_excerpt_length( $excerpt_word_count ) { |
|
174 | + public function change_excerpt_length($excerpt_word_count) { |
|
175 | 175 | global $post; |
176 | 176 | |
177 | - if ( is_front_page() && 'project' === $post->post_type ) { |
|
177 | + if (is_front_page() && 'project' === $post->post_type) { |
|
178 | 178 | $excerpt_word_count = 20; |
179 | 179 | } |
180 | 180 | |
181 | - if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) { |
|
181 | + if (is_singular('project') && ('team' === $post->post_type || 'testimonial' === $post->post_type)) { |
|
182 | 182 | $excerpt_word_count = 20; |
183 | 183 | } |
184 | 184 | |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * Change the allowed tags crop the content to excerpt (homepage widget). |
190 | 190 | */ |
191 | - public function change_excerpt_strip_tags( $allowed_tags ) { |
|
191 | + public function change_excerpt_strip_tags($allowed_tags) { |
|
192 | 192 | global $post; |
193 | 193 | |
194 | - if ( is_front_page() && 'project' === $post->post_type ) { |
|
194 | + if (is_front_page() && 'project' === $post->post_type) { |
|
195 | 195 | $allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>'; |
196 | 196 | } |
197 | 197 | |
198 | - if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) { |
|
198 | + if (is_singular('project') && ('team' === $post->post_type || 'testimonial' === $post->post_type)) { |
|
199 | 199 | $allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>'; |
200 | 200 | } |
201 | 201 | |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | /** |
206 | 206 | * Change posts per page counter for archive. |
207 | 207 | */ |
208 | - public function posts_per_page( $query ) { |
|
209 | - if ( ! is_admin() && $query->is_main_query() ) { |
|
210 | - if ( $query->is_post_type_archive( 'project' ) || $query->is_tax( 'project-group' ) ) { |
|
211 | - $query->set( 'posts_per_page', -1 ); |
|
208 | + public function posts_per_page($query) { |
|
209 | + if ( ! is_admin() && $query->is_main_query()) { |
|
210 | + if ($query->is_post_type_archive('project') || $query->is_tax('project-group')) { |
|
211 | + $query->set('posts_per_page', -1); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | public function add_form_modal() { |
222 | 222 | global $lsx_projects; |
223 | 223 | |
224 | - if ( empty( $lsx_projects->options['display']['projects_modal_enable'] ) ) { |
|
224 | + if (empty($lsx_projects->options['display']['projects_modal_enable'])) { |
|
225 | 225 | return ''; |
226 | 226 | } |
227 | 227 | |
228 | - if ( empty( $lsx_projects->options['display']['projects_modal_cta_label'] ) || empty( $lsx_projects->options['display']['projects_modal_form_id'] ) ) { |
|
228 | + if (empty($lsx_projects->options['display']['projects_modal_cta_label']) || empty($lsx_projects->options['display']['projects_modal_form_id'])) { |
|
229 | 229 | return ''; |
230 | 230 | } |
231 | 231 | |
232 | - if ( ! is_single( 'project' ) ) { |
|
232 | + if ( ! is_single('project')) { |
|
233 | 233 | return ''; |
234 | 234 | } |
235 | 235 | ?> |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | <button type="button" class="close" data-dismiss="modal">×</button> |
240 | 240 | |
241 | 241 | <div class="modal-header"> |
242 | - <h4 class="modal-title"><?php echo esc_html( $lsx_projects->options['display']['projects_modal_cta_label'] ); ?></h4> |
|
242 | + <h4 class="modal-title"><?php echo esc_html($lsx_projects->options['display']['projects_modal_cta_label']); ?></h4> |
|
243 | 243 | </div> |
244 | 244 | |
245 | 245 | <div class="modal-body"> |
246 | - <?php echo do_shortcode( '[caldera_form id="' . $lsx_projects->options['display']['projects_modal_form_id'] . '"]' ); ?> |
|
246 | + <?php echo do_shortcode('[caldera_form id="' . $lsx_projects->options['display']['projects_modal_form_id'] . '"]'); ?> |
|
247 | 247 | </div> |
248 | 248 | </div> |
249 | 249 | </div> |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | public function __construct() { |
16 | 16 | $this->options = projects_get_options(); |
17 | 17 | |
18 | - add_filter( 'lsx_banner_allowed_post_types', array( $this, 'lsx_banner_allowed_post_types' ) ); |
|
19 | - add_filter( 'lsx_banner_allowed_taxonomies', array( $this, 'lsx_banner_allowed_taxonomies' ) ); |
|
18 | + add_filter('lsx_banner_allowed_post_types', array($this, 'lsx_banner_allowed_post_types')); |
|
19 | + add_filter('lsx_banner_allowed_taxonomies', array($this, 'lsx_banner_allowed_taxonomies')); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Enable project custom post type on LSX Banners. |
24 | 24 | */ |
25 | - public function lsx_banner_allowed_post_types( $post_types ) { |
|
25 | + public function lsx_banner_allowed_post_types($post_types) { |
|
26 | 26 | $post_types[] = 'project'; |
27 | 27 | return $post_types; |
28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Enable project custom taxonomies on LSX Banners. |
32 | 32 | */ |
33 | - public function lsx_banner_allowed_taxonomies( $taxonomies ) { |
|
33 | + public function lsx_banner_allowed_taxonomies($taxonomies) { |
|
34 | 34 | $taxonomies[] = 'project-group'; |
35 | 35 | return $taxonomies; |
36 | 36 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Returns the shortcode output markup |
40 | 40 | */ |
41 | - public function output( $atts ) { |
|
41 | + public function output($atts) { |
|
42 | 42 | // @codingStandardsIgnoreLine |
43 | - extract( shortcode_atts( array( |
|
43 | + extract(shortcode_atts(array( |
|
44 | 44 | 'columns' => 3, |
45 | 45 | 'orderby' => 'name', |
46 | 46 | 'order' => 'ASC', |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | 'show_image' => 'true', |
53 | 53 | 'carousel' => 'true', |
54 | 54 | 'featured' => 'false', |
55 | - ), $atts ) ); |
|
55 | + ), $atts)); |
|
56 | 56 | |
57 | 57 | $output = ''; |
58 | 58 | |
59 | - if ( 'true' === $responsive || true === $responsive ) { |
|
59 | + if ('true' === $responsive || true === $responsive) { |
|
60 | 60 | $responsive = ' img-responsive'; |
61 | 61 | } else { |
62 | 62 | $responsive = ''; |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $this->columns = $columns; |
66 | 66 | $this->responsive = $responsive; |
67 | 67 | |
68 | - if ( ! empty( $include ) ) { |
|
69 | - $include = explode( ',', $include ); |
|
68 | + if ( ! empty($include)) { |
|
69 | + $include = explode(',', $include); |
|
70 | 70 | |
71 | 71 | $args = array( |
72 | 72 | 'post_type' => 'project', |
@@ -83,27 +83,27 @@ discard block |
||
83 | 83 | 'order' => $order, |
84 | 84 | ); |
85 | 85 | |
86 | - if ( 'true' === $featured || true === $featured ) { |
|
86 | + if ('true' === $featured || true === $featured) { |
|
87 | 87 | $args['meta_key'] = 'lsx_project_featured'; |
88 | 88 | $args['meta_value'] = 1; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - $projects = new \WP_Query( $args ); |
|
92 | + $projects = new \WP_Query($args); |
|
93 | 93 | |
94 | - if ( $projects->have_posts() ) { |
|
94 | + if ($projects->have_posts()) { |
|
95 | 95 | global $post; |
96 | 96 | |
97 | 97 | $count = 0; |
98 | 98 | $count_global = 0; |
99 | 99 | |
100 | - if ( 'true' === $carousel || true === $carousel ) { |
|
100 | + if ('true' === $carousel || true === $carousel) { |
|
101 | 101 | $output .= "<div id='lsx-projects-slider' class='lsx-projects-shortcode' data-slick='{\"slidesToShow\": $columns, \"slidesToScroll\": $columns }'>"; |
102 | 102 | } else { |
103 | 103 | $output .= "<div class='lsx-projects-shortcode'><div class='row'>"; |
104 | 104 | } |
105 | 105 | |
106 | - while ( $projects->have_posts() ) { |
|
106 | + while ($projects->have_posts()) { |
|
107 | 107 | $projects->the_post(); |
108 | 108 | |
109 | 109 | // Count |
@@ -111,31 +111,31 @@ discard block |
||
111 | 111 | $count_global++; |
112 | 112 | |
113 | 113 | // Content |
114 | - if ( 'full' === $display ) { |
|
115 | - $content = apply_filters( 'the_content', get_the_content() ); |
|
116 | - $content = str_replace( ']]>', ']]>', $content ); |
|
117 | - } elseif ( 'excerpt' === $display ) { |
|
118 | - $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
114 | + if ('full' === $display) { |
|
115 | + $content = apply_filters('the_content', get_the_content()); |
|
116 | + $content = str_replace(']]>', ']]>', $content); |
|
117 | + } elseif ('excerpt' === $display) { |
|
118 | + $content = apply_filters('the_excerpt', get_the_excerpt()); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | // Image |
122 | - if ( 'true' === $show_image || true === $show_image ) { |
|
123 | - if ( is_numeric( $size ) ) { |
|
124 | - $thumb_size = array( $size, $size ); |
|
122 | + if ('true' === $show_image || true === $show_image) { |
|
123 | + if (is_numeric($size)) { |
|
124 | + $thumb_size = array($size, $size); |
|
125 | 125 | } else { |
126 | 126 | $thumb_size = $size; |
127 | 127 | } |
128 | 128 | |
129 | - if ( ! empty( get_the_post_thumbnail( $post->ID ) ) ) { |
|
130 | - $image = get_the_post_thumbnail( $post->ID, $thumb_size, array( |
|
129 | + if ( ! empty(get_the_post_thumbnail($post->ID))) { |
|
130 | + $image = get_the_post_thumbnail($post->ID, $thumb_size, array( |
|
131 | 131 | 'class' => $responsive, |
132 | - ) ); |
|
132 | + )); |
|
133 | 133 | } else { |
134 | 134 | $image = ''; |
135 | 135 | } |
136 | 136 | |
137 | - if ( empty( $image ) ) { |
|
138 | - if ( ! empty( $this->options['display']['projects_placeholder'] ) ) { |
|
137 | + if (empty($image)) { |
|
138 | + if ( ! empty($this->options['display']['projects_placeholder'])) { |
|
139 | 139 | $image = '<img class="' . $responsive . '" src="' . $this->options['display']['projects_placeholder'] . '" width="' . $size . '" alt="placeholder" />'; |
140 | 140 | } else { |
141 | 141 | $image = ''; |
@@ -147,42 +147,42 @@ discard block |
||
147 | 147 | |
148 | 148 | // Project groups |
149 | 149 | $groups = ''; |
150 | - $terms = get_the_terms( $post->ID, 'project-group' ); |
|
150 | + $terms = get_the_terms($post->ID, 'project-group'); |
|
151 | 151 | |
152 | - if ( $terms && ! is_wp_error( $terms ) ) { |
|
152 | + if ($terms && ! is_wp_error($terms)) { |
|
153 | 153 | $groups = array(); |
154 | 154 | |
155 | - foreach ( $terms as $term ) { |
|
155 | + foreach ($terms as $term) { |
|
156 | 156 | $groups[] = $term->name; |
157 | 157 | } |
158 | 158 | |
159 | - $groups = join( ', ', $groups ); |
|
159 | + $groups = join(', ', $groups); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | $project_groups = '' !== $groups ? "<p class='lsx-projects-groups'>$groups</p>" : ''; |
163 | 163 | |
164 | - if ( 'true' === $carousel || true === $carousel ) { |
|
164 | + if ('true' === $carousel || true === $carousel) { |
|
165 | 165 | $output .= " |
166 | 166 | <div class='lsx-projects-slot'> |
167 | - " . ( ! empty( $image ) ? "<a href='" . get_permalink() . "'><figure class='lsx-projects-avatar'>$image</figure></a>" : '' ) . " |
|
168 | - <h5 class='lsx-projects-title'><a href='" . get_permalink() . "'>" . apply_filters( 'the_title', $post->post_title ) . "</a></h5> |
|
167 | + " . ( ! empty($image) ? "<a href='" . get_permalink() . "'><figure class='lsx-projects-avatar'>$image</figure></a>" : '') . " |
|
168 | + <h5 class='lsx-projects-title'><a href='" . get_permalink() . "'>" . apply_filters('the_title', $post->post_title) . "</a></h5> |
|
169 | 169 | $project_groups |
170 | - <div class='lsx-projects-content'><a href='" . get_permalink() . "' class='moretag'>" . esc_html__( 'View more', 'lsx-projects' ) . '</a></div> |
|
170 | + <div class='lsx-projects-content'><a href='" . get_permalink() . "' class='moretag'>" . esc_html__('View more', 'lsx-projects') . '</a></div> |
|
171 | 171 | </div>'; |
172 | - } elseif ( $columns >= 1 && $columns <= 4 ) { |
|
172 | + } elseif ($columns >= 1 && $columns <= 4) { |
|
173 | 173 | $md_col_width = 12 / $columns; |
174 | 174 | |
175 | 175 | $output .= " |
176 | 176 | <div class='col-xs-12 col-md-" . $md_col_width . "'> |
177 | 177 | <div class='lsx-projects-slot'> |
178 | - " . ( ! empty( $image ) ? "<a href='" . get_permalink() . "'><figure class='lsx-projects-avatar'>$image</figure></a>" : '' ) . " |
|
179 | - <h5 class='lsx-projects-title'><a href='" . get_permalink() . "'>" . apply_filters( 'the_title', $post->post_title ) . "</a></h5> |
|
178 | + " . ( ! empty($image) ? "<a href='" . get_permalink() . "'><figure class='lsx-projects-avatar'>$image</figure></a>" : '') . " |
|
179 | + <h5 class='lsx-projects-title'><a href='" . get_permalink() . "'>" . apply_filters('the_title', $post->post_title) . "</a></h5> |
|
180 | 180 | $project_groups |
181 | - <div class='lsx-projects-content'><a href='" . get_permalink() . "' class='moretag'>" . esc_html__( 'View more', 'lsx-projects' ) . '</a></div> |
|
181 | + <div class='lsx-projects-content'><a href='" . get_permalink() . "' class='moretag'>" . esc_html__('View more', 'lsx-projects') . '</a></div> |
|
182 | 182 | </div> |
183 | 183 | </div>'; |
184 | 184 | |
185 | - if ( $count == $columns && $projects->post_count > $count_global ) { |
|
185 | + if ($count == $columns && $projects->post_count > $count_global) { |
|
186 | 186 | $output .= '</div>'; |
187 | 187 | $output .= "<div class='row'>"; |
188 | 188 | $count = 0; |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | } else { |
191 | 191 | $output .= " |
192 | 192 | <p class='bg-warning' style='padding: 20px;'> |
193 | - " . esc_html__( 'Invalid number of columns set. LSX Projects supports 1 to 4 columns.', 'lsx-projects' ) . ' |
|
193 | + " . esc_html__('Invalid number of columns set. LSX Projects supports 1 to 4 columns.', 'lsx-projects') . ' |
|
194 | 194 | </p>'; |
195 | 195 | } |
196 | 196 | |
197 | 197 | wp_reset_postdata(); |
198 | 198 | } |
199 | 199 | |
200 | - if ( 'true' !== $carousel && true !== $carousel ) { |
|
200 | + if ('true' !== $carousel && true !== $carousel) { |
|
201 | 201 | $output .= '</div>'; |
202 | 202 | } |
203 | 203 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * Contructor |
30 | 30 | */ |
31 | 31 | public function __construct() { |
32 | - add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) ); |
|
33 | - add_action( 'lsx_projects_settings_page', array( $this, 'general_settings' ), 1, 1 ); |
|
34 | - add_action( 'lsx_projects_settings_page', array( $this, 'contact_modal_settings' ), 1, 1 ); |
|
32 | + add_action('cmb2_admin_init', array($this, 'register_settings_page')); |
|
33 | + add_action('lsx_projects_settings_page', array($this, 'general_settings'), 1, 1); |
|
34 | + add_action('lsx_projects_settings_page', array($this, 'contact_modal_settings'), 1, 1); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function get_instance() { |
45 | 45 | // If the single instance hasn't been set, set it now. |
46 | - if ( null === self::$instance ) { |
|
46 | + if (null === self::$instance) { |
|
47 | 47 | self::$instance = new self(); |
48 | 48 | } |
49 | 49 | return self::$instance; |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | $cmb = new_cmb2_box( |
57 | 57 | array( |
58 | 58 | 'id' => $this->screen_id, |
59 | - 'title' => esc_html__( 'Settings', 'lsx-projects' ), |
|
60 | - 'object_types' => array( 'options-page' ), |
|
59 | + 'title' => esc_html__('Settings', 'lsx-projects'), |
|
60 | + 'object_types' => array('options-page'), |
|
61 | 61 | 'option_key' => 'lsx_projects_options', // The option key and admin menu page slug. |
62 | 62 | 'parent_slug' => 'edit.php?post_type=project', // Make options page a submenu item of the themes menu. |
63 | 63 | 'capability' => 'manage_options', // Cap required to view options-page. |
64 | 64 | ) |
65 | 65 | ); |
66 | - do_action( 'lsx_projects_settings_page', $cmb ); |
|
66 | + do_action('lsx_projects_settings_page', $cmb); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -72,30 +72,30 @@ discard block |
||
72 | 72 | * @param object $cmb new_cmb2_box(). |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public function general_settings( $cmb ) { |
|
75 | + public function general_settings($cmb) { |
|
76 | 76 | $cmb->add_field( |
77 | 77 | array( |
78 | 78 | 'id' => 'settings_general_title', |
79 | 79 | 'type' => 'title', |
80 | - 'name' => __( 'General', 'lsx-projects' ), |
|
81 | - 'default' => __( 'General', 'lsx-projects' ), |
|
80 | + 'name' => __('General', 'lsx-projects'), |
|
81 | + 'default' => __('General', 'lsx-projects'), |
|
82 | 82 | ) |
83 | 83 | ); |
84 | 84 | $cmb->add_field( |
85 | 85 | array( |
86 | - 'name' => __( 'Disable Single Posts', 'lsx-projects' ), |
|
86 | + 'name' => __('Disable Single Posts', 'lsx-projects'), |
|
87 | 87 | 'id' => 'projects_disable_single', |
88 | 88 | 'type' => 'checkbox', |
89 | 89 | 'value' => 1, |
90 | 90 | 'default' => 0, |
91 | - 'description' => __( 'Disable Single Posts.', 'lsx-projects' ), |
|
91 | + 'description' => __('Disable Single Posts.', 'lsx-projects'), |
|
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | |
95 | 95 | $cmb->add_field( |
96 | 96 | array( |
97 | 97 | 'name' => 'Placeholder', |
98 | - 'desc' => __( 'Choose Image.', 'lsx-projects' ), |
|
98 | + 'desc' => __('Choose Image.', 'lsx-projects'), |
|
99 | 99 | 'id' => 'projects_placeholder', |
100 | 100 | 'type' => 'file', |
101 | 101 | 'options' => array( |
@@ -121,28 +121,28 @@ discard block |
||
121 | 121 | * @param object $cmb new_cmb2_box(). |
122 | 122 | * @return void |
123 | 123 | */ |
124 | - public function contact_modal_settings( $cmb ) { |
|
124 | + public function contact_modal_settings($cmb) { |
|
125 | 125 | $cmb->add_field( |
126 | 126 | array( |
127 | 127 | 'id' => 'settings_contact_modal_title', |
128 | 128 | 'type' => 'title', |
129 | - 'name' => __( 'Contact modal', 'lsx-projects' ), |
|
129 | + 'name' => __('Contact modal', 'lsx-projects'), |
|
130 | 130 | ) |
131 | 131 | ); |
132 | 132 | $cmb->add_field( |
133 | 133 | array( |
134 | - 'name' => __( 'Enable contact modal', 'lsx-projects' ), |
|
134 | + 'name' => __('Enable contact modal', 'lsx-projects'), |
|
135 | 135 | 'id' => 'projects_modal_enable', |
136 | 136 | 'type' => 'checkbox', |
137 | 137 | 'value' => 1, |
138 | 138 | 'default' => 0, |
139 | - 'description' => __( 'Displays contact modal on project single.', 'lsx-projects' ), |
|
139 | + 'description' => __('Displays contact modal on project single.', 'lsx-projects'), |
|
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | |
143 | 143 | $cmb->add_field( |
144 | 144 | array( |
145 | - 'name' => __( 'Button label', 'lsx-projects' ), |
|
145 | + 'name' => __('Button label', 'lsx-projects'), |
|
146 | 146 | 'id' => 'projects_modal_cta_label', |
147 | 147 | 'type' => 'text', |
148 | 148 | ) |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $cmb->add_field( |
152 | 152 | array( |
153 | - 'name' => __( 'Caldera Form ID', 'lsx-projects' ), |
|
153 | + 'name' => __('Caldera Form ID', 'lsx-projects'), |
|
154 | 154 | 'id' => 'projects_modal_form_id', |
155 | 155 | 'type' => 'text', |
156 | 156 | ) |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * Contructor |
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
42 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
43 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
44 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
45 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
46 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
47 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
48 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
41 | + add_filter('cmb2_enqueue_css', array($this, 'disable_cmb2_styles'), 1, 1); |
|
42 | + add_action('cmb2_before_form', array($this, 'generate_navigation'), 10, 4); |
|
43 | + add_action('cmb2_before_title_field_row', array($this, 'output_tab_open_div'), 10, 1); |
|
44 | + add_action('cmb2_after_tab_closing_field_row', array($this, 'output_tab_closing_div'), 10, 1); |
|
45 | + add_action('cmb2_render_tab_closing', array($this, 'cmb2_render_callback_for_tab_closing'), 10, 5); |
|
46 | + add_filter('cmb2_sanitize_tab_closing', array($this, 'cmb2_sanitize_tab_closing_callback'), 10, 2); |
|
47 | + add_action('cmb2_after_form', array($this, 'navigation_js'), 10, 4); |
|
48 | + add_filter('cmb2_options_page_redirect_url', array($this, 'add_tab_argument'), 10, 1); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public static function get_instance() { |
59 | 59 | // If the single instance hasn't been set, set it now. |
60 | - if ( null == self::$instance ) { |
|
60 | + if (null == self::$instance) { |
|
61 | 61 | self::$instance = new self(); |
62 | 62 | } |
63 | 63 | return self::$instance; |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return bool $enabled Whether to enable (enqueue) styles. |
70 | 70 | */ |
71 | - public function disable_cmb2_styles( $enabled ) { |
|
72 | - if ( is_admin() ) { |
|
71 | + public function disable_cmb2_styles($enabled) { |
|
72 | + if (is_admin()) { |
|
73 | 73 | $current_screen = get_current_screen(); |
74 | - if ( is_object( $current_screen ) && 'project_page_lsx_projects_options' === $current_screen->id ) { |
|
74 | + if (is_object($current_screen) && 'project_page_lsx_projects_options' === $current_screen->id) { |
|
75 | 75 | $enabled = false; |
76 | 76 | } |
77 | 77 | } |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | * @param object $cmb2_obj |
88 | 88 | * @return void |
89 | 89 | */ |
90 | - public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
91 | - if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) { |
|
90 | + public function generate_navigation($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
91 | + if ('lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type) { |
|
92 | 92 | $this->navigation = array(); |
93 | 93 | $this->is_options_page = true; |
94 | - if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
95 | - foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
96 | - if ( 'title' === $field['type'] ) { |
|
97 | - $this->navigation[ $field_index ] = $field['name']; |
|
94 | + if (isset($cmb2_obj->meta_box['fields']) && ! empty($cmb2_obj->meta_box['fields'])) { |
|
95 | + foreach ($cmb2_obj->meta_box['fields'] as $field_index => $field) { |
|
96 | + if ('title' === $field['type']) { |
|
97 | + $this->navigation[$field_index] = $field['name']; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
@@ -108,32 +108,32 @@ discard block |
||
108 | 108 | * @return void |
109 | 109 | */ |
110 | 110 | public function output_navigation() { |
111 | - if ( ! empty( $this->navigation ) ) { |
|
111 | + if ( ! empty($this->navigation)) { |
|
112 | 112 | ?> |
113 | 113 | <div class="wp-filter hide-if-no-js"> |
114 | 114 | <ul class="filter-links"> |
115 | 115 | <?php |
116 | 116 | $first_tab = true; |
117 | - $total = count( $this->navigation ); |
|
117 | + $total = count($this->navigation); |
|
118 | 118 | $count = 0; |
119 | 119 | $separator = ' |'; |
120 | 120 | $selected_tab = ''; |
121 | - if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
122 | - $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
121 | + if (isset($_GET['cmb_tab']) && '' !== $_GET['cmb_tab']) { |
|
122 | + $selected_tab = sanitize_text_field($_GET['cmb_tab']); |
|
123 | 123 | $selected_tab = 'settings_' . $selected_tab; |
124 | 124 | } |
125 | - foreach ( $this->navigation as $key => $label ) { |
|
125 | + foreach ($this->navigation as $key => $label) { |
|
126 | 126 | $count++; |
127 | 127 | $current_css = ''; |
128 | - if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
128 | + if ((true === $first_tab && '' === $selected_tab) || $key === $selected_tab) { |
|
129 | 129 | $first_tab = false; |
130 | 130 | $current_css = 'current'; |
131 | 131 | } |
132 | - if ( $count === $total ) { |
|
132 | + if ($count === $total) { |
|
133 | 133 | $separator = ''; |
134 | 134 | } |
135 | 135 | ?> |
136 | - <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li> |
|
136 | + <li><a href="#" class="<?php echo esc_attr($current_css); ?>" data-sort="<?php echo esc_attr($key); ?>_tab"><?php echo esc_attr($label); ?></a><?php echo esc_attr($separator); ?></li> |
|
137 | 137 | <?php |
138 | 138 | } |
139 | 139 | ?> |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * @param object $field CMB2_Field(); |
150 | 150 | * @return void |
151 | 151 | */ |
152 | - public function output_tab_open_div( $field ) { |
|
153 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
152 | + public function output_tab_open_div($field) { |
|
153 | + if (true === $this->is_options_page && isset($field->args['type']) && 'title' === $field->args['type']) { |
|
154 | 154 | ?> |
155 | - <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden"> |
|
155 | + <div id="<?php echo esc_attr($field->args['id']); ?>_tab" class="tab tab-nav hidden"> |
|
156 | 156 | <?php |
157 | 157 | } |
158 | 158 | } |
@@ -163,19 +163,19 @@ discard block |
||
163 | 163 | * @param object $field CMB2_Field(); |
164 | 164 | * @return void |
165 | 165 | */ |
166 | - public function output_tab_closing_div( $field ) { |
|
167 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
166 | + public function output_tab_closing_div($field) { |
|
167 | + if (true === $this->is_options_page && isset($field->args['type']) && 'tab_closing' === $field->args['type']) { |
|
168 | 168 | ?> |
169 | 169 | </div> |
170 | 170 | <?php |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | - public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
174 | + public function cmb2_render_callback_for_tab_closing($field, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
178 | - public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
178 | + public function cmb2_sanitize_tab_closing_callback($override_value, $value) { |
|
179 | 179 | return ''; |
180 | 180 | } |
181 | 181 | |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @param object $cmb2_obj |
189 | 189 | * @return void |
190 | 190 | */ |
191 | - public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
192 | - if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) { |
|
191 | + public function navigation_js($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
192 | + if ('lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type) { |
|
193 | 193 | ?> |
194 | 194 | <script> |
195 | 195 | var LSX_PROJECTS_CMB2 = Object.create( null ); |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | * @param string $url |
272 | 272 | * @return void |
273 | 273 | */ |
274 | - public function add_tab_argument( $url ) { |
|
275 | - if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
276 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
277 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
278 | - if ( 'single' !== $tab_selection ) { |
|
279 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
274 | + public function add_tab_argument($url) { |
|
275 | + if (isset($_POST['cmb_tab']) && '' !== $_POST['cmb_tab']) { // @codingStandardsIgnoreLine |
|
276 | + $tab_selection = sanitize_text_field($_POST['cmb_tab']); // @codingStandardsIgnoreLine |
|
277 | + $tab_selection = str_replace(array('settings_', '_tab'), '', $tab_selection); // @codingStandardsIgnoreLine |
|
278 | + if ('single' !== $tab_selection) { |
|
279 | + $url = add_query_arg('cmb_tab', $tab_selection, $url); |
|
280 | 280 | } else { |
281 | - $url = remove_query_arg( 'cmb_tab', $url ); |
|
281 | + $url = remove_query_arg('cmb_tab', $url); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | return $url; |
@@ -13,18 +13,18 @@ discard block |
||
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_filter( 'cmb2_admin_init', array( $this, 'field_setup' ) ); |
|
19 | - add_filter( 'cmb2_admin_init', array( $this, 'projects_services_metaboxes' ) ); |
|
20 | - add_filter( 'cmb2_admin_init', array( $this, 'projects_testimonials_metaboxes' ) ); |
|
21 | - add_filter( 'cmb2_admin_init', array( $this, 'projects_team_metaboxes' ) ); |
|
22 | - add_filter( 'cmb2_admin_init', array( $this, 'projects_woocommerce_metaboxes' ) ); |
|
23 | - add_action( 'cmb_save_custom', array( $this, 'post_relations' ), 3, 20 ); |
|
24 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
25 | - |
|
26 | - add_filter( 'type_url_form_media', array( $this, 'change_attachment_field_button' ), 20, 1 ); |
|
27 | - 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_filter('cmb2_admin_init', array($this, 'field_setup')); |
|
19 | + add_filter('cmb2_admin_init', array($this, 'projects_services_metaboxes')); |
|
20 | + add_filter('cmb2_admin_init', array($this, 'projects_testimonials_metaboxes')); |
|
21 | + add_filter('cmb2_admin_init', array($this, 'projects_team_metaboxes')); |
|
22 | + add_filter('cmb2_admin_init', array($this, 'projects_woocommerce_metaboxes')); |
|
23 | + add_action('cmb_save_custom', array($this, 'post_relations'), 3, 20); |
|
24 | + add_action('admin_enqueue_scripts', array($this, 'assets')); |
|
25 | + |
|
26 | + add_filter('type_url_form_media', array($this, 'change_attachment_field_button'), 20, 1); |
|
27 | + add_filter('enter_title_here', array($this, 'change_title_text')); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function post_type_setup() { |
45 | 45 | $labels = array( |
46 | - 'name' => esc_html_x( 'Projects', 'post type general name', 'lsx-projects' ), |
|
47 | - 'singular_name' => esc_html_x( 'Project', 'post type singular name', 'lsx-projects' ), |
|
48 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-projects' ), |
|
49 | - 'add_new_item' => esc_html__( 'Add New Project', 'lsx-projects' ), |
|
50 | - 'edit_item' => esc_html__( 'Edit Project', 'lsx-projects' ), |
|
51 | - 'new_item' => esc_html__( 'New Project', 'lsx-projects' ), |
|
52 | - 'all_items' => esc_html__( 'All Projects', 'lsx-projects' ), |
|
53 | - 'view_item' => esc_html__( 'View Project', 'lsx-projects' ), |
|
54 | - 'search_items' => esc_html__( 'Search Projects', 'lsx-projects' ), |
|
55 | - 'not_found' => esc_html__( 'No projects found', 'lsx-projects' ), |
|
56 | - 'not_found_in_trash' => esc_html__( 'No projects found in Trash', 'lsx-projects' ), |
|
46 | + 'name' => esc_html_x('Projects', 'post type general name', 'lsx-projects'), |
|
47 | + 'singular_name' => esc_html_x('Project', 'post type singular name', 'lsx-projects'), |
|
48 | + 'add_new' => esc_html_x('Add New', 'post type general name', 'lsx-projects'), |
|
49 | + 'add_new_item' => esc_html__('Add New Project', 'lsx-projects'), |
|
50 | + 'edit_item' => esc_html__('Edit Project', 'lsx-projects'), |
|
51 | + 'new_item' => esc_html__('New Project', 'lsx-projects'), |
|
52 | + 'all_items' => esc_html__('All Projects', 'lsx-projects'), |
|
53 | + 'view_item' => esc_html__('View Project', 'lsx-projects'), |
|
54 | + 'search_items' => esc_html__('Search Projects', 'lsx-projects'), |
|
55 | + 'not_found' => esc_html__('No projects found', 'lsx-projects'), |
|
56 | + 'not_found_in_trash' => esc_html__('No projects found in Trash', 'lsx-projects'), |
|
57 | 57 | 'parent_item_colon' => '', |
58 | - 'menu_name' => esc_html_x( 'Projects', 'admin menu', 'lsx-projects' ), |
|
58 | + 'menu_name' => esc_html_x('Projects', 'admin menu', 'lsx-projects'), |
|
59 | 59 | ); |
60 | 60 | |
61 | 61 | $args = array( |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | 'excerpt', |
81 | 81 | ), |
82 | 82 | 'show_in_rest' => true, |
83 | - 'supports' => array( 'editor', 'title', 'excerpt', 'thumbnail' ), |
|
83 | + 'supports' => array('editor', 'title', 'excerpt', 'thumbnail'), |
|
84 | 84 | ); |
85 | 85 | |
86 | - register_post_type( 'project', $args ); |
|
86 | + register_post_type('project', $args); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function taxonomy_setup() { |
93 | 93 | $labels = array( |
94 | - 'name' => esc_html_x( 'Project Groups', 'taxonomy general name', 'lsx-projects' ), |
|
95 | - 'singular_name' => esc_html_x( 'Group', 'taxonomy singular name', 'lsx-projects' ), |
|
96 | - 'search_items' => esc_html__( 'Search Groups', 'lsx-projects' ), |
|
97 | - 'all_items' => esc_html__( 'All Groups', 'lsx-projects' ), |
|
98 | - 'parent_item' => esc_html__( 'Parent Group', 'lsx-projects' ), |
|
99 | - 'parent_item_colon' => esc_html__( 'Parent Group:', 'lsx-projects' ), |
|
100 | - 'edit_item' => esc_html__( 'Edit Group', 'lsx-projects' ), |
|
101 | - 'update_item' => esc_html__( 'Update Group', 'lsx-projects' ), |
|
102 | - 'add_new_item' => esc_html__( 'Add New Group', 'lsx-projects' ), |
|
103 | - 'new_item_name' => esc_html__( 'New Group Name', 'lsx-projects' ), |
|
104 | - 'menu_name' => esc_html__( 'Groups', 'lsx-projects' ), |
|
94 | + 'name' => esc_html_x('Project Groups', 'taxonomy general name', 'lsx-projects'), |
|
95 | + 'singular_name' => esc_html_x('Group', 'taxonomy singular name', 'lsx-projects'), |
|
96 | + 'search_items' => esc_html__('Search Groups', 'lsx-projects'), |
|
97 | + 'all_items' => esc_html__('All Groups', 'lsx-projects'), |
|
98 | + 'parent_item' => esc_html__('Parent Group', 'lsx-projects'), |
|
99 | + 'parent_item_colon' => esc_html__('Parent Group:', 'lsx-projects'), |
|
100 | + 'edit_item' => esc_html__('Edit Group', 'lsx-projects'), |
|
101 | + 'update_item' => esc_html__('Update Group', 'lsx-projects'), |
|
102 | + 'add_new_item' => esc_html__('Add New Group', 'lsx-projects'), |
|
103 | + 'new_item_name' => esc_html__('New Group Name', 'lsx-projects'), |
|
104 | + 'menu_name' => esc_html__('Groups', 'lsx-projects'), |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | $args = array( |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | ), |
116 | 116 | ); |
117 | 117 | |
118 | - register_taxonomy( 'project-group', array( 'project' ), $args ); |
|
118 | + register_taxonomy('project-group', array('project'), $args); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $cmb = new_cmb2_box( |
128 | 128 | array( |
129 | 129 | 'id' => $prefix . '_project', |
130 | - 'title' => __( 'General', 'lsx-projects' ), |
|
130 | + 'title' => __('General', 'lsx-projects'), |
|
131 | 131 | 'object_types' => 'project', |
132 | 132 | 'context' => 'normal', |
133 | 133 | 'priority' => 'low', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $cmb->add_field( |
139 | 139 | array( |
140 | - 'name' => esc_html__( 'Featured:', 'lsx-projects' ), |
|
140 | + 'name' => esc_html__('Featured:', 'lsx-projects'), |
|
141 | 141 | 'id' => $prefix . 'featured', |
142 | 142 | 'type' => 'checkbox', |
143 | 143 | 'value' => 1, |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $cmb->add_field( |
150 | 150 | array( |
151 | - 'name' => esc_html__( 'Client:', 'lsx-projects' ), |
|
151 | + 'name' => esc_html__('Client:', 'lsx-projects'), |
|
152 | 152 | 'id' => $prefix . 'client', |
153 | 153 | 'type' => 'text', |
154 | 154 | 'show_in_rest' => true, |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | |
158 | 158 | $cmb->add_field( |
159 | 159 | array( |
160 | - 'name' => esc_html__( 'Client logo:', 'lsx-projects' ), |
|
160 | + 'name' => esc_html__('Client logo:', 'lsx-projects'), |
|
161 | 161 | 'id' => $prefix . 'client_logo', |
162 | 162 | 'type' => 'image', |
163 | - 'desc' => esc_html__( 'Recommended image size: 320 x 50~60', 'lsx-projects' ), |
|
163 | + 'desc' => esc_html__('Recommended image size: 320 x 50~60', 'lsx-projects'), |
|
164 | 164 | 'options' => array( |
165 | 165 | 'url' => false, // Hide the text input for the url. |
166 | 166 | ), |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | $cmb->add_field( |
175 | 175 | array( |
176 | - 'name' => esc_html__( 'URL for the finished project:', 'lsx-projects' ), |
|
176 | + 'name' => esc_html__('URL for the finished project:', 'lsx-projects'), |
|
177 | 177 | 'id' => $prefix . 'url', |
178 | 178 | 'type' => 'text', |
179 | 179 | 'show_in_rest' => true, |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | |
201 | 201 | $cmb->add_field( |
202 | 202 | array( |
203 | - 'name' => esc_html__( 'Services related to this project:', 'lsx-projects' ), |
|
203 | + 'name' => esc_html__('Services related to this project:', 'lsx-projects'), |
|
204 | 204 | 'id' => 'page_to_project', |
205 | 205 | 'type' => 'post_search_ajax', |
206 | 206 | 'show_in_rest' => true, |
207 | 207 | 'limit' => 15, |
208 | 208 | 'sortable' => true, |
209 | 209 | 'query_args' => array( |
210 | - 'post_type' => array( 'page' ), |
|
211 | - 'post_status' => array( 'publish' ), |
|
210 | + 'post_type' => array('page'), |
|
211 | + 'post_status' => array('publish'), |
|
212 | 212 | 'nopagin' => true, |
213 | 213 | 'posts_per_page' => '50', |
214 | 214 | 'orderby' => 'title', |
@@ -234,18 +234,18 @@ discard block |
||
234 | 234 | ) |
235 | 235 | ); |
236 | 236 | |
237 | - if ( class_exists( 'LSX_Testimonials' ) ) { |
|
237 | + if (class_exists('LSX_Testimonials')) { |
|
238 | 238 | $cmb->add_field( |
239 | 239 | array( |
240 | - 'name' => esc_html__( 'Testimonials related to this project:', 'lsx-projects' ), |
|
240 | + 'name' => esc_html__('Testimonials related to this project:', 'lsx-projects'), |
|
241 | 241 | 'id' => 'testimonial_to_project', |
242 | 242 | 'type' => 'post_search_ajax', |
243 | 243 | 'show_in_rest' => true, |
244 | 244 | 'limit' => 15, |
245 | 245 | 'sortable' => true, |
246 | 246 | 'query_args' => array( |
247 | - 'post_type' => array( 'testimonials' ), |
|
248 | - 'post_status' => array( 'publish' ), |
|
247 | + 'post_type' => array('testimonials'), |
|
248 | + 'post_status' => array('publish'), |
|
249 | 249 | 'nopagin' => true, |
250 | 250 | 'posts_per_page' => '50', |
251 | 251 | 'orderby' => 'title', |
@@ -272,18 +272,18 @@ discard block |
||
272 | 272 | ) |
273 | 273 | ); |
274 | 274 | |
275 | - if ( class_exists( 'LSX_Team' ) ) { |
|
275 | + if (class_exists('LSX_Team')) { |
|
276 | 276 | $cmb->add_field( |
277 | 277 | array( |
278 | - 'name' => esc_html__( 'Team members involved with this project:', 'lsx-projects' ), |
|
278 | + 'name' => esc_html__('Team members involved with this project:', 'lsx-projects'), |
|
279 | 279 | 'id' => 'team_to_project', |
280 | 280 | 'type' => 'post_search_ajax', |
281 | 281 | 'show_in_rest' => true, |
282 | 282 | 'limit' => 15, |
283 | 283 | 'sortable' => true, |
284 | 284 | 'query_args' => array( |
285 | - 'post_type' => array( 'team' ), |
|
286 | - 'post_status' => array( 'publish' ), |
|
285 | + 'post_type' => array('team'), |
|
286 | + 'post_status' => array('publish'), |
|
287 | 287 | 'nopagin' => true, |
288 | 288 | 'posts_per_page' => '50', |
289 | 289 | 'orderby' => 'title', |
@@ -310,18 +310,18 @@ discard block |
||
310 | 310 | ) |
311 | 311 | ); |
312 | 312 | |
313 | - if ( class_exists( 'woocommerce' ) ) { |
|
313 | + if (class_exists('woocommerce')) { |
|
314 | 314 | $cmb->add_field( |
315 | 315 | array( |
316 | - 'name' => esc_html__( 'Products used for this project:', 'lsx-projects' ), |
|
316 | + 'name' => esc_html__('Products used for this project:', 'lsx-projects'), |
|
317 | 317 | 'id' => 'product_to_project', |
318 | 318 | 'type' => 'post_search_ajax', |
319 | 319 | 'show_in_rest' => true, |
320 | 320 | 'limit' => 15, |
321 | 321 | 'sortable' => true, |
322 | 322 | 'query_args' => array( |
323 | - 'post_type' => array( 'product' ), |
|
324 | - 'post_status' => array( 'publish' ), |
|
323 | + 'post_type' => array('product'), |
|
324 | + 'post_status' => array('publish'), |
|
325 | 325 | 'nopagin' => true, |
326 | 326 | 'posts_per_page' => '50', |
327 | 327 | 'orderby' => 'title', |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | /** |
336 | 336 | * Sets up the "post relations". |
337 | 337 | */ |
338 | - public function post_relations( $post_id, $field, $value ) { |
|
338 | + public function post_relations($post_id, $field, $value) { |
|
339 | 339 | $connections = array( |
340 | 340 | // 'project_to_project', |
341 | 341 | |
@@ -352,31 +352,31 @@ discard block |
||
352 | 352 | 'team_to_project', |
353 | 353 | ); |
354 | 354 | |
355 | - if ( in_array( $field['id'], $connections ) ) { |
|
356 | - $this->save_related_post( $connections, $post_id, $field, $value ); |
|
355 | + if (in_array($field['id'], $connections)) { |
|
356 | + $this->save_related_post($connections, $post_id, $field, $value); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Save the reverse post relation. |
362 | 362 | */ |
363 | - public function save_related_post( $connections, $post_id, $field, $value ) { |
|
364 | - $ids = explode( '_to_', $field['id'] ); |
|
363 | + public function save_related_post($connections, $post_id, $field, $value) { |
|
364 | + $ids = explode('_to_', $field['id']); |
|
365 | 365 | $relation = $ids[1] . '_to_' . $ids[0]; |
366 | 366 | |
367 | - if ( in_array( $relation, $connections ) ) { |
|
368 | - $previous_values = get_post_meta( $post_id, $field['id'], false ); |
|
367 | + if (in_array($relation, $connections)) { |
|
368 | + $previous_values = get_post_meta($post_id, $field['id'], false); |
|
369 | 369 | |
370 | - if ( ! empty( $previous_values ) ) { |
|
371 | - foreach ( $previous_values as $v ) { |
|
372 | - delete_post_meta( $v, $relation, $post_id ); |
|
370 | + if ( ! empty($previous_values)) { |
|
371 | + foreach ($previous_values as $v) { |
|
372 | + delete_post_meta($v, $relation, $post_id); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - if ( is_array( $value ) ) { |
|
377 | - foreach ( $value as $v ) { |
|
378 | - if ( ! empty( $v ) ) { |
|
379 | - add_post_meta( $v, $relation, $post_id ); |
|
376 | + if (is_array($value)) { |
|
377 | + foreach ($value as $v) { |
|
378 | + if ( ! empty($v)) { |
|
379 | + add_post_meta($v, $relation, $post_id); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -385,30 +385,30 @@ discard block |
||
385 | 385 | |
386 | 386 | public function assets() { |
387 | 387 | //wp_enqueue_media(); |
388 | - wp_enqueue_script( 'media-upload' ); |
|
389 | - wp_enqueue_script( 'thickbox' ); |
|
390 | - wp_enqueue_style( 'thickbox' ); |
|
388 | + wp_enqueue_script('media-upload'); |
|
389 | + wp_enqueue_script('thickbox'); |
|
390 | + wp_enqueue_style('thickbox'); |
|
391 | 391 | |
392 | - wp_enqueue_script( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array( 'jquery' ), LSX_PROJECTS_VER, true ); |
|
393 | - wp_enqueue_style( 'lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER ); |
|
392 | + wp_enqueue_script('lsx-projects-admin', LSX_PROJECTS_URL . 'assets/js/lsx-projects-admin.min.js', array('jquery'), LSX_PROJECTS_VER, true); |
|
393 | + wp_enqueue_style('lsx-projects-admin', LSX_PROJECTS_URL . 'assets/css/lsx-projects-admin.css', array(), LSX_PROJECTS_VER); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Change the "Insert into Post" button text when media modal is used for feature images |
398 | 398 | */ |
399 | - public function change_attachment_field_button( $html ) { |
|
400 | - if ( isset( $_GET['feature_image_text_button'] ) ) { |
|
401 | - $html = str_replace( 'value="Insert into Post"', sprintf( 'value="%s"', esc_html__( 'Select featured image', 'lsx-projects' ) ), $html ); |
|
399 | + public function change_attachment_field_button($html) { |
|
400 | + if (isset($_GET['feature_image_text_button'])) { |
|
401 | + $html = str_replace('value="Insert into Post"', sprintf('value="%s"', esc_html__('Select featured image', 'lsx-projects')), $html); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | return $html; |
405 | 405 | } |
406 | 406 | |
407 | - public function change_title_text( $title ) { |
|
407 | + public function change_title_text($title) { |
|
408 | 408 | $screen = get_current_screen(); |
409 | 409 | |
410 | - if ( 'project' === $screen->post_type ) { |
|
411 | - $title = esc_attr__( 'Enter project title', 'lsx-projects' ); |
|
410 | + if ('project' === $screen->post_type) { |
|
411 | + $title = esc_attr__('Enter project title', 'lsx-projects'); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return $title; |
@@ -13,48 +13,48 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -5,41 +5,41 @@ discard block |
||
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 ) ) { |
|
25 | - $client_logo = wp_get_attachment_image_src( $client_logo, 'full' ); |
|
24 | + if ( ! empty($client_logo)) { |
|
25 | + $client_logo = wp_get_attachment_image_src($client_logo, 'full'); |
|
26 | 26 | |
27 | - if ( is_array( $client_logo ) ) { |
|
27 | + if (is_array($client_logo)) { |
|
28 | 28 | $client_logo = '<img src="' . $client_logo[0] . '">'; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | 32 | $groups = ''; |
33 | - $terms = get_the_terms( get_the_ID(), 'project-group' ); |
|
33 | + $terms = get_the_terms(get_the_ID(), 'project-group'); |
|
34 | 34 | |
35 | - if ( $terms && ! is_wp_error( $terms ) ) { |
|
35 | + if ($terms && ! is_wp_error($terms)) { |
|
36 | 36 | $groups = array(); |
37 | 37 | |
38 | - foreach ( $terms as $term ) { |
|
39 | - $groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>'; |
|
38 | + foreach ($terms as $term) { |
|
39 | + $groups[] = '<a href="' . get_term_link($term) . '">' . $term->name . '</a>'; |
|
40 | 40 | } |
41 | 41 | |
42 | - $groups = join( ', ', $groups ); |
|
42 | + $groups = join(', ', $groups); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // Connections |
@@ -48,22 +48,22 @@ discard block |
||
48 | 48 | |
49 | 49 | // Connection Projects |
50 | 50 | |
51 | - if ( $terms && ! is_wp_error( $terms ) ) { |
|
51 | + if ($terms && ! is_wp_error($terms)) { |
|
52 | 52 | $groups_ = array(); |
53 | 53 | |
54 | - foreach ( $terms as $term ) { |
|
54 | + foreach ($terms as $term) { |
|
55 | 55 | $groups_[] = $term->term_id; |
56 | 56 | } |
57 | 57 | |
58 | - if ( count( $groups_ ) > 0 ) { |
|
58 | + if (count($groups_) > 0) { |
|
59 | 59 | $connection_project['post_type'] = 'project'; |
60 | - $connection_project['title'] = esc_html__( 'Related Projects', 'lsx-projects' ); |
|
60 | + $connection_project['title'] = esc_html__('Related Projects', 'lsx-projects'); |
|
61 | 61 | //$connection_project['posts'] = get_post_meta( get_the_ID(), 'project_to_project', false ); |
62 | 62 | $connection_project['posts'] = array(); |
63 | 63 | |
64 | 64 | $args = array( |
65 | 65 | 'post_type' => 'project', |
66 | - 'post__not_in' => array( get_the_ID() ), |
|
66 | + 'post__not_in' => array(get_the_ID()), |
|
67 | 67 | 'no_found_rows' => true, |
68 | 68 | 'ignore_sticky_posts' => 1, |
69 | 69 | 'update_post_meta_cache' => false, |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | ), |
76 | 76 | ); |
77 | 77 | |
78 | - $projects_ = new \WP_Query( $args ); |
|
78 | + $projects_ = new \WP_Query($args); |
|
79 | 79 | |
80 | - if ( $projects_->have_posts() ) { |
|
81 | - while ( $projects_->have_posts() ) { |
|
80 | + if ($projects_->have_posts()) { |
|
81 | + while ($projects_->have_posts()) { |
|
82 | 82 | $projects_->the_post(); |
83 | 83 | $connection_project['posts'][] = get_the_ID(); |
84 | 84 | wp_reset_postdata(); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if ( ! empty( $connection_project['posts'] ) ) { |
|
89 | - $post_ids = join( ',', $connection_project['posts'] ); |
|
88 | + if ( ! empty($connection_project['posts'])) { |
|
89 | + $post_ids = join(',', $connection_project['posts']); |
|
90 | 90 | $connection_project['shortcode'] = '[lsx_projects columns="3" include="' . $post_ids . '"]'; |
91 | 91 | $connections[] = $connection_project; |
92 | 92 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | |
96 | 96 | // Connection Products |
97 | 97 | |
98 | - if ( class_exists( 'WooCommerce' ) ) { |
|
98 | + if (class_exists('WooCommerce')) { |
|
99 | 99 | $connection_product['post_type'] = 'product'; |
100 | - $connection_product['title'] = esc_html__( 'Related Products', 'lsx-projects' ) . ' <small>' . esc_html__( 'Products used to build this project', 'lsx-projects' ) . '</small>'; |
|
101 | - $connection_product['posts'] = get_post_meta( get_the_ID(), 'product_to_project', false ); |
|
100 | + $connection_product['title'] = esc_html__('Related Products', 'lsx-projects') . ' <small>' . esc_html__('Products used to build this project', 'lsx-projects') . '</small>'; |
|
101 | + $connection_product['posts'] = get_post_meta(get_the_ID(), 'product_to_project', false); |
|
102 | 102 | |
103 | - if ( ! empty( $connection_product['posts'] ) ) { |
|
103 | + if ( ! empty($connection_product['posts'])) { |
|
104 | 104 | $connection_product['small_list_html'] = ''; |
105 | 105 | |
106 | 106 | $args = array( |
@@ -113,19 +113,19 @@ discard block |
||
113 | 113 | 'update_post_meta_cache' => false, |
114 | 114 | ); |
115 | 115 | |
116 | - $connection_product['posts_obj'] = new \WP_Query( $args ); |
|
116 | + $connection_product['posts_obj'] = new \WP_Query($args); |
|
117 | 117 | |
118 | - if ( $connection_product['posts_obj']->have_posts() ) { |
|
118 | + if ($connection_product['posts_obj']->have_posts()) { |
|
119 | 119 | $connection_product['small_list_html'] = array(); |
120 | 120 | |
121 | - while ( $connection_product['posts_obj']->have_posts() ) { |
|
121 | + while ($connection_product['posts_obj']->have_posts()) { |
|
122 | 122 | $connection_product['posts_obj']->the_post(); |
123 | - $connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>'; |
|
123 | + $connection_product['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title('', '', false) . '</a>'; |
|
124 | 124 | wp_reset_postdata(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | $connection_product['posts_obj']->rewind_posts(); |
128 | - $connection_product['small_list_html'] = join( ', ', $connection_product['small_list_html'] ); |
|
128 | + $connection_product['small_list_html'] = join(', ', $connection_product['small_list_html']); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $connections[] = $connection_product; |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | |
137 | 137 | $connection_service['post_type'] = 'page'; |
138 | 138 | // $connection_service['title'] = esc_html__( 'Services', 'lsx-projects' ); |
139 | - $connection_service['pages'] = get_post_meta( get_the_ID(), 'page_to_project', false ); |
|
139 | + $connection_service['pages'] = get_post_meta(get_the_ID(), 'page_to_project', false); |
|
140 | 140 | |
141 | - if ( ! empty( $connection_service['pages'] ) ) { |
|
142 | - $post_ids = join( ',', $connection_service['pages'] ); |
|
141 | + if ( ! empty($connection_service['pages'])) { |
|
142 | + $post_ids = join(',', $connection_service['pages']); |
|
143 | 143 | //$connection_service['shortcode'] = '[lsx_services columns="3" include="' . $post_ids . '"]'; |
144 | 144 | $connection_service['small_list_html'] = ''; |
145 | 145 | |
@@ -153,18 +153,18 @@ discard block |
||
153 | 153 | 'update_post_meta_cache' => false, |
154 | 154 | ); |
155 | 155 | |
156 | - $services_ = new \WP_Query( $args ); |
|
156 | + $services_ = new \WP_Query($args); |
|
157 | 157 | |
158 | - if ( $services_->have_posts() ) { |
|
158 | + if ($services_->have_posts()) { |
|
159 | 159 | $connection_service['small_list_html'] = array(); |
160 | 160 | |
161 | - while ( $services_->have_posts() ) { |
|
161 | + while ($services_->have_posts()) { |
|
162 | 162 | $services_->the_post(); |
163 | - $connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title( '', '', false ) . '</a>'; |
|
163 | + $connection_service['small_list_html'][] = '<a href="' . get_permalink() . '">' . the_title('', '', false) . '</a>'; |
|
164 | 164 | wp_reset_postdata(); |
165 | 165 | } |
166 | 166 | |
167 | - $connection_service['small_list_html'] = join( ', ', $connection_service['small_list_html'] ); |
|
167 | + $connection_service['small_list_html'] = join(', ', $connection_service['small_list_html']); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $connections[] = $connection_service; |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | |
175 | 175 | $connection_testimonial['post_type'] = 'testimonial'; |
176 | 176 | // $connection_testimonial['title'] = esc_html__( 'Testimonials', 'lsx-projects' ); |
177 | - $connection_testimonial['posts'] = get_post_meta( get_the_ID(), 'testimonial_to_project', false ); |
|
177 | + $connection_testimonial['posts'] = get_post_meta(get_the_ID(), 'testimonial_to_project', false); |
|
178 | 178 | |
179 | - if ( ! empty( $connection_testimonial['posts'] ) ) { |
|
180 | - $post_ids = join( ',', $connection_testimonial['posts'] ); |
|
179 | + if ( ! empty($connection_testimonial['posts'])) { |
|
180 | + $post_ids = join(',', $connection_testimonial['posts']); |
|
181 | 181 | $connection_testimonial['shortcode'] = '[lsx_testimonials columns="1" include="' . $post_ids . '" orderby="date" order="DESC"]'; |
182 | 182 | $connections[] = $connection_testimonial; |
183 | 183 | } |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | |
187 | 187 | $connection_team['post_type'] = 'team'; |
188 | 188 | // $connection_team['title'] = esc_html__( 'Team', 'lsx-projects' ); |
189 | - $connection_team['posts'] = get_post_meta( get_the_ID(), 'team_to_project', false ); |
|
189 | + $connection_team['posts'] = get_post_meta(get_the_ID(), 'team_to_project', false); |
|
190 | 190 | |
191 | - if ( ! empty( $connection_team['posts'] ) ) { |
|
192 | - $post_ids = join( ',', $connection_team['posts'] ); |
|
191 | + if ( ! empty($connection_team['posts'])) { |
|
192 | + $post_ids = join(',', $connection_team['posts']); |
|
193 | 193 | $connection_team['shortcode'] = '[lsx_team columns="4" include="' . $post_ids . '" show_social="false" show_desc="false" show_link="true"]'; |
194 | 194 | $connection_team['small_list_html'] = ''; |
195 | 195 | |
@@ -203,19 +203,19 @@ discard block |
||
203 | 203 | 'update_post_meta_cache' => false, |
204 | 204 | ); |
205 | 205 | |
206 | - $team_ = new \WP_Query( $args ); |
|
206 | + $team_ = new \WP_Query($args); |
|
207 | 207 | |
208 | - if ( $team_->have_posts() ) { |
|
208 | + if ($team_->have_posts()) { |
|
209 | 209 | global $lsx_team; |
210 | 210 | $connection_team['small_list_html'] = array(); |
211 | 211 | |
212 | - while ( $team_->have_posts() ) { |
|
212 | + while ($team_->have_posts()) { |
|
213 | 213 | $team_->the_post(); |
214 | - $connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail( get_the_ID(), 'lsx-team-archive' ) . '</a>'; |
|
214 | + $connection_team['small_list_html'][] = '<a href="' . get_permalink() . '">' . $lsx_team->get_thumbnail(get_the_ID(), 'lsx-team-archive') . '</a>'; |
|
215 | 215 | wp_reset_postdata(); |
216 | 216 | } |
217 | 217 | |
218 | - $connection_team['small_list_html'] = join( ' ', $connection_team['small_list_html'] ); |
|
218 | + $connection_team['small_list_html'] = join(' ', $connection_team['small_list_html']); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | $connections[] = $connection_team; |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | <div class="col-xs-12 col-sm-7 col-md-8"> |
233 | 233 | <div class="entry-content"><?php the_content(); ?></div> |
234 | 234 | |
235 | - <?php if ( count( $connections ) > 0 ) : ?> |
|
236 | - <?php foreach ( $connections as $i => $connection ) : ?> |
|
235 | + <?php if (count($connections) > 0) : ?> |
|
236 | + <?php foreach ($connections as $i => $connection) : ?> |
|
237 | 237 | <?php |
238 | - if ( 'testimonial' === $connection['post_type'] ) { |
|
238 | + if ('testimonial' === $connection['post_type']) { |
|
239 | 239 | echo '<div class="tab-pane-fake">'; |
240 | - echo do_shortcode( $connection['shortcode'] ); |
|
240 | + echo do_shortcode($connection['shortcode']); |
|
241 | 241 | echo '</div>'; |
242 | 242 | } |
243 | 243 | ?> |
@@ -248,83 +248,83 @@ discard block |
||
248 | 248 | <div class="col-xs-12 col-sm-5 col-md-4"> |
249 | 249 | <div class="entry-fixed-sidebar-wrapper"> |
250 | 250 | <div class="entry-fixed-sidebar"> |
251 | - <?php if ( ! empty( $client_logo ) ) : ?> |
|
252 | - <div class="entry-meta-single"><?php echo wp_kses_post( $client_logo ); ?></div> |
|
253 | - <?php elseif ( ! empty( $client ) ) : ?> |
|
254 | - <div class="entry-meta-single"><?php echo esc_html( $client ); ?></div> |
|
251 | + <?php if ( ! empty($client_logo)) : ?> |
|
252 | + <div class="entry-meta-single"><?php echo wp_kses_post($client_logo); ?></div> |
|
253 | + <?php elseif ( ! empty($client)) : ?> |
|
254 | + <div class="entry-meta-single"><?php echo esc_html($client); ?></div> |
|
255 | 255 | <?php endif; ?> |
256 | 256 | |
257 | - <?php if ( ! empty( $groups ) ) : ?> |
|
258 | - <div class="entry-meta-key"><?php esc_html_e( 'Industry:', 'lsx-projects' ); ?></div> |
|
259 | - <div class="entry-meta-value"><?php echo wp_kses_post( $groups ); ?></div> |
|
257 | + <?php if ( ! empty($groups)) : ?> |
|
258 | + <div class="entry-meta-key"><?php esc_html_e('Industry:', 'lsx-projects'); ?></div> |
|
259 | + <div class="entry-meta-value"><?php echo wp_kses_post($groups); ?></div> |
|
260 | 260 | <?php endif; ?> |
261 | 261 | |
262 | - <?php if ( ! empty( $connection_service['small_list_html'] ) ) : ?> |
|
263 | - <div class="entry-meta-key"><?php esc_html_e( 'Services:', 'lsx-projects' ); ?></div> |
|
264 | - <div class="entry-meta-value"><?php echo wp_kses_post( $connection_service['small_list_html'] ); ?></div> |
|
262 | + <?php if ( ! empty($connection_service['small_list_html'])) : ?> |
|
263 | + <div class="entry-meta-key"><?php esc_html_e('Services:', 'lsx-projects'); ?></div> |
|
264 | + <div class="entry-meta-value"><?php echo wp_kses_post($connection_service['small_list_html']); ?></div> |
|
265 | 265 | <?php endif; ?> |
266 | 266 | |
267 | - <?php if ( ! empty( $connection_product['small_list_html'] ) ) : ?> |
|
267 | + <?php if ( ! empty($connection_product['small_list_html'])) : ?> |
|
268 | 268 | <!-- |
269 | - <div class="entry-meta-key"><?php esc_html_e( 'Products used:', 'lsx-projects' ); ?></div> |
|
270 | - <div class="entry-meta-value"><?php echo wp_kses_post( $connection_product['small_list_html'] ); ?></div> |
|
269 | + <div class="entry-meta-key"><?php esc_html_e('Products used:', 'lsx-projects'); ?></div> |
|
270 | + <div class="entry-meta-value"><?php echo wp_kses_post($connection_product['small_list_html']); ?></div> |
|
271 | 271 | --> |
272 | 272 | <?php endif; ?> |
273 | 273 | |
274 | - <?php if ( ! empty( $connection_team['small_list_html'] ) ) : ?> |
|
275 | - <div class="entry-meta-key"><?php esc_html_e( 'Team members involved:', 'lsx-projects' ); ?></div> |
|
276 | - <div class="entry-meta-value entry-meta-value-team"><?php echo wp_kses_post( $connection_team['small_list_html'] ); ?></div> |
|
274 | + <?php if ( ! empty($connection_team['small_list_html'])) : ?> |
|
275 | + <div class="entry-meta-key"><?php esc_html_e('Team members involved:', 'lsx-projects'); ?></div> |
|
276 | + <div class="entry-meta-value entry-meta-value-team"><?php echo wp_kses_post($connection_team['small_list_html']); ?></div> |
|
277 | 277 | <?php endif; ?> |
278 | 278 | |
279 | - <?php if ( ! empty( $url ) ) : ?> |
|
280 | - <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> |
|
279 | + <?php if ( ! empty($url)) : ?> |
|
280 | + <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> |
|
281 | 281 | <?php endif; ?> |
282 | 282 | |
283 | - <?php if ( ! empty( $button_label ) ) : ?> |
|
284 | - <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> |
|
283 | + <?php if ( ! empty($button_label)) : ?> |
|
284 | + <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> |
|
285 | 285 | <?php endif; ?> |
286 | 286 | </div> |
287 | 287 | </div> |
288 | 288 | </div> |
289 | 289 | </div> |
290 | 290 | |
291 | - <?php if ( count( $connections ) > 0 ) : ?> |
|
292 | - <?php foreach ( $connections as $i => $connection ) : ?> |
|
291 | + <?php if (count($connections) > 0) : ?> |
|
292 | + <?php foreach ($connections as $i => $connection) : ?> |
|
293 | 293 | <?php |
294 | 294 | // Team is now visible on detail box |
295 | 295 | // Services is now visible on detail box |
296 | 296 | // Testimonials is now visible below the content |
297 | - if ( in_array( $connection['post_type'], array( 'team', 'testimonial', 'service' ) ) ) { |
|
297 | + if (in_array($connection['post_type'], array('team', 'testimonial', 'service'))) { |
|
298 | 298 | continue; |
299 | 299 | } |
300 | 300 | ?> |
301 | - <?php if ( 'page' !== $connection['post_type'] ) { ?> |
|
301 | + <?php if ('page' !== $connection['post_type']) { ?> |
|
302 | 302 | <div class="lsx-projects-section lsx-full-width"> |
303 | 303 | <div class="row"> |
304 | 304 | <div class="col-xs-12"> |
305 | - <h3 class="lsx-title"><?php echo wp_kses_post( $connection['title'] ); ?></h3> |
|
305 | + <h3 class="lsx-title"><?php echo wp_kses_post($connection['title']); ?></h3> |
|
306 | 306 | |
307 | 307 | <?php |
308 | - if ( 'product' === $connection['post_type'] ) { |
|
309 | - if ( $connection_product['posts_obj']->have_posts() ) { |
|
308 | + if ('product' === $connection['post_type']) { |
|
309 | + if ($connection_product['posts_obj']->have_posts()) { |
|
310 | 310 | // @codingStandardsIgnoreLine |
311 | - echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ); |
|
311 | + echo apply_filters('woocommerce_before_widget_product_list', '<ul class="product_list_widget">'); |
|
312 | 312 | |
313 | - while ( $connection_product['posts_obj']->have_posts() ) { |
|
313 | + while ($connection_product['posts_obj']->have_posts()) { |
|
314 | 314 | $connection_product['posts_obj']->the_post(); |
315 | 315 | |
316 | - wc_get_template( 'content-widget-product.php', array( |
|
316 | + wc_get_template('content-widget-product.php', array( |
|
317 | 317 | 'show_rating' => false, |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | |
320 | 320 | wp_reset_postdata(); |
321 | 321 | } |
322 | 322 | |
323 | 323 | // @codingStandardsIgnoreLine |
324 | - echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ); |
|
324 | + echo apply_filters('woocommerce_after_widget_product_list', '</ul>'); |
|
325 | 325 | } |
326 | 326 | } else { |
327 | - echo do_shortcode( $connection['shortcode'] ); |
|
327 | + echo do_shortcode($connection['shortcode']); |
|
328 | 328 | } |
329 | 329 | ?> |
330 | 330 | </div> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Class MAG_CMB2_Field_Post_Search_Ajax |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! class_exists( 'MAG_CMB2_Field_Post_Search_Ajax' ) ) { |
|
6 | +if ( ! class_exists('MAG_CMB2_Field_Post_Search_Ajax')) { |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * The LSX Post Search Field |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * Initialize the plugin by hooking into CMB2 |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_action( 'cmb2_render_post_search_ajax', array( $this, 'render' ), 10, 5 ); |
|
39 | - add_action( 'cmb2_sanitize_post_search_ajax', array( $this, 'sanitize' ), 10, 4 ); |
|
40 | - add_action( 'wp_ajax_cmb_post_search_ajax_get_results', array( $this, 'cmb_post_search_ajax_get_results' ) ); |
|
38 | + add_action('cmb2_render_post_search_ajax', array($this, 'render'), 10, 5); |
|
39 | + add_action('cmb2_sanitize_post_search_ajax', array($this, 'sanitize'), 10, 4); |
|
40 | + add_action('wp_ajax_cmb_post_search_ajax_get_results', array($this, 'cmb_post_search_ajax_get_results')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public static function get_instance() { |
51 | 51 | // If the single instance hasn't been set, set it now. |
52 | - if ( null === self::$instance ) { |
|
52 | + if (null === self::$instance) { |
|
53 | 53 | self::$instance = new self(); |
54 | 54 | } |
55 | 55 | return self::$instance; |
@@ -58,29 +58,29 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * Render field |
60 | 60 | */ |
61 | - public function render( $field, $value, $object_id, $object_type, $field_type ) { |
|
61 | + public function render($field, $value, $object_id, $object_type, $field_type) { |
|
62 | 62 | $this->setup_admin_scripts(); |
63 | 63 | $field_name = $field->_name(); |
64 | 64 | |
65 | - if ( $field->args( 'limit' ) > 1 ) { |
|
65 | + if ($field->args('limit') > 1) { |
|
66 | 66 | |
67 | 67 | echo '<ul class="cmb-post-search-ajax-results" id="' . $field_name . '_results">'; |
68 | - if ( isset( $value ) && ! empty( $value ) ) { |
|
69 | - if ( ! is_array( $value ) ) { |
|
70 | - $value = array( $value ); |
|
68 | + if (isset($value) && ! empty($value)) { |
|
69 | + if ( ! is_array($value)) { |
|
70 | + $value = array($value); |
|
71 | 71 | } |
72 | - $value = array_unique( $value ); |
|
73 | - foreach ( $value as $val ) { |
|
74 | - $handle = ( $field->args( 'sortable' ) ) ? '<span class="hndl"></span>' : ''; |
|
72 | + $value = array_unique($value); |
|
73 | + foreach ($value as $val) { |
|
74 | + $handle = ($field->args('sortable')) ? '<span class="hndl"></span>' : ''; |
|
75 | 75 | $li_css = ''; |
76 | - if ( $field->args( 'object_type' ) == 'user' ) { |
|
77 | - $guid = get_edit_user_link( $val ); |
|
78 | - $user = get_userdata( $val ); |
|
76 | + if ($field->args('object_type') == 'user') { |
|
77 | + $guid = get_edit_user_link($val); |
|
78 | + $user = get_userdata($val); |
|
79 | 79 | $title = $user->display_name; |
80 | 80 | } else { |
81 | - $guid = get_edit_post_link( $val ); |
|
82 | - $title = get_the_title( $val ); |
|
83 | - if ( 'trash' === get_post_status( $val ) ) { |
|
81 | + $guid = get_edit_post_link($val); |
|
82 | + $title = get_the_title($val); |
|
83 | + if ('trash' === get_post_status($val)) { |
|
84 | 84 | $li_css = 'display:none;'; |
85 | 85 | } |
86 | 86 | } |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | echo '</ul>'; |
91 | 91 | $field_value = ''; |
92 | 92 | } else { |
93 | - if ( is_array( $value ) ) { |
|
93 | + if (is_array($value)) { |
|
94 | 94 | $value = $value[0]; |
95 | 95 | } |
96 | - if ( $field->args( 'object_type' ) == 'user' ) { |
|
97 | - $field_value = ( $value ? get_userdata( $value )->display_name : '' ); |
|
96 | + if ($field->args('object_type') == 'user') { |
|
97 | + $field_value = ($value ? get_userdata($value)->display_name : ''); |
|
98 | 98 | } else { |
99 | - $field_value = ( $value ? get_the_title( $value ) : '' ); |
|
99 | + $field_value = ($value ? get_the_title($value) : ''); |
|
100 | 100 | } |
101 | 101 | echo $field_type->input( |
102 | 102 | array( |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | 'desc' => false, |
107 | 107 | ) |
108 | 108 | ); |
109 | - if ( isset( $field->group ) ) { |
|
110 | - $store_name = str_replace( '][', '_', $field_name ); |
|
111 | - $store_name = str_replace( ']', '', $store_name ); |
|
112 | - $store_name = str_replace( '[', '_', $store_name ); |
|
109 | + if (isset($field->group)) { |
|
110 | + $store_name = str_replace('][', '_', $field_name); |
|
111 | + $store_name = str_replace(']', '', $store_name); |
|
112 | + $store_name = str_replace('[', '_', $store_name); |
|
113 | 113 | |
114 | 114 | echo $field_type->input( |
115 | 115 | array( |
@@ -132,59 +132,59 @@ discard block |
||
132 | 132 | 'class' => 'cmb-post-search-ajax', |
133 | 133 | 'value' => $field_value, |
134 | 134 | 'desc' => false, |
135 | - 'data-limit' => $field->args( 'limit' ) ? $field->args( 'limit' ) : '1', |
|
136 | - 'data-sortable' => $field->args( 'sortable' ) ? $field->args( 'sortable' ) : '0', |
|
137 | - 'data-object' => $field->args( 'object_type' ) ? $field->args( 'object_type' ) : 'post', |
|
138 | - 'data-queryargs'=> $field->args( 'query_args' ) ? htmlspecialchars( json_encode( $field->args( 'query_args' ) ), ENT_QUOTES, 'UTF-8' ) : '' |
|
135 | + 'data-limit' => $field->args('limit') ? $field->args('limit') : '1', |
|
136 | + 'data-sortable' => $field->args('sortable') ? $field->args('sortable') : '0', |
|
137 | + 'data-object' => $field->args('object_type') ? $field->args('object_type') : 'post', |
|
138 | + 'data-queryargs'=> $field->args('query_args') ? htmlspecialchars(json_encode($field->args('query_args')), ENT_QUOTES, 'UTF-8') : '' |
|
139 | 139 | ) |
140 | 140 | ); |
141 | 141 | |
142 | - echo '<img src="' . admin_url( 'images/spinner.gif' ) . '" class="cmb-post-search-ajax-spinner" />'; |
|
142 | + echo '<img src="' . admin_url('images/spinner.gif') . '" class="cmb-post-search-ajax-spinner" />'; |
|
143 | 143 | |
144 | - $field_type->_desc( true, true ); |
|
144 | + $field_type->_desc(true, true); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Optionally save the latitude/longitude values into two custom fields |
150 | 150 | */ |
151 | - public function sanitize( $override_value, $value, $object_id, $field_args ) { |
|
151 | + public function sanitize($override_value, $value, $object_id, $field_args) { |
|
152 | 152 | $fid = ''; |
153 | - if ( isset( $field_args['id'] ) ) { |
|
153 | + if (isset($field_args['id'])) { |
|
154 | 154 | $fid = $field_args['id']; |
155 | 155 | } |
156 | 156 | |
157 | 157 | // IF the field is in a repeatable group, then get the info from the post data. |
158 | - if ( isset( $field_args['render_row_cb'][0]->group ) && ! empty( $field_args['render_row_cb'][0]->group ) ) { |
|
158 | + if (isset($field_args['render_row_cb'][0]->group) && ! empty($field_args['render_row_cb'][0]->group)) { |
|
159 | 159 | $new_index = ''; |
160 | 160 | |
161 | 161 | $data_to_save = $field_args['render_row_cb'][0]->group->args['render_row_cb'][0]->data_to_save; |
162 | 162 | $oid = $field_args['_name']; |
163 | 163 | $iid = $field_args['_id']; |
164 | - $oid = explode( '[', $oid ); |
|
165 | - if ( is_array( $oid ) ) { |
|
164 | + $oid = explode('[', $oid); |
|
165 | + if (is_array($oid)) { |
|
166 | 166 | $oid = $oid[0]; |
167 | 167 | } |
168 | 168 | |
169 | - if ( isset( $data_to_save[ $oid ] ) && ! empty( $data_to_save[ $oid ] ) ) { |
|
170 | - foreach( $data_to_save[ $oid ] as $index => $svalues ) { |
|
171 | - if ( isset( $svalues[ $iid ] ) && $value === $svalues[ $iid ] ) { |
|
169 | + if (isset($data_to_save[$oid]) && ! empty($data_to_save[$oid])) { |
|
170 | + foreach ($data_to_save[$oid] as $index => $svalues) { |
|
171 | + if (isset($svalues[$iid]) && $value === $svalues[$iid]) { |
|
172 | 172 | $new_index = $index; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - if ( '' !== $new_index ) { |
|
177 | + if ('' !== $new_index) { |
|
178 | 178 | $new_index = $oid . '_' . $new_index . '_' . $iid . '_store'; |
179 | 179 | |
180 | - if ( ! empty( $data_to_save[ $new_index ] ) ) { |
|
181 | - $value = $data_to_save[ $new_index ]; |
|
180 | + if ( ! empty($data_to_save[$new_index])) { |
|
181 | + $value = $data_to_save[$new_index]; |
|
182 | 182 | } |
183 | 183 | } else { |
184 | 184 | $value = false; |
185 | 185 | } |
186 | - } else if ( ! empty( $field_args['render_row_cb'][0]->data_to_save[ $fid . '_results' ] ) ) { |
|
187 | - $value = $field_args['render_row_cb'][0]->data_to_save[ $fid . '_results' ]; |
|
186 | + } else if ( ! empty($field_args['render_row_cb'][0]->data_to_save[$fid . '_results'])) { |
|
187 | + $value = $field_args['render_row_cb'][0]->data_to_save[$fid . '_results']; |
|
188 | 188 | } else { |
189 | 189 | $value = false; |
190 | 190 | } |
@@ -196,25 +196,25 @@ discard block |
||
196 | 196 | * Defines the url which is used to load local resources. Based on, and uses, |
197 | 197 | * the CMB2_Utils class from the CMB2 library. |
198 | 198 | */ |
199 | - public static function url( $path = '' ) { |
|
200 | - if ( self::$url ) { |
|
199 | + public static function url($path = '') { |
|
200 | + if (self::$url) { |
|
201 | 201 | return self::$url . $path; |
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | 205 | * Set the variable cmb2_fpsa_dir |
206 | 206 | */ |
207 | - $cmb2_fpsa_dir = trailingslashit( dirname( __FILE__ ) ); |
|
207 | + $cmb2_fpsa_dir = trailingslashit(dirname(__FILE__)); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * Use CMB2_Utils to gather the url from cmb2_fpsa_dir |
211 | 211 | */ |
212 | - $cmb2_fpsa_url = CMB2_Utils::get_url_from_dir( $cmb2_fpsa_dir ); |
|
212 | + $cmb2_fpsa_url = CMB2_Utils::get_url_from_dir($cmb2_fpsa_dir); |
|
213 | 213 | |
214 | 214 | /** |
215 | 215 | * Filter the CMB2 FPSA location url |
216 | 216 | */ |
217 | - self::$url = trailingslashit( apply_filters( 'cmb2_fpsa_url', $cmb2_fpsa_url, self::VERSION ) ); |
|
217 | + self::$url = trailingslashit(apply_filters('cmb2_fpsa_url', $cmb2_fpsa_url, self::VERSION)); |
|
218 | 218 | |
219 | 219 | return self::$url . $path; |
220 | 220 | } |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function setup_admin_scripts() { |
226 | 226 | |
227 | - wp_register_script( 'jquery-devautocomplete', self::url( 'js/jquery.autocomplete.min.js' ), array( 'jquery' ), self::VERSION ); |
|
228 | - wp_register_script( 'mag-post-search-ajax', self::url( 'js/mag-post-search-ajax.js' ), array( 'jquery', 'jquery-devautocomplete', 'jquery-ui-sortable' ), self::VERSION ); |
|
229 | - wp_localize_script( 'mag-post-search-ajax', 'psa', array( |
|
230 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
231 | - 'nonce' => wp_create_nonce( 'mag_cmb_post_search_ajax_get_results' ) |
|
232 | - ) ); |
|
233 | - wp_enqueue_script( 'mag-post-search-ajax' ); |
|
234 | - wp_enqueue_style( 'mag-post-search-ajax', self::url( 'css/mag-post-search-ajax.css' ), array(), self::VERSION ); |
|
227 | + wp_register_script('jquery-devautocomplete', self::url('js/jquery.autocomplete.min.js'), array('jquery'), self::VERSION); |
|
228 | + wp_register_script('mag-post-search-ajax', self::url('js/mag-post-search-ajax.js'), array('jquery', 'jquery-devautocomplete', 'jquery-ui-sortable'), self::VERSION); |
|
229 | + wp_localize_script('mag-post-search-ajax', 'psa', array( |
|
230 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
231 | + 'nonce' => wp_create_nonce('mag_cmb_post_search_ajax_get_results') |
|
232 | + )); |
|
233 | + wp_enqueue_script('mag-post-search-ajax'); |
|
234 | + wp_enqueue_style('mag-post-search-ajax', self::url('css/mag-post-search-ajax.css'), array(), self::VERSION); |
|
235 | 235 | |
236 | 236 | } |
237 | 237 | |
@@ -239,45 +239,45 @@ discard block |
||
239 | 239 | * Ajax request : get results |
240 | 240 | */ |
241 | 241 | public function cmb_post_search_ajax_get_results() { |
242 | - $nonce = sanitize_text_field( $_POST['psacheck'] ); |
|
243 | - if ( ! wp_verify_nonce( $nonce, 'mag_cmb_post_search_ajax_get_results' ) ) { |
|
244 | - die( json_encode( array( 'error' => __( 'Error : Unauthorized action' ) ) ) ); |
|
242 | + $nonce = sanitize_text_field($_POST['psacheck']); |
|
243 | + if ( ! wp_verify_nonce($nonce, 'mag_cmb_post_search_ajax_get_results')) { |
|
244 | + die(json_encode(array('error' => __('Error : Unauthorized action')))); |
|
245 | 245 | } else { |
246 | - $args = json_decode( stripslashes( htmlspecialchars_decode( sanitize_text_field( $_POST['query_args'] ) ) ), true ); |
|
247 | - $args['s'] = sanitize_text_field( $_POST['query'] ); |
|
246 | + $args = json_decode(stripslashes(htmlspecialchars_decode(sanitize_text_field($_POST['query_args']))), true); |
|
247 | + $args['s'] = sanitize_text_field($_POST['query']); |
|
248 | 248 | $datas = array(); |
249 | - if ( $_POST['object'] == 'user' ) { |
|
249 | + if ($_POST['object'] == 'user') { |
|
250 | 250 | |
251 | - $args['search'] = '*' . esc_attr( sanitize_text_field( $_POST['query'] ) ) . '*'; |
|
252 | - $users = new WP_User_Query( $args ); |
|
251 | + $args['search'] = '*' . esc_attr(sanitize_text_field($_POST['query'])) . '*'; |
|
252 | + $users = new WP_User_Query($args); |
|
253 | 253 | $results = $users->get_results(); |
254 | 254 | |
255 | - if ( ! empty( $results ) ) { |
|
256 | - foreach ( $results as $result ){ |
|
257 | - $user_info = get_userdata( $result->ID ); |
|
255 | + if ( ! empty($results)) { |
|
256 | + foreach ($results as $result) { |
|
257 | + $user_info = get_userdata($result->ID); |
|
258 | 258 | // Define filter "mag_cmb_post_search_ajax_result" to allow customize ajax results. |
259 | - $datas[] = apply_filters( 'mag_cmb_post_search_ajax_result', array( |
|
259 | + $datas[] = apply_filters('mag_cmb_post_search_ajax_result', array( |
|
260 | 260 | 'value' => $user_info->display_name, |
261 | 261 | 'data' => $result->ID, |
262 | - 'guid' => get_edit_user_link( $result->ID ), |
|
263 | - ) ); |
|
262 | + 'guid' => get_edit_user_link($result->ID), |
|
263 | + )); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } else { |
267 | - $results = new WP_Query( $args ); |
|
268 | - if ( $results->have_posts() ) : |
|
269 | - while ( $results->have_posts() ) : $results->the_post(); |
|
267 | + $results = new WP_Query($args); |
|
268 | + if ($results->have_posts()) : |
|
269 | + while ($results->have_posts()) : $results->the_post(); |
|
270 | 270 | // Define filter "mag_cmb_post_search_ajax_result" to allow customize ajax results. |
271 | - $datas[] = apply_filters( 'mag_cmb_post_search_ajax_result', array( |
|
271 | + $datas[] = apply_filters('mag_cmb_post_search_ajax_result', array( |
|
272 | 272 | 'value' => get_the_title() . ' - ' . '#' . get_the_ID(), |
273 | 273 | 'data' => get_the_ID(), |
274 | 274 | 'guid' => get_edit_post_link(), |
275 | - ) ); |
|
275 | + )); |
|
276 | 276 | endwhile; |
277 | 277 | endif; |
278 | 278 | } |
279 | 279 | wp_reset_postdata(); |
280 | - die( json_encode( $datas ) ); |
|
280 | + die(json_encode($datas)); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | } |
@@ -29,7 +29,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |