class-simple-job-board-applicants.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php if (!defined('ABSPATH')) { exit; } // Exit if accessed directly
  2. /**
  3. * Simple_Job_Board_Applicants Class
  4. *
  5. * This is used to display the applicant details in WP admin. It also display the
  6. * applicant data & resume.
  7. *
  8. * @link https://wordpress.org/plugins/simple-job-board
  9. * @since 1.0.0
  10. * @since 2.3.0 Added "sjb_resume_link_after" and "sjb_applicant_name" hooks.
  11. *
  12. * @package Simple_Job_Board
  13. * @subpackage Simple_Job_Board/includes
  14. * @author PressTigers <support@presstigers.com>
  15. */
  16. class Simple_Job_Board_Applicants {
  17. /**
  18. * Initialize the class and set its properties.
  19. *
  20. * @since 1.0.0
  21. */
  22. public function __construct() {
  23. // Hook -> Job Applicants Data
  24. add_action('edit_form_after_title', array($this, 'jobpost_applicants_detail_page_content'));
  25. }
  26. /**
  27. * Create Detail Page for Applicants
  28. *
  29. * @since 1.0.0
  30. */
  31. public function jobpost_applicants_detail_page_content() {
  32. global $post;
  33. if (!empty($post) and 'jobpost_applicants' === $post->post_type):
  34. $keys = get_post_custom_keys($post->ID);
  35. /**
  36. * Fires before displaying the applicant details
  37. *
  38. * @since 2.2.0
  39. */
  40. do_action('sjb_applicants_details_before', $post->ID);
  41. ?>
  42. <div class="wrap"><div id="icon-tools" class="icon32"></div>
  43. <?php
  44. // Applicant Name
  45. if (NULL != $keys):
  46. foreach ($keys as $key) {
  47. if ('jobapp_' === substr($key, 0, 7)) {
  48. $place = strpos($key, 'name');
  49. if (!empty($place)) {
  50. $applicant_name = get_post_meta($post->ID, $key, TRUE);
  51. $applicant_name = apply_filters('sjb_applicant_name', $applicant_name);
  52. break;
  53. }
  54. }
  55. }
  56. endif;
  57. ?>
  58. <!-- Applicant's Name & Resume in Admin Area -->
  59. <h3>
  60. <?php
  61. echo isset($applicant_name) ? $applicant_name : '';
  62. // Applicant Resume
  63. if (in_array('resume', $keys) && '/' != get_post_meta($post->ID, 'resume', TRUE)):
  64. $resume = '&nbsp; &nbsp; <small><a href="' . esc_url(get_admin_url() . 'post.php?post=' . intval($post->ID) . '&action=edit&resume_id=' . intval($post->ID)) . '" rel="nofollow">' . esc_html__('Resume', 'simple-job-board') . '</a></small>';
  65. else:
  66. $resume = '&nbsp; &nbsp; <small>Resume[deleted]</small>';
  67. endif;
  68. echo apply_filters('sjb_applicant_resume', $resume, $post->ID);
  69. ?>
  70. </h3>
  71. <?php
  72. /**
  73. * Action -> Fires after Resume Link
  74. *
  75. * @since 2.3.0
  76. */
  77. do_action('sjb_resume_link_after', $post->ID);
  78. ?>
  79. <!-- Applicant's Detail in Admin Area -->
  80. <table class="widefat striped">
  81. <?php
  82. /**
  83. * Fires at start of applicant details
  84. *
  85. * @since 2.2.0
  86. */
  87. do_action('sjb_applicants_details_start', $post->ID);
  88. foreach ($keys as $key):
  89. if (substr($key, 0, 7) == 'jobapp_') {
  90. if (!is_serialized(get_post_meta($post->ID, $key, TRUE))) {
  91. echo '<tr><td>' . ucwords(str_replace('_', ' ', substr($key, 7))) . '</td><td>' . get_post_meta($post->ID, $key, TRUE) . '</td></tr>';
  92. } else {
  93. $values = unserialize(get_post_meta($post->ID, $key, TRUE));
  94. if (is_array($values)) {
  95. echo '<tr><td>' . ucwords(str_replace('_', ' ', substr($key, 7))) . '</td><td>';
  96. $count = sizeof($values);
  97. foreach ($values as $val):
  98. echo esc_attr($val);
  99. if ($count > 1) {
  100. echo ',&nbsp';
  101. }
  102. $count--;
  103. endforeach;
  104. echo '</td></tr>';
  105. } else {
  106. echo '<tr><td>' . ucwords(str_replace('_', ' ', substr($key, 7))) . '</td><td>' . get_post_meta($post->ID, $key, TRUE) . '</td></tr>';
  107. }
  108. }
  109. }
  110. endforeach;
  111. /**
  112. * Fires at the end of applicant details
  113. *
  114. * @since 2.2.0
  115. */
  116. do_action('sjb_applicants_details_end', $post->ID);
  117. ?>
  118. </table>
  119. </div>
  120. <?php
  121. /**
  122. * Fires after displaying the applicant details
  123. *
  124. * @since 2.2.0
  125. */
  126. do_action('sjb_applicants_details_after', $post->ID);
  127. ?>
  128. <h2><?php esc_html_e('Application Notes', 'simple-job-board'); ?></h2>
  129. <?php
  130. /**
  131. * Fires after displaying the applicant details
  132. *
  133. * @since 2.2.0
  134. */
  135. do_action('sjb_applicantion_notes', $post->ID);
  136. endif;
  137. }
  138. }
  139. new Simple_Job_Board_Applicants();