diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 1e9da48..0000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "workbench.colorCustomizations": {
- "activityBar.activeBackground": "#8f685e",
- "activityBar.background": "#8f685e",
- "activityBar.foreground": "#e7e7e7",
- "activityBar.inactiveForeground": "#e7e7e799",
- "activityBarBadge.background": "#8cb394",
- "activityBarBadge.foreground": "#15202b",
- "sash.hoverBorder": "#8f685e",
- "statusBar.background": "#70524a",
- "statusBar.foreground": "#e7e7e7",
- "statusBarItem.hoverBackground": "#8f685e",
- "statusBarItem.remoteBackground": "#70524a",
- "statusBarItem.remoteForeground": "#e7e7e7"
- },
- "peacock.color": "#70524a"
-}
\ No newline at end of file
diff --git a/admin/css/style.css b/admin/css/style.css
index 7cc839e..3f59733 100644
--- a/admin/css/style.css
+++ b/admin/css/style.css
@@ -1,5 +1,4 @@
-
body #jobs_help code{
padding: 5px 5px 5px;
margin: 0 1px;
@@ -1407,6 +1406,9 @@ body #jobs_help code{
margin: 0;
}
+.jobs_plugin_ads img{
+ width:100%;
+}
.jobs_plugin_settings .row{
padding: 2px 0;
diff --git a/admin/help.php b/admin/help.php
index 4c2633c..ef18106 100644
--- a/admin/help.php
+++ b/admin/help.php
@@ -112,41 +112,6 @@
-
-
-
';
$val = isset($job_remote_data[$key]['type']) ? $job_remote_data[$key]['type'] : '';
+ $val = htmlspecialchars($val);
echo '
'.__('Type', 'job-postings').' ';
echo '
';
echo '- ';
@@ -639,6 +653,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a
echo ' ';
$val2 = isset($job_remote_data[$key]['name']) ? $job_remote_data[$key]['name'] : '';
+ $val2 = htmlspecialchars($val2);
echo '
'.__('Location', 'job-postings').' ';
echo '
';
@@ -673,6 +688,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a
case 'tinymce':
# INPUT
$value = isset( $values[$key] ) ? $values[$key][0] : '';
+ //$value = htmlspecialchars($value);
wp_editor( $value, $key, array(
'textarea_rows' => 5,
@@ -744,6 +760,8 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a
echo '
';
foreach ($options as $option_key => $option_name) {
$checked = '';
+ $option_key = htmlspecialchars($option_key);
+ $option_name = htmlspecialchars($option_name);
if( is_array($value) && in_array($option_key, $value) ) $checked = 'checked';
echo '
';
echo ' ';
@@ -753,7 +771,9 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a
if( is_array($value) ){
$other_input_value = isset($value['other_input']) ? $value['other_input']:"";
+ $other_input_value = htmlspecialchars($other_input_value);
}else{
+ $value = htmlspecialchars($value);
$other_input_value = $value;
}
@@ -773,8 +793,11 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a
# INPUT
$unitText = isset($field['unitText']) ? $field['unitText'] : array();
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$upto = isset( $values[$key.'_upto'] ) ? esc_attr( $values[$key.'_upto'][0] ) : '';
+ $upto = htmlspecialchars($upto);
$unittext_value = isset( $values[$key.'_unittext'] ) ? esc_attr( $values[$key.'_unittext'][0] ) : '';
+ $unittext_value = htmlspecialchars($unittext_value);
$currency_before = '';
$currency_after = '';
@@ -836,6 +859,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a
}else{
+ $value = htmlspecialchars($value);
echo $currency_before;
echo ' ';
echo $currency_after;
@@ -868,6 +892,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-custom-title';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Custom title', 'jobs-field', 'job-postings');
@@ -881,6 +906,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-hide-title';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Hide title', 'jobs-field', 'job-postings');
@@ -896,6 +922,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-hide-field';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Hide field', 'jobs-field', 'job-postings');
@@ -913,6 +940,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-field-tag-title';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Heading HTML Tag', 'jobs-field', 'job-postings');
@@ -933,6 +961,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-field-tag';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Content HTML Tag', 'jobs-field', 'job-postings');
@@ -953,6 +982,7 @@ public static function renderFieldSettings( $post_id, $key ){
//
$name = $key.'-field-class';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Custom CSS class', 'jobs-field', 'job-postings');
@@ -966,6 +996,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-url';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('URL', 'jobs-field', 'job-postings');
@@ -977,6 +1008,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-url-target';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Link target', 'jobs-field', 'job-postings');
@@ -991,6 +1023,7 @@ public static function renderFieldSettings( $post_id, $key ){
$name = $key.'-style';
$value = get_post_meta($post_id, $name, true);
+ $value = htmlspecialchars($value);
$out .= '';
$out .= _x('Style', 'jobs-field', 'job-postings');
@@ -1349,7 +1382,7 @@ public static function getDatalist( $key ){
if( !empty($rows) ){
$out .= '';
foreach ($rows as $key => $row) {
- $out .= ' ';
+ $out .= ' ';
}
$out .= ' ';
return $out;
diff --git a/include/class-job-application-submit.php b/include/class-job-application-submit.php
index 469fb0d..cadce21 100644
--- a/include/class-job-application-submit.php
+++ b/include/class-job-application-submit.php
@@ -14,7 +14,7 @@ public static function init(){
public static function ajax_submit(){
- $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
+ $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$posted_data = isset( $_POST ) ? $_POST : array();
$file_data = isset( $_FILES ) ? $_FILES : array();
@@ -33,6 +33,49 @@ public static function ajax_submit(){
$site_key = get_option( 'jobs_recaptcha_site_key' );
$secret_key = get_option( 'jobs_recaptcha_secret_key' );
$re_type = get_option( 'jobs_recaptcha_type' );
+ $apply_advanced = get_option( 'jobs_apply_advanced' );
+
+ if( isset( $file_data ) ){
+ $chosenFileType = [];
+ foreach( $file_data as $file ){
+ $extension = substr($file['name'], strrpos($file['name'], '.') + 1);
+ $chosenFileType[] = $extension;
+ }
+
+ if( isset($chosenFileType) ){
+ $chosenFileType = array_unique($chosenFileType);
+ }
+
+ $collectAcceptedFiles = array_map(function( $param ){
+ $setVal = '';
+ if( !empty($param['multi_files_accepted']) ){
+ $setVal = $param['multi_files_accepted'];
+ }
+
+ if( !empty($param['files_accepted']) ){
+ $setVal = $param['files_accepted'];
+ }
+
+ return $setVal;
+
+ }, $apply_advanced['modal']);
+
+ // Use array_filter to remove indexes with empty 'multi_files_accepted' values
+ $filteredData = array_filter($collectAcceptedFiles, function ($item) {
+ return !empty($item);
+ });
+
+
+ if( isset($filteredData) || !empty($filteredData) ){
+ $accepted_types = implode(", ", $filteredData);
+ foreach( $chosenFileType as $type ){
+ if( strpos($accepted_types, $type) === false ){
+ echo json_encode( array('status' => 'error', 'messages' => array('Not_valid_file_type') ) );
+ die();
+ }
+ }
+ }
+ }
if( $site_key && $secret_key) {
$data = array(
@@ -52,9 +95,6 @@ public static function ajax_submit(){
$captcha_success = json_decode($verify_response);
if ( $captcha_success && $captcha_success->success == false ) {
- //This user was not verified by recaptcha.
- //echo 'recaptcha_not_valid';
- //echo json_encode(array('status' => 'recaptcha_not_valid'));
echo json_encode( array('status' => 'error', 'messages' => array('recaptcha_not_valid') ) );
die();
}
@@ -64,7 +104,7 @@ public static function ajax_submit(){
$pre_post_id = strip_tags($_POST['post_id']);
$post_id = sanitize_title($pre_post_id);
- $current_language = strip_tags($_POST['language']);
+ $current_language = isset($_POST['language']) ? strip_tags($_POST['language']) : 'en';
$current_language = sanitize_title($current_language);
if ( in_array( 'sitepress-multilingual-cms/sitepress.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
@@ -85,7 +125,6 @@ public static function ajax_submit(){
);
- $apply_advanced = get_option( 'jobs_apply_advanced' );
$file_storage = get_option( 'jobs_file_storage' );
$disable_notification = apply_filters('job-entry/notification', false);
@@ -355,9 +394,10 @@ public static function ajax_submit(){
$response[$key]['type'] = $type;
$response[$key]['attachment_id'] = $attachment_id;
$response[$key]['post_id'] = $post_id;
- $response[$key]['label'] = $label;
- $lbl = $labels[$key];
+ $lbl = isset($labels[$key]) ? $labels[$key] : '';
+
+ $response[$key]['label'] = $lbl;
if( strpos($key, 'file_multi') !== false ){
$trimmed_key = preg_replace("/\d+$/","",$key);
@@ -366,7 +406,7 @@ public static function ajax_submit(){
}
$url = esc_url_raw($url);
- $entry_data = array('label' => $lbl, 'value' => $url);
+ $entry_data = array('label' => $lbl, 'value' => $url, 'path' => $fullsize_path);
switch ($file_storage) {
case 'media':
@@ -473,7 +513,7 @@ public static function ajax_submit(){
$response[$key]['post_id'] = $post_id;
$url = esc_url_raw($url);
- $entry_data = array('label' => 'Attachment', 'value' => $url);
+ $entry_data = array('label' => 'Attachment', 'value' => $url, 'path' => $fullsize_path);
switch ($file_storage) {
case 'media':
diff --git a/include/class-job-apply-form.php b/include/class-job-apply-form.php
index c1ff217..e9be7e5 100644
--- a/include/class-job-apply-form.php
+++ b/include/class-job-apply-form.php
@@ -26,6 +26,8 @@ public static function get_apply_form( $inline = false, $custom_title = '', $nam
$post_id = $post->ID;
}
+ $name = htmlspecialchars($name);
+ $custom_title = htmlspecialchars($custom_title);
//add_action('job-postings/front_enqueue_scripts', array('JobDependencies', 'reCaptchaScripts'));
$out = '';
@@ -33,6 +35,7 @@ public static function get_apply_form( $inline = false, $custom_title = '', $nam
$apply_advanced = get_option( 'jobs_apply_advanced' );
$confirmation = get_post_meta( $post_id, 'job_notification_message', true );
$postition_title = apply_filters('jp-modal-position-title', get_post_meta($post_id, 'position_title', true));
+ $postition_title = htmlspecialchars($postition_title);
$close_img = apply_filters('jp-modal-close-image', ' ');
@@ -48,12 +51,12 @@ public static function get_apply_form( $inline = false, $custom_title = '', $nam
$out .= ' ';
@@ -341,7 +344,7 @@ public static function get_modal_input( $options = array() ){
$out .= '
';
$out .= ' ';
- $out .= ''.$option.' ';
+ $out .= ''.htmlspecialchars_decode($option).' ';
$out .= ' ';
$k++;
}
@@ -475,8 +478,9 @@ public static function get_modal_input( $options = array() ){
case 'section':
$out .= '
';
if($label){
+
$out .= '
';
- $out .= $label;
+ $out .= htmlspecialchars_decode($label);
$out .= '
';
}
$out .= '
';
diff --git a/include/class-job-dependencies.php b/include/class-job-dependencies.php
index 083b521..aebfe1d 100644
--- a/include/class-job-dependencies.php
+++ b/include/class-job-dependencies.php
@@ -105,6 +105,7 @@ public static function front_enqueue_scripts(){
$localized['Not_valid_phone_number'] = __('Not valid phone number', 'job-postings');
$localized['Not_valid_email'] = __('Not valid email', 'job-postings');
$localized['Error_sending_notification'] = __('Error sending notification message, but dont worry, We saved Your data securelly. Thank you.', 'job-postings');
+ $localized['Not_valid_file_type'] = __('Not a valid file-type selected', 'job-postings');
$filesize_placeholder = __('File %2$s exceeds the allowed file size of %1$s MB.', 'job-postings');
$filesize_exceeded = get_option( 'jobs_filesize_validation_'.Job_Postings::$lang );
$filesize_exceeded = $filesize_exceeded ? $filesize_exceeded : $filesize_placeholder;
diff --git a/include/class-job-notifications.php b/include/class-job-notifications.php
index 01947ac..b1227b7 100644
--- a/include/class-job-notifications.php
+++ b/include/class-job-notifications.php
@@ -51,14 +51,21 @@ public static function sendEntryEmail( $job_id, $entry_id ) {
if( $post_meta ){
foreach ($post_meta as $key => $meta) {
+ $meta = isset($meta[0]) ? $meta[0] : $meta;
//$value = get_post_meta($entry_id, $key, true);
- $meta = unserialize($meta[0]);
- if( Job_Postings_Helper::is_serialized($meta) ) $meta = unserialize($meta);
+ //$meta = unserialize($meta[0]);
+
+ if( Job_Postings_Helper::is_serialized($meta) )
+ $meta = unserialize($meta);
+
+ if( Job_Postings_Helper::is_serialized($meta) )
+ $meta = unserialize($meta);
+
if( $meta ){
- $label = $meta['label'];
- $value = $meta['value'];
+ $label = isset($meta['label']) ? $meta['label'] : '';
+ $value = isset($meta['value']) ? $meta['value'] : '';
if( strpos($key, 'jobs_attachment_') !== false ){
// Add files to attachments
@@ -90,12 +97,12 @@ public static function sendEntryEmail( $job_id, $entry_id ) {
//if( $contact_email == '' ) $contact_email = $admin_email;
}
-
+ //var_dump( $attachments );
+ //die();
+
// Legacy support
$dep_contact_email = isset($post_meta['job_email']) ? $post_meta['job_email'][0] : '';
$letter = isset($post_meta['jobs_attachment_input_job_letter']) ? unserialize($post_meta['jobs_attachment_input_job_letter'][0]) : '';
-
-
if( $dep_contact_email || $letter ){
$name = isset($post_meta['job_fullname']) ? $post_meta['job_fullname'][0] : 'Applicant';
@@ -106,9 +113,23 @@ public static function sendEntryEmail( $job_id, $entry_id ) {
}
foreach ($post_meta as $key => $field) {
if( strpos($key, 'jobs_attachment_input_job_cv') !== false ){
- if( Job_Postings_Helper::is_serialized($field[0]) ) $field = unserialize($field[0]);
- $filepath = Job_Postings_Helper::getFilePath( $field['value'] );
- $attachments[] = $filepath;
+ $field = isset($field[0]) ? $field[0] : $field;
+ if( Job_Postings_Helper::is_serialized($field) ) $field = unserialize($field);
+ if( Job_Postings_Helper::is_serialized($field) ) $field = unserialize($field);
+ //var_dump( $field );
+ switch ($file_storage) {
+ case 'media':
+ $filepath = Job_Postings_Helper::getFilePath( $field );
+ $attachments[] = $filepath;
+ break;
+
+ default:
+ $filepath = $field['path'];
+ $attachments[] = $filepath;
+ break;
+ }
+ //$filepath = Job_Postings_Helper::getFilePath( $field['value'] );
+ //$attachments[] = $filepath;
}
}
if( $contact_email == '' ) $contact_email = $dep_contact_email;
@@ -172,22 +193,24 @@ public static function convertMergeFields( $output, $job_id, $entry_id, $all_fie
$apply_advanced = get_option( 'jobs_apply_advanced' );
- if(!empty($apply_advanced['modal'])){
+ //if(!empty($apply_advanced['modal'])){
$merge_tags = array();
$merge_tags[] = '{all_fields}';
$merge_tags[] = '{position_title}';
- foreach ($apply_advanced['modal'] as $key => $field) {
- $field_type = isset($field['field_type']) ? $field['field_type'] : '';
- $label = isset($field['label_'.Job_Postings::$lang]) ? $field['label_'.Job_Postings::$lang] : '';
- $san_label = sanitize_title( $label );
- $field_key = $field_type . '_' . $san_label;
+ if(!empty($apply_advanced['modal'])){
+ foreach ($apply_advanced['modal'] as $key => $field) {
+ $field_type = isset($field['field_type']) ? $field['field_type'] : '';
+ $label = isset($field['label_'.Job_Postings::$lang]) ? $field['label_'.Job_Postings::$lang] : '';
+ $san_label = sanitize_title( $label );
+ $field_key = $field_type . '_' . $san_label;
- if( $field_type == 'name' ){
- $field_key = 'job_applicant_' . $field_type;
+ if( $field_type == 'name' ){
+ $field_key = 'job_applicant_' . $field_type;
+ }
+
+ $merge_tags[] = '{'.$field_key.'}';
}
-
- $merge_tags[] = '{'.$field_key.'}';
}
if( !empty($merge_tags) ){
@@ -209,6 +232,8 @@ public static function convertMergeFields( $output, $job_id, $entry_id, $all_fie
$tag_value = '';
$meta = get_post_meta($entry_id, $meta_key, true);
+ if( Job_Postings_Helper::is_serialized($meta) )
+ $meta = unserialize($meta);
if( Job_Postings_Helper::is_serialized($meta) )
$meta = unserialize($meta);
@@ -244,7 +269,7 @@ public static function convertMergeFields( $output, $job_id, $entry_id, $all_fie
}
}
}
- }
+ //}
return wpautop($output);
@@ -291,20 +316,20 @@ public static function getAllFields( $output, $job_id, $entry_id, $all_fields =
// die();
foreach ($post_meta as $key => $meta) {
-
+ //$meta = isset($meta[0]) ? $meta[0] : $meta;
$meta = get_post_meta($entry_id, $key, true);
if( Job_Postings_Helper::is_serialized($meta) )
$meta = unserialize($meta);
-
if( Job_Postings_Helper::is_serialized($meta) )
$meta = unserialize($meta);
if( $meta ){
- $label = $meta['label'];
- $value = $meta['value'];
+ $label = isset($meta['label']) ? $meta['label'] : '';
+ $value = isset($meta['value']) ? $meta['value'] : '';
+ if( !$label && !$value ) continue;
if( strpos($key, 'jobs_attachment_') !== false ){
// // Add files to attachments
diff --git a/include/class-job-settings.php b/include/class-job-settings.php
index f6eca71..2caf6d7 100644
--- a/include/class-job-settings.php
+++ b/include/class-job-settings.php
@@ -49,6 +49,7 @@ public static function register_settings() {
register_setting( 'jobs_options' , 'jobs_hide_letter_upload' );
register_setting( 'jobs_options' , 'jobs_hide_cv_upload' );
register_setting( 'jobs_options' , 'jobs_default_email' );
+ register_setting( 'jobs_options' , 'jobs_selected_schema' );
register_setting( 'jobs_options' , 'jobs_file_storage' );
register_setting( 'jobs_options' , 'jobs_max_filesize' );
diff --git a/include/class-job-single-view.php b/include/class-job-single-view.php
index 3705f46..131037a 100644
--- a/include/class-job-single-view.php
+++ b/include/class-job-single-view.php
@@ -109,6 +109,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$custom_title = isset( $values[$key.'-custom-title'] ) ? esc_attr($values[$key.'-custom-title'][0]) : '';
+ $custom_title = htmlspecialchars($custom_title);
if( $custom_title ) $name = sanitize_text_field( $custom_title );
$show_title = true;
@@ -136,6 +137,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="title"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['title'] = $value;
break;
@@ -143,6 +145,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="description"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['description'] = $value;
break;
@@ -150,6 +153,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="responsibilities"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['responsibilities'] = $value;
break;
@@ -157,6 +161,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="qualifications"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['qualifications'] = $value;
break;
@@ -164,6 +169,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="jobBenefits"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['jobBenefits'] = $value;
break;
@@ -171,6 +177,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="workHours"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['workHours'] = $value;
break;
@@ -178,8 +185,11 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="baseSalary"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$upto = isset( $values[$key.'_upto'] ) ? esc_attr( $values[$key.'_upto'][0] ) : '';
+ $upto = htmlspecialchars($upto);
$unittext_value = isset( $values[$key.'_unittext'] ) ? esc_attr( $values[$key.'_unittext'][0] ) : '';
+ $unittext_value = htmlspecialchars($unittext_value);
$baseSalary = Job_Postings_Helper::numbers_only($value);
if($upto) $upto = Job_Postings_Helper::numbers_only($upto);
@@ -224,6 +234,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="industry"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['industry'] = $value;
break;
@@ -233,6 +244,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
//$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
$value = get_post_meta( $post_id, $key, true );
$value = is_array($value) ? array_values($value) : $value;
+ if( $value && !is_array($value) ) $value = htmlspecialchars($value);
if( $value ) self::$json_ld['employmentType'] = $value;
break;
@@ -242,6 +254,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="educationRequirements"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['educationRequirements'] = $value;
break;
@@ -249,6 +262,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="experienceRequirements"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['experienceRequirements'] = $value;
break;
@@ -256,6 +270,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="skills"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) self::$json_ld['skills'] = $value;
break;
@@ -266,14 +281,22 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$city = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $city = htmlspecialchars($city);
$streetAddress = isset( $values[$key.'_streetAddress'] ) ? esc_attr( $values[$key.'_streetAddress'][0] ) : '';
+ $streetAddress = htmlspecialchars($streetAddress);
+
$postalCode = isset( $values[$key.'_postalCode'] ) ? esc_attr( $values[$key.'_postalCode'][0] ) : '';
+ $postalCode = htmlspecialchars($postalCode);
+
$addressLocality = (isset( $values[$key.'_addressLocality'] ) && $values[$key.'_addressLocality'][0] != '') ? esc_attr( $values[$key.'_addressLocality'][0] ) : '';
+ $addressLocality = htmlspecialchars($addressLocality);
$addressRegion = (isset( $values[$key.'_addressRegion'] ) && $values[$key.'_addressRegion'][0] != '') ? esc_attr( $values[$key.'_addressRegion'][0] ) : '';
+ $addressRegion = htmlspecialchars($addressRegion);
$addressCountry = (isset( $values[$key.'_addressCountry'] ) && $values[$key.'_addressCountry'][0] != '') ? esc_attr( $values[$key.'_addressCountry'][0] ) : '';
+ $addressCountry = htmlspecialchars($addressCountry);
$remote = isset( $values[$key.'_remote'] ) ? $values[$key.'_remote'][0] : '';
@@ -342,6 +365,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$meta = 'itemprop="validThrough"';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
if( $value ) {
$value = date('c', strtotime($value));
if($value) self::$json_ld['validThrough'] = $value;
@@ -354,6 +378,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$hiring_organization_logo = isset( $values[$key] ) && $values[$key][0] != '' ? esc_attr( $values[$key][0] ) : $company_logo;
$hiring_organization = isset( $values['position_hiring_organization_name'] ) && $values['position_hiring_organization_name'][0] != '' ? esc_attr( $values['position_hiring_organization_name'][0] ) : get_option('jobs_hiring_organization'.'_'.Job_Postings::$lang);
+ $hiring_organization = htmlspecialchars($hiring_organization);
if(!$hiring_organization) $hiring_organization = get_option('blogname');
if ( $hiring_organization ) {
@@ -429,6 +454,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
case 'textarea':
# INPUT
$value = isset( $values[$key] ) ? $values[$key][0] : '';
+ $value = htmlspecialchars_decode($value);
$icon = '';
if($key == 'position_work_hours'){
@@ -443,12 +469,20 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
# INPUT
$city = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $city = htmlspecialchars($city);
$streetAddress = isset( $values[$key.'_streetAddress'] ) ? esc_attr( $values[$key.'_streetAddress'][0] ) : '';
+ $streetAddress = htmlspecialchars($streetAddress);
+
$postalCode = isset( $values[$key.'_postalCode'] ) ? esc_attr( $values[$key.'_postalCode'][0] ) : '';
+ $postalCode = htmlspecialchars($postalCode);
+
// $addressLocality = (isset( $values[$key.'_addressLocality'] ) && $values[$key.'_addressLocality'][0] != '') ? esc_attr( $values[$key.'_addressLocality'][0] ) : '';
$addressRegion = (isset( $values[$key.'_addressRegion'] ) && $values[$key.'_addressRegion'][0] != '') ? esc_attr( $values[$key.'_addressRegion'][0] ) : '';
+ $addressRegion = htmlspecialchars($addressRegion);
+
$addressCountry = (isset( $values[$key.'_addressCountry'] ) && $values[$key.'_addressCountry'][0] != '') ? esc_attr( $values[$key.'_addressCountry'][0] ) : '';
+ $addressCountry = htmlspecialchars($addressCountry);
$remote = isset( $values[$key.'_remote'] ) ? $values[$key.'_remote'][0] : '';
@@ -525,6 +559,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
# INPUT
$value = isset( $values[$key] ) ? $values[$key][0] : '';
+ //$value = htmlspecialchars($value);
//$out .= apply_filters('the_content', $value);
$tinymce_content = wpautop($value);
@@ -542,7 +577,9 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
case 'file':
# INPUT
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$btn_name = isset( $values[$key.'_name'] ) ? esc_attr( $values[$key.'_name'][0] ) : '';
+ $btn_name = htmlspecialchars($btn_name);
$url = '';
$filename = $btn_name;
@@ -588,7 +625,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
if( is_array($value) && !empty($options) ){
foreach ($value as $vk => $value_key) {
if( isset($options[$value_key]) && $value_key != 'OTHER' ) {
- $list[] = $options[$value_key];
+ $list[] = htmlspecialchars($options[$value_key]);
}
}
if( isset($value['other_input']) ){
@@ -604,6 +641,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
default:
# INPUT
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$out .= $value;
break;
@@ -613,8 +651,11 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
if( $key == 'position_base_salary' ){
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$upto = isset( $values[$key.'_upto'] ) ? esc_attr( $values[$key.'_upto'][0] ) : '';
+ $upto = htmlspecialchars($upto);
$unittext_value = isset( $values[$key.'_unittext'] ) ? esc_attr( $values[$key.'_unittext'][0] ) : '';
+ $unittext_value = htmlspecialchars($unittext_value);
$unitText = isset($field['unitText']) ? $field['unitText'] : array();
if($currency_symbol){
@@ -754,6 +795,8 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
}
if( $key == 'position_pdf_export' ){
+
+ $value = htmlspecialchars($value);
$out .= '
';
$out .= '
';
if( $meta_2 ) $out .= '
';
@@ -785,9 +828,12 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
// JobSingleView::$inline_form_in = false;
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$offer_ended_enabled = get_option( 'jobs_offer_ended_message_enabled_'.Job_Postings::getLang() );
+ $offer_ended_enabled = htmlspecialchars($offer_ended_enabled);
$offer_ended_message = get_option( 'jobs_offer_ended_message_'.Job_Postings::getLang() );
+ $offer_ended_message = htmlspecialchars($offer_ended_message);
$offer_ended_message = $offer_ended_message ? sprintf($offer_ended_message, date_i18n(get_option('date_format'), strtotime($job_valid_date)) ) : sprintf(_x('Offer ended on %s', 'job-message', 'job-postings'), date_i18n(get_option('date_format'), strtotime($job_valid_date)) );
$out .= '';
@@ -812,6 +858,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
// JobSingleView::$modal_form_in = false;
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$offer_ended_enabled = get_option( 'jobs_offer_ended_message_enabled_'.Job_Postings::getLang() );
$offer_ended_message = get_option( 'jobs_offer_ended_message_'.Job_Postings::getLang() );
@@ -834,6 +881,7 @@ public static function get_job_fields( $post_id, $position = 'sort-left' ){
$url = isset( $values[$key.'-url'] ) ? esc_url( $values[$key.'-url'][0] ) : '';
$target = isset( $values[$key.'-url-target'] ) ? esc_attr( $values[$key.'-url-target'][0] ) : '_blank';
$value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : '';
+ $value = htmlspecialchars($value);
$out .= '
';
if( $show_title ){
@@ -906,13 +954,135 @@ public static function print_json_ld( $job_id ){
echo '';
}
-
public static function get_json_ld( $job_id ){
- $json_ld = apply_filters( 'job-postings/json_ld', self::$json_ld, $job_id );
+ $json_ld_keys = self::$json_ld;
+ $json_script = $json_ld_keys;
+
+ /**
+ * Adding multiple tags (e.g reponsibilities, qualifications, benefits) to description as whole
+ */
+ foreach( $json_script as $k => $v ){
+
+ if( $k == 'description' && !empty($v) ){
+ $current_description = $v;
+ $json_ld_keys = $json_script;
+ }
+
+ $values = get_post_custom( $job_id );
+ $prefix = $k;
+ $prefix = ( $prefix == "jobBenefits" ) ? "job_benefits" : $prefix;
+ $custom_title = isset( $values['position_'.$prefix.'-custom-title'] ) ? esc_attr($values['position_'.$prefix.'-custom-title'][0]) : '';
+ $custom_title = htmlspecialchars($custom_title);
+ if( $custom_title ) $name = sanitize_text_field( $custom_title );
+
+ $show_title = true;
+
+ if( $custom_title != '' )
+ $show_title = true;
+
+ if( empty($custom_title) )
+ $show_title = false;
+
+ if( isset( $values['position_'.$prefix.'-hide-title'] ) && $values['position_'.$prefix.'-hide-title'][0] == 'on' )
+ $show_title = false;
+
+ if( $k == 'responsibilities' ){
+ $title = ( $show_title ) ? '
'.$name.' ' : '';
+ $responsibilities_data = $title.$json_script['responsibilities'];
+ $json_script['description'] = $current_description . $responsibilities_data;
+ $current_description = $current_description . $responsibilities_data;
+ }
+
+ if( $k == 'qualifications' ){
+ $title = ( $show_title ) ? ''.$name.' ' : '';
+ $qualifications_data = $title.$json_script['qualifications'];
+ $json_script['description'] = $current_description . $qualifications_data;
+ $current_description = $current_description . $qualifications_data;
+ }
+
+ if( $k == 'jobBenefits' ){
+ $title = ( $show_title ) ? ''.$name.' ' : '';
+ $jobbenefits_data = $title.$json_script['jobBenefits'];
+ $json_script['description'] = $current_description . $jobbenefits_data;
+ $current_description = $current_description . $jobbenefits_data;
+ }
+ }
+
+ $json_ld = apply_filters( 'job-postings/json_ld', $json_script, $job_id );
return $json_ld;
}
-}
+ public static function print_json_ld_yoast($job_id){
+ $site_url = site_url();
+ $custom_slug = get_option('jobs_custom_slug_'.Job_Postings::$lang );
+ $slug = ( !empty($custom_slug) ) ? sanitize_key($custom_slug) : 'job';
+
+ $graph_id = $site_url."/".$slug.'#'."jobpost";
+
+ $yoast_script = [
+ "@context" => "http://schema.org",
+ "@graph" => [
+ "@id" => $graph_id
+ ]
+ ];
+
+ $json_ld_keys = self::$json_ld;
+ foreach( $json_ld_keys as $k => $v ){
+ $yoast_script['@graph'][$k] = $v;
+ if( $k == "hiringOrganization" ){
+ $org_slug = preg_replace('/\s+/', '_', $yoast_script['@graph'][$k]['name']);
+ $org_slug = strtolower($org_slug);
+ $yoast_script['@graph'][$k]['@id'] = site_url().'/#organization_'.$org_slug;
+ }
+
+ /**
+ * Added multiple tags (e.g reponsibilities, qualifications, benefits) to description as whole
+ */
+ if( isset($yoast_script['@graph']['description']) ){
+
+ $current_description = $yoast_script['@graph']['description'];
+ $values = get_post_custom( $job_id );
+ $prefix = $k;
+ $prefix = ( $prefix == "jobBenefits" ) ? "job_benefits" : $prefix;
+ $custom_title = isset( $values['position_'.$prefix.'-custom-title'] ) ? esc_attr($values['position_'.$prefix.'-custom-title'][0]) : '';
+ $custom_title = htmlspecialchars($custom_title);
+ if( $custom_title ) $name = sanitize_text_field( $custom_title );
+
+ $show_title = true;
+
+ if( $custom_title != '' )
+ $show_title = true;
+
+ if( empty($custom_title) )
+ $show_title = false;
+
+ if( isset( $values['position_'.$prefix.'-hide-title'] ) && $values['position_'.$prefix.'-hide-title'][0] == 'on' )
+ $show_title = false;
+
+ if( isset($yoast_script['@graph']['responsibilities']) && $k == "responsibilities" ){
+ $title = ( $show_title ) ? ''.$name.' ' : '';
+ $responsibilities_data = $title.$yoast_script['@graph']['responsibilities'];
+ $yoast_script['@graph']['description'] = $current_description . $responsibilities_data;
+ }
+
+ if( isset($yoast_script['@graph']['qualifications']) && $k == "qualifications" ){
+ $title = ( $show_title ) ? ''.$name.' ' : '';
+ $qualifications_data = $title.$yoast_script['@graph']['qualifications'];
+ $yoast_script['@graph']['description'] = $current_description . $qualifications_data;
+ }
+
+ if( isset($yoast_script['@graph']['jobBenefits']) && $k == "jobBenefits" ){
+ $title = ( $show_title ) ? ''.$name.' ' : '';
+ $jobbenefits_data = $title.$yoast_script['@graph']['jobBenefits'];
+ $yoast_script['@graph']['description'] = $current_description . $jobbenefits_data;
+ }
+ }
+ }
+
+ $json_ld = apply_filters( 'job-postings/json_ld_yoast', $yoast_script, $job_id );
+ echo '';
+ }
+}
function get_job_fields( $job_id = '' ){
//global $job_postings;
@@ -983,13 +1153,23 @@ function get_job_fields( $job_id = '' ){
echo JobSingleView::get_apply_modal_markup( $job_id );
// This must be at the end, as we combine it with 2 functions above
- echo JobSingleView::print_json_ld( $job_id );
+ $jobs_selected_schema = get_option( 'jobs_selected_schema' );
+ if( !$jobs_selected_schema || empty($jobs_selected_schema) || $jobs_selected_schema == "default" ){
+ echo JobSingleView::print_json_ld( $job_id );
+ }
+ else if( $jobs_selected_schema == "yoast_seo" && class_exists('WPSEO_Admin') ){
+ echo JobSingleView::print_json_ld_yoast( $job_id );
+ }
+ else{
+ echo JobSingleView::print_json_ld( $job_id );
+ }
+
+
echo '';
}
-
function jobs_list(){
echo JobList::do_job_list();
}
diff --git a/job-postings.php b/job-postings.php
index e327a6f..164fa92 100644
--- a/job-postings.php
+++ b/job-postings.php
@@ -4,8 +4,8 @@
Plugin URI: https://wordpress.org/plugins/job-postings/
Description: WordPress plugin that make it easy to add job postings to your company’s website in a structured way.
Author: BlueGlass
-Version: 2.5.10.2
-Author URI: http://blueglass.ee/en/
+Version: 2.7.1
+Author URI: http://blueglass.ch/
Text Domain: job-postings
Domain Path: /languages
*/
@@ -13,7 +13,7 @@
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
-define('JOBPOSTINGSVERSION', '2.5.10.2');
+define('JOBPOSTINGSVERSION', '2.7.1');
define('JOBPOSTINGSPATH', plugin_dir_path( __FILE__ ));
define('JOBPOSTINGSURL', plugin_dir_url(__FILE__));
define('JOBPOSTINGSFILESDIR', ABSPATH . '../jobs-dir/');
@@ -28,22 +28,10 @@ function job_postings_plugin_langs_init() {
}
add_action('init', 'job_postings_plugin_langs_init');
-
-include_once('include/class-bg-analytics.php');
-
//do analytics
+include_once('include/class-bg-analytics.php');
$BlueGlassAnalytics = new BG_Analytics();
-/*
-spl_autoload_register(function($className) {
- $className = str_replace("\\", DIRECTORY_SEPARATOR, $className);
- $file = JOBPOSTINGSPATH . 'include/class-' . $className . '.php';
- if( file_exists($file) ) include_once $file;
-});
-*/
-
-include_once('verify/class-jobs-module-verify.php');
-
include_once('include/class-job-security.php');
include_once('include/class-job-posting-helper.php');
diff --git a/js/script.js b/js/script.js
index 7e5e18f..5f67724 100644
--- a/js/script.js
+++ b/js/script.js
@@ -192,10 +192,11 @@ if( re_type != 'on' && site_key ){
if( $('.choose_file_multi_add').length ){
var i = 1;
+
$( document ).on( "click", ".choose_file_multi_add", function(e) {
//$('.choose_file_multi_add').click(function(e){
- e.preventDefault();
-
+ //e.preventDefault();
+
var key_id = $(this).data('key');
var parent = $(this).parents('.modal-input-fileinput');
@@ -205,28 +206,45 @@ if( re_type != 'on' && site_key ){
var id = key_id + '-'+i;
var key = key_id + '-key-'+i;
+
input = input.replace( '{id}', id ).replace( '{id}', id ).replace( '{id}', id );
input = input.replace( '{nr}', i ).replace( '{nr}', i ).replace( '{nr}', i );
input = input.replace( '{key}', key ).replace( '{key}', key ).replace( '{key}', key );
label = label.replace( '{id}', id ).replace( '{id}', id ).replace( '{id}', id );
+
$(input).insertBefore( $('#'+key_id+' .choose_file_multi_add') );
$(label).insertBefore( $('#'+key_id+' .choose_file_multi_add') );
- //parent.prepend( input );
- //parent.prepend( label );
+
+ var accept_msg = parent.find('.message').text();
+ var accept = parent.find('input[type=file]').attr('accept');
+
+ accept = accept ? accept.split(','):'';
+
$( document ).on( "change", '#'+id, function(e) {
//$('#'+id).change(function(e){
var fileName = '';
-
+
validateSize(this, e, true);
if( this.files && this.files.length > 1 )
fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length );
+
else
fileName = e.target.value.split( '\\' ).pop();
+
+ var ext = true;
+ if(accept) ext = validateFileExt( this, fileName, accept, accept_msg);
+
+ if( ext == false ) {
+ $('#'+id).remove();
+ $('#file-input-tpl-'+id).remove();
+ $('#label-'+id).remove();
+ return false;
+ }
if( fileName ){
$('#label-'+id).find('span.name').text( fileName );
@@ -234,6 +252,7 @@ if( re_type != 'on' && site_key ){
num = Number(num) + 1;
$(this).parents('.modal-input-fileinput').attr('data-files', num);
}
+
});
@@ -254,10 +273,23 @@ if( re_type != 'on' && site_key ){
return false;
});
+
$('#'+id).click();
recalculateInputs();
+ $( document ).on( "mousemove", function(e) {
+ setTimeout(function(){
+ var current_obj = $('#' + id)[0];
+ if( ! current_obj.value ){
+ $('#label-'+id).find('.remove').trigger('click');
+ }
+ }, 300);
+
+ return false;
+
+ } );
+
i++;
});
}
@@ -412,7 +444,7 @@ if( re_type != 'on' && site_key ){
case 'error':
var messages = data.messages
-
+ console.log(data);
if( $.isArray(messages) ){
$(messages).each(function(i){
diff --git a/readme.txt b/readme.txt
index 0dc6cff..be968a3 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,9 +1,9 @@
=== Jobs for WordPress ===
Contributors: blueglassinteractive, cfoellmann
Tags: jobs, work, google, job, recruiter, structured data, json-ld, microdata, postings, employment, career, vacancy, hr, recruitment
-Requires at least: 4.3
-Tested up to: 5.9
-Stable tag: 2.5.10.2
+Requires at least: 5.0
+Tested up to: 6.4
+Stable tag: 2.7.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -40,6 +40,29 @@ Jobs for WordPress is a powerfull WordPress plugin that make it easy to add job
== Changelog ==
+= 2.7.1 =
+* Minor Fixes
+
+= 2.7.0 =
+* Fixed a security issue concerning upload of files
+* Removed deprecated FILTER_SANITIZE_STRING
+* Improved the compatibility with Yoast SEO
+* Optimized the Job Postings for Google Jobs
+
+= 2.6.2 =
+* Minor fixes
+
+= 2.6.0 =
+* Fixed XSS vulnerability (Medium severity)
+
+= 2.5.11.2 =
+* Bug fix: Email attachments
+* Other minor fixes
+
+= 2.5.11 =
+* Fixed XSS vulnerability (Medium severity)
+* Other minor fixes
+
= 2.5.10.2 =
* Large file validation and submittion fix
diff --git a/verify/class-jobs-module-verify.php b/verify/class-jobs-module-verify.php
deleted file mode 100644
index 62c30da..0000000
--- a/verify/class-jobs-module-verify.php
+++ /dev/null
@@ -1,166 +0,0 @@
-= self::$cache_time ){
- // $response = self::recheck_validation();
- // }
-
- return $response;
- }
-
- public static function revalidate( $new_key ){
-
- //delete_transient( self::$transient_key );
-
- $response = self::recheck_validation( $new_key );
- if($response) set_transient( self::$transient_key, $response, self::$cache_time );
- return $response;
- }
-
- public static function recheck_validation( $purchase_code = '' ){
- if(!$purchase_code) {
- $purchase_code = get_option( self::$transient_key );
- }
-
- if( $purchase_code ){
-
- $domain = $_SERVER['HTTP_HOST'];
-
- $body = array(
- "purchase_key" => $purchase_code,
- "plugin" => self::$plugin,
- "domain" => $domain
- );
-
- $response = wp_remote_post( self::$url . '/verify/?key='.self::$api_key, array(
- 'method' => 'POST',
- 'body' => json_encode($body)
- )
- );
-
- $response = json_decode( wp_remote_retrieve_body( $response ), true );
-
-
- if( isset($response['response']['buyer']) && strip_tags($response['response']['buyer']) != '' ){
-
- $response['response']['time'] = time();
- //print_r($response);
-
- update_option( self::$transient_key.'-response', $response['response'] );
-
- // Save valid transient
- //delete_transient( self::$transient_key );
- //set_transient( self::$transient_key, true, self::$cache_time );
-
- return true;
- }else{
-
- delete_option( self::$transient_key.'-response' );
- delete_option( self::$transient_key );
-
- $errors = array();
- switch($response['response']){
-
- case 'wrong_key':
- $errors[] = __('Purchase code is from other product. Please check and try again with correct one.', 'job-postings');
- break;
-
- case 'invalid_purchase_code':
- case 'not_valid':
- $errors[] = __('Not valid purchase code provided. Please check and try again.', 'job-postings');
- break;
- }
-
- //print_r($errors);
- if(!empty($errors)) update_option(self::$transient_key.'-errors', $errors);
-
- }
- }
-
- // Save not valid transient
- //delete_transient( self::$transient_key );
- //set_transient( self::$transient_key, false, self::$cache_time );
- return false;
- }
-
-
- public static function deactivate_validation(){
- $purchase_code = get_option( self::$transient_key );
-
- if( $purchase_code ){
-
- $domain = $_SERVER['HTTP_HOST'];
-
- $body = array(
- "purchase_key" => $purchase_code,
- "plugin" => self::$plugin,
- "domain" => $domain
- );
-
- $response = wp_remote_post( self::$url . '/deactivate/?key='.self::$api_key, array(
- 'method' => 'POST',
- 'body' => $body
- )
- );
-
- if( isset($response['response']['buyer']) && strip_tags($response['response']['buyer']) != '' ){
-
- delete_option( self::$transient_key.'-response' );
- delete_option( self::$transient_key );
- return true;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
-
- public static function get_messages(){
- $errors = get_option(self::$transient_key.'-errors');
- if(!empty($errors)){
- $out = '
';
- foreach ($errors as $msg) {
- $out .= ''.$msg.' ';
- }
- $out .= ' ';
-
- delete_option( self::$transient_key.'-errors' );
- return $out;
- }
- }
-}
\ No newline at end of file