179 /* Add options 'post_type_name' */ |
200 /* Add options 'post_type_name' */ |
180 if ( ! isset( $prtfl_options['post_type_name'] ) ) { |
201 if ( ! isset( $prtfl_options['post_type_name'] ) ) { |
181 $option_defaults['post_type_name'] = 'bws-portfolio'; |
202 $option_defaults['post_type_name'] = 'bws-portfolio'; |
182 } |
203 } |
183 |
204 |
184 $prtfl_options = array_merge( $option_defaults, $prtfl_options ); |
205 $prtfl_options = array_merge( $option_defaults, $prtfl_options ); |
185 $prtfl_options['plugin_option_version'] = $option_defaults['plugin_option_version']; |
206 $prtfl_options['plugin_option_version'] = $option_defaults['plugin_option_version']; |
186 /* show pro features */ |
207 /* show pro features */ |
187 $prtfl_options['hide_premium_options'] = array(); |
208 $prtfl_options['hide_premium_options'] = array(); |
188 |
209 |
189 update_option( 'prtfl_options', $prtfl_options ); |
210 update_option( 'prtfl_options', $prtfl_options ); |
190 } |
211 } |
191 |
212 |
192 if ( function_exists( 'add_image_size' ) ) { |
213 if ( function_exists( 'add_image_size' ) ) { |
193 if ( 'portfolio-thumb' == $prtfl_options['image_size_album'] ) { |
214 if ( 'portfolio-thumb' === $prtfl_options['image_size_album'] ) { |
194 add_image_size( 'portfolio-thumb', $prtfl_options['custom_size_px']['portfolio-thumb'][0], $prtfl_options['custom_size_px']['portfolio-thumb'][1], true ); |
215 add_image_size( 'portfolio-thumb', $prtfl_options['custom_size_px']['portfolio-thumb'][0], $prtfl_options['custom_size_px']['portfolio-thumb'][1], true ); |
195 } |
216 } |
196 if ( 'portfolio-photo-thumb' == $prtfl_options['image_size_photo'] ) { |
217 if ( 'portfolio-photo-thumb' === $prtfl_options['image_size_photo'] ) { |
197 add_image_size( 'portfolio-photo-thumb', $prtfl_options['custom_size_px']['portfolio-photo-thumb'][0], $prtfl_options['custom_size_px']['portfolio-photo-thumb'][1], true ); |
218 add_image_size( 'portfolio-photo-thumb', $prtfl_options['custom_size_px']['portfolio-photo-thumb'][0], $prtfl_options['custom_size_px']['portfolio-photo-thumb'][1], true ); |
198 } |
219 } |
199 } |
220 } |
200 } |
221 } |
201 } |
222 } |
202 |
223 |
203 /** |
|
204 * Get Plugin default options |
|
205 */ |
|
206 if ( ! function_exists( 'prtfl_get_options_default' ) ) { |
224 if ( ! function_exists( 'prtfl_get_options_default' ) ) { |
|
225 /** |
|
226 * Get Plugin default options |
|
227 */ |
207 function prtfl_get_options_default() { |
228 function prtfl_get_options_default() { |
208 global $prtfl_plugin_info; |
229 global $prtfl_plugin_info; |
209 |
230 |
210 $option_defaults = array( |
231 $option_defaults = array( |
211 /* internal general */ |
232 /* internal general */ |
212 'plugin_option_version' => $prtfl_plugin_info["Version"], |
233 'plugin_option_version' => $prtfl_plugin_info['Version'], |
213 'first_install' => strtotime( "now" ), |
234 'first_install' => strtotime( 'now' ), |
214 'suggest_feature_banner' => 1, |
235 'suggest_feature_banner' => 1, |
215 'display_settings_notice' => 1, |
236 'display_settings_notice' => 1, |
216 /* internal */ |
237 /* internal */ |
217 'display_demo_notice' => 1, |
238 'display_demo_notice' => 1, |
218 /* settings */ |
239 /* settings */ |
219 'image_size_album' => 'medium', |
240 'image_size_album' => 'medium', |
220 'image_size_photo' => 'thumbnail', |
241 'image_size_photo' => 'thumbnail', |
221 'custom_size_px' => array( |
242 'custom_size_px' => array( |
222 'portfolio-thumb' => array( 280, 300 ), |
243 'portfolio-thumb' => array( 280, 300 ), |
223 'portfolio-photo-thumb' => array( 240, 260 ) |
244 'portfolio-photo-thumb' => array( 240, 260 ), |
224 ), |
245 ), |
225 'page_id_portfolio_template' => '', |
246 'page_id_portfolio_template' => '', |
226 'order_by' => 'date', |
247 'order_by' => 'date', |
227 'order' => 'DESC', |
248 'order' => 'DESC', |
228 'custom_image_row_count' => 3, |
249 'custom_image_row_count' => 3, |
229 'custom_portfolio_row_count' => 1, |
250 'custom_portfolio_row_count' => 1, |
230 'date_additional_field' => 1, |
251 'date_additional_field' => 1, |
231 'link_additional_field' => 1, |
252 'link_additional_field' => 1, |
232 'shrdescription_additional_field' => 1, |
253 'shrdescription_additional_field' => 1, |
233 'description_additional_field' => 1, |
254 'description_additional_field' => 1, |
234 'svn_additional_field' => 1, |
255 'svn_additional_field' => 1, |
235 'svn_additional_field_for_non_logged' => 1, |
256 'svn_additional_field_for_non_logged' => 1, |
236 'executor_additional_field' => 1, |
257 'executor_additional_field' => 1, |
237 'technologies_additional_field' => 1, |
258 'technologies_additional_field' => 1, |
238 'link_additional_field_for_non_registered' => 1, |
259 'link_additional_field_for_non_registered' => 1, |
239 'date_text_field' => __( 'Date of completion:', 'portfolio' ), |
260 'date_text_field' => __( 'Date of completion:', 'portfolio' ), |
240 'link_text_field' => __( 'Project, URL:', 'portfolio' ), |
261 'link_text_field' => __( 'Project, URL:', 'portfolio' ), |
241 'shrdescription_text_field' => __( 'Short description:', 'portfolio' ), |
262 'shrdescription_text_field' => __( 'Short description:', 'portfolio' ), |
242 'description_text_field' => __( 'Description:', 'portfolio' ), |
263 'description_text_field' => __( 'Description:', 'portfolio' ), |
243 'svn_text_field' => __( 'Source Files, URL:', 'portfolio' ), |
264 'svn_text_field' => __( 'Source Files, URL:', 'portfolio' ), |
244 'executor_text_field' => __( 'Executor:', 'portfolio' ), |
265 'executor_text_field' => __( 'Executor:', 'portfolio' ), |
245 'screenshot_text_field' => __( 'More screenshots:', 'portfolio' ), |
266 'screenshot_text_field' => __( 'More screenshots:', 'portfolio' ), |
246 'technologies_text_field' => __( 'Technologies:', 'portfolio' ), |
267 'technologies_text_field' => __( 'Technologies:', 'portfolio' ), |
247 /* misc */ |
268 /* misc */ |
248 'slug' => 'portfolio', |
269 'slug' => 'portfolio', |
249 'post_type_name' => 'bws-portfolio', |
270 'post_type_name' => 'bws-portfolio', |
250 /* other */ |
271 /* other */ |
251 'widget_updated' => 1, /* this option is for updating plugin was added in v2.29 */ |
272 'widget_updated' => 1, /* this option is for updating plugin was added in v2.29 */ |
252 'flush_rewrite_rules' => 1, |
273 'flush_rewrite_rules' => 1, |
253 ); |
274 ); |
254 return $option_defaults; |
275 return $option_defaults; |
255 } |
276 } |
256 } |
277 } |
257 |
278 |
258 /* Create post type for portfolio */ |
|
259 if ( ! function_exists( 'prtfl_post_type_portfolio' ) ) { |
279 if ( ! function_exists( 'prtfl_post_type_portfolio' ) ) { |
|
280 /** |
|
281 * Create post type for portfolio |
|
282 */ |
260 function prtfl_post_type_portfolio() { |
283 function prtfl_post_type_portfolio() { |
261 global $wpdb, $prtfl_options; |
284 global $wpdb, $prtfl_options; |
262 |
285 |
263 register_post_type( |
286 register_post_type( |
264 $prtfl_options['post_type_name'], |
287 $prtfl_options['post_type_name'], |
265 array( |
288 array( |
266 'labels' => array( |
289 'labels' => array( |
267 'name' => __( 'Portfolio', 'portfolio' ), |
290 'name' => __( 'Portfolio', 'portfolio' ), |
268 'all_items' => __( 'Projects', 'portfolio' ), |
291 'all_items' => __( 'Projects', 'portfolio' ), |
269 'singular_name' => __( 'Project', 'portfolio' ), |
292 'singular_name' => __( 'Project', 'portfolio' ), |
270 'add_new' => __( 'Add New', 'portfolio' ), |
293 'add_new' => __( 'Add New', 'portfolio' ), |
271 'add_new_item' => __( 'Add New Project', 'portfolio' ), |
294 'add_new_item' => __( 'Add New Project', 'portfolio' ), |
272 'edit' => __( 'Edit', 'portfolio' ), |
295 'edit' => __( 'Edit', 'portfolio' ), |
273 'edit_item' => __( 'Edit Project', 'portfolio' ), |
296 'edit_item' => __( 'Edit Project', 'portfolio' ), |
274 'new_item' => __( 'New Project', 'portfolio' ), |
297 'new_item' => __( 'New Project', 'portfolio' ), |
275 'view' => __( 'View Project', 'portfolio' ), |
298 'view' => __( 'View Project', 'portfolio' ), |
276 'view_item' => __( 'View Project', 'portfolio' ), |
299 'view_item' => __( 'View Project', 'portfolio' ), |
277 'search_items' => __( 'Search Projects', 'portfolio' ), |
300 'search_items' => __( 'Search Projects', 'portfolio' ), |
278 'not_found' => __( 'No project found', 'portfolio' ), |
301 'not_found' => __( 'No project found', 'portfolio' ), |
279 'not_found_in_trash' => __( 'No project found in Trash', 'portfolio' ), |
302 'not_found_in_trash' => __( 'No project found in Trash', 'portfolio' ), |
280 'parent' => __( 'Parent Project', 'portfolio' ), |
303 'parent' => __( 'Parent Project', 'portfolio' ), |
281 'filter_items_list' => __( 'Filter projects list', 'portfolio' ), |
304 'filter_items_list' => __( 'Filter projects list', 'portfolio' ), |
282 'items_list_navigation' => __( 'Projects list navigation', 'portfolio' ), |
305 'items_list_navigation' => __( 'Projects list navigation', 'portfolio' ), |
283 'items_list' => __( 'Projects list', 'portfolio' ) |
306 'items_list' => __( 'Projects list', 'portfolio' ), |
284 ), |
307 ), |
285 'description' => __( 'Create a project item', 'portfolio' ), |
308 'description' => __( 'Create a project item', 'portfolio' ), |
286 'public' => true, |
309 'public' => true, |
287 'show_ui' => true, |
310 'show_ui' => true, |
288 'publicly_queryable' => true, |
311 'publicly_queryable' => true, |
289 'exclude_from_search' => true, |
312 'exclude_from_search' => true, |
290 'hierarchical' => true, |
313 'hierarchical' => true, |
291 'query_var' => true, |
314 'query_var' => true, |
292 'register_meta_box_cb' => 'prtfl_init_metaboxes', |
315 'register_meta_box_cb' => 'prtfl_init_metaboxes', |
293 'rewrite' => array( 'slug' => $prtfl_options['slug'] ), |
316 'rewrite' => array( 'slug' => $prtfl_options['slug'] ), |
294 'menu_icon' => 'dashicons-id-alt', |
317 'menu_icon' => 'dashicons-id-alt', |
295 'supports' => array( |
318 'supports' => array( |
296 'title', /* Text input field to create a post title. */ |
319 'title', /* Text input field to create a post title. */ |
297 'editor', |
320 'editor', |
298 'custom-fields', |
321 'custom-fields', |
299 'comments', /* Ability to turn on/off comments. */ |
322 'comments', /* Ability to turn on/off comments. */ |
300 'thumbnail', /* Displays a box for featured image. */ |
323 'thumbnail', /* Displays a box for featured image. */ |
301 'author', |
324 'author', |
302 'page-attributes' |
325 'page-attributes', |
303 ) |
326 ), |
304 ) |
327 ) |
305 ); |
328 ); |
306 |
329 |
307 register_taxonomy( |
330 register_taxonomy( |
308 'portfolio_executor_profile', |
331 'portfolio_executor_profile', |
309 $prtfl_options['post_type_name'], |
332 $prtfl_options['post_type_name'], |
310 array( |
333 array( |
311 'hierarchical' => false, |
334 'hierarchical' => false, |
312 'update_count_callback' => '_update_post_term_count', |
335 'update_count_callback' => '_update_post_term_count', |
313 'labels' => array( |
336 'labels' => array( |
314 'name' => __( 'Executors', 'portfolio' ), |
337 'name' => __( 'Executors', 'portfolio' ), |
315 'singular_name' => __( 'Executor', 'portfolio' ), |
338 'singular_name' => __( 'Executor', 'portfolio' ), |
316 'search_items' => __( 'Search Executors', 'portfolio' ), |
339 'search_items' => __( 'Search Executors', 'portfolio' ), |
317 'popular_items' => __( 'Popular Executors', 'portfolio' ), |
340 'popular_items' => __( 'Popular Executors', 'portfolio' ), |
318 'all_items' => __( 'All Executors', 'portfolio' ), |
341 'all_items' => __( 'All Executors', 'portfolio' ), |
319 'parent_item' => __( 'Parent Executor', 'portfolio' ), |
342 'parent_item' => __( 'Parent Executor', 'portfolio' ), |
320 'parent_item_colon' => __( 'Parent Executor:', 'portfolio' ), |
343 'parent_item_colon' => __( 'Parent Executor:', 'portfolio' ), |
321 'edit_item' => __( 'Edit Executor', 'portfolio' ), |
344 'edit_item' => __( 'Edit Executor', 'portfolio' ), |
322 'update_item' => __( 'Update Executor', 'portfolio' ), |
345 'update_item' => __( 'Update Executor', 'portfolio' ), |
323 'add_new_item' => __( 'Add New Executor', 'portfolio' ), |
346 'add_new_item' => __( 'Add New Executor', 'portfolio' ), |
324 'new_item_name' => __( 'New Executor Name', 'portfolio' ), |
347 'new_item_name' => __( 'New Executor Name', 'portfolio' ), |
325 'separate_items_with_commas' => __( 'Separate executors with commas', 'portfolio' ), |
348 'separate_items_with_commas' => __( 'Separate executors with commas', 'portfolio' ), |
326 'add_or_remove_items' => __( 'Add or remove Executor', 'portfolio' ), |
349 'add_or_remove_items' => __( 'Add or remove Executor', 'portfolio' ), |
327 'choose_from_most_used' => __( 'Choose from the most used Executors', 'portfolio' ), |
350 'choose_from_most_used' => __( 'Choose from the most used Executors', 'portfolio' ), |
328 'menu_name' => __( 'Executors', 'portfolio' ), |
351 'menu_name' => __( 'Executors', 'portfolio' ), |
329 'items_list_navigation' => __( 'Executors list navigation', 'portfolio' ), |
352 'items_list_navigation' => __( 'Executors list navigation', 'portfolio' ), |
330 'items_list' => __( 'Executors list', 'portfolio' ) |
353 'items_list' => __( 'Executors list', 'portfolio' ), |
331 ), |
354 ), |
332 'sort' => true, |
355 'sort' => true, |
333 'args' => array( 'orderby' => 'term_order' ), |
356 'args' => array( 'orderby' => 'term_order' ), |
334 'rewrite' => array( 'slug' => 'executor_profile' ), |
357 'rewrite' => array( 'slug' => 'executor_profile' ), |
335 'show_tagcloud' => false |
358 'show_tagcloud' => false, |
336 ) |
359 ) |
337 ); |
360 ); |
338 |
361 |
339 register_taxonomy( |
362 register_taxonomy( |
340 'portfolio_technologies', |
363 'portfolio_technologies', |
341 $prtfl_options['post_type_name'], |
364 $prtfl_options['post_type_name'], |
342 array( |
365 array( |
343 'hierarchical' => false, |
366 'hierarchical' => false, |
344 'update_count_callback' => '_update_post_term_count', |
367 'update_count_callback' => '_update_post_term_count', |
345 'labels' => array( |
368 'labels' => array( |
346 'name' => __( 'Technologies', 'portfolio' ), |
369 'name' => __( 'Technologies', 'portfolio' ), |
347 'singular_name' => __( 'Technology', 'portfolio' ), |
370 'singular_name' => __( 'Technology', 'portfolio' ), |
348 'search_items' => __( 'Search Technologies', 'portfolio' ), |
371 'search_items' => __( 'Search Technologies', 'portfolio' ), |
349 'popular_items' => __( 'Popular Technologies', 'portfolio' ), |
372 'popular_items' => __( 'Popular Technologies', 'portfolio' ), |
350 'all_items' => __( 'All Technologies', 'portfolio' ), |
373 'all_items' => __( 'All Technologies', 'portfolio' ), |
351 'parent_item' => __( 'Parent Technology', 'portfolio' ), |
374 'parent_item' => __( 'Parent Technology', 'portfolio' ), |
352 'parent_item_colon' => __( 'Parent Technology:', 'portfolio' ), |
375 'parent_item_colon' => __( 'Parent Technology:', 'portfolio' ), |
353 'edit_item' => __( 'Edit Technology', 'portfolio' ), |
376 'edit_item' => __( 'Edit Technology', 'portfolio' ), |
354 'update_item' => __( 'Update Technology', 'portfolio' ), |
377 'update_item' => __( 'Update Technology', 'portfolio' ), |
355 'add_new_item' => __( 'Add New Technology', 'portfolio' ), |
378 'add_new_item' => __( 'Add New Technology', 'portfolio' ), |
356 'new_item_name' => __( 'New Technology Name', 'portfolio' ), |
379 'new_item_name' => __( 'New Technology Name', 'portfolio' ), |
357 'separate_items_with_commas' => __( 'Separate technologies with commas', 'portfolio' ), |
380 'separate_items_with_commas' => __( 'Separate technologies with commas', 'portfolio' ), |
358 'add_or_remove_items' => __( 'Add or remove Technology', 'portfolio' ), |
381 'add_or_remove_items' => __( 'Add or remove Technology', 'portfolio' ), |
359 'choose_from_most_used' => __( 'Choose from the most used technologies', 'portfolio' ), |
382 'choose_from_most_used' => __( 'Choose from the most used technologies', 'portfolio' ), |
360 'menu_name' => __( 'Technologies', 'portfolio' ), |
383 'menu_name' => __( 'Technologies', 'portfolio' ), |
361 'items_list_navigation' => __( 'Technologies list navigation', 'portfolio' ), |
384 'items_list_navigation' => __( 'Technologies list navigation', 'portfolio' ), |
362 'items_list' => __( 'Technologies list', 'portfolio' ) |
385 'items_list' => __( 'Technologies list', 'portfolio' ), |
363 ), |
386 ), |
364 'query_var' => 'technologies', |
387 'query_var' => 'technologies', |
365 'rewrite' => array( 'slug' => 'technologies' ), |
388 'rewrite' => array( 'slug' => 'technologies' ), |
366 'show_ui' => true, |
389 'show_ui' => true, |
367 'show_tagcloud' => false |
390 'show_tagcloud' => false, |
368 ) |
391 ) |
369 ); |
392 ); |
370 |
393 |
371 if ( isset( $prtfl_options["flush_rewrite_rules"] ) && 1 == $prtfl_options["flush_rewrite_rules"] ) { |
394 if ( isset( $prtfl_options['flush_rewrite_rules'] ) && 1 === absint( $prtfl_options['flush_rewrite_rules'] ) ) { |
372 flush_rewrite_rules(); |
395 flush_rewrite_rules(); |
373 $prtfl_options["flush_rewrite_rules"] = 0; |
396 $prtfl_options['flush_rewrite_rules'] = 0; |
374 update_option( 'prtfl_options', $prtfl_options ); |
397 update_option( 'prtfl_options', $prtfl_options ); |
375 } |
398 } |
376 } |
399 } |
377 } |
400 } |
378 |
401 |
379 /** |
|
380 * Plugin include demo |
|
381 * @return void |
|
382 */ |
|
383 if ( ! function_exists( 'prtfl_include_demo_data' ) ) { |
402 if ( ! function_exists( 'prtfl_include_demo_data' ) ) { |
|
403 /** |
|
404 * Plugin include demo |
|
405 */ |
384 function prtfl_include_demo_data() { |
406 function prtfl_include_demo_data() { |
385 global $prtfl_BWS_demo_data; |
407 global $prtfl_bws_demo_data; |
386 require_once( plugin_dir_path( __FILE__ ) . 'inc/demo-data/class-bws-demo-data.php' ); |
408 require_once plugin_dir_path( __FILE__ ) . 'includes/demo-data/class-bws-demo-data.php'; |
387 $args = array( |
409 $args = array( |
388 'plugin_basename' => plugin_basename( __FILE__ ), |
410 'plugin_basename' => plugin_basename( __FILE__ ), |
389 'plugin_prefix' => 'prtfl_', |
411 'plugin_prefix' => 'prtfl_', |
390 'plugin_name' => 'Portfolio', |
412 'plugin_name' => 'Portfolio', |
391 'plugin_page' => 'portfolio.php&bws_active_tab=import-export', |
413 'plugin_page' => 'portfolio.php&bws_active_tab=import-export', |
392 'demo_folder' => plugin_dir_path( __FILE__ ) . 'inc/demo-data/' |
414 'demo_folder' => plugin_dir_path( __FILE__ ) . 'includes/demo-data/', |
393 ); |
415 ); |
394 $prtfl_BWS_demo_data = new Bws_Demo_Data( $args ); |
416 $prtfl_bws_demo_data = new Bws_Demo_Data( $args ); |
395 |
417 |
396 /* filter for image url from demo data */ |
418 /* filter for image url from demo data */ |
397 add_filter( 'wp_get_attachment_url', array( $prtfl_BWS_demo_data, 'bws_wp_get_attachment_url' ), 10, 2 ); |
419 add_filter( 'wp_get_attachment_url', array( $prtfl_bws_demo_data, 'bws_wp_get_attachment_url' ), 10, 2 ); |
398 add_filter( 'wp_get_attachment_image_attributes', array( $prtfl_BWS_demo_data, 'bws_wp_get_attachment_image_attributes' ), 10, 3 ); |
420 add_filter( 'wp_get_attachment_image_attributes', array( $prtfl_bws_demo_data, 'bws_wp_get_attachment_image_attributes' ), 10, 3 ); |
399 add_filter( 'wp_update_attachment_metadata',array( $prtfl_BWS_demo_data, 'bws_wp_update_attachment_metadata' ), 10, 2 ); |
421 add_filter( 'wp_update_attachment_metadata', array( $prtfl_bws_demo_data, 'bws_wp_update_attachment_metadata' ), 10, 2 ); |
400 } |
422 } |
401 } |
423 } |
402 |
424 |
403 /** |
|
404 * Plugin settings page |
|
405 * @return void |
|
406 */ |
|
407 if ( ! function_exists( 'prtfl_settings_page' ) ) { |
425 if ( ! function_exists( 'prtfl_settings_page' ) ) { |
|
426 /** |
|
427 * Plugin settings page |
|
428 */ |
408 function prtfl_settings_page() { |
429 function prtfl_settings_page() { |
409 if ( ! class_exists( 'Bws_Settings_Tabs' ) ) |
430 if ( ! class_exists( 'Bws_Settings_Tabs' ) ) { |
410 require_once( dirname( __FILE__ ) . '/bws_menu/class-bws-settings.php' ); |
431 require_once dirname( __FILE__ ) . '/bws_menu/class-bws-settings.php'; |
411 require_once( dirname( __FILE__ ) . '/inc/class-prtfl-settings.php' ); |
432 } |
|
433 require_once dirname( __FILE__ ) . '/includes/class-prtfl-settings.php'; |
412 $page = new Prtfl_Settings_Tabs( plugin_basename( __FILE__ ) ); |
434 $page = new Prtfl_Settings_Tabs( plugin_basename( __FILE__ ) ); |
413 if ( method_exists( $page,'add_request_feature' ) ) |
435 if ( method_exists( $page, 'add_request_feature' ) ) { |
414 $page->add_request_feature(); ?> |
436 $page->add_request_feature(); |
|
437 } ?> |
415 <div class="wrap"> |
438 <div class="wrap"> |
416 <h1><?php _e( 'Portfolio Settings', 'portfolio' ); ?></h1> |
439 <h1><?php esc_html_e( 'Portfolio Settings', 'portfolio' ); ?></h1> |
417 <?php $page->display_content(); ?> |
440 <?php $page->display_content(); ?> |
418 </div> |
441 </div> |
419 <?php } |
442 <?php |
420 } |
443 } |
421 |
444 } |
422 /* add query_var "post_type" in case we have another custom post type with query_var 'portfolio' (example: jetpack portfolio) */ |
445 |
423 if ( ! function_exists( 'prtfl_request_filter' ) ) { |
446 if ( ! function_exists( 'prtfl_request_filter' ) ) { |
|
447 /** |
|
448 * Add query_var "post_type" in case we have another custom post type with query_var 'portfolio' (example: jetpack portfolio) |
|
449 * |
|
450 * @param array $query_vars Query vars array. |
|
451 * @return array $query_vars Query vars array. |
|
452 */ |
424 function prtfl_request_filter( $query_vars ) { |
453 function prtfl_request_filter( $query_vars ) { |
425 global $prtfl_options; |
454 global $prtfl_options; |
426 if ( isset( $query_vars["post_type"] ) && 'jetpack-portfolio' == $query_vars["post_type"] ) { |
455 if ( isset( $query_vars['post_type'] ) && 'jetpack-portfolio' === $query_vars['post_type'] ) { |
427 if ( ! get_posts( $query_vars ) ) { |
456 if ( ! get_posts( $query_vars ) ) { |
428 $query_vars["post_type"] = $prtfl_options['post_type_name']; |
457 $query_vars['post_type'] = $prtfl_options['post_type_name']; |
429 } |
458 } |
430 } |
459 } |
431 return $query_vars; |
460 return $query_vars; |
432 } |
461 } |
433 } |
462 } |
434 |
463 |
435 if ( ! function_exists( 'prtfl_technologies_get_posts' ) ) { |
464 if ( ! function_exists( 'prtfl_technologies_get_posts' ) ) { |
|
465 /** |
|
466 * Change post type for portfolio |
|
467 * |
|
468 * @param object $query WP Query object. |
|
469 * @return object $query Changed WP Query object. |
|
470 */ |
436 function prtfl_technologies_get_posts( $query ) { |
471 function prtfl_technologies_get_posts( $query ) { |
437 global $prtfl_options; |
472 global $prtfl_options; |
438 |
473 |
439 if ( ( isset( $query->query_vars["technologies"] ) || isset( $query->query_vars["portfolio_executor_profile"] ) ) && ( ! is_admin() ) ) { |
474 if ( ( isset( $query->query_vars['technologies'] ) || isset( $query->query_vars['portfolio_executor_profile'] ) ) && ( ! is_admin() ) ) { |
440 $query->set( 'post_type', array( $prtfl_options['post_type_name'] ) ); |
475 $query->set( 'post_type', array( $prtfl_options['post_type_name'] ) ); |
441 } |
476 } |
442 return $query; |
477 return $query; |
443 } |
478 } |
444 } |
479 } |
445 |
480 |
446 /** |
|
447 * Class extends WP class WP_Widget, and create new widget |
|
448 */ |
|
449 if ( ! class_exists( 'portfolio_technologies_widget' ) ) { |
|
450 class portfolio_technologies_widget extends WP_Widget { |
|
451 /* constructor of class */ |
|
452 function __construct() { |
|
453 parent::__construct( |
|
454 'portfolio_technologies_widget', |
|
455 __( 'Technologies', 'portfolio' ), |
|
456 array( 'description' => __( 'The tag cloud with your most used portfolio technologies.', 'portfolio' ) ) |
|
457 ); |
|
458 } |
|
459 /* Function to displaying widget in front end */ |
|
460 function widget( $args, $instance ) { |
|
461 $widget_title = isset( $instance['widget_title'] ) ? $instance['widget_title'] : null; |
|
462 $widget_title = apply_filters( 'widget_title', $widget_title, $instance, $this->id_base ); |
|
463 echo $args['before_widget']; |
|
464 if ( $widget_title ) |
|
465 echo $args['before_title'] . $widget_title . $args['after_title']; |
|
466 echo '<div class="tagcloud">'; |
|
467 wp_tag_cloud( apply_filters( 'widget_tag_cloud_args', array( 'taxonomy' => 'portfolio_technologies', 'number' => 0 ) ) ); |
|
468 echo "</div>\n"; |
|
469 echo $args['after_widget']; |
|
470 } |
|
471 /* Function to save widget settings */ |
|
472 function update( $new_instance, $old_instance ) { |
|
473 $instance = array(); |
|
474 $instance['widget_title'] = ( ! empty( $new_instance['widget_title'] ) ) ? strip_tags( $new_instance['widget_title'] ) : null; |
|
475 return $instance; |
|
476 } |
|
477 /* Function to displaying widget settings in back end */ |
|
478 function form( $instance ) { |
|
479 $widget_title = isset( $instance['widget_title'] ) ? stripslashes( esc_html( $instance['widget_title'] ) ) : null; ?> |
|
480 <p> |
|
481 <label for="<?php echo $this->get_field_id( 'widget_title' ); ?>"><?php _e( 'Title', 'portfolio' ); ?>:</label> |
|
482 <input class="widefat" id="<?php echo $this->get_field_id( 'widget_title' ); ?>" name="<?php echo $this->get_field_name( 'widget_title' ); ?>" type="text" value="<?php echo esc_attr( $widget_title ); ?>"/> |
|
483 </p> |
|
484 <?php } |
|
485 } |
|
486 } |
|
487 if ( ! function_exists( 'prtfl_register_widget' ) ) { |
481 if ( ! function_exists( 'prtfl_register_widget' ) ) { |
|
482 /** |
|
483 * Create new widget |
|
484 */ |
488 function prtfl_register_widget() { |
485 function prtfl_register_widget() { |
489 register_widget( 'portfolio_technologies_widget' ); |
486 if ( ! class_exists( 'Portfolio_Technologies_Widget' ) ) { |
490 } |
487 require_once dirname( __FILE__ ) . '/includes/class-portfolio-technologies-widget.php'; |
491 } |
488 } |
492 |
489 register_widget( 'Portfolio_Technologies_Widget' ); |
493 /* Create custom permalinks for portfolio post type */ |
490 if ( ! class_exists( 'Prtfl_Widget' ) ) { |
|
491 require_once dirname( __FILE__ ) . '/includes/class-prtfl-widget.php'; |
|
492 } |
|
493 register_widget( 'Prtfl_Widget' ); |
|
494 } |
|
495 } |
|
496 |
494 if ( ! function_exists( 'prtfl_custom_permalinks' ) ) { |
497 if ( ! function_exists( 'prtfl_custom_permalinks' ) ) { |
|
498 /** |
|
499 * Create custom permalinks for portfolio post type |
|
500 * |
|
501 * @param array $rules Array with permalink rules. |
|
502 * @return array $rules Updated array with permalink rules. |
|
503 */ |
495 function prtfl_custom_permalinks( $rules ) { |
504 function prtfl_custom_permalinks( $rules ) { |
496 global $prtfl_options; |
505 global $prtfl_options; |
497 $newrules = array(); |
506 $newrules = array(); |
498 |
507 |
499 if ( empty( $prtfl_options ) ) { |
508 if ( empty( $prtfl_options ) ) { |
581 add_meta_box( 'prtfl_services_meta_box', __( 'Services', 'portfolio' ), 'prtfl_services_meta_box', $prtfl_options['post_type_name'], 'side', 'low' ); |
601 add_meta_box( 'prtfl_services_meta_box', __( 'Services', 'portfolio' ), 'prtfl_services_meta_box', $prtfl_options['post_type_name'], 'side', 'low' ); |
582 } |
602 } |
583 } |
603 } |
584 } |
604 } |
585 |
605 |
586 /* Create custom meta box for portfolio post type */ |
|
587 if ( ! function_exists( 'prtfl_post_custom_box' ) ) { |
606 if ( ! function_exists( 'prtfl_post_custom_box' ) ) { |
|
607 /** |
|
608 * Create custom meta box for portfolio post type |
|
609 * |
|
610 * @param string $obj Object. |
|
611 * @param array $box Box array. |
|
612 */ |
588 function prtfl_post_custom_box( $obj = '', $box = '' ) { |
613 function prtfl_post_custom_box( $obj = '', $box = '' ) { |
589 global $prtfl_boxes, $prtfl_plugin_info, $wp_version, $prtfl_options; |
614 global $prtfl_boxes, $prtfl_plugin_info, $wp_version, $prtfl_options; |
590 /* Generate box contents */ |
615 /* Generate box contents */ |
591 foreach ( $prtfl_boxes[ $box['id'] ] as $box ) { |
616 foreach ( $prtfl_boxes[ $box['id'] ] as $box ) { |
592 echo prtfl_general_field( $box ); |
617 echo wp_kses_post( prtfl_general_field( $box ) ); |
593 } |
618 } |
594 |
619 |
595 $bws_hide_premium_options_check = bws_hide_premium_options_check( $prtfl_options ); |
620 $bws_hide_premium_options_check = bws_hide_premium_options_check( $prtfl_options ); |
596 if ( ! $bws_hide_premium_options_check ) { ?> |
621 if ( ! $bws_hide_premium_options_check ) { |
|
622 ?> |
597 <div class="bws_pro_version_bloc"> |
623 <div class="bws_pro_version_bloc"> |
598 <div class="bws_pro_version_table_bloc"> |
624 <div class="bws_pro_version_table_bloc"> |
599 <div class="bws_table_bg" style="top: 0px; z-index: 2;"></div> |
625 <div class="bws_table_bg" style="top: 0px; z-index: 2;"></div> |
600 |
626 |
601 |
627 |
602 <div class="portfolio_admin_box"> |
628 <div class="portfolio_admin_box"> |
603 <p><label for="prtfl_client"><strong><?php _e( 'Client', 'portfolio' ); ?></strong></label></p> |
629 <p><label for="prtfl_client"><strong><?php esc_html_e( 'Client', 'portfolio' ); ?></strong></label></p> |
604 <?php /* display visual editor */ |
630 <?php |
|
631 /* display visual editor */ |
605 $settings = array( |
632 $settings = array( |
606 'media_buttons' => 1, |
633 'media_buttons' => 1, |
607 'textarea_name' => 'prtfl_client', |
634 'textarea_name' => 'prtfl_client', |
608 'textarea_rows' => 5, |
635 'textarea_rows' => 5, |
609 'tinymce' => 1 |
636 'tinymce' => 1, |
610 ); |
637 ); |
611 wp_editor( '', 'prtfl_client', $settings ); ?> |
638 wp_editor( '', 'prtfl_client', $settings ); |
|
639 ?> |
612 </div> |
640 </div> |
613 <div class="portfolio_admin_box"> |
641 <div class="portfolio_admin_box"> |
614 <p><label for="prtfl_featured"><strong><?php _e( 'Featured project', 'portfolio' ); ?></strong></label></p> |
642 <p><label for="prtfl_featured"><strong><?php esc_html_e( 'Featured project', 'portfolio' ); ?></strong></label></p> |
615 <p><input id="prtfl_featured" disabled="disabled" type="checkbox" name="prtfl_featured" value="1" /> |
643 <p><input id="prtfl_featured" disabled="disabled" type="checkbox" name="prtfl_featured" value="1" /> |
616 <em><?php _e( 'Add to slider', 'portfolio' ); ?></em> |
644 <em><?php esc_html_e( 'Add to slider', 'portfolio' ); ?></em> |
617 </p> |
645 </p> |
618 </div> |
646 </div> |
619 <div class="bws_pro_version_tooltip"> |
647 <div class="bws_pro_version_tooltip"> |
620 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro Plugin" style="z-index: 3;" ><?php _e( 'Learn More', 'portfolio' ); ?></a> |
648 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo esc_attr( $prtfl_plugin_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="Portfolio Pro Plugin" style="z-index: 3;" ><?php esc_html_e( 'Learn More', 'portfolio' ); ?></a> |
621 <div class="clear"></div> |
649 <div class="clear"></div> |
622 </div> |
650 </div> |
623 </div> |
651 </div> |
624 </div> |
652 </div> |
625 <?php } |
653 <?php |
626 } |
654 } |
627 } |
655 } |
628 |
656 } |
629 /** |
657 |
630 * This is the field meta box |
|
631 * @param array $args array of data for meta box |
|
632 * @return html structure of meta box |
|
633 */ |
|
634 if ( ! function_exists( 'prtfl_general_field' ) ) { |
658 if ( ! function_exists( 'prtfl_general_field' ) ) { |
|
659 /** |
|
660 * This is the field meta box |
|
661 * |
|
662 * @param array $args Array of data for meta box. |
|
663 */ |
635 function prtfl_general_field( $args ) { |
664 function prtfl_general_field( $args ) { |
636 global $post; |
665 global $post; |
637 |
666 |
638 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
667 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
639 $value = ! empty( $post_meta ) && is_array( $post_meta ) && ! empty( $post_meta[ $args['name'] ] ) ? $post_meta[ $args['name'] ] : ""; ?> |
668 $value = ! empty( $post_meta ) && is_array( $post_meta ) && ! empty( $post_meta[ $args['name'] ] ) ? $post_meta[ $args['name'] ] : ''; |
|
669 ?> |
640 <div class="portfolio_admin_box"> |
670 <div class="portfolio_admin_box"> |
641 <p><label for="<?php echo $args['name']; ?>"><strong><?php echo $args['title']; ?></strong></label></p> |
671 <p><label for="<?php echo esc_attr( $args['name'] ); ?>"><strong><?php echo esc_html( $args['title'] ); ?></strong></label></p> |
642 <p><input id="<?php echo $args['name']; ?>" type="text" style="width:80%;" name="<?php echo $args['name']; ?>" value="<?php echo $value; ?>" /></p> |
672 <p><input id="<?php echo esc_attr( $args['name'] ); ?>" type="text" style="width:80%;" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_html( $value ); ?>" /></p> |
643 </div> |
673 </div> |
644 <?php } |
674 <?php |
645 } |
675 } |
646 |
676 } |
647 /** |
677 |
648 * Banner on Portfolio Edit Page |
|
649 */ |
|
650 if ( ! function_exists( 'prtfl_categories_meta_box' ) ) { |
678 if ( ! function_exists( 'prtfl_categories_meta_box' ) ) { |
|
679 /** |
|
680 * Banner on Portfolio Edit Page |
|
681 */ |
651 function prtfl_categories_meta_box() { |
682 function prtfl_categories_meta_box() { |
652 global $prtfl_plugin_info, $wp_version; ?> |
683 global $prtfl_plugin_info, $wp_version; |
|
684 ?> |
653 <div class="bws_pro_version_bloc"> |
685 <div class="bws_pro_version_bloc"> |
654 <div class="bws_pro_version_table_bloc"> |
686 <div class="bws_pro_version_table_bloc"> |
655 <div class="bws_table_bg" style="top: 0px;"></div> |
687 <div class="bws_table_bg" style="top: 0px;"></div> |
656 <div class="prtfl_portfolio_categoriesdiv"> |
688 <div class="prtfl_portfolio_categoriesdiv"> |
657 <div class="inside"> |
689 <div class="inside"> |
658 <div class=""> |
690 <div class=""> |
659 <ul class="category-tabs"> |
691 <ul class="category-tabs"> |
660 <li class="tabs"><a href="#"><?php _e( 'All Categories', 'portfolio' ); ?></a></li> |
692 <li class="tabs"><a href="#"><?php esc_html_e( 'All Categories', 'portfolio' ); ?></a></li> |
661 <li><a href="#"><?php _e( 'Most Used', 'portfolio' ); ?></a></li> |
693 <li><a href="#"><?php esc_html_e( 'Most Used', 'portfolio' ); ?></a></li> |
662 </ul> |
694 </ul> |
663 <div class="tabs-panel" style="display: none;"> |
695 <div class="tabs-panel" style="display: none;"> |
664 <ul class="categorychecklist form-no-clear"> |
696 <ul class="categorychecklist form-no-clear"> |
665 <li class="popular-category"> |
697 <li class="popular-category"> |
666 <label class="selectit"><input checked="checked" disabled="disabled" value="236" type="checkbox" /><?php _e( 'Uncatgorized', 'portfolio' ); ?></label> |
698 <label class="selectit"><input checked="checked" disabled="disabled" value="236" type="checkbox" /><?php esc_html_e( 'Uncatgorized', 'portfolio' ); ?></label> |
667 </li> |
699 </li> |
668 </ul> |
700 </ul> |
669 </div> |
701 </div> |
670 <div class="tabs-panel"> |
702 <div class="tabs-panel"> |
671 <ul class="categorychecklist form-no-clear"> |
703 <ul class="categorychecklist form-no-clear"> |
672 <li class="popular-category"><label class="selectit"><input value="236" name="tax_input[portfolio_categories][]" checked="checked" disabled="disabled" type="checkbox" /> <?php _e( 'Uncatgorized', 'portfolio' ); ?></label></li> |
704 <li class="popular-category"><label class="selectit"><input value="236" name="tax_input[portfolio_categories][]" checked="checked" disabled="disabled" type="checkbox" /> <?php esc_html_e( 'Uncatgorized', 'portfolio' ); ?></label></li> |
673 </ul> |
705 </ul> |
674 </div> |
706 </div> |
675 </div> |
707 </div> |
676 </div> |
708 </div> |
677 </div> |
709 </div> |
678 <div class="bws_pro_version_tooltip"> |
710 <div class="bws_pro_version_tooltip"> |
679 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro Plugin"><?php _e( 'Learn More', 'portfolio' ); ?></a> |
711 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo esc_attr( $prtfl_plugin_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="Portfolio Pro Plugin"><?php esc_html_e( 'Learn More', 'portfolio' ); ?></a> |
680 <div class="clear"></div> |
712 <div class="clear"></div> |
681 </div> |
713 </div> |
682 </div> |
714 </div> |
683 </div> |
715 </div> |
684 <?php } |
716 <?php |
685 } |
717 } |
686 |
718 } |
687 /** |
719 |
688 * Banner on Portfolio Edit Page |
|
689 */ |
|
690 if ( ! function_exists( 'prtfl_sectors_meta_box' ) ) { |
720 if ( ! function_exists( 'prtfl_sectors_meta_box' ) ) { |
|
721 /** |
|
722 * Banner on Portfolio Edit Page |
|
723 */ |
691 function prtfl_sectors_meta_box() { |
724 function prtfl_sectors_meta_box() { |
692 global $prtfl_plugin_info, $wp_version; ?> |
725 global $prtfl_plugin_info, $wp_version; |
|
726 ?> |
693 <div class="bws_pro_version_bloc"> |
727 <div class="bws_pro_version_bloc"> |
694 <div class="bws_pro_version_table_bloc"> |
728 <div class="bws_pro_version_table_bloc"> |
695 <div class="bws_table_bg" style="top: 0px;"></div> |
729 <div class="bws_table_bg" style="top: 0px;"></div> |
696 <div class="prtfl_portfolio_sectorsdiv"> |
730 <div class="prtfl_portfolio_sectorsdiv"> |
697 <div class="inside"> |
731 <div class="inside"> |
698 <div class=""> |
732 <div class=""> |
699 <ul class="category-tabs"> |
733 <ul class="category-tabs"> |
700 <li class="tabs"><a href="#"><?php _e( 'All Sectors', 'portfolio' ); ?></a></li> |
734 <li class="tabs"><a href="#"><?php esc_html_e( 'All Sectors', 'portfolio' ); ?></a></li> |
701 <li><a href="#"><?php _e( 'Most Used', 'portfolio' ); ?></a></li> |
735 <li><a href="#"><?php esc_html_e( 'Most Used', 'portfolio' ); ?></a></li> |
702 </ul> |
736 </ul> |
703 <div class="tabs-panel" style="display: none;"> |
737 <div class="tabs-panel" style="display: none;"> |
704 <ul class="categorychecklist form-no-clear"> |
738 <ul class="categorychecklist form-no-clear"> |
705 <li class="popular-category"> |
739 <li class="popular-category"> |
706 <label class="selectit"><input disabled="disabled" value="236" type="checkbox" /><?php _e( 'Uncatgorized', 'portfolio' ); ?></label> |
740 <label class="selectit"><input disabled="disabled" value="236" type="checkbox" /><?php esc_html_e( 'Uncatgorized', 'portfolio' ); ?></label> |
707 </li> |
741 </li> |
708 </ul> |
742 </ul> |
709 </div> |
743 </div> |
710 <div class="tabs-panel"> |
744 <div class="tabs-panel"> |
711 <ul class="categorychecklist form-no-clear"> |
745 <ul class="categorychecklist form-no-clear"> |
712 <li class="popular-category"><label class="selectit"><input value="236" name="tax_input[portfolio_sectors][]" disabled="disabled" type="checkbox" /> <?php _e( 'Sector', 'portfolio' ); ?> 1</label></li> |
746 <li class="popular-category"><label class="selectit"><input value="236" name="tax_input[portfolio_sectors][]" disabled="disabled" type="checkbox" /> <?php esc_html_e( 'Sector', 'portfolio' ); ?> 1</label></li> |
713 <li class="popular-category"><label class="selectit"><input value="237" name="tax_input[portfolio_sectors][]" disabled="disabled" type="checkbox" /> <?php _e( 'Sector', 'portfolio' ); ?> 2</label></li> |
747 <li class="popular-category"><label class="selectit"><input value="237" name="tax_input[portfolio_sectors][]" disabled="disabled" type="checkbox" /> <?php esc_html_e( 'Sector', 'portfolio' ); ?> 2</label></li> |
714 </ul> |
748 </ul> |
715 </div> |
749 </div> |
716 </div> |
750 </div> |
717 </div> |
751 </div> |
718 </div> |
752 </div> |
719 <div class="bws_pro_version_tooltip"> |
753 <div class="bws_pro_version_tooltip"> |
720 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro Plugin"><?php _e( 'Learn More', 'portfolio' ); ?></a> |
754 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo esc_attr( $prtfl_plugin_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="Portfolio Pro Plugin"><?php esc_html_e( 'Learn More', 'portfolio' ); ?></a> |
721 <div class="clear"></div> |
755 <div class="clear"></div> |
722 </div> |
756 </div> |
723 </div> |
757 </div> |
724 </div> |
758 </div> |
725 <?php } |
759 <?php |
726 } |
760 } |
727 |
761 } |
728 /** |
762 |
729 * Banner on Portfolio Edit Page |
|
730 */ |
|
731 if ( ! function_exists( 'prtfl_services_meta_box' ) ) { |
763 if ( ! function_exists( 'prtfl_services_meta_box' ) ) { |
|
764 /** |
|
765 * Banner on Portfolio Edit Page |
|
766 */ |
732 function prtfl_services_meta_box() { |
767 function prtfl_services_meta_box() { |
733 global $prtfl_plugin_info, $wp_version; ?> |
768 global $prtfl_plugin_info, $wp_version; |
|
769 ?> |
734 <div class="bws_pro_version_bloc"> |
770 <div class="bws_pro_version_bloc"> |
735 <div class="bws_pro_version_table_bloc"> |
771 <div class="bws_pro_version_table_bloc"> |
736 <div class="bws_table_bg" style="top: 0px;"></div> |
772 <div class="bws_table_bg" style="top: 0px;"></div> |
737 <div class="prtfl_portfolio_servicesdiv"> |
773 <div class="prtfl_portfolio_servicesdiv"> |
738 <div class="inside"> |
774 <div class="inside"> |
739 <div class=""> |
775 <div class=""> |
740 <ul class="category-tabs"> |
776 <ul class="category-tabs"> |
741 <li class="tabs"><a href="#"><?php _e( 'All Services', 'portfolio' ); ?></a></li> |
777 <li class="tabs"><a href="#"><?php esc_html_e( 'All Services', 'portfolio' ); ?></a></li> |
742 <li><a href="#"><?php _e( 'Most Used', 'portfolio' ); ?></a></li> |
778 <li><a href="#"><?php esc_html_e( 'Most Used', 'portfolio' ); ?></a></li> |
743 </ul> |
779 </ul> |
744 <div class="tabs-panel" style="display: none;"> |
780 <div class="tabs-panel" style="display: none;"> |
745 <ul class="categorychecklist form-no-clear"> |
781 <ul class="categorychecklist form-no-clear"> |
746 <li class="popular-category"> |
782 <li class="popular-category"> |
747 <label class="selectit"><input disabled="disabled" value="236" type="checkbox" /><?php _e( 'Uncatgorized', 'portfolio' ); ?></label> |
783 <label class="selectit"><input disabled="disabled" value="236" type="checkbox" /><?php esc_html_e( 'Uncatgorized', 'portfolio' ); ?></label> |
748 </li> |
784 </li> |
749 </ul> |
785 </ul> |
750 </div> |
786 </div> |
751 <div class="tabs-panel"> |
787 <div class="tabs-panel"> |
752 <ul class="categorychecklist form-no-clear"> |
788 <ul class="categorychecklist form-no-clear"> |
753 <li class="popular-category"><label class="selectit"><input value="236" name="tax_input[portfolio_services][]" disabled="disabled" type="checkbox" /> <?php _e( 'Service', 'portfolio' ); ?> 1</label></li> |
789 <li class="popular-category"><label class="selectit"><input value="236" name="tax_input[portfolio_services][]" disabled="disabled" type="checkbox" /> <?php esc_html_e( 'Service', 'portfolio' ); ?> 1</label></li> |
754 <li class="popular-category"><label class="selectit"><input value="237" name="tax_input[portfolio_services][]" disabled="disabled" type="checkbox" /> <?php _e( 'Service', 'portfolio' ); ?> 2</label></li> |
790 <li class="popular-category"><label class="selectit"><input value="237" name="tax_input[portfolio_services][]" disabled="disabled" type="checkbox" /> <?php esc_html_e( 'Service', 'portfolio' ); ?> 2</label></li> |
755 </ul> |
791 </ul> |
756 </div> |
792 </div> |
757 </div> |
793 </div> |
758 </div> |
794 </div> |
759 </div> |
795 </div> |
760 <div class="bws_pro_version_tooltip"> |
796 <div class="bws_pro_version_tooltip"> |
761 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo $prtfl_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Portfolio Pro Plugin"><?php _e( 'Learn More', 'portfolio' ); ?></a> |
797 <a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/portfolio/?k=f047e20c92c972c398187a4f70240285&pn=74&v=<?php echo esc_attr( $prtfl_plugin_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="Portfolio Pro Plugin"><?php esc_html_e( 'Learn More', 'portfolio' ); ?></a> |
762 <div class="clear"></div> |
798 <div class="clear"></div> |
763 </div> |
799 </div> |
764 </div> |
800 </div> |
765 </div> |
801 </div> |
766 <?php } |
802 <?php |
|
803 } |
767 } |
804 } |
768 |
805 |
769 if ( ! function_exists( 'prtfl_metabox_images_block' ) ) { |
806 if ( ! function_exists( 'prtfl_metabox_images_block' ) ) { |
|
807 /** |
|
808 * Metabox for image |
|
809 */ |
770 function prtfl_metabox_images_block() { |
810 function prtfl_metabox_images_block() { |
771 global $post; ?> |
811 global $post; |
|
812 ?> |
772 <div id="prtfl_images_container"> |
813 <div id="prtfl_images_container"> |
773 <noscript><div class="error"><p><?php _e( 'Please enable JavaScript to add or delete images.', 'portfolio' ); ?></p></div></noscript> |
814 <noscript><div class="error"><p><?php esc_html_e( 'Please enable JavaScript to add or delete images.', 'portfolio' ); ?></p></div></noscript> |
774 <ul> |
815 <ul> |
775 <?php if ( metadata_exists( 'post', $post->ID, '_prtfl_images' ) ) { |
816 <?php |
|
817 if ( metadata_exists( 'post', $post->ID, '_prtfl_images' ) ) { |
776 $prtfl_images = get_post_meta( $post->ID, '_prtfl_images', true ); |
818 $prtfl_images = get_post_meta( $post->ID, '_prtfl_images', true ); |
777 } else { |
819 } else { |
778 /* Compatibility with old version 1.0.3 */ |
820 /* Compatibility with old version 1.0.3 */ |
779 $args = array( |
821 $args = array( |
780 'post_parent' => $post->ID, |
822 'post_parent' => $post->ID, |
781 'post_type' => 'attachment', |
823 'post_type' => 'attachment', |
782 'post_mime_type' => 'image', |
824 'post_mime_type' => 'image', |
783 'numberposts' => -1, |
825 'numberposts' => -1, |
784 'orderby' => 'menu_order', |
826 'orderby' => 'menu_order', |
785 'order' => 'ASC', |
827 'order' => 'ASC', |
786 'exclude' => get_post_thumbnail_id(), |
828 'exclude' => get_post_thumbnail_id(), |
787 'fields' => 'ids' |
829 'fields' => 'ids', |
788 ); |
830 ); |
789 $attachments = get_children( $args ); |
831 $attachments = get_children( $args ); |
790 $prtfl_images = implode( ',', $attachments ); |
832 $prtfl_images = implode( ',', $attachments ); |
791 } |
833 } |
792 |
834 |
793 $attachments = array_filter( explode( ',', $prtfl_images ) ); |
835 $attachments = array_filter( explode( ',', $prtfl_images ) ); |
794 |
836 |
803 $update_meta = true; |
845 $update_meta = true; |
804 continue; |
846 continue; |
805 } |
847 } |
806 |
848 |
807 echo '<li class="prtfl_single_image" data-attachment_id="' . esc_attr( $attachment_id ) . '"> |
849 echo '<li class="prtfl_single_image" data-attachment_id="' . esc_attr( $attachment_id ) . '"> |
808 ' . $attachment . ' |
850 ' . wp_kses_post( $attachment ) . ' |
809 <span class="prtfl_delete_image"><a href="#" title="' . __( 'Delete image', 'portfolio' ) . '">' . __( 'Delete', 'portfolio' ) . '</a></span> |
851 <span class="prtfl_delete_image"><a href="#" title="' . esc_html__( 'Delete image', 'portfolio' ) . '">' . esc_html__( 'Delete', 'portfolio' ) . '</a></span> |
810 </li>'; |
852 </li>'; |
811 |
853 |
812 $updated_images_ids[] = $attachment_id; |
854 $updated_images_ids[] = $attachment_id; |
813 } |
855 } |
814 |
856 |
815 /* update product meta to set new portfolio ids */ |
857 /* update product meta to set new portfolio ids */ |
816 if ( $update_meta ) |
858 if ( $update_meta ) { |
817 update_post_meta( $post->ID, '_prtfl_images', implode( ',', $updated_images_ids ) ); |
859 update_post_meta( $post->ID, '_prtfl_images', implode( ',', $updated_images_ids ) ); |
818 } ?> |
860 } |
|
861 } |
|
862 ?> |
819 </ul> |
863 </ul> |
820 <input type="hidden" id="prtfl_images" name="prtfl_images" value="<?php echo esc_attr( $prtfl_images ); ?>" /> |
864 <input type="hidden" id="prtfl_images" name="prtfl_images" value="<?php echo esc_attr( $prtfl_images ); ?>" /> |
821 </div> |
865 </div> |
822 <p class="prtfl_add_portfolio_images hide-if-no-js"> |
866 <p class="prtfl_add_portfolio_images hide-if-no-js"> |
823 <a href="#" data-choose="<?php esc_attr_e( 'Add Images to Portfolio', 'portfolio' ); ?>" data-update="<?php esc_attr_e( 'Add to portfolio', 'portfolio' ); ?>" data-delete="<?php esc_attr_e( 'Delete image', 'portfolio' ); ?>" data-text="<?php esc_attr_e( 'Delete', 'portfolio' ); ?>"><?php _e( 'Add images', 'portfolio' ); ?></a> |
867 <a href="#" data-choose="<?php esc_attr_e( 'Add Images to Portfolio', 'portfolio' ); ?>" data-update="<?php esc_attr_e( 'Add to portfolio', 'portfolio' ); ?>" data-delete="<?php esc_attr_e( 'Delete image', 'portfolio' ); ?>" data-text="<?php esc_attr_e( 'Delete', 'portfolio' ); ?>"><?php esc_html_e( 'Add images', 'portfolio' ); ?></a> |
824 </p> |
868 </p> |
825 <?php } |
869 <?php |
826 } |
870 } |
827 |
871 } |
828 /* When the post is saved, saves our custom data */ |
872 |
829 if ( ! function_exists( 'prtfl_save_postdata' ) ) { |
873 if ( ! function_exists( 'prtfl_save_postdata' ) ) { |
|
874 /** |
|
875 * Saves our custom data when the post is saved |
|
876 * |
|
877 * @param int $post_id Post ID. |
|
878 * @param object $post Post object. |
|
879 */ |
830 function prtfl_save_postdata( $post_id, $post ) { |
880 function prtfl_save_postdata( $post_id, $post ) { |
831 global $prtfl_boxes, $prtfl_options; |
881 global $prtfl_boxes, $prtfl_options; |
832 |
882 |
833 if ( $prtfl_options['post_type_name'] == $post->post_type && ! wp_is_post_revision( $post_id ) && ! empty( $_POST ) ) { /* Don't store custom data twice */ |
883 if ( $prtfl_options['post_type_name'] === $post->post_type && ! wp_is_post_revision( $post_id ) && ! empty( $_POST ) ) { |
834 /* Verify this came from the our screen and with proper authorization, because save_post can be triggered at other times */ |
884 /** |
|
885 * Don't store custom data twice |
|
886 * Verify this came from the our screen and with proper authorization, because save_post can be triggered at other times |
|
887 */ |
835 if ( ! current_user_can( 'edit_page', $post->ID ) ) { |
888 if ( ! current_user_can( 'edit_page', $post->ID ) ) { |
836 return $post->ID; |
889 return $post->ID; |
837 } |
890 } |
838 |
891 |
839 /* We'll put it into an array to make it easier to loop though. The data is already in $prtfl_boxes, but we need to flatten it out. */ |
892 /* We'll put it into an array to make it easier to loop though. The data is already in $prtfl_boxes, but we need to flatten it out. */ |
840 foreach ( $prtfl_boxes as $prtfl_boxe ) { |
893 foreach ( $prtfl_boxes as $prtfl_boxe ) { |
841 foreach ( $prtfl_boxe as $prtfl_fields ) { |
894 foreach ( $prtfl_boxe as $prtfl_fields ) { |
842 if ( isset( $_POST[ $prtfl_fields['name'] ] ) ) { |
895 if ( isset( $_POST[ $prtfl_fields['name'] ] ) ) { |
843 if ( 'url' == $prtfl_fields['type'] ) { |
896 if ( 'url' === $prtfl_fields['type'] ) { |
844 $my_data[ $prtfl_fields['name'] ] = esc_url( $_POST[ $prtfl_fields['name'] ] ); |
897 $my_data[ $prtfl_fields['name'] ] = esc_url( wp_unslash( $_POST[ $prtfl_fields['name'] ] ) ); |
845 } else { |
898 } else { |
846 $my_data[ $prtfl_fields['name'] ] = stripslashes( esc_html( $_POST[ $prtfl_fields['name'] ] ) ); |
899 $my_data[ $prtfl_fields['name'] ] = sanitize_text_field( wp_unslash( $_POST[ $prtfl_fields['name'] ] ) ); |
847 } |
900 } |
848 } |
901 } |
849 } |
902 } |
850 } |
903 } |
851 if ( isset( $my_data ) ) { |
904 if ( isset( $my_data ) ) { |
852 /* Add values of $my_data as custom fields. Let's cycle through the $my_data array! */ |
905 /* Add values of $my_data as custom fields. Let's cycle through the $my_data array! */ |
853 if ( get_post_meta( $post->ID, 'prtfl_information', FALSE ) ) { |
906 if ( get_post_meta( $post->ID, 'prtfl_information', false ) ) { |
854 /* Custom field has a value and this custom field exists in database */ |
907 /* Custom field has a value and this custom field exists in database */ |
855 update_post_meta( $post->ID, 'prtfl_information', $my_data ); |
908 update_post_meta( $post->ID, 'prtfl_information', $my_data ); |
856 } else { |
909 } else { |
857 /* Custom field does not have a value, but this custom field exists in database */ |
910 /* Custom field does not have a value, but this custom field exists in database */ |
858 update_post_meta( $post->ID, 'prtfl_information', $my_data ); |
911 update_post_meta( $post->ID, 'prtfl_information', $my_data ); |
859 } |
912 } |
860 } |
913 } |
861 if ( isset( $_POST['prtfl_images'] ) ) { |
914 if ( isset( $_POST['prtfl_images'] ) ) { |
862 $attachment_ids = ! empty( $_POST['prtfl_images'] ) ? array_filter( explode( ',', sanitize_text_field( $_POST['prtfl_images'] ) ) ) : array(); |
915 $attachment_ids = ! empty( $_POST['prtfl_images'] ) ? array_filter( explode( ',', sanitize_text_field( wp_unslash( $_POST['prtfl_images'] ) ) ) ) : array(); |
863 update_post_meta( $post_id, '_prtfl_images', implode( ',', $attachment_ids ) ); |
916 update_post_meta( $post_id, '_prtfl_images', implode( ',', $attachment_ids ) ); |
864 } |
917 } |
865 } |
918 } |
866 } |
919 } |
867 } |
920 } |
868 |
921 |
869 /** |
|
870 * Replace shortcode [latest_portfolio_items] from portfolio content before portfolio saving |
|
871 */ |
|
872 if ( ! function_exists( 'prtfl_content_save_pre' ) ) { |
922 if ( ! function_exists( 'prtfl_content_save_pre' ) ) { |
|
923 /** |
|
924 * Replace shortcode [latest_portfolio_items] from portfolio content before portfolio saving |
|
925 * |
|
926 * @param string $content Content. |
|
927 * @returnm string $content Content. |
|
928 */ |
873 function prtfl_content_save_pre( $content ) { |
929 function prtfl_content_save_pre( $content ) { |
874 global $post, $prtfl_options; |
930 global $post, $prtfl_options; |
875 if ( isset( $post ) && $prtfl_options['post_type_name'] == $post->post_type && ! wp_is_post_revision( $post->ID ) && ! empty( $_POST ) ) { |
931 if ( isset( $post ) && $prtfl_options['post_type_name'] === $post->post_type && ! wp_is_post_revision( $post->ID ) && ! empty( $_POST ) ) { |
876 /* remove shortcode */ |
932 /* remove shortcode */ |
877 $content = preg_replace( '/\[latest_portfolio_items count=[\d]*\]/', '', $content ); |
933 $content = preg_replace( '/\[latest_portfolio_items count=[\d]*\]/', '', $content ); |
878 } |
934 } |
879 return $content; |
935 return $content; |
880 } |
936 } |
881 } |
937 } |
882 |
938 |
883 /* this function add custom fields and images for PDF&Print plugin in Portfolio post */ |
|
884 if ( ! function_exists( 'prtfl_add_pdf_print_content' ) ) { |
939 if ( ! function_exists( 'prtfl_add_pdf_print_content' ) ) { |
|
940 /** |
|
941 * Add custom fields and images for PDF&Print plugin in Portfolio post |
|
942 * |
|
943 * @param string $content Contetn for print. |
|
944 */ |
885 function prtfl_add_pdf_print_content( $content ) { |
945 function prtfl_add_pdf_print_content( $content ) { |
886 global $post, $prtfl_options; |
946 global $post, $prtfl_options; |
887 $current_post_type = get_post_type(); |
947 $current_post_type = get_post_type(); |
888 $custom_content = ''; |
948 $custom_content = ''; |
889 |
949 |
890 if ( $prtfl_options['post_type_name'] == $current_post_type && ! empty( $post ) ) { |
950 if ( ! $prtfl_options ) { |
|
951 $prtfl_options = get_option( 'prtfl_options' ); |
|
952 } |
|
953 |
|
954 if ( $prtfl_options['post_type_name'] === $current_post_type && ! empty( $post ) ) { |
891 |
955 |
892 if ( ! $prtfl_options ) { |
956 if ( ! $prtfl_options ) { |
893 $prtfl_options = get_option( 'prtfl_options' ); |
957 $prtfl_options = get_option( 'prtfl_options' ); |
894 } |
958 } |
895 |
959 |
896 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
960 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
897 $user_id = get_current_user_id(); |
961 $user_id = get_current_user_id(); |
898 |
962 |
899 if ( 1 == $prtfl_options['date_additional_field'] ) { |
963 if ( 1 === absint( $prtfl_options['date_additional_field'] ) ) { |
900 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
964 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
901 if ( ! empty( $date_compl ) ) { |
965 if ( ! empty( $date_compl ) ) { |
902 $custom_content .= '<p><span class="lable">' . $prtfl_options['date_text_field'] .' </span> ' . $date_compl . '</p>'; |
966 $custom_content .= '<p><span class="lable">' . $prtfl_options['date_text_field'] . ' </span> ' . $date_compl . '</p>'; |
903 } |
967 } |
904 } |
968 } |
905 |
969 |
906 if ( 1 == $prtfl_options['link_additional_field'] && ! empty( $post_meta['_prtfl_link'] ) ) { |
970 if ( 1 === absint( $prtfl_options['link_additional_field'] ) && ! empty( $post_meta['_prtfl_link'] ) ) { |
907 |
971 |
908 if ( false !== parse_url( $post_meta['_prtfl_link'] ) ) { |
972 if ( false !== wp_parse_url( $post_meta['_prtfl_link'] ) ) { |
909 if ( ( 0 == $user_id && 0 == $prtfl_options['link_additional_field_for_non_registered'] ) || 0 != $user_id ) { |
973 if ( ( 0 === $user_id && 0 === absint( $prtfl_options['link_additional_field_for_non_registered'] ) ) || 0 !== $user_id ) { |
910 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> <a href="' . $post_meta['_prtfl_link'] . '">' . $post_meta['_prtfl_link'] . '</a></p>'; |
974 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> <a href="' . $post_meta['_prtfl_link'] . '">' . $post_meta['_prtfl_link'] . '</a></p>'; |
911 } else { |
975 } else { |
912 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
976 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
913 } |
977 } |
914 } else { |
978 } else { |
915 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
979 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
916 } |
980 } |
917 } |
981 } |
918 if ( 0 != $user_id || 0 == $prtfl_options['svn_additional_field_for_non_logged'] ) { |
982 if ( 0 !== $user_id || 0 === absint( $prtfl_options['svn_additional_field_for_non_logged'] ) ) { |
919 if ( 1 == $prtfl_options['svn_additional_field'] && ! empty( $post_meta['_prtfl_svn'] ) ) { |
983 if ( 1 === absint( $prtfl_options['svn_additional_field'] ) && ! empty( $post_meta['_prtfl_svn'] ) ) { |
920 $custom_content .= '<p><span class="lable">' . $prtfl_options['svn_text_field'] . '</span> ' . $post_meta['_prtfl_svn'] . '</p>'; |
984 $custom_content .= '<p><span class="lable">' . $prtfl_options['svn_text_field'] . '</span> ' . $post_meta['_prtfl_svn'] . '</p>'; |
921 } |
985 } |
922 } |
986 } |
923 if ( 0 != $user_id ) { |
987 if ( 0 !== $user_id ) { |
924 if ( 1 == $prtfl_options['executor_additional_field'] ) { |
988 if ( 1 === absint( $prtfl_options['executor_additional_field'] ) ) { |
925 $executors_profile = wp_get_object_terms( $post->ID, 'portfolio_executor_profile' ); |
989 $executors_profile = wp_get_object_terms( $post->ID, 'portfolio_executor_profile' ); |
926 if ( ! empty( $executors_profile ) ) { |
990 if ( ! empty( $executors_profile ) ) { |
927 $custom_content .= '<p><span class="lable">' . $prtfl_options['executor_text_field'] . '</span>'; |
991 $custom_content .= '<p><span class="lable">' . $prtfl_options['executor_text_field'] . '</span>'; |
928 $count = 0; |
992 $count = 0; |
929 foreach ( $executors_profile as $profile ) { |
993 foreach ( $executors_profile as $profile ) { |
930 if ( $count > 0 ) { |
994 if ( $count > 0 ) { |
931 $custom_content .= ', '; |
995 $custom_content .= ', '; |
932 } |
996 } |
933 $custom_content .= '<a href="' . get_term_link( $profile->slug, 'portfolio_executor_profile' ) . '" title="' . $profile->name . ' profile" target="_blank">' . $profile->name . '</a>'; |
997 $custom_content .= '<a href="' . get_term_link( $profile->slug, 'portfolio_executor_profile' ) . '" title="' . $profile->name . ' profile" target="_blank">' . $profile->name . '</a>'; |
935 } |
999 } |
936 $custom_content .= '</p>'; |
1000 $custom_content .= '</p>'; |
937 } |
1001 } |
938 } |
1002 } |
939 } |
1003 } |
940 |
1004 } elseif ( 'portfolio.php' === basename( get_page_template() ) || ( ! empty( $prtfl_options['page_id_portfolio_template'] ) && $post->ID === $prtfl_options['page_id_portfolio_template'] ) ) { |
941 } elseif ( 'portfolio.php' == basename( get_page_template() ) ) { |
1005 global $wp_query, $request, $pdfprnt_options_array, $pdfprnt_options; |
942 global $wp_query, $request, $prtfl_options, $pdfprnt_options_array, $pdfprntpr_options; |
|
943 |
|
944 if ( ! $prtfl_options ) { |
|
945 $prtfl_options = get_option( 'prtfl_options' ); |
|
946 } |
|
947 |
1006 |
948 $count = 0; |
1007 $count = 0; |
949 if ( get_query_var( 'paged' ) ) { |
1008 if ( get_query_var( 'paged' ) ) { |
950 $paged = get_query_var( 'paged' ); |
1009 $paged = get_query_var( 'paged' ); |
951 } elseif ( get_query_var( 'page' ) ) { |
1010 } elseif ( get_query_var( 'page' ) ) { |
952 $paged = get_query_var( 'page' ); |
1011 $paged = get_query_var( 'page' ); |
953 } else { |
1012 } else { |
954 $paged = 1; |
1013 $paged = 1; |
955 } |
1014 } |
956 $per_page = $showitems = get_option( 'posts_per_page' ); |
1015 $per_page = get_option( 'posts_per_page' ); |
957 $technologies = isset( $wp_query->query_vars["technologies"] ) ? $wp_query->query_vars["technologies"] : ""; |
1016 $showitems = $per_page; |
958 $executor_profile = isset( $wp_query->query_vars["portfolio_executor_profile"] ) ? $wp_query->query_vars["portfolio_executor_profile"] : ""; |
1017 $technologies = isset( $wp_query->query_vars['technologies'] ) ? $wp_query->query_vars['technologies'] : ''; |
959 if ( "" != $technologies ) { |
1018 $executor_profile = isset( $wp_query->query_vars['portfolio_executor_profile'] ) ? $wp_query->query_vars['portfolio_executor_profile'] : ''; |
|
1019 if ( '' !== $technologies ) { |
960 $args = array( |
1020 $args = array( |
961 'post_type' => $prtfl_options['post_type_name'], |
1021 'post_type' => $prtfl_options['post_type_name'], |
962 'post_status' => 'publish', |
1022 'post_status' => 'publish', |
963 'orderby' => $prtfl_options['order_by'], |
1023 'orderby' => $prtfl_options['order_by'], |
964 'order' => $prtfl_options['order'], |
1024 'order' => $prtfl_options['order'], |
965 'posts_per_page' => $per_page, |
1025 'posts_per_page' => $per_page, |
966 'paged' => $paged, |
1026 'paged' => $paged, |
967 'tax_query' => array( |
1027 'tax_query' => array( |
968 array( |
1028 array( |
969 'taxonomy' => 'portfolio_technologies', |
1029 'taxonomy' => 'portfolio_technologies', |
970 'field' => 'slug', |
1030 'field' => 'slug', |
971 'terms' => $technologies |
1031 'terms' => $technologies, |
972 ) |
1032 ), |
973 ) |
1033 ), |
974 ); |
1034 ); |
975 } elseif ( "" != $executor_profile ) { |
1035 } elseif ( '' !== $executor_profile ) { |
976 $args = array( |
1036 $args = array( |
977 'post_type' => $prtfl_options['post_type_name'], |
1037 'post_type' => $prtfl_options['post_type_name'], |
978 'post_status' => 'publish', |
1038 'post_status' => 'publish', |
979 'orderby' => $prtfl_options['order_by'], |
1039 'orderby' => $prtfl_options['order_by'], |
980 'order' => $prtfl_options['order'], |
1040 'order' => $prtfl_options['order'], |
981 'posts_per_page' => $per_page, |
1041 'posts_per_page' => $per_page, |
982 'paged' => $paged, |
1042 'paged' => $paged, |
983 'tax_query' => array( |
1043 'tax_query' => array( |
984 array( |
1044 array( |
985 'taxonomy' => 'portfolio_executor_profile', |
1045 'taxonomy' => 'portfolio_executor_profile', |
986 'field' => 'slug', |
1046 'field' => 'slug', |
987 'terms' => $executor_profile |
1047 'terms' => $executor_profile, |
988 ) |
1048 ), |
989 ) |
1049 ), |
990 ); |
1050 ); |
991 } else { |
1051 } else { |
992 $args = array( |
1052 $args = array( |
993 'post_type' => $prtfl_options['post_type_name'], |
1053 'post_type' => $prtfl_options['post_type_name'], |
994 'post_status' => 'publish', |
1054 'post_status' => 'publish', |
995 'orderby' => $prtfl_options['order_by'], |
1055 'orderby' => $prtfl_options['order_by'], |
996 'order' => $prtfl_options['order'], |
1056 'order' => $prtfl_options['order'], |
997 'posts_per_page' => $per_page, |
1057 'posts_per_page' => $per_page, |
998 'paged' => $paged |
1058 'paged' => $paged, |
999 ); |
1059 ); |
1000 } |
1060 } |
1001 |
1061 |
1002 $second_query = new WP_Query( $args ); |
1062 $second_query = new WP_Query( $args ); |
1003 $request = $second_query->request; |
1063 $request = $second_query->request; |
1004 |
1064 |
1005 if ( $second_query->have_posts() ) { |
1065 if ( $second_query->have_posts() ) { |
1006 while ( $second_query->have_posts() ) { |
1066 while ( $second_query->have_posts() ) { |
1007 $second_query->the_post(); |
1067 $second_query->the_post(); |
1008 $custom_content .= '<div class="portfolio_content entry-content"> |
1068 $custom_content .= '<div class="portfolio_content entry-content"> |
1009 <div class="entry">'; |
1069 <div class="entry">'; |
1010 |
1070 |
1011 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
1071 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
1012 $user_id = get_current_user_id(); |
1072 $user_id = get_current_user_id(); |
1013 |
1073 |
1014 $short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
1074 $short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
1015 if ( empty( $short_descr ) ) { |
1075 if ( empty( $short_descr ) ) { |
1016 $short_descr = get_the_excerpt(); |
1076 $short_descr = get_the_excerpt(); |
1017 } |
1077 } |
1018 $title = get_the_title(); |
1078 $title = get_the_title(); |
1019 if ( empty( $title ) ) { |
1079 if ( empty( $title ) ) { |
1020 $title = '(' . __( 'No title', 'portfolio' ) . ')'; |
1080 $title = '(' . __( 'No title', 'portfolio' ) . ')'; |
1021 } |
1081 } |
1022 $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
1082 $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
1023 if ( empty( $post_thumbnail_id ) ) { |
1083 if ( empty( $post_thumbnail_id ) ) { |
1024 $args = array( |
1084 $args = array( |
1025 'post_parent' => $post->ID, |
1085 'post_parent' => $post->ID, |
1026 'post_type' => 'attachment', |
1086 'post_type' => 'attachment', |
1027 'post_mime_type' => 'image', |
1087 'post_mime_type' => 'image', |
1028 'numberposts' => 1 |
1088 'numberposts' => 1, |
1029 ); |
1089 ); |
1030 $attachments = get_children( $args ); |
1090 $attachments = get_children( $args ); |
1031 $post_thumbnail_id = key( $attachments ); |
1091 $post_thumbnail_id = key( $attachments ); |
1032 } |
1092 } |
1033 |
1093 |
1034 if ( ( isset( $pdfprnt_options_array['show_featured_image'] ) && 1 == $pdfprnt_options_array['show_featured_image'] ) |
1094 if ( ( isset( $pdfprnt_options_array['show_featured_image'] ) && 1 === absint( $pdfprnt_options_array['show_featured_image'] ) ) |
1035 || ( isset( $pdfprntpr_options['show_featured_image'] ) && 1 == $pdfprntpr_options['show_featured_image'] ) ) { |
1095 || ( isset( $pdfprnt_options['show_featured_image'] ) && 1 === absint( $pdfprnt_options['show_featured_image'] ) ) ) { |
1036 |
1096 |
1037 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
1097 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
1038 |
1098 |
1039 if ( ! empty( $image[0] ) ) { |
1099 if ( ! empty( $image[0] ) ) { |
1040 /* get width and height for image_size_album */ |
1100 /* get width and height for image_size_album */ |
1041 if ( 'portfolio-thumb' != $prtfl_options['image_size_album'] ) { |
1101 if ( 'portfolio-thumb' !== $prtfl_options['image_size_album'] ) { |
1042 $width = absint( get_option( $prtfl_options['image_size_album'] . '_size_w' ) ); |
1102 $width = absint( get_option( $prtfl_options['image_size_album'] . '_size_w' ) ); |
1043 $height = absint( get_option( $prtfl_options['image_size_album'] . '_size_h' ) ); |
1103 $height = absint( get_option( $prtfl_options['image_size_album'] . '_size_h' ) ); |
1044 } else { |
1104 } else { |
1045 $width = $prtfl_options['custom_size_px']['portfolio-thumb'][0]; |
1105 $width = $prtfl_options['custom_size_px']['portfolio-thumb'][0]; |
1046 $height = $prtfl_options['custom_size_px']['portfolio-thumb'][1]; |
1106 $height = $prtfl_options['custom_size_px']['portfolio-thumb'][1]; |
1047 } |
1107 } |
1048 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
1108 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
1049 |
1109 |
1050 $custom_content .= '<div class="portfolio_thumb"><img src="' . $image[0] . '" width="' . $width . '" height="' . $height . '" style="width:' . $width . 'px; height:' . $height . 'px;" alt="' . $image_alt . '" /></div>'; |
1110 $custom_content .= '<div class="portfolio_thumb"><img src="' . $image[0] . '" width="' . $width . '" height="' . $height . '" style="width:' . $width . 'px; height:' . $height . 'px;" alt="' . $image_alt . '" /></div>'; |
1051 } |
1111 } |
1052 } |
1112 } |
1053 |
1113 |
1054 $custom_content .= '<div class="portfolio_short_content"> |
1114 $custom_content .= '<div class="portfolio_short_content"> |
1055 <div class="item_title"> |
1115 <div class="item_title"> |
1056 <p><a href="' . get_permalink() . '" rel="bookmark">' . $title . '</a></p> |
1116 <p><a href="' . get_permalink() . '" rel="bookmark">' . $title . '</a></p> |
1057 </div>'; |
1117 </div>'; |
1058 if ( 1 == $prtfl_options['date_additional_field'] ) { |
1118 if ( 1 === absint( $prtfl_options['date_additional_field'] ) ) { |
1059 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
1119 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
1060 if ( ! empty( $date_compl ) ) { |
1120 if ( ! empty( $date_compl ) ) { |
1061 $custom_content .= '<p><span class="lable">' . $prtfl_options['date_text_field'] . '</span> ' . $date_compl . '</p>'; |
1121 $custom_content .= '<p><span class="lable">' . $prtfl_options['date_text_field'] . '</span> ' . $date_compl . '</p>'; |
1062 } |
1122 } |
1063 } |
1123 } |
1064 |
1124 |
1065 if ( 1 == $prtfl_options['link_additional_field'] && ! empty( $post_meta['_prtfl_link'] ) ) { |
1125 if ( 1 === absint( $prtfl_options['link_additional_field'] ) && ! empty( $post_meta['_prtfl_link'] ) ) { |
1066 if ( false !== parse_url( $post_meta['_prtfl_link'] ) ) { |
1126 if ( false !== wp_parse_url( $post_meta['_prtfl_link'] ) ) { |
1067 if ( ( 0 == $user_id && 0 == $prtfl_options['link_additional_field_for_non_registered'] ) || 0 != $user_id ) { |
1127 if ( ( 0 === $user_id && 0 === absint( $prtfl_options['link_additional_field_for_non_registered'] ) ) || 0 !== $user_id ) { |
1068 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> <a href="' . $post_meta['_prtfl_link'] . '">' . $post_meta['_prtfl_link'] . '</a></p>'; |
1128 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> <a href="' . $post_meta['_prtfl_link'] . '">' . $post_meta['_prtfl_link'] . '</a></p>'; |
1069 } else { |
1129 } else { |
1070 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
1130 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
1071 } |
1131 } |
1072 } else { |
1132 } else { |
1073 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
1133 $custom_content .= '<p><span class="lable">' . $prtfl_options['link_text_field'] . '</span> ' . $post_meta['_prtfl_link'] . '</p>'; |
1074 } |
1134 } |
1075 } |
1135 } |
1076 if ( 1 == $prtfl_options['shrdescription_additional_field'] ) { |
1136 if ( 1 === absint( $prtfl_options['shrdescription_additional_field'] ) ) { |
1077 $custom_content .= '<p><span class="lable">' . $prtfl_options['shrdescription_text_field'] . '</span> ' . $short_descr . '</p>'; |
1137 $custom_content .= '<p><span class="lable">' . $prtfl_options['shrdescription_text_field'] . '</span> ' . $short_descr . '</p>'; |
1078 } |
1138 } |
1079 $custom_content .= '</div> |
1139 $custom_content .= '</div> |
1080 </div> |
1140 </div> |
1081 </div>'; |
1141 </div>'; |
1083 } |
1143 } |
1084 } |
1144 } |
1085 return $content . $custom_content; |
1145 return $content . $custom_content; |
1086 } |
1146 } |
1087 } |
1147 } |
1088 /* adding class to manu items */ |
1148 |
1089 if ( ! function_exists( 'prtfl_add_portfolio_ancestor_to_menu' ) ) { |
1149 if ( ! function_exists( 'prtfl_add_portfolio_ancestor_to_menu' ) ) { |
|
1150 /** |
|
1151 * Adding class to manu items |
|
1152 * |
|
1153 * @param array $classes Array with classes. |
|
1154 * @param object $item Post object. |
|
1155 * @return array $classes Array with classes. |
|
1156 */ |
1090 function prtfl_add_portfolio_ancestor_to_menu( $classes, $item ) { |
1157 function prtfl_add_portfolio_ancestor_to_menu( $classes, $item ) { |
1091 global $prtfl_options; |
1158 global $prtfl_options; |
1092 if ( is_singular( $prtfl_options['post_type_name'] ) ) { |
1159 if ( is_singular( $prtfl_options['post_type_name'] ) ) { |
1093 global $wpdb, $post; |
1160 global $wpdb, $post; |
1094 $parent = $wpdb->get_var( "SELECT $wpdb->posts.post_name FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'portfolio.php' AND (post_status = 'publish' OR post_status = 'private') AND $wpdb->posts.ID = $wpdb->postmeta.post_id" ); |
1161 $parent = $wpdb->get_var( "SELECT $wpdb->posts.post_name FROM $wpdb->posts, $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = 'portfolio.php' AND (post_status = 'publish' OR post_status = 'private') AND $wpdb->posts.ID = $wpdb->postmeta.post_id" ); |
1095 |
1162 |
1096 if ( in_array( 'menu-item-' . $item->ID, $classes ) && $parent == strtolower( $item->title ) ) { |
1163 if ( in_array( 'menu-item-' . $item->ID, $classes ) && strtolower( $item->title ) === $parent ) { |
1097 $classes[] = 'current-page-ancestor'; |
1164 $classes[] = 'current-page-ancestor'; |
1098 } |
1165 } |
1099 } |
1166 } |
1100 return $classes; |
1167 return $classes; |
1101 } |
1168 } |
1102 } |
1169 } |
1103 |
1170 |
1104 /* forming content for portfolio items */ |
|
1105 if ( ! function_exists( 'prtfl_latest_items' ) ) { |
1171 if ( ! function_exists( 'prtfl_latest_items' ) ) { |
1106 function prtfl_latest_items( $atts, $widget = false ) { |
1172 /** |
|
1173 * Forming content for portfolio items |
|
1174 * |
|
1175 * @param array $atts Attributes. |
|
1176 * @param array $count Count or false. |
|
1177 */ |
|
1178 function prtfl_latest_items( $atts, $count = false ) { |
1107 global $prtfl_options, $wp_query; |
1179 global $prtfl_options, $wp_query; |
1108 $old_wp_query = $wp_query; |
1180 if ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) { |
1109 $count_portfolio_row_block = 0; |
1181 $old_wp_query = $wp_query; |
1110 if ( $widget == false) { |
1182 $count_portfolio_row_block = 0; |
1111 $custom_portfolio_row_count = $prtfl_options['custom_portfolio_row_count']; |
1183 if ( false === $count || empty( $count ) ) { |
1112 } else { |
1184 $custom_portfolio_row_count = $prtfl_options['custom_portfolio_row_count']; |
1113 $custom_portfolio_row_count = $widget; |
1185 } else { |
1114 } |
1186 $custom_portfolio_row_count = $count; |
1115 $prtfl_widht = 100 / $custom_portfolio_row_count; |
1187 } |
1116 |
1188 $prtfl_widht = 100 / $custom_portfolio_row_count; |
1117 |
1189 |
1118 if( 1 < $custom_portfolio_row_count ) { |
1190 if ( 1 < $custom_portfolio_row_count ) { |
1119 $prtfl_img_width = ''; |
1191 $prtfl_img_width = ''; |
1120 }else{ |
1192 } else { |
1121 $prtfl_img_width = 'style="width:165px"'; |
1193 $prtfl_img_width = 'style="width:165px"'; |
1122 } |
1194 } |
1123 |
1195 |
1124 $content = '<div class="prtfl_portfolio_block">'; |
1196 $content = '<div class="prtfl_portfolio_block">'; |
1125 if ( empty( $atts['count'] ) ) { |
1197 if ( empty( $atts['count'] ) ) { |
1126 $atts['count'] = 3; |
1198 $atts['count'] = 3; |
1127 } |
1199 } |
1128 $args = array( |
1200 $args = array( |
1129 'post_type' => $prtfl_options['post_type_name'], |
1201 'post_type' => $prtfl_options['post_type_name'], |
1130 'post_status' => 'publish', |
1202 'post_status' => 'publish', |
1131 'orderby' => 'date', |
1203 'orderby' => 'date', |
1132 'order' => $prtfl_options['order'], |
1204 'order' => $prtfl_options['order'], |
1133 'posts_per_page' => $atts['count'], |
1205 'posts_per_page' => $atts['count'], |
1134 ); |
1206 ); |
1135 $second_query = new WP_Query( $args ); |
1207 $second_query = new WP_Query( $args ); |
1136 $request = $second_query->request; |
1208 $request = $second_query->request; |
1137 |
1209 |
1138 if ( $second_query->have_posts() ) { |
1210 if ( $second_query->have_posts() ) { |
1139 while ( $second_query->have_posts() ) { |
1211 while ( $second_query->have_posts() ) { |
1140 $second_query->the_post(); |
1212 $second_query->the_post(); |
1141 if ( $count_portfolio_row_block % $custom_portfolio_row_count == 0 ) { |
1213 if ( 0 === $count_portfolio_row_block % $custom_portfolio_row_count ) { |
1142 $content .= '<div class="portfolio_row_count">'; |
1214 $content .= '<div class="portfolio_row_count">'; |
1143 } |
1215 } |
1144 $content .= '<div id="portfolio_row_count_block" class="portfolio_row_count_block" style="width: ' . $prtfl_widht . '%"> |
1216 $content .= '<div id="portfolio_row_count_block" class="portfolio_row_count_block" style="width: ' . $prtfl_widht . '%"> |
1145 <div class="portfolio_content"> |
1217 <div class="portfolio_content"> |
1146 <div class="entry">'; |
1218 <div class="entry">'; |
1147 global $post; |
1219 global $post; |
1148 $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
1220 $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
1149 if ( empty ( $post_thumbnail_id ) ) { |
1221 if ( empty( $post_thumbnail_id ) ) { |
1150 $args = array( |
1222 $args = array( |
1151 'post_parent' => $post->ID, |
1223 'post_parent' => $post->ID, |
1152 'post_type' => 'attachment', |
1224 'post_type' => 'attachment', |
1153 'post_mime_type' => 'image', |
1225 'post_mime_type' => 'image', |
1154 'numberposts' => 1 |
1226 'numberposts' => 1, |
1155 ); |
1227 ); |
1156 $attachments = get_children( $args ); |
1228 $attachments = get_children( $args ); |
1157 $post_thumbnail_id = key( $attachments ); |
1229 $post_thumbnail_id = key( $attachments ); |
1158 } |
1230 } |
1159 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
1231 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
1160 |
1232 |
1161 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
1233 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
1162 $image_desc = get_post( $post_thumbnail_id ); |
1234 $image_desc = get_post( $post_thumbnail_id ); |
1163 $image_desc = $image_desc->post_content; |
1235 $image_desc = $image_desc->post_content; |
1164 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
1236 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
1165 |
1237 |
1166 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
1238 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
1167 $link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
1239 $link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
1168 $short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
1240 $short_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
1169 if ( empty( $short_descr ) ) { |
1241 if ( empty( $short_descr ) ) { |
1170 $short_descr = get_the_excerpt(); |
1242 $short_descr = get_the_excerpt(); |
1171 } |
1243 } |
1172 $title = get_the_title(); |
1244 $title = get_the_title(); |
1174 $title = '(' . __( 'No title', 'portfolio' ) . ')'; |
1246 $title = '(' . __( 'No title', 'portfolio' ) . ')'; |
1175 } |
1247 } |
1176 $permalink = get_permalink(); |
1248 $permalink = get_permalink(); |
1177 |
1249 |
1178 $content .= '<div class="portfolio_thumb" ' . $prtfl_img_width . '> |
1250 $content .= '<div class="portfolio_thumb" ' . $prtfl_img_width . '> |
1179 <img src="' . $image[0] . '" width="' . $image[1] . '" alt="' . $image_alt . '" /> |
1251 <img src="' . $image[0] . '" width="' . $image[1] . '" alt="' . $image_alt . '" /> |
1180 </div> |
1252 </div> |
1181 <div class="portfolio_short_content"> |
1253 <div class="portfolio_short_content"> |
1182 <div class="item_title"> |
1254 <div class="item_title"> |
1183 <p> |
1255 <p> |
1184 <a href="' . $permalink . '" rel="bookmark">' . $title . '</a> |
1256 <a href="' . $permalink . '" rel="bookmark">' . $title . '</a> |
1185 </p> |
1257 </p> |
1186 </div> <!-- .item_title -->'; |
1258 </div> <!-- .item_title -->'; |
1187 if ( 1 == $prtfl_options['shrdescription_additional_field'] && ( ! empty( $short_descr ) ) ) { |
1259 if ( 1 === absint( $prtfl_options['shrdescription_additional_field'] ) && ( ! empty( $short_descr ) ) ) { |
1188 $content .= '<p>' . $short_descr . '</p>'; |
1260 $content .= '<p>' . $short_descr . '</p>'; |
|
1261 } |
|
1262 $content .= '</div> <!-- .portfolio_short_content --> |
|
1263 </div> <!-- .entry --> |
|
1264 <div class="read_more"> |
|
1265 <a href="' . $permalink . '" rel="bookmark">' . __( 'Read more', 'portfolio' ) . '</a> |
|
1266 </div> <!-- .read_more --> |
|
1267 <div class="portfolio_terms">'; |
|
1268 if ( 1 === absint( $prtfl_options['technologies_additional_field'] ) ) { |
|
1269 $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
|
1270 if ( is_array( $terms ) && 0 < count( $terms ) ) { |
|
1271 $content .= '<b>' . __( 'Technologies', 'portfolio' ) . ':</b> '; |
|
1272 $count = 0; |
|
1273 foreach ( $terms as $term ) { |
|
1274 if ( $count > 0 ) { |
|
1275 $content .= ', '; |
|
1276 } |
|
1277 $content .= '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( 'View all projects in %s' ), $term->name ) . '">' . $term->name . '</a>'; |
|
1278 $count++; |
|
1279 } |
|
1280 } else { |
|
1281 $content .= ' '; |
1189 } |
1282 } |
1190 $content .= '</div> <!-- .portfolio_short_content --> |
|
1191 </div> <!-- .entry --> |
|
1192 <div class="read_more"> |
|
1193 <a href="' . $permalink . '" rel="bookmark">' . __( 'Read more', 'portfolio' ) . '</a> |
|
1194 </div> <!-- .read_more --> |
|
1195 <div class="portfolio_terms">'; |
|
1196 if ( 1 == $prtfl_options['technologies_additional_field'] ) { |
|
1197 $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
|
1198 if ( is_array( $terms ) && 0 < count( $terms ) ) { |
|
1199 $content .= __( 'Technologies', 'portfolio' ) . ':'; |
|
1200 $count = 0; |
|
1201 foreach ( $terms as $term ) { |
|
1202 if ( $count > 0 ) { |
|
1203 $content .= ', '; |
|
1204 } |
|
1205 $content .= '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( "View all projects in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>'; |
|
1206 $count++; |
|
1207 } |
|
1208 } else { |
|
1209 $content .= ' '; |
|
1210 } |
1283 } |
|
1284 $content .= '</div><!-- .portfolio_terms -->'; |
|
1285 $content .= '<div class="prtfl_clear"></div></div> <!-- .portfolio_content --></div><!-- .gllr_image_block -->'; |
|
1286 if ( ( $count_portfolio_row_block % $custom_portfolio_row_count ) === ( $custom_portfolio_row_count - 1 ) ) { |
|
1287 $content .= '<div class="clear"></div> |
|
1288 </div><!-- .gllr_image_row -->'; |
|
1289 } |
|
1290 $count_portfolio_row_block++; |
1211 } |
1291 } |
1212 $content .= '</div><!-- .portfolio_terms -->'; |
1292 } |
1213 $content .= '<div class="prtfl_clear"></div></div> <!-- .portfolio_content --></div><!-- .gllr_image_block -->'; |
1293 $content .= '</div> <!-- .prtfl_portfolio_block --><div class="clear"></div>'; |
1214 if ( ( $count_portfolio_row_block % $custom_portfolio_row_count ) == ( $custom_portfolio_row_count - 1 ) ) { |
1294 wp_reset_query(); |
1215 $content .= '<div class="clear"></div> |
1295 $wp_query = $old_wp_query; |
1216 </div><!-- .gllr_image_row -->'; |
1296 return $content; |
1217 } |
1297 } |
1218 $count_portfolio_row_block = $count_portfolio_row_block + 1; |
1298 } |
1219 } |
1299 } |
1220 } |
1300 |
1221 $content .= '</div> <!-- .prtfl_portfolio_block --><div class="clear"></div>'; |
|
1222 wp_reset_query(); |
|
1223 $wp_query = $old_wp_query; |
|
1224 return $content; |
|
1225 } |
|
1226 } |
|
1227 |
|
1228 /* Register style and script files */ |
|
1229 if ( ! function_exists( 'prtfl_admin_head' ) ) { |
1301 if ( ! function_exists( 'prtfl_admin_head' ) ) { |
|
1302 /** |
|
1303 * Register style and script files |
|
1304 */ |
1230 function prtfl_admin_head() { |
1305 function prtfl_admin_head() { |
1231 global $prtfl_plugin_info, $hook_suffix, $post_type, $prtfl_options; |
1306 global $prtfl_plugin_info, $hook_suffix, $post_type, $prtfl_options; |
1232 |
1307 |
1233 wp_enqueue_style( 'prtfl_icon', plugins_url( 'css/icon.css', __FILE__ ) ); |
1308 if ( ! $prtfl_plugin_info ) { |
1234 |
1309 if ( ! function_exists( 'get_plugin_data' ) ) { |
1235 if ( ( ( 'post.php' == $hook_suffix || 'post-new.php' == $hook_suffix ) && isset( $post_type ) && $prtfl_options['post_type_name'] == $post_type ) || |
1310 require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
1236 ( isset( $_GET['page'] ) && 'portfolio.php' == $_GET['page'] ) ) { |
1311 } |
1237 wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ) ); |
1312 $prtfl_plugin_info = get_plugin_data( __FILE__ ); |
1238 wp_enqueue_style( 'prtfl_jquery-style', plugins_url( 'css/jquery-ui.css', __FILE__ ) ); |
1313 } |
|
1314 |
|
1315 wp_enqueue_style( 'prtfl_icon', plugins_url( 'css/icon.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] ); |
|
1316 |
|
1317 if ( ( ( 'post.php' === $hook_suffix || 'post-new.php' === $hook_suffix ) && isset( $post_type ) && $prtfl_options['post_type_name'] === $post_type ) || |
|
1318 ( isset( $_GET['page'] ) && 'portfolio.php' === $_GET['page'] ) ) { |
|
1319 wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] ); |
|
1320 wp_enqueue_style( 'prtfl_jquery-style', plugins_url( 'css/jquery-ui.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] ); |
1239 wp_enqueue_script( 'jquery-ui-datepicker' ); |
1321 wp_enqueue_script( 'jquery-ui-datepicker' ); |
1240 |
1322 |
1241 wp_enqueue_script( 'prtfl_script', plugins_url( 'js/script.js', __FILE__ ) ); |
1323 wp_enqueue_script( 'prtfl_script', plugins_url( 'js/script.js', __FILE__ ), array(), $prtfl_plugin_info['Version'], true ); |
1242 wp_localize_script( 'prtfl_script', 'prtfl_vars', array( |
1324 wp_localize_script( |
1243 'prtfl_nonce' => wp_create_nonce( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' ), |
1325 'prtfl_script', |
1244 'update_img_message' => __( 'Updating images...', 'portfolio' ) . '<img class="prtfl_loader" src="' . plugins_url( 'images/ajax-loader.gif', __FILE__ ) . '" alt="" />', |
1326 'prtfl_vars', |
1245 'not_found_img_info' => __( 'No image found.', 'portfolio' ), |
1327 array( |
1246 'img_success' => __( 'All images are updated.', 'portfolio' ), |
1328 'prtfl_nonce' => wp_create_nonce( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' ), |
1247 'img_error' => __( 'Error:', 'portfolio' ) ) ); |
1329 'update_img_message' => __( 'Updating images...', 'portfolio' ) . '<img class="prtfl_loader" src="' . plugins_url( 'images/ajax-loader.gif', __FILE__ ) . '" alt="" />', |
|
1330 'not_found_img_info' => __( 'No image found.', 'portfolio' ), |
|
1331 'img_success' => __( 'All images are updated.', 'portfolio' ), |
|
1332 'img_error' => __( |
|
1333 'Error:', |
|
1334 'portfolio' |
|
1335 ), |
|
1336 ) |
|
1337 ); |
1248 |
1338 |
1249 bws_enqueue_settings_scripts(); |
1339 bws_enqueue_settings_scripts(); |
1250 bws_plugins_include_codemirror(); |
1340 bws_plugins_include_codemirror(); |
1251 } |
1341 } |
1252 } |
1342 } |
1253 } |
1343 } |
1254 |
1344 |
1255 /* enqueue fancybox script and style css */ |
|
1256 if ( ! function_exists( 'prtfl_wp_enqueue_scripts' ) ) { |
1345 if ( ! function_exists( 'prtfl_wp_enqueue_scripts' ) ) { |
|
1346 /** |
|
1347 * Enqueue fancybox script and style css |
|
1348 */ |
1257 function prtfl_wp_enqueue_scripts() { |
1349 function prtfl_wp_enqueue_scripts() { |
1258 wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ) ); |
1350 global $prtfl_plugin_info; |
1259 wp_enqueue_style( 'prtfl_lightbox_stylesheet', plugins_url( 'fancybox/jquery.fancybox.min.css', __FILE__ ) ); |
1351 |
1260 } |
1352 if ( ! $prtfl_plugin_info ) { |
1261 } |
1353 if ( ! function_exists( 'get_plugin_data' ) ) { |
1262 |
1354 require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
1263 /* styles for IE */ |
1355 } |
|
1356 $prtfl_plugin_info = get_plugin_data( __FILE__ ); |
|
1357 } |
|
1358 wp_enqueue_style( 'prtfl_stylesheet', plugins_url( 'css/style.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] ); |
|
1359 wp_enqueue_style( 'prtfl_lightbox_stylesheet', plugins_url( 'fancybox/jquery.fancybox.min.css', __FILE__ ), array(), $prtfl_plugin_info['Version'] ); |
|
1360 } |
|
1361 } |
|
1362 |
1264 if ( ! function_exists( 'prtfl_wp_head' ) ) { |
1363 if ( ! function_exists( 'prtfl_wp_head' ) ) { |
|
1364 /** |
|
1365 * Styles for IE |
|
1366 */ |
1265 function prtfl_wp_head() { |
1367 function prtfl_wp_head() { |
1266 global $prtfl_options; |
1368 global $prtfl_options; |
1267 /* Add style for IE compatibility */ |
1369 /* Add style for IE compatibility */ |
1268 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) { |
1370 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Trident/7.0; rv:11.0' ) !== false || strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'MSIE' ) !== false ) { |
1269 $post_type = get_post_type(); |
1371 $post_type = get_post_type(); |
1270 if ( is_single() && $prtfl_options['post_type_name'] == $post_type ) { ?> |
1372 if ( is_single() && $prtfl_options['post_type_name'] === $post_type ) { |
|
1373 ?> |
1271 <style type="text/css"> |
1374 <style type="text/css"> |
1272 .portfolio_images_gallery { |
1375 .portfolio_images_gallery { |
1273 display: block; |
1376 display: block; |
1274 } |
1377 } |
1275 .portfolio_thumb { |
1378 .portfolio_thumb { |
1276 float: none; |
1379 float: none; |
1277 } |
1380 } |
1278 </style> |
1381 </style> |
1279 <?php } |
1382 <?php |
1280 } |
1383 } |
1281 } |
1384 } |
1282 } |
1385 } |
1283 |
1386 } |
1284 /* initializing script of fancybox */ |
1387 |
1285 if ( ! function_exists( 'prtfl_wp_footer' ) ) { |
1388 if ( ! function_exists( 'prtfl_wp_footer' ) ) { |
|
1389 /** |
|
1390 * Initializing script of fancybox |
|
1391 */ |
1286 function prtfl_wp_footer() { |
1392 function prtfl_wp_footer() { |
1287 global $prtfl_options, $post, $wp_query; |
1393 global $prtfl_options, $post, $wp_query, $prtfl_plugin_info; |
|
1394 |
|
1395 if ( ! $prtfl_plugin_info ) { |
|
1396 if ( ! function_exists( 'get_plugin_data' ) ) { |
|
1397 require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
1398 } |
|
1399 $prtfl_plugin_info = get_plugin_data( __FILE__ ); |
|
1400 } |
1288 $post_thumbnail_id = ''; |
1401 $post_thumbnail_id = ''; |
1289 if ( ! empty( $wp_query->post->ID ) ) { |
1402 if ( ! empty( $wp_query->post->ID ) ) { |
1290 $post_thumbnail_id = get_post_thumbnail_id( $wp_query->post->ID ); |
1403 $post_thumbnail_id = get_post_thumbnail_id( $wp_query->post->ID ); |
1291 } |
1404 } |
1292 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
1405 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
1293 |
1406 |
1294 if ( wp_script_is( 'prtfl_front_script', 'registered' ) ) { |
1407 if ( wp_script_is( 'prtfl_front_script', 'registered' ) ) { |
1295 wp_enqueue_script( 'prtfl_front_script' ); |
1408 wp_enqueue_script( 'prtfl_front_script' ); |
1296 wp_enqueue_script( 'prtfl_fancyboxJs', plugins_url( 'fancybox/jquery.fancybox.min.js', __FILE__ ), array( 'jquery' ) ); |
1409 wp_enqueue_script( 'prtfl_fancyboxJs', plugins_url( 'fancybox/jquery.fancybox.min.js', __FILE__ ), array( 'jquery' ), $prtfl_plugin_info['Version'] ); |
1297 |
1410 |
1298 /* Initialization of fancybox script */ |
1411 /* Initialization of fancybox script */ |
1299 if ( ! empty( $image[0] ) ) { |
1412 if ( ! empty( $image[0] ) ) { |
1300 $script = "( function( $ ){ |
1413 $script = "( function( $ ){ |
1301 $( document ).ready( function(){ |
1414 $( document ).ready( function(){ |
1302 $( \"a[data-fancybox=portfolio_fancybox]\" ).fancybox({ |
1415 $( \"a[data-fancybox=portfolio_fancybox]\" ).fancybox({ |
1303 loop : true, |
1416 loop : true, |
1304 arrows : false, |
1417 arrows : false, |
1305 infobar : true, |
1418 infobar : true, |
1306 speed : 500, |
1419 speed : 500, |
1307 toolbar: false, |
1420 toolbar: false, |
1308 animationEffect : 'zoom', |
1421 animationEffect : 'zoom', |
1309 openEffect : 'elastic', |
1422 openEffect : 'elastic', |
1310 closeEffect : 'elastic' |
1423 closeEffect : 'elastic' |
1311 } ); |
1424 } ); |
1312 } ); |
1425 } ); |
1313 } )( jQuery );"; |
1426 } )( jQuery );"; |
1314 wp_register_script( 'prtfl_fancybox_script', '' ); |
1427 wp_register_script( 'prtfl_fancybox_script', '', array(), $prtfl_plugin_info['Version'] ); |
1315 wp_enqueue_script( 'prtfl_fancybox_script' ); |
1428 wp_enqueue_script( 'prtfl_fancybox_script' ); |
1316 wp_add_inline_script( 'prtfl_fancybox_script', sprintf( $script ) ); |
1429 wp_add_inline_script( 'prtfl_fancybox_script', sprintf( $script ) ); |
1317 } |
1430 } |
1318 } |
1431 } |
1319 |
1432 |
1320 } |
1433 } |
1321 } |
1434 } |
1322 |
1435 |
1323 /** |
|
1324 * Ajax function for updating images |
|
1325 * @return void |
|
1326 */ |
|
1327 if ( ! function_exists( 'prtfl_update_image' ) ) { |
1436 if ( ! function_exists( 'prtfl_update_image' ) ) { |
|
1437 /** |
|
1438 * Ajax function for updating images |
|
1439 */ |
1328 function prtfl_update_image() { |
1440 function prtfl_update_image() { |
1329 global $wpdb, $prtfl_options; |
1441 global $wpdb, $prtfl_options; |
1330 check_ajax_referer( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' ); |
1442 check_ajax_referer( plugin_basename( __FILE__ ), 'prtfl_ajax_nonce_field' ); |
1331 $action = isset( $_REQUEST['action1'] ) ? $_REQUEST['action1'] : ""; |
1443 $action = isset( $_REQUEST['action1'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action1'] ) ) : ''; |
1332 $id = isset( $_REQUEST['id'] ) ? $_REQUEST['id'] : ""; |
1444 $id = isset( $_REQUEST['id'] ) ? absint( $_REQUEST['id'] ) : ''; |
1333 switch ( $action ) { |
1445 switch ( $action ) { |
1334 case 'get_all_attachment': |
1446 case 'get_all_attachment': |
1335 |
1447 $array_parent_id = $wpdb->get_col( |
1336 $array_parent_id = $wpdb->get_col( $wpdb->prepare( " |
1448 $wpdb->prepare( |
1337 SELECT |
1449 'SELECT ID |
1338 ID |
1450 FROM ' . $wpdb->posts . ' |
1339 FROM |
1451 WHERE post_type = %s', |
1340 {$wpdb->posts} |
1452 $prtfl_options['post_type_name'] |
1341 WHERE |
1453 ) |
1342 post_type = %s |
1454 ); |
1343 ", $prtfl_options['post_type_name'] ) ); |
|
1344 |
1455 |
1345 if ( ! empty( $array_parent_id ) ) { |
1456 if ( ! empty( $array_parent_id ) ) { |
1346 $string_parent_id = implode( ",", $array_parent_id ); |
1457 $parent_id_placeholders = implode( ', ', array_fill( 0, count( (array) $array_parent_id ), '%d' ) ); |
1347 |
1458 |
1348 $metas = $wpdb->get_results( " |
1459 $metas = $wpdb->get_results( |
1349 SELECT |
1460 $wpdb->prepare( |
1350 meta_value |
1461 'SELECT meta_value |
1351 FROM |
1462 FROM ' . $wpdb->postmeta . ' |
1352 {$wpdb->postmeta} |
1463 WHERE meta_key = %s |
1353 WHERE |
1464 AND post_id IN (' . $parent_id_placeholders . ')', |
1354 meta_key = '_prtfl_images' AND |
1465 '_prtfl_images', |
1355 post_id IN (" . $string_parent_id . ") |
1466 $array_parent_id |
1356 ", ARRAY_A ); |
1467 ), |
|
1468 ARRAY_A |
|
1469 ); |
1357 |
1470 |
1358 $result_attachment_id = ''; |
1471 $result_attachment_id = ''; |
1359 foreach ( $metas as $key => $value ) { |
1472 foreach ( $metas as $key => $value ) { |
1360 if ( ! empty( $value['meta_value'] ) ) { |
1473 if ( ! empty( $value['meta_value'] ) ) { |
1361 $result_attachment_id .= $value['meta_value'] . ','; |
1474 $result_attachment_id .= $value['meta_value'] . ','; |
1362 } |
1475 } |
1363 } |
1476 } |
1364 $result_attachment_id_array = explode( ",", rtrim( $result_attachment_id, ',' ) ); |
1477 $result_attachment_id_array = explode( ',', rtrim( $result_attachment_id, ',' ) ); |
1365 |
1478 |
1366 $attached_id = $wpdb->get_results( " |
1479 $attached_id = $wpdb->get_results( |
1367 SELECT |
1480 $wpdb->prepare( |
1368 ID |
1481 'SELECT ID |
1369 FROM |
1482 FROM ' . $wpdb->posts . ' |
1370 {$wpdb->posts} |
1483 WHERE post_type = %s |
1371 WHERE |
1484 AND post_mime_type LIKE %s |
1372 post_type = 'attachment' AND |
1485 AND post_parent IN (' . $parent_id_placeholders . ')', |
1373 post_mime_type LIKE 'image%' AND |
1486 'attachment', |
1374 post_parent IN (" . $string_parent_id . ") |
1487 'image%', |
1375 ", ARRAY_A ); |
1488 $array_parent_id |
|
1489 ), |
|
1490 ARRAY_A |
|
1491 ); |
1376 |
1492 |
1377 foreach ( $attached_id as $key => $value ) { |
1493 foreach ( $attached_id as $key => $value ) { |
1378 $result_attachment_id_array[] = $value['ID']; |
1494 $result_attachment_id_array[] = $value['ID']; |
1379 } |
1495 } |
1380 echo json_encode( array_unique( $result_attachment_id_array ) ); |
1496 echo wp_json_encode( array_unique( $result_attachment_id_array ) ); |
1381 } |
1497 } |
1382 break; |
1498 break; |
1383 case 'update_image': |
1499 case 'update_image': |
1384 $metadata = wp_get_attachment_metadata( $id ); |
1500 $metadata = wp_get_attachment_metadata( $id ); |
1385 $uploads = wp_upload_dir(); |
1501 $uploads = wp_upload_dir(); |
1386 $path = $uploads['basedir'] . "/" . $metadata['file']; |
1502 $path = $uploads['basedir'] . '/' . $metadata['file']; |
1387 require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
1503 require_once ABSPATH . 'wp-admin/includes/image.php'; |
1388 $metadata_new = prtfl_wp_generate_attachment_metadata( $id, $path, $metadata ); |
1504 $metadata_new = prtfl_wp_generate_attachment_metadata( $id, $path, $metadata ); |
1389 wp_update_attachment_metadata( $id, array_merge( $metadata, $metadata_new ) ); |
1505 wp_update_attachment_metadata( $id, array_merge( $metadata, $metadata_new ) ); |
1390 break; |
1506 break; |
1391 case 'update_options': |
1507 case 'update_options': |
1392 unset( $prtfl_options['need_image_update'] ); |
1508 unset( $prtfl_options['need_image_update'] ); |
1462 return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id ); |
1589 return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id ); |
1463 } |
1590 } |
1464 } |
1591 } |
1465 |
1592 |
1466 if ( ! function_exists( 'prtfl_image_make_intermediate_size' ) ) { |
1593 if ( ! function_exists( 'prtfl_image_make_intermediate_size' ) ) { |
1467 function prtfl_image_make_intermediate_size( $file, $width, $height, $crop=false ) { |
1594 /** |
|
1595 * Change size for attachment |
|
1596 * |
|
1597 * @param string $file File string. |
|
1598 * @param int $width Width for attachment. |
|
1599 * @param int $height Height for attachment. |
|
1600 * @param bool $crop Flag for crop. |
|
1601 */ |
|
1602 function prtfl_image_make_intermediate_size( $file, $width, $height, $crop = false ) { |
1468 if ( $width || $height ) { |
1603 if ( $width || $height ) { |
1469 $resized_file = prtfl_image_resize( $file, $width, $height, $crop ); |
1604 $resized_file = prtfl_image_resize( $file, $width, $height, $crop ); |
1470 if ( ! is_wp_error( $resized_file ) && $resized_file && $info = getimagesize( $resized_file ) ) { |
1605 if ( ! is_wp_error( $resized_file ) && $resized_file ) { |
1471 $resized_file = apply_filters( 'image_make_intermediate_size', $resized_file ); |
1606 $info = getimagesize( $resized_file ); |
1472 return array( |
1607 if ( ! empty( $info ) ) { |
1473 'file' => wp_basename( $resized_file ), |
1608 $resized_file = apply_filters( 'image_make_intermediate_size', $resized_file ); |
1474 'width' => $info[0], |
1609 return array( |
1475 'height' => $info[1], |
1610 'file' => wp_basename( $resized_file ), |
1476 ); |
1611 'width' => $info[0], |
|
1612 'height' => $info[1], |
|
1613 ); |
|
1614 } |
1477 } |
1615 } |
1478 } |
1616 } |
1479 return false; |
1617 return false; |
1480 } |
1618 } |
1481 } |
1619 } |
1482 |
1620 |
1483 if ( ! function_exists( 'prtfl_image_resize' ) ) { |
1621 if ( ! function_exists( 'prtfl_image_resize' ) ) { |
|
1622 /** |
|
1623 * Resize for attachment |
|
1624 * |
|
1625 * @param string $file File string. |
|
1626 * @param int $max_w Max width for attachment. |
|
1627 * @param int $max_h Max height for attachment. |
|
1628 * @param bool $crop Flag for crop. |
|
1629 * @param string $suffix Suffix for file name. |
|
1630 * @param string $dest_path Destination path. |
|
1631 * @param int $jpeg_quality Quality for attachment. |
|
1632 */ |
1484 function prtfl_image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { |
1633 function prtfl_image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { |
1485 $size = @getimagesize( $file ); |
1634 $size = @getimagesize( $file ); |
1486 if ( ! $size ) { |
1635 if ( ! $size ) { |
1487 return new WP_Error( 'invalid_image', __( 'Image size not defined', 'portfolio' ), $file ); |
1636 return new WP_Error( 'invalid_image', __( 'Image size not defined', 'portfolio' ), $file ); |
1488 } |
1637 } |
1489 $type = $size[2]; |
1638 $type = $size[2]; |
1490 |
1639 |
1491 if ( 3 == $type ) { |
1640 if ( 3 === $type ) { |
1492 $image = imagecreatefrompng( $file ); |
1641 $image = imagecreatefrompng( $file ); |
1493 } elseif ( 2 == $type ) { |
1642 } elseif ( 2 === $type ) { |
1494 $image = imagecreatefromjpeg( $file ); |
1643 $image = imagecreatefromjpeg( $file ); |
1495 } elseif ( 1 == $type ) { |
1644 } elseif ( 1 === $type ) { |
1496 $image = imagecreatefromgif( $file ); |
1645 $image = imagecreatefromgif( $file ); |
1497 } elseif ( 15 == $type ) { |
1646 } elseif ( 15 === $type ) { |
1498 $image = imagecreatefromwbmp( $file ); |
1647 $image = imagecreatefromwbmp( $file ); |
1499 } elseif ( 16 == $type ) { |
1648 } elseif ( 16 === $type ) { |
1500 $image = imagecreatefromxbm( $file ); |
1649 $image = imagecreatefromxbm( $file ); |
1501 } else { |
1650 } else { |
1502 return new WP_Error( 'invalid_image', __( 'We can update only PNG, JPEG, GIF, WPMP or XBM filetype. For other image formats, please manually reload image.', 'portfolio' ), $file ); |
1651 return new WP_Error( 'invalid_image', __( 'We can update only PNG, JPEG, GIF, WPMP or XBM filetype. For other image formats, please manually reload image.', 'portfolio' ), $file ); |
1503 } |
1652 } |
1504 if ( ! is_resource( $image ) ) { |
1653 if ( ! is_resource( $image ) ) { |
1505 return new WP_Error( 'error_loading_image', $image, $file ); |
1654 return new WP_Error( 'error_loading_image', $image, $file ); |
1506 } |
1655 } |
1507 /* $size = @getimagesize( $file ); */ |
1656 /* $size = @getimagesize( $file ); */ |
1508 list( $orig_w, $orig_h, $orig_type ) = $size; |
1657 list( $orig_w, $orig_h, $orig_type ) = $size; |
1509 $dims = prtfl_image_resize_dimensions( $orig_w, $orig_h, $max_w, $max_h, $crop ); |
1658 $dims = prtfl_image_resize_dimensions( $orig_w, $orig_h, $max_w, $max_h, $crop ); |
1510 |
1659 |
1511 if ( ! $dims ) { |
1660 if ( ! $dims ) { |
1512 return new WP_Error( 'error_getting_dimensions', __( 'Image size changes not defined', 'portfolio' ) ); |
1661 return new WP_Error( 'error_getting_dimensions', __( 'Image size changes not defined', 'portfolio' ) ); |
1513 } |
1662 } |
1514 list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; |
1663 list( $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ) = $dims; |
1515 $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h ); |
1664 $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h ); |
1516 imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); |
1665 imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); |
1517 /* Convert from full colors to index colors, like original PNG. */ |
1666 /* Convert from full colors to index colors, like original PNG. */ |
1518 if ( IMAGETYPE_PNG == $orig_type && function_exists( 'imageistruecolor' ) && ! imageistruecolor( $image ) ) { |
1667 if ( IMAGETYPE_PNG === $orig_type && function_exists( 'imageistruecolor' ) && ! imageistruecolor( $image ) ) { |
1519 imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) ); |
1668 imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) ); |
1520 } |
1669 } |
1521 /* We don't need the original in memory anymore */ |
1670 /* We don't need the original in memory anymore */ |
1522 imagedestroy( $image ); |
1671 imagedestroy( $image ); |
1523 |
1672 |
1524 /* $suffix will be appended to the destination filename, just before the extension */ |
1673 /* $suffix will be appended to the destination filename, just before the extension */ |
1525 if ( ! $suffix ) { |
1674 if ( ! $suffix ) { |
1526 $suffix = "{$dst_w}x{$dst_h}"; |
1675 $suffix = "{$dst_w}x{$dst_h}"; |
1527 } |
1676 } |
1528 $info = pathinfo( $file ); |
1677 $info = pathinfo( $file ); |
1529 $dir = $info['dirname']; |
1678 $dir = $info['dirname']; |
1530 $ext = $info['extension']; |
1679 $ext = $info['extension']; |
1531 $name = wp_basename( $file, ".$ext" ); |
1680 $name = wp_basename( $file, ".$ext" ); |
1532 |
1681 |
1533 if ( ! is_null( $dest_path ) and $_dest_path = realpath( $dest_path ) ) { |
1682 if ( ! is_null( $dest_path ) ) { |
1534 $dir = $_dest_path; |
1683 $_dest_path = realpath( $dest_path ); |
|
1684 if ( $_dest_path ) { |
|
1685 $dir = $_dest_path; |
|
1686 } |
1535 } |
1687 } |
1536 $destfilename = "{$dir}/{$name}-{$suffix}.{$ext}"; |
1688 $destfilename = "{$dir}/{$name}-{$suffix}.{$ext}"; |
1537 |
1689 |
1538 if ( IMAGETYPE_GIF == $orig_type ) { |
1690 if ( IMAGETYPE_GIF === $orig_type ) { |
1539 if ( ! imagegif( $newimage, $destfilename ) ) { |
1691 if ( ! imagegif( $newimage, $destfilename ) ) { |
1540 return new WP_Error( 'resize_path_invalid', __( 'Invalid path', 'portfolio' ) ); |
1692 return new WP_Error( 'resize_path_invalid', __( 'Invalid path', 'portfolio' ) ); |
1541 } |
1693 } |
1542 } elseif ( IMAGETYPE_PNG == $orig_type ) { |
1694 } elseif ( IMAGETYPE_PNG === $orig_type ) { |
1543 if ( ! imagepng( $newimage, $destfilename ) ) { |
1695 if ( ! imagepng( $newimage, $destfilename ) ) { |
1544 return new WP_Error( 'resize_path_invalid', __( 'Invalid path', 'portfolio' ) ); |
1696 return new WP_Error( 'resize_path_invalid', __( 'Invalid path', 'portfolio' ) ); |
1545 } |
1697 } |
1546 } else { |
1698 } else { |
1547 /* All other formats are converted to jpg */ |
1699 /* All other formats are converted to jpg */ |
1571 return false; |
1732 return false; |
1572 } |
1733 } |
1573 |
1734 |
1574 if ( $crop ) { |
1735 if ( $crop ) { |
1575 /* Crop the largest possible portion of the original image that we can size to $dest_w x $dest_h */ |
1736 /* Crop the largest possible portion of the original image that we can size to $dest_w x $dest_h */ |
1576 $aspect_ratio = $orig_w / $orig_h; |
1737 $aspect_ratio = $orig_w / $orig_h; |
1577 $new_w = min( $dest_w, $orig_w ); |
1738 $new_w = min( $dest_w, $orig_w ); |
1578 $new_h = min( $dest_h, $orig_h ); |
1739 $new_h = min( $dest_h, $orig_h ); |
1579 |
1740 |
1580 if ( ! $new_w ) { |
1741 if ( ! $new_w ) { |
1581 $new_w = intval( $new_h * $aspect_ratio ); |
1742 $new_w = intval( $new_h * $aspect_ratio ); |
1582 } |
1743 } |
1583 |
1744 |
1584 if ( ! $new_h ) { |
1745 if ( ! $new_h ) { |
1585 $new_h = intval( $new_w / $aspect_ratio ); |
1746 $new_h = intval( $new_w / $aspect_ratio ); |
1586 } |
1747 } |
1587 |
1748 |
1588 $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h ); |
1749 $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h ); |
1589 $crop_w = round( $new_w / $size_ratio ); |
1750 $crop_w = round( $new_w / $size_ratio ); |
1590 $crop_h = round( $new_h / $size_ratio ); |
1751 $crop_h = round( $new_h / $size_ratio ); |
1591 $s_x = floor( ( $orig_w - $crop_w ) / 2 ); |
1752 $s_x = floor( ( $orig_w - $crop_w ) / 2 ); |
1592 $s_y = 0; |
1753 $s_y = 0; |
1593 } else { |
1754 } else { |
1594 /* Don't crop, just resize using $dest_w x $dest_h as a maximum bounding box */ |
1755 /* Don't crop, just resize using $dest_w x $dest_h as a maximum bounding box */ |
1595 $crop_w = $orig_w; |
1756 $crop_w = $orig_w; |
1596 $crop_h = $orig_h; |
1757 $crop_h = $orig_h; |
1597 $s_x = 0; |
1758 $s_x = 0; |
1598 $s_y = 0; |
1759 $s_y = 0; |
1599 list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); |
1760 list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); |
1600 } |
1761 } |
1601 |
1762 |
1602 /* If the resulting image would be the same size or larger we don't want to resize it */ |
1763 /* If the resulting image would be the same size or larger we don't want to resize it */ |
1603 if ( $new_w >= $orig_w && $new_h >= $orig_h ) { |
1764 if ( $new_w >= $orig_w && $new_h >= $orig_h ) { |
1604 return false; |
1765 return false; |
1605 } |
1766 } |
1606 /* The return array matches the parameters to imagecopyresampled() */ |
1767 /** |
1607 /* Int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h */ |
1768 * The return array matches the parameters to imagecopyresampled() |
1608 return array( 0, 0, ( int ) $s_x, ( int ) $s_y, ( int ) $new_w, ( int ) $new_h, ( int ) $crop_w, ( int ) $crop_h ); |
1769 * Int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h |
|
1770 */ |
|
1771 return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h ); |
1609 } |
1772 } |
1610 } |
1773 } |
1611 |
1774 |
1612 if ( ! function_exists( 'prtfl_theme_body_classes' ) ) { |
1775 if ( ! function_exists( 'prtfl_theme_body_classes' ) ) { |
|
1776 /** |
|
1777 * Add class for body |
|
1778 * |
|
1779 * @param array $classes Classes array. |
|
1780 */ |
1613 function prtfl_theme_body_classes( $classes ) { |
1781 function prtfl_theme_body_classes( $classes ) { |
1614 global $prtfl_options; |
1782 global $prtfl_options; |
1615 if ( function_exists( 'wp_get_theme' ) ) { |
1783 if ( function_exists( 'wp_get_theme' ) ) { |
1616 $current_theme = wp_get_theme(); |
1784 $current_theme = wp_get_theme(); |
1617 $classes[] = 'prtfl_' . basename( $current_theme->get( 'ThemeURI' ) ); |
1785 $classes[] = 'prtfl_' . basename( $current_theme->get( 'ThemeURI' ) ); |
1618 } |
1786 } |
1619 if ( in_array( 'page-id-' . $prtfl_options['page_id_portfolio_template'], $classes ) ) { |
1787 if ( in_array( 'page-id-' . $prtfl_options['page_id_portfolio_template'], $classes ) ) { |
1620 $classes[] = 'prtfl-page-template'; |
1788 $classes[] = 'prtfl-page-template'; |
1621 $classes[] = 'has-sidebar'; |
1789 $classes[] = 'has-sidebar'; |
1622 } |
1790 } |
1623 return $classes; |
1791 return $classes; |
1624 } |
1792 } |
1625 } |
1793 } |
1626 |
1794 |
1627 if ( ! function_exists( 'prtfl_register_plugin_links' ) ) { |
1795 if ( ! function_exists( 'prtfl_register_plugin_links' ) ) { |
|
1796 /** |
|
1797 * Add Settings and Support links |
|
1798 * |
|
1799 * @param array $links Action link array. |
|
1800 * @param file $file Plugin file. |
|
1801 * @return array $links Returned link array. |
|
1802 */ |
1628 function prtfl_register_plugin_links( $links, $file ) { |
1803 function prtfl_register_plugin_links( $links, $file ) { |
1629 global $prtfl_options; |
1804 global $prtfl_options; |
1630 $base = plugin_basename( __FILE__ ); |
1805 $base = plugin_basename( __FILE__ ); |
1631 if ( $file == $base ) { |
1806 if ( $file === $base ) { |
1632 if ( ! is_network_admin() ) { |
1807 if ( ! is_network_admin() ) { |
1633 $links[] = '<a href="edit.php?post_type=' . $prtfl_options['post_type_name'] . '&page=portfolio.php">' . __( 'Settings', 'portfolio' ) . '</a>'; |
1808 $links[] = '<a href="edit.php?post_type=' . $prtfl_options['post_type_name'] . '&page=portfolio.php">' . __( 'Settings', 'portfolio' ) . '</a>'; |
1634 } |
1809 } |
1635 $links[] = '<a href="https://support.bestwebsoft.com/hc/en-us/sections/200538929" target="_blank">' . __( 'FAQ', 'portfolio' ) . '</a>'; |
1810 $links[] = '<a href="https://support.bestwebsoft.com/hc/en-us/sections/200538929" target="_blank">' . __( 'FAQ', 'portfolio' ) . '</a>'; |
1636 $links[] = '<a href="https://support.bestwebsoft.com">' . __( 'Support', 'portfolio' ) . '</a>'; |
1811 $links[] = '<a href="https://support.bestwebsoft.com">' . __( 'Support', 'portfolio' ) . '</a>'; |
1637 } |
1812 } |
1638 return $links; |
1813 return $links; |
1639 } |
1814 } |
1640 } |
1815 } |
1641 |
1816 |
1642 if ( ! function_exists( 'prtfl_plugin_action_links' ) ) { |
1817 if ( ! function_exists( 'prtfl_plugin_action_links' ) ) { |
|
1818 /** |
|
1819 * Add action links |
|
1820 * |
|
1821 * @param array $links Action link array. |
|
1822 * @param file $file Plugin file. |
|
1823 * @return array $links Returned link array. |
|
1824 */ |
1643 function prtfl_plugin_action_links( $links, $file ) { |
1825 function prtfl_plugin_action_links( $links, $file ) { |
1644 if ( ! is_network_admin() ) { |
1826 if ( ! is_network_admin() ) { |
1645 /* Static so we don't call plugin_basename on every plugin row. */ |
1827 /* Static so we don't call plugin_basename on every plugin row. */ |
1646 static $this_plugin; |
1828 static $this_plugin; |
1647 if ( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ ); |
1829 if ( ! $this_plugin ) { |
1648 |
1830 $this_plugin = plugin_basename( __FILE__ ); |
1649 if ( $file == $this_plugin ) { |
1831 } |
|
1832 |
|
1833 if ( $file === $this_plugin ) { |
1650 global $prtfl_options; |
1834 global $prtfl_options; |
1651 $settings_link = '<a href="edit.php?post_type=' . $prtfl_options['post_type_name'] . '&page=portfolio.php">' . __( 'Settings', 'portfolio' ) . '</a>'; |
1835 $settings_link = '<a href="edit.php?post_type=' . $prtfl_options['post_type_name'] . '&page=portfolio.php">' . __( 'Settings', 'portfolio' ) . '</a>'; |
1652 array_unshift( $links, $settings_link ); |
1836 array_unshift( $links, $settings_link ); |
1653 } |
1837 } |
1654 } |
1838 } |
1655 return $links; |
1839 return $links; |
1656 } |
1840 } |
1657 } |
1841 } |
1658 |
1842 |
1659 if ( ! function_exists( 'prtfl_admin_notices' ) ) { |
1843 if ( ! function_exists( 'prtfl_admin_notices' ) ) { |
|
1844 /** |
|
1845 * Display notice in the main dashboard page / plugins page |
|
1846 */ |
1660 function prtfl_admin_notices() { |
1847 function prtfl_admin_notices() { |
1661 global $hook_suffix, $prtfl_plugin_info, $prtfl_options, $prtfl_BWS_demo_data; |
1848 global $hook_suffix, $prtfl_plugin_info, $prtfl_options, $prtfl_bws_demo_data; |
1662 |
1849 |
1663 if ( 'plugins.php' == $hook_suffix || ( isset( $_GET['page'] ) && 'portfolio.php' == $_GET['page'] ) ) { |
1850 if ( 'plugins.php' === $hook_suffix || ( isset( $_GET['page'] ) && 'portfolio.php' === $_GET['page'] ) ) { |
1664 |
1851 |
1665 if ( ! $prtfl_BWS_demo_data ) { |
1852 if ( ! $prtfl_bws_demo_data ) { |
1666 prtfl_include_demo_data(); |
1853 prtfl_include_demo_data(); |
1667 } |
1854 } |
1668 |
1855 |
1669 if ( isset( $_GET['page'] ) && 'portfolio.php' == $_GET['page'] ) { |
1856 if ( isset( $_GET['page'] ) && 'portfolio.php' === $_GET['page'] ) { |
1670 $prtfl_BWS_demo_data->bws_handle_demo_notice( $prtfl_options['display_demo_notice'] ); |
1857 $prtfl_bws_demo_data->bws_handle_demo_notice( $prtfl_options['display_demo_notice'] ); |
1671 } |
1858 } |
1672 |
1859 |
1673 if ( 'plugins.php' == $hook_suffix ) { |
1860 if ( 'plugins.php' === $hook_suffix ) { |
1674 if ( ! is_network_admin() ) { |
1861 if ( ! is_network_admin() ) { |
1675 bws_plugin_banner_to_settings( $prtfl_plugin_info, 'prtfl_options', 'portfolio', 'edit.php?post_type=portfolio&page=portfolio.php', 'Portfolio' ); |
1862 bws_plugin_banner_to_settings( $prtfl_plugin_info, 'prtfl_options', 'portfolio', 'edit.php?post_type=portfolio&page=portfolio.php', 'Portfolio' ); |
1676 } |
1863 } |
1677 if ( 0 == $prtfl_options['widget_updated'] ) { |
1864 if ( 0 === absint( $prtfl_options['widget_updated'] ) ) { |
1678 /* Save data for settings page */ |
1865 /* Save data for settings page */ |
1679 if ( isset( $_REQUEST['prtfl_form_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'prtfl_nonce_name' ) ) { |
1866 if ( isset( $_REQUEST['prtfl_form_submit'] ) && check_admin_referer( plugin_basename( __FILE__ ), 'prtfl_nonce_name' ) ) { |
1680 $prtfl_options['widget_updated'] = 1; |
1867 $prtfl_options['widget_updated'] = 1; |
1681 update_option( 'prtfl_options', $prtfl_options ); |
1868 update_option( 'prtfl_options', $prtfl_options ); |
1682 } else { ?> |
1869 } else { |
|
1870 ?> |
1683 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
1871 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
1684 <div class="prtfl_admin_notices bws_banner_on_plugin_page"> |
1872 <div class="prtfl_admin_notices bws_banner_on_plugin_page"> |
1685 <form method="post" action="<?php echo $hook_suffix; ?>"> |
1873 <form method="post" action="<?php echo esc_attr( $hook_suffix ); ?>"> |
1686 <div class="text"> |
1874 <div class="text"> |
1687 <p> |
1875 <p> |
1688 <strong><?php _e( "ATTENTION!", 'portfolio' ); ?></strong> |
1876 <strong><?php esc_html_e( 'ATTENTION!', 'portfolio' ); ?></strong> |
1689 <?php _e( "In the current version of Portfolio plugin we updated the Technologies widget. If it was added to the sidebar, it will disappear and you will have to add it again.", 'portfolio' ); ?> |
1877 <?php esc_html_e( 'In the current version of Portfolio plugin we updated the Technologies widget. If it was added to the sidebar, it will disappear and you will have to add it again.', 'portfolio' ); ?> |
1690 </p> |
1878 </p> |
1691 <input type="hidden" name="prtfl_form_submit" value="submit" /> |
1879 <input type="hidden" name="prtfl_form_submit" value="submit" /> |
1692 <p class="submit"> |
1880 <p class="submit"> |
1693 <input type="submit" class="button-primary" value="<?php _e( 'Read and Understood', 'portfolio' ); ?>" /> |
1881 <input type="submit" class="button-primary" value="<?php esc_html_e( 'Read and Understood', 'portfolio' ); ?>" /> |
1694 </p> |
1882 </p> |
1695 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'prtfl_nonce_name' ); ?> |
1883 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'prtfl_nonce_name' ); ?> |
1696 </div> |
1884 </div> |
1697 </form> |
1885 </form> |
1698 </div> |
1886 </div> |
1699 </div> |
1887 </div> |
1700 <?php } |
1888 <?php |
|
1889 } |
1701 } |
1890 } |
1702 } else { |
1891 } else { |
1703 bws_plugin_suggest_feature_banner( $prtfl_plugin_info, 'prtfl_options', 'portfolio' ); |
1892 bws_plugin_suggest_feature_banner( $prtfl_plugin_info, 'prtfl_options', 'portfolio' ); |
1704 } |
1893 } |
1705 } |
1894 } |
1706 } |
1895 } |
1707 } |
1896 } |
1708 |
1897 |
1709 /* This function will display title for portfolio type template */ |
|
1710 if ( ! function_exists( 'prtfl_template_title' ) ) { |
1898 if ( ! function_exists( 'prtfl_template_title' ) ) { |
|
1899 /** |
|
1900 * This function will display title for portfolio type template |
|
1901 */ |
1711 function prtfl_template_title() { |
1902 function prtfl_template_title() { |
1712 global $wp_query, $prtfl_options; |
1903 global $wp_query, $prtfl_options; |
1713 |
1904 |
1714 if ( isset( $wp_query->query_vars["technologies"] ) ) { |
1905 if ( isset( $wp_query->query_vars['technologies'] ) ) { |
1715 $term = get_term_by( 'slug', $wp_query->query_vars["technologies"], 'portfolio_technologies' ); |
1906 $term = get_term_by( 'slug', $wp_query->query_vars['technologies'], 'portfolio_technologies' ); |
1716 echo $prtfl_options['technologies_text_field'] . " " . ( $term->name ); |
1907 echo esc_html( $prtfl_options['technologies_text_field'] . ' ' . $term->name ); |
1717 } elseif ( isset( $wp_query->query_vars["portfolio_executor_profile"] ) ) { |
1908 } elseif ( isset( $wp_query->query_vars['portfolio_executor_profile'] ) ) { |
1718 $term = get_term_by( 'slug', $wp_query->query_vars["portfolio_executor_profile"], 'portfolio_executor_profile' ); |
1909 $term = get_term_by( 'slug', $wp_query->query_vars['portfolio_executor_profile'], 'portfolio_executor_profile' ); |
1719 echo $prtfl_options['executor_text_field'] . " <h1>" . ( $term->name ) . "</h1>"; |
1910 echo esc_html( $prtfl_options['executor_text_field'] ) . ' <h1>' . esc_html( $term->name ) . '</h1>'; |
1720 $_SESSION['prtfl_page_name'] = $prtfl_options['executor_text_field'] . " " . ( $term->name ); |
1911 $_SESSION['prtfl_page_name'] = $prtfl_options['executor_text_field'] . ' ' . $term->name; |
1721 $_SESSION['prtfl_page_url'] = get_pagenum_link( $wp_query->query_vars['paged'] ); |
1912 $_SESSION['prtfl_page_url'] = get_pagenum_link( $wp_query->query_vars['paged'] ); |
1722 } else { |
1913 } else { |
1723 the_title( '<h1>', '</h1>' ); |
1914 the_title( '<h1>', '</h1>' ); |
1724 } |
1915 } |
1725 } |
1916 } |
1726 } |
1917 } |
1727 |
1918 |
1728 /* This function will display title for portfolio post type template */ |
|
1729 if ( ! function_exists( 'prtfl_post_template_title' ) ) { |
1919 if ( ! function_exists( 'prtfl_post_template_title' ) ) { |
|
1920 /** |
|
1921 * This function will display title for portfolio post type template |
|
1922 */ |
1730 function prtfl_post_template_title() { |
1923 function prtfl_post_template_title() { |
1731 $title = get_the_title(); |
1924 $title = get_the_title(); |
1732 echo empty( $title ) ? '(' . __( 'No title', 'portfolio' ) . ')' : '<h1>'. $title . '</h1>' ; |
1925 echo empty( $title ) ? '(' . esc_html__( 'No title', 'portfolio' ) . ')' : '<h1>' . esc_html( $title ) . '</h1>'; |
1733 } |
1926 } |
1734 } |
1927 } |
1735 |
1928 |
1736 /** |
|
1737 * Prepare arguments for post query |
|
1738 * @return array|false |
|
1739 */ |
|
1740 if ( ! function_exists( 'prtfl_get_query_args' ) ) { |
1929 if ( ! function_exists( 'prtfl_get_query_args' ) ) { |
|
1930 /** |
|
1931 * Prepare arguments for post query |
|
1932 * |
|
1933 * @return array|false |
|
1934 */ |
1741 function prtfl_get_query_args() { |
1935 function prtfl_get_query_args() { |
1742 global $prtfl_options, $wp_query; |
1936 global $prtfl_options, $wp_query; |
1743 $count = 0; |
1937 $count = 0; |
1744 if ( get_query_var( 'paged' ) ) { |
1938 if ( get_query_var( 'paged' ) ) { |
1745 $paged = get_query_var( 'paged' ); |
1939 $paged = get_query_var( 'paged' ); |
1746 } elseif ( get_query_var( 'page' ) ) { |
1940 } elseif ( get_query_var( 'page' ) ) { |
1747 $paged = get_query_var( 'page' ); |
1941 $paged = get_query_var( 'page' ); |
1748 } else { |
1942 } else { |
1749 $paged = 1; |
1943 $paged = 1; |
1750 } |
1944 } |
1751 $per_page = $showitems = get_option( 'posts_per_page' ); |
1945 $per_page = get_option( 'posts_per_page' ); |
1752 |
1946 $showitems = $per_page; |
1753 if ( ! empty( $wp_query->query_vars["technologies"] ) ) { |
1947 |
|
1948 if ( ! empty( $wp_query->query_vars['technologies'] ) ) { |
1754 $args = array( |
1949 $args = array( |
1755 'post_type' => $prtfl_options['post_type_name'], |
1950 'post_type' => $prtfl_options['post_type_name'], |
1756 'post_status' => 'publish', |
1951 'post_status' => 'publish', |
1757 'orderby' => $prtfl_options['order_by'], |
1952 'orderby' => $prtfl_options['order_by'], |
1758 'order' => $prtfl_options['order'], |
1953 'order' => $prtfl_options['order'], |
1759 'posts_per_page' => $per_page, |
1954 'posts_per_page' => $per_page, |
1760 'paged' => $paged, |
1955 'paged' => $paged, |
1761 'tax_query' => array( |
1956 'tax_query' => array( |
1762 array( |
1957 array( |
1763 'taxonomy' => 'portfolio_technologies', |
1958 'taxonomy' => 'portfolio_technologies', |
1764 'field' => 'slug', |
1959 'field' => 'slug', |
1765 'terms' => $wp_query->query_vars["technologies"] |
1960 'terms' => $wp_query->query_vars['technologies'], |
1766 ) |
1961 ), |
1767 ) |
1962 ), |
1768 ); |
1963 ); |
1769 } elseif ( ! empty( $wp_query->query_vars["portfolio_executor_profile"] ) ) { |
1964 } elseif ( ! empty( $wp_query->query_vars['portfolio_executor_profile'] ) ) { |
1770 $args = array( |
1965 $args = array( |
1771 'post_type' => $prtfl_options['post_type_name'], |
1966 'post_type' => $prtfl_options['post_type_name'], |
1772 'post_status' => 'publish', |
1967 'post_status' => 'publish', |
1773 'orderby' => $prtfl_options['order_by'], |
1968 'orderby' => $prtfl_options['order_by'], |
1774 'order' => $prtfl_options['order'], |
1969 'order' => $prtfl_options['order'], |
1775 'posts_per_page' => $per_page, |
1970 'posts_per_page' => $per_page, |
1776 'paged' => $paged, |
1971 'paged' => $paged, |
1777 'tax_query' => array( |
1972 'tax_query' => array( |
1778 array( |
1973 array( |
1779 'taxonomy' => 'portfolio_executor_profile', |
1974 'taxonomy' => 'portfolio_executor_profile', |
1780 'field' => 'slug', |
1975 'field' => 'slug', |
1781 'terms' => $wp_query->query_vars["portfolio_executor_profile"] |
1976 'terms' => $wp_query->query_vars['portfolio_executor_profile'], |
1782 ) |
1977 ), |
1783 ) |
1978 ), |
1784 ); |
1979 ); |
1785 } else { |
1980 } else { |
1786 $args = array( |
1981 $args = array( |
1787 'post_type' => $prtfl_options['post_type_name'], |
1982 'post_type' => $prtfl_options['post_type_name'], |
1788 'post_status' => 'publish', |
1983 'post_status' => 'publish', |
1789 'orderby' => $prtfl_options['order_by'], |
1984 'orderby' => $prtfl_options['order_by'], |
1790 'order' => $prtfl_options['order'], |
1985 'order' => $prtfl_options['order'], |
1791 'posts_per_page' => $per_page, |
1986 'posts_per_page' => $per_page, |
1792 'paged' => $paged |
1987 'paged' => $paged, |
1793 ); |
1988 ); |
1794 } |
1989 } |
1795 |
1990 |
1796 if ( isset( $args ) ) { |
1991 if ( isset( $args ) ) { |
1797 return $args; |
1992 return $args; |
1866 $title = '(' . __( 'No title', 'portfolio' ) . ')'; |
2071 $title = '(' . __( 'No title', 'portfolio' ) . ')'; |
1867 } |
2072 } |
1868 $permalink = get_permalink(); |
2073 $permalink = get_permalink(); |
1869 if ( ! empty( $image[0] ) ) { |
2074 if ( ! empty( $image[0] ) ) { |
1870 /* get width and height for image_size_album */ |
2075 /* get width and height for image_size_album */ |
1871 if ( 'portfolio-thumb' != $prtfl_options['image_size_album'] ) { |
2076 if ( 'portfolio-thumb' !== $prtfl_options['image_size_album'] ) { |
1872 $width = absint( get_option( $prtfl_options['image_size_album'] . '_size_w' ) ); |
2077 $width = absint( get_option( $prtfl_options['image_size_album'] . '_size_w' ) ); |
1873 $height = absint( get_option( $prtfl_options['image_size_album'] . '_size_h' ) ); |
2078 $height = absint( get_option( $prtfl_options['image_size_album'] . '_size_h' ) ); |
1874 } else { |
2079 } else { |
1875 $width = $prtfl_options['custom_size_px']['portfolio-thumb'][0]; |
2080 $width = $prtfl_options['custom_size_px']['portfolio-thumb'][0]; |
1876 $height = $prtfl_options['custom_size_px']['portfolio-thumb'][1]; |
2081 $height = $prtfl_options['custom_size_px']['portfolio-thumb'][1]; |
1877 } |
2082 } |
1878 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); ?> |
2083 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
|
2084 ?> |
1879 <div class="portfolio_thumb"> |
2085 <div class="portfolio_thumb"> |
1880 <a rel="bookmark" href="<?php echo $permalink; ?>" title="<?php echo $title; ?>"> |
2086 <a rel="bookmark" href="<?php echo esc_url( $permalink ); ?>" title="<?php echo esc_html( $title ); ?>"> |
1881 <img src="<?php echo $image[0]; ?>" alt="<?php echo $image_alt; ?>" <?php if ( $width ) echo 'width="' . $width . '"'; if ( $height ) echo 'height="' . $height . '"'; ?> style="<?php if ( $width ) echo 'width:' . $width . 'px;'; if ( $height ) echo 'height:' . $height . 'px;'; ?>" /> |
2087 <img src="<?php echo esc_url( $image[0] ); ?>" alt="<?php echo esc_html( $image_alt ); ?>" <?php echo isset( $width ) ? 'width="' . esc_attr( $width ) . '"' : ''; ?> <?php echo isset( $height ) ? 'height="' . esc_attr( $height ) . '"' : ''; ?> |
|
2088 style="<?php echo isset( $width ) ? 'width:' . esc_attr( $width ) . 'px;' : ''; ?> <?php echo isset( $height ) ? 'height:' . esc_attr( $height ) . 'px;' : ''; ?>" /> |
1882 </a> |
2089 </a> |
1883 </div><!-- .portfolio_thumb --> |
2090 </div><!-- .portfolio_thumb --> |
1884 <?php } ?> |
2091 <?php } ?> |
1885 <div class="portfolio_short_content"> |
2092 <div class="portfolio_short_content"> |
1886 <div class="item_title"> |
2093 <div class="item_title"> |
1887 <p> |
2094 <p> |
1888 <a href="<?php echo $permalink; ?>" rel="bookmark"><?php echo $title; ?></a> |
2095 <a href="<?php echo esc_url( $permalink ); ?>" rel="bookmark"><?php echo wp_kses_post( $title ); ?></a> |
1889 </p> |
2096 </p> |
1890 </div><!-- .item_title --> |
2097 </div><!-- .item_title --> |
1891 <?php $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
2098 <?php |
1892 if ( 1 == $prtfl_options['date_additional_field'] && ! empty( $date_compl ) ) { ?> |
2099 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
|
2100 if ( 1 === absint( $prtfl_options['date_additional_field'] ) && ! empty( $date_compl ) ) { |
|
2101 ?> |
1893 <p> |
2102 <p> |
1894 <span class="lable"><?php echo '<b>' . $prtfl_options['date_text_field'] . '</b>'; ?></span> <?php echo $date_compl; ?> |
2103 <span class="lable"><?php echo '<b>' . wp_kses_post( $prtfl_options['date_text_field'] ) . '</b>'; ?></span> <?php echo wp_kses_post( $date_compl ); ?> |
1895 </p> |
2104 </p> |
1896 <?php } |
2105 <?php |
|
2106 } |
1897 $user_id = get_current_user_id(); |
2107 $user_id = get_current_user_id(); |
1898 |
2108 |
1899 $link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
2109 $link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
1900 if ( 1 == $prtfl_options['link_additional_field'] && ! empty( $link ) ) { |
2110 if ( 1 === absint( $prtfl_options['link_additional_field'] ) && ! empty( $link ) ) { |
1901 |
2111 |
1902 if ( false !== parse_url( $link ) ) { |
2112 if ( false !== wp_parse_url( $link ) ) { |
1903 if ( ( 0 == $user_id && 0 == $prtfl_options['link_additional_field_for_non_registered'] ) || 0 != $user_id ) { ?> |
2113 if ( ( 0 === $user_id && 0 === absint( $prtfl_options['link_additional_field_for_non_registered'] ) ) || 0 !== $user_id ) { |
1904 <p><span class="lable"><?php echo '<b>' . $prtfl_options['link_text_field'] . '</b>'; ?></span> <a href="<?php echo $link; ?>"><?php echo $link; ?></a></p> |
2114 ?> |
|
2115 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $prtfl_options['link_text_field'] ) . '</b>'; ?></span> <a href="<?php echo esc_url( $link ); ?>"><?php echo esc_url( $link ); ?></a></p> |
1905 <?php } else { ?> |
2116 <?php } else { ?> |
1906 <p><span class="lable"><?php echo '<b>' . $prtfl_options['link_text_field'] . '</b>'; ?></span> <?php echo $link; ?></p> |
2117 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $prtfl_options['link_text_field'] ) . '</b>'; ?></span> <?php echo esc_url( $link ); ?></p> |
1907 <?php } |
2118 <?php |
1908 } else { ?>prtfl_options |
2119 } |
1909 <p><span class="lable"><?php echo '<b>' . $prtfl_options['link_text_field'] . '</b>'; ?></span> <?php echo $link; ?></p> |
2120 } else { |
1910 <?php } |
2121 ?> |
|
2122 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $prtfl_options['link_text_field'] ) . '</b>'; ?></span> <?php echo esc_url( $link ); ?></p> |
|
2123 <?php |
|
2124 } |
1911 } |
2125 } |
1912 if ( 1 == $prtfl_options['shrdescription_additional_field'] ) { ?> |
2126 if ( 1 === absint( $prtfl_options['shrdescription_additional_field'] ) ) { |
1913 <p><span class="lable"><?php echo '<b>' . $prtfl_options['shrdescription_text_field'] . '</b>'; ?></span> <?php echo $short_descr; ?></p> |
2127 ?> |
|
2128 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $prtfl_options['shrdescription_text_field'] ) . '</b>'; ?></span> <?php echo wp_kses_post( $short_descr ); ?></p> |
1914 <?php } ?> |
2129 <?php } ?> |
1915 </div><!-- .portfolio_short_content --> |
2130 </div><!-- .portfolio_short_content --> |
1916 </div><!-- .entry --> |
2131 </div><!-- .entry --> |
1917 <div class="entry_footer"> |
2132 <div class="entry_footer"> |
1918 <div class="read_more"> |
2133 <div class="read_more"> |
1919 <a href="<?php the_permalink(); ?>" rel="bookmark"><?php _e( 'Read more', 'portfolio' ); ?></a> |
2134 <a href="<?php the_permalink(); ?>" rel="bookmark"><?php esc_html_e( 'Read more', 'portfolio' ); ?></a> |
1920 </div><!-- .read_more --> |
2135 </div><!-- .read_more --> |
1921 <?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
2136 <?php |
1922 if ( 1 == $prtfl_options['technologies_additional_field'] && ! is_wp_error( $terms ) ) { |
2137 $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
1923 if ( is_array( $terms ) && 0 < count( $terms ) ) { ?> |
2138 if ( 1 === absint( $prtfl_options['technologies_additional_field'] ) && ! is_wp_error( $terms ) ) { |
|
2139 if ( is_array( $terms ) && 0 < count( $terms ) ) { |
|
2140 ?> |
1924 <div class="portfolio_terms"> |
2141 <div class="portfolio_terms"> |
1925 <?php if ( isset( $prtfl_options['technologies_text_field'] ) ) echo '<b>' . $prtfl_options['technologies_text_field'] . ' </b>'; |
2142 <?php |
|
2143 if ( isset( $prtfl_options['technologies_text_field'] ) ) { |
|
2144 echo '<b>' . esc_html( $prtfl_options['technologies_text_field'] ) . ' </b>';} |
1926 $links = array(); |
2145 $links = array(); |
1927 foreach ( $terms as $term ) { |
2146 foreach ( $terms as $term ) { |
1928 $links[] = '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( "View all projects in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>'; |
2147 $links[] = '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( esc_html__( 'View all projects in %s' ), $term->name ) . '">' . $term->name . '</a>'; |
1929 } |
2148 } |
1930 echo implode( ', ', $links ); ?> |
2149 echo wp_kses_post( implode( ', ', $links ) ); |
1931 </div><!-- .portfolio_terms --><?php |
2150 ?> |
|
2151 </div><!-- .portfolio_terms --> |
|
2152 <?php |
1932 } |
2153 } |
1933 } ?> |
2154 } |
|
2155 ?> |
1934 </div><!-- .entry_footer --> |
2156 </div><!-- .entry_footer --> |
1935 </div><!-- .portfolio_content --> |
2157 </div><!-- .portfolio_content --> |
1936 </div> |
2158 </div> |
1937 <?php if ( ( $count_portfolio_row_block % $prtfl_options['custom_portfolio_row_count'] ) == ( $prtfl_options['custom_portfolio_row_count'] - 1 ) ) {?> |
2159 <?php if ( ( $count_portfolio_row_block % $prtfl_options['custom_portfolio_row_count'] ) === ( $prtfl_options['custom_portfolio_row_count'] - 1 ) ) { ?> |
1938 <div class="clear"></div> |
2160 <div class="clear"></div> |
1939 </div><!-- .portfolio_row_count --><?php |
2161 </div><!-- .portfolio_row_count --> |
1940 } |
2162 <?php |
1941 $count_portfolio_row_block = $count_portfolio_row_block + 1; |
2163 } |
1942 } |
2164 $count_portfolio_row_block++; |
1943 } |
2165 } |
1944 if ( 0 != $count_portfolio_row_block % $prtfl_options['custom_portfolio_row_count'] ) { |
2166 } |
1945 ?></div><?php |
2167 if ( 0 !== $count_portfolio_row_block % $prtfl_options['custom_portfolio_row_count'] ) { |
|
2168 ?> |
|
2169 </div> |
|
2170 <?php |
1946 } |
2171 } |
1947 ?> |
2172 ?> |
1948 <div class="clear"></div><?php |
2173 <div class="clear"></div> |
1949 } |
2174 <?php |
1950 } |
2175 } |
1951 |
2176 } |
1952 /** |
2177 |
1953 * Display post template content |
|
1954 * @return void |
|
1955 */ |
|
1956 if ( ! function_exists( 'prtfl_post_get_content' ) ) { |
2178 if ( ! function_exists( 'prtfl_post_get_content' ) ) { |
|
2179 /** |
|
2180 * Display post template content |
|
2181 */ |
1957 function prtfl_post_get_content() { |
2182 function prtfl_post_get_content() { |
1958 global $post, $prtfl_options; |
2183 global $post, $prtfl_options; |
1959 |
2184 |
1960 while ( have_posts() ) : the_post(); ?> |
2185 while ( have_posts() ) : |
|
2186 the_post(); |
|
2187 ?> |
1961 <article class="portfolio_content entry-content"> |
2188 <article class="portfolio_content entry-content"> |
|
2189 <?php |
|
2190 ob_start(); |
|
2191 ?> |
1962 <div class="entry"> |
2192 <div class="entry"> |
1963 <?php global $post; |
2193 <?php |
1964 $portfolio_options = get_option( 'prtfl_options' ); |
2194 $portfolio_options = get_option( 'prtfl_options' ); |
1965 $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
2195 $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); |
1966 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
2196 $image = wp_get_attachment_image_src( $post_thumbnail_id, $prtfl_options['image_size_album'] ); |
1967 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
2197 $post_meta = get_post_meta( $post->ID, 'prtfl_information', true ); |
1968 |
2198 |
1969 if ( ! empty( $image[0] ) ) { |
2199 if ( ! empty( $image[0] ) ) { |
1970 $image_large = wp_get_attachment_image_src( $post_thumbnail_id, 'large' ); |
2200 $image_large = wp_get_attachment_image_src( $post_thumbnail_id, 'large' ); |
1971 $image_desc = get_post( $post_thumbnail_id ); |
2201 $image_desc = get_post( $post_thumbnail_id ); |
1972 $image_desc = $image_desc->post_content; |
2202 $image_desc = $image_desc->post_content; |
1973 /* get width and height for image_size_album */ |
2203 /* get width and height for image_size_album */ |
1974 if ( 'portfolio-thumb' != $prtfl_options['image_size_album'] ) { |
2204 if ( 'portfolio-thumb' !== $prtfl_options['image_size_album'] ) { |
1975 $width = absint( get_option( $prtfl_options['image_size_album'] . '_size_w' ) ); |
2205 $width = absint( get_option( $prtfl_options['image_size_album'] . '_size_w' ) ); |
1976 $height = absint( get_option( $prtfl_options['image_size_album'] . '_size_h' ) ); |
2206 $height = absint( get_option( $prtfl_options['image_size_album'] . '_size_h' ) ); |
1977 } else { |
2207 } else { |
1978 $width = $prtfl_options['custom_size_px']['portfolio-thumb'][0]; |
2208 $width = $prtfl_options['custom_size_px']['portfolio-thumb'][0]; |
1979 $height = $prtfl_options['custom_size_px']['portfolio-thumb'][1]; |
2209 $height = $prtfl_options['custom_size_px']['portfolio-thumb'][1]; |
1980 } |
2210 } |
1981 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); ?> |
2211 $image_alt = get_post_meta( $post_thumbnail_id, '_wp_attachment_image_alt', true ); |
|
2212 ?> |
1982 <div class="portfolio_thumb"> |
2213 <div class="portfolio_thumb"> |
1983 <a class="lightbox" data-fancybox="portfolio_fancybox" href="<?php echo $image_large[0]; ?>" title="<?php echo $image_desc; ?>"> |
2214 <a class="lightbox" data-fancybox="portfolio_fancybox" href="<?php echo esc_url( $image_large[0] ); ?>" title="<?php echo wp_kses_post( $image_desc ); ?>"> |
1984 <img src="<?php echo $image[0]; ?>" alt="<?php echo $image_alt; ?>" <?php if ( $width ) echo 'width="' . $width . '"'; if ( $height ) echo 'height="' . $height . '"'; ?> /> |
2215 <img src="<?php echo esc_url( $image[0] ); ?>" alt="<?php echo esc_html( $image_alt ); ?>" |
|
2216 <?php |
|
2217 if ( $width ) { |
|
2218 echo 'width="' . esc_attr( $width ) . '"'; |
|
2219 } |
|
2220 if ( $height ) { |
|
2221 echo 'height="' . esc_attr( $height ) . '"'; |
|
2222 } |
|
2223 ?> |
|
2224 /> |
1985 </a> |
2225 </a> |
1986 </div><!-- .portfolio_thumb --> |
2226 </div><!-- .portfolio_thumb --> |
1987 <?php } ?> |
2227 <?php } ?> |
1988 <div class="portfolio_short_content"> |
2228 <div class="portfolio_short_content"> |
1989 <?php $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
2229 <?php |
1990 if ( 1 == $portfolio_options['date_additional_field'] && ! empty( $date_compl ) ) { ?> |
2230 $date_compl = isset( $post_meta['_prtfl_date_compl'] ) ? $post_meta['_prtfl_date_compl'] : ''; |
|
2231 if ( 1 === absint( $portfolio_options['date_additional_field'] ) && ! empty( $date_compl ) ) { |
|
2232 ?> |
1991 <p> |
2233 <p> |
1992 <span class="lable"><?php echo '<b>' . $portfolio_options['date_text_field'] . '</b>'; ?></span> <?php echo $date_compl; ?> |
2234 <span class="lable"><?php echo '<b>' . wp_kses_post( $portfolio_options['date_text_field'] ) . '</b>'; ?></span> <?php echo wp_kses_post( $date_compl ); ?> |
1993 </p> |
2235 </p> |
1994 <?php } |
2236 <?php |
|
2237 } |
1995 $user_id = get_current_user_id(); |
2238 $user_id = get_current_user_id(); |
1996 |
2239 |
1997 $link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
2240 $link = isset( $post_meta['_prtfl_link'] ) ? $post_meta['_prtfl_link'] : ''; |
1998 if ( 1 == $portfolio_options['link_additional_field'] && ! empty( $link ) ) { |
2241 if ( 1 === absint( $portfolio_options['link_additional_field'] ) && ! empty( $link ) ) { |
1999 |
2242 |
2000 if ( false !== parse_url( $link ) ) { ?> |
2243 if ( false !== wp_parse_url( $link ) ) { |
2001 <?php if ( ( 0 == $user_id && 0 == $portfolio_options['link_additional_field_for_non_registered'] ) || 0 != $user_id ) { ?> |
2244 ?> |
2002 <p><span class="lable"><?php echo '<b>'. $portfolio_options['link_text_field'] . '</b>'; ?></span> <a href="<?php echo $link; ?>"><?php echo $link; ?></a></p> |
2245 <?php if ( ( 0 === $user_id && 0 === absint( $portfolio_options['link_additional_field_for_non_registered'] ) ) || 0 !== $user_id ) { ?> |
|
2246 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $portfolio_options['link_text_field'] ) . '</b>'; ?></span> <a href="<?php echo esc_url( $link ); ?>"><?php echo esc_url( $link ); ?></a></p> |
2003 <?php } else { ?> |
2247 <?php } else { ?> |
2004 <p><span class="lable"><?php echo '<b>' . $portfolio_options['link_text_field'] . '</b>'; ?></span> <?php echo $link; ?></p> |
2248 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $portfolio_options['link_text_field'] ) . '</b>'; ?></span> <?php echo esc_url( $link ); ?></p> |
2005 <?php } |
2249 <?php |
2006 } else { ?> |
2250 } |
2007 <p><span class="lable"><?php echo '<b>' . $portfolio_options['link_text_field'] . '</b>'; ?></span> <?php echo $link; ?></p> |
2251 } else { |
2008 <?php } |
2252 ?> |
|
2253 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $portfolio_options['link_text_field'] ) . '</b>'; ?></span> <?php echo esc_url( $link ); ?></p> |
|
2254 <?php |
|
2255 } |
2009 } |
2256 } |
2010 if ( 1 == $portfolio_options['description_additional_field'] ) { |
2257 if ( 1 === absint( $portfolio_options['description_additional_field'] ) ) { |
2011 $full_descr = $post->post_content != "" ? $post->post_content : ''; |
2258 remove_filter( 'the_content', 'pdfprnt_content' ); |
2012 if ( empty( $full_descr ) ){ |
2259 $full_descr = '' !== $post->post_content ? apply_filters( 'the_content', $post->post_content ) : ''; |
|
2260 add_filter( 'the_content', 'pdfprnt_content' ); |
|
2261 if ( empty( $full_descr ) ) { |
2013 $full_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
2262 $full_descr = isset( $post_meta['_prtfl_short_descr'] ) ? $post_meta['_prtfl_short_descr'] : ''; |
2014 } else { |
2263 } else { |
2015 if ( function_exists( 'mltlngg_the_content_filter' ) ) { |
2264 if ( function_exists( 'mltlngg_the_content_filter' ) ) { |
2016 $full_descr = mltlngg_the_content_filter( $full_descr ); |
2265 $full_descr = mltlngg_the_content_filter( $full_descr ); |
2017 } |
2266 } |
2029 $full_descr = shortcode_unautop( $full_descr ); |
2278 $full_descr = shortcode_unautop( $full_descr ); |
2030 } |
2279 } |
2031 if ( function_exists( 'prepend_attachment' ) ) { |
2280 if ( function_exists( 'prepend_attachment' ) ) { |
2032 $full_descr = prepend_attachment( $full_descr ); |
2281 $full_descr = prepend_attachment( $full_descr ); |
2033 } |
2282 } |
2034 if ( function_exists( 'wp_make_content_images_responsive' ) ) { |
2283 if ( function_exists( 'wp_filter_content_tags' ) ) { |
|
2284 $full_descr = wp_filter_content_tags( $full_descr ); |
|
2285 } elseif ( function_exists( 'wp_make_content_images_responsive' ) ) { |
2035 $full_descr = wp_make_content_images_responsive( $full_descr ); |
2286 $full_descr = wp_make_content_images_responsive( $full_descr ); |
2036 } |
2287 } |
2037 if ( function_exists( 'do_shortcode' ) ) { |
2288 if ( function_exists( 'do_shortcode' ) ) { |
2038 $full_descr = do_shortcode( $full_descr ); |
2289 $full_descr = do_shortcode( $full_descr ); |
2039 } |
2290 } |
2040 } |
2291 } |
2041 if ( ! empty( $full_descr ) ) { ?> |
2292 if ( ! empty( $full_descr ) ) { |
2042 <div style = "clear: both;"><span class="lable"><?php echo '<b>' . $prtfl_options['description_text_field'] . '</b>'; ?></span> <?php echo $full_descr; ?></div> |
2293 ?> |
2043 <?php } |
2294 <div style = "clear: both;"><span class="lable"><?php echo '<b>' . wp_kses_post( $prtfl_options['description_text_field'] ) . '</b>'; ?></span> <?php echo wp_kses_post( $full_descr ); ?></div> |
|
2295 <?php |
|
2296 } |
2044 } |
2297 } |
2045 |
2298 |
2046 if ( 0 != $user_id || 0 == $portfolio_options['svn_additional_field_for_non_logged'] ) { |
2299 if ( 0 !== $user_id || 0 === absint( $portfolio_options['svn_additional_field_for_non_logged'] ) ) { |
2047 $svn = isset( $post_meta['_prtfl_svn'] ) ? $post_meta['_prtfl_svn'] : ''; |
2300 $svn = isset( $post_meta['_prtfl_svn'] ) ? $post_meta['_prtfl_svn'] : ''; |
2048 if ( 1 == $portfolio_options['svn_additional_field'] && ! empty( $svn ) ) { ?> |
2301 if ( 1 === absint( $portfolio_options['svn_additional_field'] ) && ! empty( $svn ) ) { |
2049 <p><span class="lable"><?php echo '<b>' . $portfolio_options['svn_text_field'] . '</b>'; ?></span> <?php echo $svn; ?></p> |
2302 ?> |
2050 <?php } |
2303 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $portfolio_options['svn_text_field'] ) . '</b>'; ?></span> <?php echo esc_url( $svn ); ?></p> |
|
2304 <?php |
|
2305 } |
2051 } |
2306 } |
2052 if ( $user_id ) { |
2307 if ( $user_id ) { |
2053 $executors_profile = wp_get_object_terms( $post->ID, 'portfolio_executor_profile' ); |
2308 $executors_profile = wp_get_object_terms( $post->ID, 'portfolio_executor_profile' ); |
2054 if ( 1 == $portfolio_options['executor_additional_field'] && ! empty( $executors_profile ) ) { ?> |
2309 if ( 1 === absint( $portfolio_options['executor_additional_field'] ) && ! empty( $executors_profile ) ) { |
2055 <p><span class="lable"><?php echo '<b>' . $portfolio_options['executor_text_field'] . '</b>'; ?></span> |
2310 ?> |
2056 <?php $count = 0; |
2311 <p><span class="lable"><?php echo '<b>' . wp_kses_post( $portfolio_options['executor_text_field'] ) . '</b>'; ?></span> |
|
2312 <?php |
|
2313 $count = 0; |
2057 foreach ( $executors_profile as $profile ) { |
2314 foreach ( $executors_profile as $profile ) { |
2058 if ( $count > 0 ) { |
2315 if ( $count > 0 ) { |
2059 echo ', '; |
2316 echo ', '; |
2060 } ?> |
2317 } |
2061 <a href="<?php echo get_term_link( $profile->slug, 'portfolio_executor_profile' ); ?>" title="<?php echo $profile->name; ?> profile" target="_blank"><?php echo $profile->name; ?></a> |
2318 ?> |
2062 <?php $count++; |
2319 <a href="<?php echo esc_url( get_term_link( $profile->slug, 'portfolio_executor_profile' ) ); ?>" title="<?php echo wp_kses_post( $profile->name ); ?> profile" target="_blank"><?php echo wp_kses_post( $profile->name ); ?></a> |
2063 } ?> |
2320 <?php |
|
2321 $count++; |
|
2322 } |
|
2323 ?> |
2064 </p> |
2324 </p> |
2065 <?php } |
2325 <?php |
2066 } ?> |
2326 } |
|
2327 } |
|
2328 ?> |
2067 </div><!-- .portfolio_short_content --> |
2329 </div><!-- .portfolio_short_content --> |
2068 <div class="portfolio_images_block" data-columns="<?php echo $portfolio_options['custom_image_row_count'] ?>"> |
2330 <div class="portfolio_images_block" data-columns="<?php echo esc_attr( $portfolio_options['custom_image_row_count'] ); ?>"> |
2069 <?php if ( metadata_exists( 'post', $post->ID, '_prtfl_images' ) ) { |
2331 <?php |
|
2332 if ( metadata_exists( 'post', $post->ID, '_prtfl_images' ) ) { |
2070 $array_post_thumbnail_id = array_filter( explode( ',', get_post_meta( $post->ID, '_prtfl_images', true ) ) ); |
2333 $array_post_thumbnail_id = array_filter( explode( ',', get_post_meta( $post->ID, '_prtfl_images', true ) ) ); |
2071 } else { |
2334 } else { |
2072 /* Compatibility with old plugin version 2.37 */ |
2335 /* Compatibility with old plugin version 2.37 */ |
2073 $args = array( |
2336 $args = array( |
2074 'post_parent' => $post->ID, |
2337 'post_parent' => $post->ID, |
2075 'post_type' => 'attachment', |
2338 'post_type' => 'attachment', |
2076 'post_mime_type' => 'image', |
2339 'post_mime_type' => 'image', |
2077 'numberposts' => -1, |
2340 'numberposts' => -1, |
2078 'orderby' => 'menu_order', |
2341 'orderby' => 'menu_order', |
2079 'order' => 'ASC', |
2342 'order' => 'ASC', |
2080 'exclude' => $post_thumbnail_id, |
2343 'exclude' => $post_thumbnail_id, |
2081 'fields' => 'ids' |
2344 'fields' => 'ids', |
2082 ); |
2345 ); |
2083 $array_post_thumbnail_id = get_children( $args ); |
2346 $array_post_thumbnail_id = get_children( $args ); |
2084 } |
2347 } |
2085 $count_element = count( $array_post_thumbnail_id ); |
2348 $count_element = count( $array_post_thumbnail_id ); |
2086 |
2349 |
2087 foreach ( $array_post_thumbnail_id as $key => $value ) { |
2350 foreach ( $array_post_thumbnail_id as $key => $value ) { |
2088 $image = wp_get_attachment_image_src( $value, $prtfl_options['image_size_photo'] ); |
2351 $image = wp_get_attachment_image_src( $value, $prtfl_options['image_size_photo'] ); |
2089 $image_large = wp_get_attachment_image_src( $value, 'large' ); |
2352 $image_large = wp_get_attachment_image_src( $value, 'large' ); |
2090 $image_alt = get_post_meta( $value, '_wp_attachment_image_alt', true ); |
2353 $image_alt = get_post_meta( $value, '_wp_attachment_image_alt', true ); |
2091 $image_title = get_post_meta( $value, '_wp_attachment_image_title', true ); |
2354 $image_title = get_post_meta( $value, '_wp_attachment_image_title', true ); |
2092 $image_desc = get_post( $value ); |
2355 $image_desc = get_post( $value ); |
2093 $image_desc = $image_desc->post_content; |
2356 $image_desc = $image_desc->post_content; |
2094 |
2357 |
2095 /* get width and height for image_size_photo */ |
2358 /* get width and height for image_size_photo */ |
2096 if ( 'portfolio-photo-thumb' != $prtfl_options['image_size_photo'] ) { |
2359 if ( 'portfolio-photo-thumb' !== $prtfl_options['image_size_photo'] ) { |
2097 $width = absint( get_option( $prtfl_options['image_size_photo'] . '_size_w' ) ); |
2360 $width = absint( get_option( $prtfl_options['image_size_photo'] . '_size_w' ) ); |
2098 $height = absint( get_option( $prtfl_options['image_size_photo'] . '_size_h' ) ); |
2361 $height = absint( get_option( $prtfl_options['image_size_photo'] . '_size_h' ) ); |
2099 } else { |
2362 } else { |
2100 $width = $prtfl_options['custom_size_px']['portfolio-photo-thumb'][0]; |
2363 $width = $prtfl_options['custom_size_px']['portfolio-photo-thumb'][0]; |
2101 $height = $prtfl_options['custom_size_px']['portfolio-photo-thumb'][1]; |
2364 $height = $prtfl_options['custom_size_px']['portfolio-photo-thumb'][1]; |
2102 } |
2365 } |
2103 |
2366 |
2104 if ( 0 == $key ) { ?> |
2367 if ( 0 === $key ) { |
2105 <span class="lable"><?php echo '<b>' . $portfolio_options['screenshot_text_field'] . '</b>'; ?></span> |
2368 ?> |
|
2369 <span class="lable"><?php echo '<b>' . wp_kses_post( $portfolio_options['screenshot_text_field'] ) . '</b>'; ?></span> |
2106 <div class="portfolio_images_rows"> |
2370 <div class="portfolio_images_rows"> |
2107 <?php } ?> |
2371 <?php } ?> |
2108 <div class="portfolio_images_gallery"> |
2372 <div class="portfolio_images_gallery"> |
2109 <a class="lightbox" data-fancybox="portfolio_fancybox" href="<?php echo $image_large[0]; ?>" title="<?php echo $image_desc; ?>"> |
2373 <a class="lightbox" data-fancybox="portfolio_fancybox" href="<?php echo esc_url( $image_large[0] ); ?>" title="<?php echo esc_html( $image_desc ); ?>"> |
2110 <img src="<?php echo $image[0]; ?>" alt="<?php echo $image_alt; ?>" <?php if ( $width ) echo 'width="' . $width . '"'; if ( $height ) echo 'height="' . $height . '"'; ?> style="<?php if ( $width ) echo 'width:' . $width . 'px;'; if ( $height ) echo 'height:' . $height . 'px;'; ?>" /> |
2374 <img src="<?php echo esc_url( $image[0] ); ?>" alt="<?php echo esc_html( $image_alt ); ?>" <?php echo isset( $width ) ? 'width="' . esc_attr( $width ) . '"' : ''; ?> <?php echo isset( $height ) ? 'height="' . esc_attr( $height ) . '"' : ''; ?> |
|
2375 style="<?php echo isset( $width ) ? 'width:' . esc_attr( $width ) . 'px;' : ''; ?> <?php echo isset( $height ) ? 'height:' . esc_attr( $height ) . 'px;' : ''; ?>" /> |
2111 </a> |
2376 </a> |
2112 <br /><?php echo $image_title;?> |
2377 <br /><?php echo wp_kses_post( $image_title ); ?> |
2113 </div> |
2378 </div> |
2114 <?php if ( 0 == ( $key + 1 ) % $portfolio_options['custom_image_row_count'] && 0 != $key && $key + 1 != $count_element ) { ?> |
2379 <?php if ( 0 === ( $key + 1 ) % $portfolio_options['custom_image_row_count'] && 0 !== $key && $key + 1 !== $count_element ) { ?> |
2115 </div><!-- .portfolio_images_rows --> |
2380 </div><!-- .portfolio_images_rows --> |
2116 <div class="portfolio_images_rows"> |
2381 <div class="portfolio_images_rows"> |
2117 <?php } |
2382 <?php |
|
2383 } |
2118 } |
2384 } |
2119 if ( 0 < $count_element ) { ?> |
2385 if ( 0 < $count_element ) { |
|
2386 ?> |
2120 </div><!-- .portfolio_images_rows --> |
2387 </div><!-- .portfolio_images_rows --> |
2121 <?php } ?> |
2388 <?php } ?> |
2122 </div><!-- .portfolio_images_block --> |
2389 </div><!-- .portfolio_images_block --> |
2123 </div><!-- .entry --> |
2390 </div><!-- .entry --> |
2124 <div class="entry_footer entry-footer"> |
2391 <div class="entry_footer entry-footer"> |
2125 <?php $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
2392 <?php |
2126 if ( 1 == $portfolio_options['technologies_additional_field'] && ! ( empty( $terms ) || is_wp_error( $terms ) ) ) { |
2393 $terms = wp_get_object_terms( $post->ID, 'portfolio_technologies' ); |
2127 if ( is_array( $terms ) && 0 < count( $terms ) ) { ?> |
2394 if ( 1 === absint( $portfolio_options['technologies_additional_field'] ) && ! ( empty( $terms ) || is_wp_error( $terms ) ) ) { |
|
2395 if ( is_array( $terms ) && 0 < count( $terms ) ) { |
|
2396 ?> |
2128 <div class="portfolio_terms"> |
2397 <div class="portfolio_terms"> |
2129 <?php if ( isset( $portfolio_options['technologies_text_field'] ) ) echo '<b>'. $portfolio_options['technologies_text_field'] . ' </b>'; |
2398 <?php |
|
2399 if ( isset( $portfolio_options['technologies_text_field'] ) ) { |
|
2400 echo '<b>' . wp_kses_post( $portfolio_options['technologies_text_field'] ) . ' </b>';} |
2130 $links = array(); |
2401 $links = array(); |
2131 foreach ( $terms as $term ) { |
2402 foreach ( $terms as $term ) { |
2132 $links[] = '<a href="' . get_term_link( $term->slug, 'portfolio_technologies' ) . '" title="' . sprintf( __( "View all projects in %s" ), $term->name ) . '" ' . '>' . $term->name . '</a>'; |
2403 $links[] = '<a href="' . esc_url( get_term_link( $term->slug, 'portfolio_technologies' ) ) . '" title="' . sprintf( esc_html__( 'View all projects in %s' ), $term->name ) . '">' . esc_html( $term->name ) . '</a>'; |
2133 } |
2404 } |
2134 echo implode( ', ', $links ); ?> |
2405 echo wp_kses_post( implode( ', ', $links ) ); |
|
2406 ?> |
2135 </div><!-- .portfolio_terms --> |
2407 </div><!-- .portfolio_terms --> |
2136 <?php } |
2408 <?php |
2137 } ?> |
2409 } |
|
2410 } |
|
2411 ?> |
2138 </div><!-- .entry_footer .entry-footer --> |
2412 </div><!-- .entry_footer .entry-footer --> |
|
2413 <?php |
|
2414 $content = ob_get_contents(); |
|
2415 ob_end_clean(); |
|
2416 echo wp_kses_post( $content ); |
|
2417 ?> |
2139 </article><!-- .portfolio_content --> |
2418 </article><!-- .portfolio_content --> |
2140 <?php endwhile; |
2419 <?php |
2141 } |
2420 endwhile; |
2142 } |
2421 } |
2143 |
2422 } |
2144 /* This function prints pagination for portfolio post type template */ |
2423 |
2145 if ( ! function_exists( 'prtfl_pro_pagination' ) ) { |
2424 if ( ! function_exists( 'prtfl_pro_pagination' ) ) { |
|
2425 /** |
|
2426 * This function prints pagination for portfolio post type template |
|
2427 * |
|
2428 * @param object $second_query Query object. |
|
2429 * @param array $args Link to args. |
|
2430 */ |
2146 function prtfl_pro_pagination( $second_query, &$args ) { |
2431 function prtfl_pro_pagination( $second_query, &$args ) { |
2147 global $wp_query, $prtfl_options; |
2432 global $wp_query, $prtfl_options; |
2148 $count_all_albums = $second_query->found_posts; |
2433 $count_all_albums = $second_query->found_posts; |
2149 |
2434 |
2150 $request = $wp_query->request; |
2435 $request = $wp_query->request; |
2151 $paged = $showitems = $args['paged']; |
2436 $paged = $args['paged']; |
2152 $per_page = $args['posts_per_page']; |
2437 $showitems = $paged; |
2153 $pages = intval( $count_all_albums / $per_page ); |
2438 $per_page = $args['posts_per_page']; |
|
2439 $pages = intval( $count_all_albums / $per_page ); |
2154 |
2440 |
2155 if ( $count_all_albums % $per_page > 0 ) { |
2441 if ( $count_all_albums % $per_page > 0 ) { |
2156 $pages += 1; |
2442 $pages++; |
2157 } |
2443 } |
2158 $range = 2; |
2444 $range = 2; |
2159 |
2445 |
2160 if ( ! $pages ) { |
2446 if ( ! $pages ) { |
2161 $pages = 1; |
2447 $pages = 1; |
2162 } |
2448 } |
2163 if ( 1 != $pages ) { ?> |
2449 if ( 1 !== $pages ) { |
|
2450 ?> |
2164 <div class='clear'></div> |
2451 <div class='clear'></div> |
2165 <div id="portfolio_pagenation"> |
2452 <div id="portfolio_pagenation"> |
2166 <div class="pagination"> |
2453 <div class="pagination"> |
2167 <div class="<?php echo 'twentynineteen' == get_stylesheet() ? 'nav-links' : '' ?>"> |
2454 <div class="<?php echo 'twentynineteen' === get_stylesheet() ? esc_attr( 'nav-links' ) : ''; ?>"> |
2168 <?php if ( 2 < $paged && $paged > $range + 1 && $showitems < $pages ) { |
2455 <?php |
2169 echo "<a href='" . get_pagenum_link( 1 ) . "'>«</a>"; |
2456 if ( 2 < $paged && $paged > $range + 1 && $showitems < $pages ) { |
|
2457 echo "<a href='" . esc_url( get_pagenum_link( 1 ) ) . "'>«</a>"; |
2170 } |
2458 } |
2171 if ( 1 < $paged && $showitems < $pages ) { |
2459 if ( 1 < $paged && $showitems < $pages ) { |
2172 echo "<a href='" . get_pagenum_link( $paged - 1 ) . "'>‹</a>"; |
2460 echo "<a href='" . esc_url( get_pagenum_link( $paged - 1 ) ) . "'>‹</a>"; |
2173 } |
2461 } |
2174 for ( $i = 1; $i <= $pages; $i++ ) { |
2462 for ( $i = 1; $i <= $pages; $i++ ) { |
2175 if ( 1 != $pages && ( ! ( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) ) { |
2463 if ( 1 !== $pages && ( ! ( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) ) { |
2176 echo ( $paged == $i ) ? "<span class='current'>" . $i . "</span>":"<a href='" . get_pagenum_link( $i ) . "' class='inactive' >" . $i . "</a>"; |
2464 echo ( $paged === $i ) ? "<span class='current'>" . esc_html( $i ) . '</span>' : "<a href='" . esc_url( get_pagenum_link( $i ) ) . "' class='inactive' >" . esc_html( $i ) . '</a>'; |
2177 } |
2465 } |
2178 } |
2466 } |
2179 if ( $paged < $pages && $showitems < $pages ) { |
2467 if ( $paged < $pages && $showitems < $pages ) { |
2180 echo "<a href='" . get_pagenum_link( $paged + 1 ) . "'>›</a>"; |
2468 echo "<a href='" . esc_url( get_pagenum_link( $paged + 1 ) ) . "'>›</a>"; |
2181 } |
2469 } |
2182 if ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages ) { |
2470 if ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages ) { |
2183 echo "<a href='" . get_pagenum_link( $pages ) . "'>»</a>"; |
2471 echo "<a href='" . esc_url( get_pagenum_link( $pages ) ) . "'>»</a>"; |
2184 } ?> |
2472 } |
2185 <div class='clear'></div> |
2473 ?> |
2186 </div> |
2474 <div class='clear'></div> |
|
2475 </div> |
2187 </div><!-- .pagination --> |
2476 </div><!-- .pagination --> |
2188 <?php if ( function_exists( 'pgntn_display_pagination' ) ) pgntn_display_pagination( 'custom', $second_query ); ?> |
2477 <?php |
|
2478 if ( function_exists( 'pgntn_display_pagination' ) ) { |
|
2479 pgntn_display_pagination( 'custom', $second_query );} |
|
2480 ?> |
2189 </div><!-- #portfolio_pagenation --> |
2481 </div><!-- #portfolio_pagenation --> |
2190 <?php } |
2482 <?php |
2191 } |
2483 } |
2192 } |
2484 } |
2193 |
2485 } |
2194 /* add shortcode content */ |
2486 |
2195 if ( ! function_exists( 'prtfl_shortcode_button_content' ) ) { |
2487 if ( ! function_exists( 'prtfl_shortcode_button_content' ) ) { |
2196 function prtfl_shortcode_button_content( $content ) { ?> |
2488 /** |
|
2489 * Add shortcode content |
|
2490 * |
|
2491 * @param string $content Shortcode content. |
|
2492 */ |
|
2493 function prtfl_shortcode_button_content( $content ) { |
|
2494 ?> |
2197 <div id="prtfl" style="display:none;"> |
2495 <div id="prtfl" style="display:none;"> |
2198 <fieldset> |
2496 <fieldset> |
2199 <label> |
2497 <label> |
2200 <input type="number" value="3" min="0" max="1000" name="prtfl_display_count" id="prtfl_display_count" class="small-text" /> |
2498 <input type="number" value="3" min="0" max="1000" name="prtfl_display_count" id="prtfl_display_count" class="small-text" /> |
2201 <span> |
2499 <span> |
2202 <?php _e( 'The number of portfolio projects to display', 'portfolio' ); ?> |
2500 <?php esc_html_e( 'The number of portfolio projects to display', 'portfolio' ); ?> |
2203 </span> |
2501 </span> |
2204 </label> |
2502 </label> |
2205 </fieldset> |
2503 </fieldset> |
2206 <input class="bws_default_shortcode" type="hidden" name="default" value="[latest_portfolio_items count=3]" /> |
2504 <input class="bws_default_shortcode" type="hidden" name="default" value="[latest_portfolio_items count=3]" /> |
2207 <?php $script = "function prtfl_shortcode_init() { |
2505 <?php |
2208 ( function( $ ) { |
2506 $script = "function prtfl_shortcode_init() { |
2209 $( '.mce-reset #prtfl_display_count' ).on( 'change', function() { |
2507 ( function( $ ) { |
2210 var count = $( '.mce-reset #prtfl_display_count' ).val(); |
2508 $( '.mce-reset #prtfl_display_count' ).on( 'change', function() { |
2211 var shortcode = '[latest_portfolio_items count=' + count + ']'; |
2509 var count = $( '.mce-reset #prtfl_display_count' ).val(); |
2212 $( '.mce-reset #bws_shortcode_display' ).text( shortcode ); |
2510 var shortcode = '[latest_portfolio_items count=' + count + ']'; |
2213 } ); |
2511 $( '.mce-reset #bws_shortcode_display' ).text( shortcode ); |
2214 } )( jQuery ); |
2512 } ); |
2215 }"; |
2513 } )( jQuery ); |
|
2514 }"; |
2216 wp_register_script( 'prtfl_display_script', '' ); |
2515 wp_register_script( 'prtfl_display_script', '' ); |
2217 wp_enqueue_script( 'prtfl_display_script' ); |
2516 wp_enqueue_script( 'prtfl_display_script' ); |
2218 wp_add_inline_script( 'prtfl_display_script', sprintf( $script ) ); ?> |
2517 wp_add_inline_script( 'prtfl_display_script', sprintf( $script ) ); |
|
2518 ?> |
2219 <div class="clear"></div> |
2519 <div class="clear"></div> |
2220 </div> |
2520 </div> |
2221 <?php } |
2521 <?php |
2222 } |
2522 } |
2223 |
2523 } |
2224 /* add help tab */ |
2524 |
|
2525 if ( ! function_exists( 'prtfl_get_data' ) ) { |
|
2526 /** |
|
2527 * Get data for portfolio by ID |
|
2528 * |
|
2529 * @param int $prtfl_id Portfolio ID. |
|
2530 */ |
|
2531 function prtfl_get_data( $prtfl_id ) { |
|
2532 |
|
2533 $post_type = array( 'bws-portfolio' ); |
|
2534 $prtfl_posts = array(); |
|
2535 $prtfl_images_all = array(); |
|
2536 |
|
2537 if ( 'all' === $prtfl_id || is_array( $prtfl_id ) ) { |
|
2538 |
|
2539 $prtfl_id_list = ( is_array( $prtfl_id ) && ! empty( $prtfl_id ) ) ? $prtfl_id : array(); |
|
2540 $args = ( is_array( $prtfl_id ) ) ? array( |
|
2541 'post_type' => 'bws-portfolio', |
|
2542 'include' => $prtfl_id_list, |
|
2543 ) : array( 'post_type' => 'bws-portfolio' ); |
|
2544 $prtfl_posts = get_posts( $args ); |
|
2545 |
|
2546 } elseif ( is_int( $prtfl_id ) || is_string( $prtfl_id ) ) { |
|
2547 |
|
2548 $prtfl_int_id = is_int( $prtfl_id ) ? $prtfl_id : intval( $prtfl_id ); |
|
2549 $prtfl_posts = get_post( $prtfl_int_id ); |
|
2550 |
|
2551 } |
|
2552 |
|
2553 $prtfl_posts_end = array(); |
|
2554 foreach ( (array) $prtfl_posts as $key => $prtfl_post ) { |
|
2555 |
|
2556 $prtfl_meta = get_post_meta( $prtfl_post->ID, '' ); |
|
2557 unset( $prtfl_meta['_edit_lock'] ); |
|
2558 unset( $prtfl_meta['_edit_last'] ); |
|
2559 |
|
2560 foreach ( $prtfl_meta['prtfl_information'] as $key => $prtfl_information ) { |
|
2561 $prtfl_information = isset( $prtfl_information ) ? unserialize( $prtfl_information ) : ''; |
|
2562 $prtfl_meta['prtfl_information'][ $key ] = $prtfl_information; |
|
2563 } |
|
2564 |
|
2565 foreach ( $prtfl_meta['_prtfl_images'] as $key => $prtfl_images ) { |
|
2566 $prtfl_images_all = isset( $prtfl_images ) ? explode( ',', $prtfl_images ) : ''; |
|
2567 $args = array( |
|
2568 'post_type' => 'attachment', |
|
2569 'include' => $prtfl_images_all, |
|
2570 ); |
|
2571 $prtfl_images = ! empty( $prtfl_images_all ) ? get_posts( $args ) : ''; |
|
2572 $prtfl_meta['_prtfl_images'][ $key ] = $prtfl_images; |
|
2573 } |
|
2574 |
|
2575 $prtfl_posts[ $key ]->prtfl_post_meta = $prtfl_meta; |
|
2576 } |
|
2577 |
|
2578 return $prtfl_posts; |
|
2579 } |
|
2580 } |
|
2581 |
2225 if ( ! function_exists( 'prtfl_add_tabs' ) ) { |
2582 if ( ! function_exists( 'prtfl_add_tabs' ) ) { |
|
2583 /** |
|
2584 * Add help tab |
|
2585 */ |
2226 function prtfl_add_tabs() { |
2586 function prtfl_add_tabs() { |
2227 global $prtfl_options; |
2587 global $prtfl_options; |
2228 $screen = get_current_screen(); |
2588 $screen = get_current_screen(); |
2229 if ( ( ! empty( $screen->post_type ) && $prtfl_options['post_type_name'] == $screen->post_type ) || |
2589 if ( ( ! empty( $screen->post_type ) && $prtfl_options['post_type_name'] === $screen->post_type ) || |
2230 ( ! empty( $screen->taxonomy ) && 'portfolio_executor_profile' == $screen->taxonomy ) || |
2590 ( ! empty( $screen->taxonomy ) && 'portfolio_executor_profile' === $screen->taxonomy ) || |
2231 ( ! empty( $screen->taxonomy ) && 'portfolio_technologies' == $screen->taxonomy ) || |
2591 ( ! empty( $screen->taxonomy ) && 'portfolio_technologies' === $screen->taxonomy ) || |
2232 ( isset( $_GET['page'] ) && 'portfolio.php' == $_GET['page'] ) ) { |
2592 ( isset( $_GET['page'] ) && 'portfolio.php' === $_GET['page'] ) ) { |
2233 $args = array( |
2593 $args = array( |
2234 'id' => 'prtfl', |
2594 'id' => 'prtfl', |
2235 'section' => '200538929' |
2595 'section' => '200538929', |
2236 ); |
2596 ); |
2237 bws_help_tab( $screen, $args ); |
2597 bws_help_tab( $screen, $args ); |
2238 } |
2598 } |
2239 } |
2599 } |
2240 } |
2600 } |
2241 |
2601 |
2242 if ( ! function_exists( 'prtfl_plugin_deactivation' ) ) { |
2602 if ( ! function_exists( 'prtfl_plugin_deactivation' ) ) { |
|
2603 /** |
|
2604 * Action when deactivating the plugin |
|
2605 */ |
2243 function prtfl_plugin_deactivation() { |
2606 function prtfl_plugin_deactivation() { |
2244 global $wpdb, $prtfl_BWS_demo_data; |
2607 global $wpdb, $prtfl_bws_demo_data; |
2245 |
2608 |
2246 if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
2609 if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
2247 $old_blog = $wpdb->blogid; |
2610 $old_blog = $wpdb->blogid; |
2248 /* Get all blog ids */ |
2611 /* Get all blog ids */ |
2249 $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" ); |
2612 $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" ); |
2250 foreach ( $blogids as $blog_id ) { |
2613 foreach ( $blogids as $blog_id ) { |
2251 switch_to_blog( $blog_id ); |
2614 switch_to_blog( $blog_id ); |
2252 prtfl_include_demo_data(); |
2615 prtfl_include_demo_data(); |
2253 $prtfl_BWS_demo_data->bws_remove_demo_data(); |
2616 $prtfl_bws_demo_data->bws_remove_demo_data(); |
2254 } |
2617 } |
2255 switch_to_blog( $old_blog ); |
2618 switch_to_blog( $old_blog ); |
2256 } else { |
2619 } else { |
2257 global $prtfl_BWS_demo_data; |
2620 global $prtfl_bws_demo_data; |
2258 |
2621 |
2259 if ( ! $prtfl_BWS_demo_data ) { |
2622 if ( ! $prtfl_bws_demo_data ) { |
2260 prtfl_include_demo_data(); |
2623 prtfl_include_demo_data(); |
2261 } |
2624 } |
2262 $prtfl_BWS_demo_data->bws_remove_demo_data(); |
2625 $prtfl_bws_demo_data->bws_remove_demo_data(); |
2263 } |
2626 } |
2264 } |
2627 } |
2265 } |
2628 } |
2266 |
2629 |
2267 if ( ! function_exists( 'prtfl_plugin_uninstall' ) ) { |
2630 if ( ! function_exists( 'prtfl_plugin_uninstall' ) ) { |
|
2631 /** |
|
2632 * Action when uninstalling the plugin |
|
2633 */ |
2268 function prtfl_plugin_uninstall() { |
2634 function prtfl_plugin_uninstall() { |
2269 global $wpdb; |
2635 global $wpdb; |
2270 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
2636 require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
2271 |
2637 |
2272 $plugins_list = get_plugins(); |
2638 $plugins_list = get_plugins(); |
2273 |
2639 |
2274 if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
2640 if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
2275 $old_blog = $wpdb->blogid; |
2641 $old_blog = $wpdb->blogid; |