class-simple-job-board-settings-privacy.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?php
  2. if (!defined('ABSPATH')) {
  3. exit;
  4. } // Exit if accessed directly
  5. /**
  6. * Simple_Job_Board_GDPR_Settings Class
  7. *
  8. * This file used to define the settings for the GDPR Settings. User can enable/disable
  9. * GDPR Settings and set the content for Privacy Policy and Terms & Conditions.
  10. *
  11. * @link https://wordpress.org/plugins/simple-job-board
  12. * @since 2.6.0
  13. *
  14. * @package Simple_Job_Board
  15. * @subpackage Simple_Job_Board/admin/settings
  16. * @author PressTigers <support@presstigers.com>
  17. */
  18. class Simple_Job_Board_Privacy {
  19. /**
  20. * Initialize the class and set its properties.
  21. *
  22. * @since 2.6.0
  23. */
  24. public function __construct() {
  25. // Filter -> Add GDPR Settings Tab
  26. add_filter('sjb_settings_tab_menus', array($this, 'sjb_add_settings_tab'), 80);
  27. // Action -> Add GDPR Settings Section
  28. add_action('sjb_settings_tab_section', array($this, 'sjb_add_settings_section'), 80);
  29. // Action -> Save GDPR Settings Section
  30. add_action('sjb_save_setting_sections', array($this, 'sjb_save_settings_section'));
  31. }
  32. /**
  33. * Add GDPR Settings Tab.
  34. *
  35. * @since 2.6.0
  36. *
  37. * @param array $tabs Settings Tab
  38. * @return array $tabs Merge array of Settings Tab with "GDPR Settings" Tab.
  39. */
  40. public function sjb_add_settings_tab($tabs) {
  41. $tabs['privacy_settings'] = esc_html__('Privacy', 'simple-job-board');
  42. return $tabs;
  43. }
  44. /**
  45. * Add GDPR Settings section.
  46. *
  47. * @since 2.6.0
  48. */
  49. public function sjb_add_settings_section() {
  50. ?>
  51. <!-- Filters Setting -->
  52. <div id="settings-privacy_settings" class="sjb-admin-settings" style="display: none;">
  53. <?php
  54. /**
  55. * Action -> Add new section before GDPR settings .
  56. *
  57. * @since 2.6.0
  58. */
  59. do_action('sjb_privacy_settings_section_start');
  60. ?>
  61. <h4 class="first"><?php esc_html_e('Configure Privacy Policy Settings', 'simple-job-board'); ?></h4>
  62. <form method="post" id="privacy-settings-form">
  63. <div class="sjb-section">
  64. <div class="sjb-content">
  65. <?php
  66. /**
  67. * Action -> Add new fields at the start of GDPR settings section.
  68. *
  69. * @since 2.6.0
  70. */
  71. do_action('sjb_privacy_settings_start');
  72. //Enable GDPR Settings
  73. $sjb_privacy_settings = get_option('job_board_privacy_settings', 'no');
  74. //Enable Settings to Remove Personal Data from the Applicants
  75. $remove_applicant_data = get_option('sjb_erasure_request_removes_applicant_data', 'no');
  76. $job_board_privacy_policy_label = get_option('job_board_privacy_policy_label', '');
  77. $job_board_privacy_policy_content = get_option('job_board_privacy_policy_content', '');
  78. $job_board_term_conditions_label = get_option('job_board_term_conditions_label', '');
  79. $job_board_term_conditions_content = get_option('job_board_term_conditions_content', '');
  80. ?>
  81. <div class="sjb-form-group">
  82. <input type="checkbox" name="job_privacy_settings" value="yes" <?php checked('yes', esc_attr($sjb_privacy_settings)); ?> />
  83. <label><?php echo esc_html__('Enable Terms & Conditions Field', 'simple-job-board'); ?></label>
  84. <input type='hidden' name="empty_privacy_settings" value="empty_privacy_settings" >
  85. </div>
  86. <div class="sjb-form-group">
  87. <label class="font-bold"><?php echo esc_html__('Privacy Policy Label (Opt.)', 'simple-job-board'); ?></label>
  88. </div>
  89. <div>
  90. <input type="text" id="setting_privacy_policy_label" name="privacy_policy_label" class="form-control full-width" value="<?php echo $job_board_privacy_policy_label; ?>" >
  91. </div>
  92. <div class="sjb-form-group">
  93. <label class="font-bold"><?php echo esc_html__('Privacy Policy Content', 'simple-job-board'); ?></label>
  94. </div>
  95. <div>
  96. <textarea rows="4" cols="40" name="privacy_policy_content" id="setting_privacy_policy_content" class="form-control full-width"><?php echo esc_attr($job_board_privacy_policy_content); ?></textarea>
  97. </div>
  98. <div class="sjb-form-group">
  99. <label class="font-bold"><?php echo esc_html__('Terms & Conditions Label (Opt.)', 'simple-job-board'); ?></label>
  100. </div>
  101. <div>
  102. <input type="text" id="setting_term_conditions_label" name="term_conditions_label" class="form-control full-width" value="<?php echo esc_attr($job_board_term_conditions_label); ?>">
  103. </div>
  104. <div class="sjb-form-group">
  105. <label class="font-bold"><?php echo esc_html__('Terms & Conditions Content', 'simple-job-board'); ?></label>
  106. </div>
  107. <div>
  108. <textarea rows="4" cols="50" name="term_conditions_content" id="setting_term_conditions_content" class="form-control full-width"><?php echo esc_attr($job_board_term_conditions_content); ?></textarea>
  109. </div>
  110. <?php
  111. /**
  112. * Action -> Add new fields at the end of GDPR settings section.
  113. *
  114. * @since 2.6.0
  115. */
  116. do_action('sjb_privacy_settings_end');
  117. ?>
  118. </div>
  119. </div>
  120. <?php
  121. /**
  122. * Action -> Add new section before Remove Personal Data Settings settings.
  123. *
  124. * @since 2.6.0
  125. */
  126. do_action('sjb_eraser_applicant_data_section_start');
  127. ?>
  128. <h4 class = "first"><?php esc_html_e('Remove Personal Data Settings', 'simple-job-board'); ?></h4>
  129. <div class = "sjb-section">
  130. <div class="sjb-content">
  131. <div class = "sjb-form-group">
  132. <input type = "checkbox" name = "job_remove_applicant_data_settings" value = "yes" <?php checked('yes', esc_attr($remove_applicant_data)); ?> />
  133. <label><?php echo esc_html__('Remove personal data from applcations including resume.', 'simple-job-board'); ?></label>
  134. <input type='hidden' name="empty_remove_applicant_data_settings" value="empty_remove_applicant_data_settings" >
  135. </div>
  136. </div>
  137. </div>
  138. <input type="hidden" value="1" name="admin_notices" />
  139. <input type="submit" name="privacysettings_submit" id="privacy_settings" class="button button-primary" value="<?php echo esc_html__('Save Changes', 'simple-job-board'); ?>" />
  140. </form>
  141. <?php
  142. /**
  143. * Action -> Add new section after Remove Personal Data Settings settings.
  144. *
  145. * @since 2.6.0
  146. */
  147. do_action('sjb_eraser_applicant_data_section_end');
  148. ?>
  149. </div>
  150. <?php
  151. }
  152. /**
  153. * Save Settings GDPR Settings Section.
  154. *
  155. * This function is used to save the job filters settings. User can
  156. * enable/disable the job filters on frontend for keyword search, category, job
  157. * type & job location filters.
  158. *
  159. * @since 2.6.0
  160. */
  161. public function sjb_save_settings_section() {
  162. $privacy_policy_label = isset($_POST['privacy_policy_label']) ? sanitize_text_field($_POST['privacy_policy_label']) : '';
  163. $privacy_policy_content = isset($_POST['privacy_policy_content']) ? sanitize_text_field($_POST['privacy_policy_content']) : '';
  164. $term_conditions_label = isset($_POST['term_conditions_label']) ? sanitize_text_field($_POST['term_conditions_label']) : '';
  165. $term_conditions_content = isset($_POST['term_conditions_content']) ? sanitize_text_field($_POST['term_conditions_content']) : '';
  166. $sjb_privacy_settings = isset($_POST['job_privacy_settings']) ? sanitize_text_field($_POST['job_privacy_settings']) : '';
  167. $empty_privacy_settings = isset($_POST['empty_privacy_settings']) ? sanitize_text_field($_POST['empty_privacy_settings']) : '';
  168. $privacy_settings = 0;
  169. $enable_applicant_erasure = isset($_POST['job_remove_applicant_data_settings']) ? sanitize_text_field($_POST['job_remove_applicant_data_settings']) : '';
  170. $empty_applicant_settings = isset($_POST['empty_remove_applicant_data_settings']) ? sanitize_text_field($_POST['empty_remove_applicant_data_settings']) : '';
  171. $applicant_settings = 0;
  172. // Save GDPR Settings
  173. if (!empty($empty_privacy_settings)) {
  174. if (!empty($sjb_privacy_settings)) {
  175. update_option('job_board_privacy_settings', $sjb_privacy_settings);
  176. $privacy_settings = 1;
  177. }
  178. if (0 === $privacy_settings) {
  179. update_option('job_board_privacy_settings', 'no');
  180. }
  181. //Save Privacy Policy Label Settings
  182. if (!empty($privacy_policy_label)) {
  183. update_option('job_board_privacy_policy_label', sanitize_text_field($privacy_policy_label));
  184. } elseif ('' === $privacy_policy_label) {
  185. update_option('job_board_privacy_policy_label', $privacy_policy_label);
  186. }
  187. // Update Privacy Policy Content
  188. if (!empty($privacy_policy_content)) {
  189. update_option('job_board_privacy_policy_content', $privacy_policy_content);
  190. } elseif ('' === $privacy_policy_content) {
  191. update_option('job_board_privacy_policy_content', $privacy_policy_content);
  192. }
  193. // Update T&C Label
  194. if (!empty($term_conditions_label)) {
  195. update_option('job_board_term_conditions_label', $term_conditions_label);
  196. } elseif ('' === $term_conditions_label) {
  197. update_option('job_board_term_conditions_label', $term_conditions_label);
  198. }
  199. // Update T&C Content
  200. if (!empty($term_conditions_content)) {
  201. update_option('job_board_term_conditions_content', $term_conditions_content);
  202. } elseif ('' === $term_conditions_content) {
  203. update_option('job_board_term_conditions_content', $term_conditions_content);
  204. }
  205. // Save GDPR Remove Application Data Settings
  206. if ( !empty( $empty_applicant_settings ) ) {
  207. if ( !empty( $enable_applicant_erasure ) ) {
  208. update_option( 'sjb_erasure_request_removes_applicant_data', $enable_applicant_erasure );
  209. $applicant_settings = 1;
  210. }
  211. if ( 0 === $applicant_settings ) {
  212. update_option( 'sjb_erasure_request_removes_applicant_data', 'no' );
  213. }
  214. }
  215. }
  216. }
  217. }