@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | // If this file is called directly, abort. |
16 | 16 | if ( ! defined( 'WPINC' ) ) { |
17 | - die; |
|
17 | + die; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | define( 'LSX_PROJECTS_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -5,23 +5,23 @@ discard block |
||
5 | 5 | ?> |
6 | 6 | |
7 | 7 | <?php |
8 | - $groups = ''; |
|
9 | - $groups_class = ''; |
|
10 | - $terms = get_the_terms( get_the_ID(), 'project-group' ); |
|
11 | - $lsx_projects_frontend = projects_get_options(); |
|
12 | - |
|
13 | - if ( $terms && ! is_wp_error( $terms ) ) { |
|
14 | - $groups = array(); |
|
15 | - $groups_class = array(); |
|
16 | - |
|
17 | - foreach ( $terms as $term ) { |
|
18 | - $groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>'; |
|
19 | - $groups_class[] = 'filter-' . $term->slug; |
|
20 | - } |
|
21 | - |
|
22 | - $groups = join( ', ', $groups ); |
|
23 | - $groups_class = join( ' ', $groups_class ); |
|
24 | - } |
|
8 | + $groups = ''; |
|
9 | + $groups_class = ''; |
|
10 | + $terms = get_the_terms( get_the_ID(), 'project-group' ); |
|
11 | + $lsx_projects_frontend = projects_get_options(); |
|
12 | + |
|
13 | + if ( $terms && ! is_wp_error( $terms ) ) { |
|
14 | + $groups = array(); |
|
15 | + $groups_class = array(); |
|
16 | + |
|
17 | + foreach ( $terms as $term ) { |
|
18 | + $groups[] = '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>'; |
|
19 | + $groups_class[] = 'filter-' . $term->slug; |
|
20 | + } |
|
21 | + |
|
22 | + $groups = join( ', ', $groups ); |
|
23 | + $groups_class = join( ' ', $groups_class ); |
|
24 | + } |
|
25 | 25 | ?> |
26 | 26 | |
27 | 27 | <div class="col-xs-12 col-sm-6 col-md-4 lsx-projects-column <?php echo esc_attr( $groups_class ); ?>"> |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | <?php } ?> |
36 | 36 | |
37 | 37 | <?php |
38 | - if ( empty( lsx_get_thumbnail( 'lsx-thumbnail-single' ) ) ) { |
|
39 | - if ( ! empty( projects_get_option( 'projects_placeholder' ) ) ) { |
|
40 | - echo wp_kses_post( '<img src="' . projects_get_option( 'projects_placeholder' ) . '" width="auto" alt="placeholder" />' ); |
|
41 | - } |
|
42 | - } |
|
43 | - ?> |
|
38 | + if ( empty( lsx_get_thumbnail( 'lsx-thumbnail-single' ) ) ) { |
|
39 | + if ( ! empty( projects_get_option( 'projects_placeholder' ) ) ) { |
|
40 | + echo wp_kses_post( '<img src="' . projects_get_option( 'projects_placeholder' ) . '" width="auto" alt="placeholder" />' ); |
|
41 | + } |
|
42 | + } |
|
43 | + ?> |
|
44 | 44 | |
45 | 45 | <h5 class="lsx-projects-title"> |
46 | 46 | <?php if ( 'on' !== projects_get_option( 'projects_disable_single', false ) ) { ?> |
@@ -11,186 +11,186 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class Settings_Theme { |
13 | 13 | |
14 | - /** |
|
15 | - * Holds class instance |
|
16 | - * |
|
17 | - * @since 1.0.0 |
|
18 | - * |
|
19 | - * @var object \lsx\projects\classes\admin\Settings_Theme() |
|
20 | - */ |
|
21 | - protected static $instance = null; |
|
14 | + /** |
|
15 | + * Holds class instance |
|
16 | + * |
|
17 | + * @since 1.0.0 |
|
18 | + * |
|
19 | + * @var object \lsx\projects\classes\admin\Settings_Theme() |
|
20 | + */ |
|
21 | + protected static $instance = null; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Will return true if this is the LSX projects settings page. |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - public $is_options_page = false; |
|
23 | + /** |
|
24 | + * Will return true if this is the LSX projects settings page. |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + public $is_options_page = false; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Holds the id and labels for the navigation. |
|
32 | - * |
|
33 | - * @var array |
|
34 | - */ |
|
35 | - public $navigation = array(); |
|
30 | + /** |
|
31 | + * Holds the id and labels for the navigation. |
|
32 | + * |
|
33 | + * @var array |
|
34 | + */ |
|
35 | + public $navigation = array(); |
|
36 | 36 | |
37 | - /** |
|
38 | - * Contructor |
|
39 | - */ |
|
40 | - public function __construct() { |
|
41 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
42 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
43 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
44 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
45 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
46 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
47 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
48 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
49 | - } |
|
37 | + /** |
|
38 | + * Contructor |
|
39 | + */ |
|
40 | + public function __construct() { |
|
41 | + add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
42 | + add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
43 | + add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
44 | + add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
45 | + add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
46 | + add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
47 | + add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
48 | + add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Return an instance of this class. |
|
53 | - * |
|
54 | - * @since 1.0.0 |
|
55 | - * |
|
56 | - * @return object \lsx\projects\classes\admin\Settings_Theme() A single instance of this class. |
|
57 | - */ |
|
58 | - public static function get_instance() { |
|
59 | - // If the single instance hasn't been set, set it now. |
|
60 | - if ( null == self::$instance ) { |
|
61 | - self::$instance = new self(); |
|
62 | - } |
|
63 | - return self::$instance; |
|
64 | - } |
|
51 | + /** |
|
52 | + * Return an instance of this class. |
|
53 | + * |
|
54 | + * @since 1.0.0 |
|
55 | + * |
|
56 | + * @return object \lsx\projects\classes\admin\Settings_Theme() A single instance of this class. |
|
57 | + */ |
|
58 | + public static function get_instance() { |
|
59 | + // If the single instance hasn't been set, set it now. |
|
60 | + if ( null == self::$instance ) { |
|
61 | + self::$instance = new self(); |
|
62 | + } |
|
63 | + return self::$instance; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Disable CMB2 styles on front end forms. |
|
68 | - * |
|
69 | - * @return bool $enabled Whether to enable (enqueue) styles. |
|
70 | - */ |
|
71 | - public function disable_cmb2_styles( $enabled ) { |
|
72 | - if ( is_admin() ) { |
|
73 | - $current_screen = get_current_screen(); |
|
74 | - if ( is_object( $current_screen ) && 'project_page_lsx_projects_options' === $current_screen->id ) { |
|
75 | - $enabled = false; |
|
76 | - } |
|
77 | - } |
|
78 | - return $enabled; |
|
79 | - } |
|
66 | + /** |
|
67 | + * Disable CMB2 styles on front end forms. |
|
68 | + * |
|
69 | + * @return bool $enabled Whether to enable (enqueue) styles. |
|
70 | + */ |
|
71 | + public function disable_cmb2_styles( $enabled ) { |
|
72 | + if ( is_admin() ) { |
|
73 | + $current_screen = get_current_screen(); |
|
74 | + if ( is_object( $current_screen ) && 'project_page_lsx_projects_options' === $current_screen->id ) { |
|
75 | + $enabled = false; |
|
76 | + } |
|
77 | + } |
|
78 | + return $enabled; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Generates the tabbed navigation for the settings page. |
|
83 | - * |
|
84 | - * @param string $cmb_id |
|
85 | - * @param string $object_id |
|
86 | - * @param string $object_type |
|
87 | - * @param object $cmb2_obj |
|
88 | - * @return void |
|
89 | - */ |
|
90 | - public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
91 | - if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) { |
|
92 | - $this->navigation = array(); |
|
93 | - $this->is_options_page = true; |
|
94 | - if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
95 | - foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
96 | - if ( 'title' === $field['type'] ) { |
|
97 | - $this->navigation[ $field_index ] = $field['name']; |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
101 | - $this->output_navigation(); |
|
102 | - } |
|
103 | - } |
|
81 | + /** |
|
82 | + * Generates the tabbed navigation for the settings page. |
|
83 | + * |
|
84 | + * @param string $cmb_id |
|
85 | + * @param string $object_id |
|
86 | + * @param string $object_type |
|
87 | + * @param object $cmb2_obj |
|
88 | + * @return void |
|
89 | + */ |
|
90 | + public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
91 | + if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) { |
|
92 | + $this->navigation = array(); |
|
93 | + $this->is_options_page = true; |
|
94 | + if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
95 | + foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
96 | + if ( 'title' === $field['type'] ) { |
|
97 | + $this->navigation[ $field_index ] = $field['name']; |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | + $this->output_navigation(); |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Outputs the WP style navigation for the Settings page. |
|
107 | - * |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - public function output_navigation() { |
|
111 | - if ( ! empty( $this->navigation ) ) { |
|
112 | - ?> |
|
105 | + /** |
|
106 | + * Outputs the WP style navigation for the Settings page. |
|
107 | + * |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + public function output_navigation() { |
|
111 | + if ( ! empty( $this->navigation ) ) { |
|
112 | + ?> |
|
113 | 113 | <div class="wp-filter hide-if-no-js"> |
114 | 114 | <ul class="filter-links"> |
115 | 115 | <?php |
116 | - $first_tab = true; |
|
117 | - $total = count( $this->navigation ); |
|
118 | - $count = 0; |
|
119 | - $separator = ' |'; |
|
120 | - $selected_tab = ''; |
|
121 | - if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
122 | - $selected_tab = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) ); |
|
123 | - $selected_tab = 'settings_' . $selected_tab; |
|
124 | - } |
|
125 | - foreach ( $this->navigation as $key => $label ) { |
|
126 | - $count++; |
|
127 | - $current_css = ''; |
|
128 | - if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
129 | - $first_tab = false; |
|
130 | - $current_css = 'current'; |
|
131 | - } |
|
132 | - if ( $count === $total ) { |
|
133 | - $separator = ''; |
|
134 | - } |
|
135 | - ?> |
|
116 | + $first_tab = true; |
|
117 | + $total = count( $this->navigation ); |
|
118 | + $count = 0; |
|
119 | + $separator = ' |'; |
|
120 | + $selected_tab = ''; |
|
121 | + if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
122 | + $selected_tab = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) ); |
|
123 | + $selected_tab = 'settings_' . $selected_tab; |
|
124 | + } |
|
125 | + foreach ( $this->navigation as $key => $label ) { |
|
126 | + $count++; |
|
127 | + $current_css = ''; |
|
128 | + if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
129 | + $first_tab = false; |
|
130 | + $current_css = 'current'; |
|
131 | + } |
|
132 | + if ( $count === $total ) { |
|
133 | + $separator = ''; |
|
134 | + } |
|
135 | + ?> |
|
136 | 136 | <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li> |
137 | 137 | <?php |
138 | - } |
|
139 | - ?> |
|
138 | + } |
|
139 | + ?> |
|
140 | 140 | </ul> |
141 | 141 | </div> |
142 | 142 | <?php |
143 | - } |
|
144 | - } |
|
143 | + } |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * Outputs the opening tab div. |
|
148 | - * |
|
149 | - * @param object $field CMB2_Field(); |
|
150 | - * @return void |
|
151 | - */ |
|
152 | - public function output_tab_open_div( $field ) { |
|
153 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
154 | - ?> |
|
146 | + /** |
|
147 | + * Outputs the opening tab div. |
|
148 | + * |
|
149 | + * @param object $field CMB2_Field(); |
|
150 | + * @return void |
|
151 | + */ |
|
152 | + public function output_tab_open_div( $field ) { |
|
153 | + if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
154 | + ?> |
|
155 | 155 | <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden"> |
156 | 156 | <?php |
157 | - } |
|
158 | - } |
|
157 | + } |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * Outputs the opening closing div. |
|
162 | - * |
|
163 | - * @param object $field CMB2_Field(); |
|
164 | - * @return void |
|
165 | - */ |
|
166 | - public function output_tab_closing_div( $field ) { |
|
167 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
168 | - ?> |
|
160 | + /** |
|
161 | + * Outputs the opening closing div. |
|
162 | + * |
|
163 | + * @param object $field CMB2_Field(); |
|
164 | + * @return void |
|
165 | + */ |
|
166 | + public function output_tab_closing_div( $field ) { |
|
167 | + if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
168 | + ?> |
|
169 | 169 | </div> |
170 | 170 | <?php |
171 | - } |
|
172 | - } |
|
171 | + } |
|
172 | + } |
|
173 | 173 | |
174 | - public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
175 | - return; |
|
176 | - } |
|
174 | + public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
175 | + return; |
|
176 | + } |
|
177 | 177 | |
178 | - public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
179 | - return ''; |
|
180 | - } |
|
178 | + public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
179 | + return ''; |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * Outputs the Script for the tabbed navigation. |
|
184 | - * |
|
185 | - * @param string $cmb_id |
|
186 | - * @param string $object_id |
|
187 | - * @param string $object_type |
|
188 | - * @param object $cmb2_obj |
|
189 | - * @return void |
|
190 | - */ |
|
191 | - public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
192 | - if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) { |
|
193 | - ?> |
|
182 | + /** |
|
183 | + * Outputs the Script for the tabbed navigation. |
|
184 | + * |
|
185 | + * @param string $cmb_id |
|
186 | + * @param string $object_id |
|
187 | + * @param string $object_type |
|
188 | + * @param object $cmb2_obj |
|
189 | + * @return void |
|
190 | + */ |
|
191 | + public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
192 | + if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) { |
|
193 | + ?> |
|
194 | 194 | <script> |
195 | 195 | var LSX_PROJECTS_CMB2 = Object.create( null ); |
196 | 196 | |
@@ -262,25 +262,25 @@ discard block |
||
262 | 262 | } )( jQuery, window, document ); |
263 | 263 | </script> |
264 | 264 | <?php |
265 | - } |
|
266 | - } |
|
265 | + } |
|
266 | + } |
|
267 | 267 | |
268 | - /** |
|
269 | - * This will add the tab selection to the url. |
|
270 | - * |
|
271 | - * @param string $url |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - public function add_tab_argument( $url ) { |
|
275 | - if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
276 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
277 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
278 | - if ( 'single' !== $tab_selection ) { |
|
279 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
280 | - } else { |
|
281 | - $url = remove_query_arg( 'cmb_tab', $url ); |
|
282 | - } |
|
283 | - } |
|
284 | - return $url; |
|
285 | - } |
|
268 | + /** |
|
269 | + * This will add the tab selection to the url. |
|
270 | + * |
|
271 | + * @param string $url |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + public function add_tab_argument( $url ) { |
|
275 | + if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
276 | + $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
277 | + $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
278 | + if ( 'single' !== $tab_selection ) { |
|
279 | + $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
280 | + } else { |
|
281 | + $url = remove_query_arg( 'cmb_tab', $url ); |
|
282 | + } |
|
283 | + } |
|
284 | + return $url; |
|
285 | + } |
|
286 | 286 | } |