PageRenderTime 47ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/listify/inc/integrations/wp-job-manager/widgets/class-widget-job_listing-map.php

https://gitlab.com/najomie/ljm
PHP | 118 lines | 86 code | 25 blank | 7 comment | 21 complexity | 5c877316f974a0900cb2a4d27d46c6be MD5 | raw file
  1. <?php
  2. /**
  3. * Job Listing: Map
  4. *
  5. * @since Listify 1.0.0
  6. */
  7. class Listify_Widget_Listing_Map extends Listify_Widget {
  8. public function __construct() {
  9. $this->widget_description = __( 'Display the listing location and contact details.', 'listify' );
  10. $this->widget_id = 'listify_widget_panel_listing_map';
  11. $this->widget_name = __( 'Listify - Listing: Map & Contact Details', 'listify' );
  12. $this->settings = array(
  13. 'map' => array(
  14. 'type' => 'checkbox',
  15. 'std' => 1,
  16. 'label' => __( 'Display Map', 'listify' )
  17. ),
  18. 'address' => array(
  19. 'type' => 'checkbox',
  20. 'std' => 1,
  21. 'label' => __( 'Display Address', 'listify' )
  22. ),
  23. 'phone' => array(
  24. 'type' => 'checkbox',
  25. 'std' => 1,
  26. 'label' => __( 'Display Phone Number', 'listify' )
  27. ),
  28. 'web' => array(
  29. 'type' => 'checkbox',
  30. 'std' => 1,
  31. 'label' => __( 'Display Website', 'listify' )
  32. ),
  33. 'directions' => array(
  34. 'type' => 'checkbox',
  35. 'std' => 1,
  36. 'label' => __( 'Display "Get Directions"', 'listify' )
  37. )
  38. );
  39. parent::__construct();
  40. }
  41. function widget( $args, $instance ) {
  42. if ( $this->get_cached_widget( $args ) )
  43. return;
  44. global $job_manager, $post, $listify_job_manager;
  45. extract( $args );
  46. $fields = array( 'map', 'address', 'phone', 'web', 'directions' );
  47. $location = $listify_job_manager->template->get_the_location_formatted();
  48. foreach ( $fields as $field ) {
  49. $$field = isset( $instance[ $field ] ) && 1 == $instance[ $field ] ? true : false;
  50. }
  51. // map also needs location data
  52. $map = $map && $post->geolocation_lat;
  53. // figure out split
  54. $just_directions = $directions && ! ( $web || $address || $phone );
  55. $split = $map && ! $just_directions && ( $phone || $web || $address || $directions ) ? 'map-widget-section--split' : '';
  56. ob_start();
  57. echo $before_widget;
  58. ?>
  59. <div class="map-widget-sections">
  60. <?php if ( $map ) : ?>
  61. <div class="map-widget-section <?php echo $split; ?>">
  62. <div id="listing-contact-map"></div>
  63. </div>
  64. <?php endif; ?>
  65. <?php if ( $phone || $web || $address || $directions ) : ?>
  66. <div class="map-widget-section <?php echo $split; ?>">
  67. <?php
  68. do_action( 'listify_widget_job_listing_map_before' );
  69. if ( $address ) :
  70. $listify_job_manager->template->the_location_formatted();
  71. endif;
  72. if ( $phone ) :
  73. $listify_job_manager->template->the_phone();
  74. endif;
  75. if ( $web ) :
  76. $listify_job_manager->template->the_url();
  77. endif;
  78. if ( $directions ) :
  79. $listify_job_manager->template->the_directions();
  80. endif;
  81. do_action( 'listify_widget_job_listing_map_after' );
  82. ?>
  83. </div>
  84. <?php endif; ?>
  85. </div>
  86. <?php
  87. echo $after_widget;
  88. $content = ob_get_clean();
  89. echo apply_filters( $this->widget_id, $content );
  90. add_filter( 'listify_page_needs_map', '__return_false' );
  91. $this->cache_widget( $args, $content );
  92. }
  93. }