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 @@
- - -

Jobs for WordPress Analytics (Status: )

- - ' . __( 'I agree to share anonymous data', 'job-posting' ) . ''; - }else{ - echo '' . __( 'Stop sharing', 'job-posting' ) . ''; - } - ?> -

-
-

-

-
- -

@@ -282,11 +247,7 @@
- Plugin developed by Blueglass - - Load WooCommerce Stores in 249ms! - - Load WordPress Sites in as fast as 37ms! + Plugin developed by Blueglass
diff --git a/admin/settings.php b/admin/settings.php index fec5692..f157827 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -192,7 +192,7 @@ '; @@ -206,7 +206,7 @@ '; @@ -220,7 +220,7 @@ @@ -239,7 +239,7 @@ '; @@ -254,7 +254,7 @@ @@ -291,7 +291,7 @@ '; @@ -306,7 +306,7 @@ '; @@ -321,7 +321,7 @@ $language) { $val = isset($options['modal'][$key]['placeholder_'.$lang]) ? $options['modal'][$key]['placeholder_'.$lang] : ''; echo ''; - echo ''; + echo ''; } } ?>
@@ -510,12 +510,12 @@ $val = isset($options['modal'][$key]['check_options_'.$lang]) ? $options['modal'][$key]['check_options_'.$lang]:''; echo ''; - echo ''; + echo ''; // preselection $val = isset($options['modal'][$key]['check_preselected_'.$lang]) ? $options['modal'][$key]['check_preselected_'.$lang]:''; echo ''; - echo ''; + echo ''; echo ''; } @@ -537,12 +537,12 @@ $val = isset($options['modal'][$key]['radio_options_'.$lang]) ? $options['modal'][$key]['radio_options_'.$lang]:''; echo ''; - echo ''; + echo ''; // preselection $val = isset($options['modal'][$key]['radio_preselected_'.$lang]) ? $options['modal'][$key]['radio_preselected_'.$lang]:''; echo ''; - echo ''; + echo ''; echo ''; } @@ -564,12 +564,12 @@ $val = isset($options['modal'][$key]['select_options_'.$lang]) ? $options['modal'][$key]['select_options_'.$lang]:''; echo ''; - echo ''; + echo ''; // preselection $val = isset($options['modal'][$key]['select_preselected_'.$lang]) ? $options['modal'][$key]['select_preselected_'.$lang]:''; echo ''; - echo ''; + echo ''; echo ''; } @@ -603,7 +603,7 @@ // preselection $val = isset($options['modal'][$key]['files_accepted']) ? $options['modal'][$key]['files_accepted'] : ''; echo ''; - echo ''; + echo ''; echo ''; @@ -626,7 +626,7 @@ // preselection $val = isset($options['modal'][$key]['multi_files_accepted_message_'.$lang]) ? $options['modal'][$key]['multi_files_accepted_message_'.$lang] : ''; echo ''; - echo ''; + echo ''; echo ''; } @@ -639,7 +639,7 @@ // preselection $val = isset($options['modal'][$key]['multi_files_accepted']) ? $options['modal'][$key]['multi_files_accepted'] : ''; echo ''; - echo ''; + echo ''; echo ''; @@ -1237,6 +1237,27 @@ +
+ +
+ '; + echo ''; + if( !class_exists('WPSEO_Admin') ){ + $disabled = "disabled"; + } + echo ''; + + echo ''; + + echo '

'.__("If your site uses Yoast SEO, the structured SEO Schema will follow Yoast's recommendations. Choose 'Default' if you are not sure.", 'job-postings').'

'; + ?> +
+
+

@@ -1388,11 +1409,8 @@
- Plugin developed by Blueglass - - Load WordPress Sites in as fast as 37ms! + Plugin developed by Blueglass - Load WooCommerce Stores in 249ms!
diff --git a/class-job-postings.php b/class-job-postings.php index 883d75d..896a21a 100644 --- a/class-job-postings.php +++ b/class-job-postings.php @@ -64,9 +64,36 @@ public static function load() { add_action( 'nav_menu_css_class', array('Job_Postings', 'add_current_nav_class'), 10, 2 ); - add_action( 'wp_ajax_jobs_metrics_notice_seen', array('Job_Postings', 'jobs_metrics_notice_seen') ); + //add_action( 'wp_ajax_jobs_metrics_notice_seen', array('Job_Postings', 'jobs_metrics_notice_seen') ); add_action( 'wp_ajax_jobs_metrics_attachemnt_notice_seen', array('Job_Postings', 'jobs_metrics_attachemnt_notice_seen') ); - + + $jobs_selected_schema = get_option( 'jobs_selected_schema' ); + if( !$jobs_selected_schema || empty($jobs_selected_schema) || $jobs_selected_schema == "default" ){ + add_filter( 'wpseo_json_ld_output', array('Job_Postings','jp_disable_yoast_seo_schema'), 10, 1 ); + } + else if( $jobs_selected_schema == "yoast_seo" && is_singular( 'jobs' ) ){ + add_filter( 'job-postings/disable_json_ld', array('Job_Postings', 'jp_disable_job_postings_schema') ); + add_filter( 'wpseo_json_ld_output', array('Job_Postings','jp_disable_yoast_seo_schema'), 10, 1 ); + } + + add_action('deactivated_plugin', array('Job_Postings', 'set_deafult_on_yoast_deactivation') ); + + } + + public static function jp_disable_yoast_seo_schema($data){ + $data = []; + return $data; + } + + public static function jp_disable_job_postings_schema(){ + return true; + } + + public static function set_deafult_on_yoast_deactivation($plugin) { + // Check if Yoast SEO plugin is deactivated + if ($plugin === 'wordpress-seo/wp-seo.php') { + update_option( 'jobs_selected_schema', 'default' ); + } } public static function init_current_language(){ @@ -473,7 +500,7 @@ public static function jobs_metrics_notice_seen(){ } public static function jobs_metrics_attachemnt_notice_seen(){ - update_option('jobs_file_location_notice_seen', 'seen'); + update_option('jobs_file_location_notice_seen_v2', 'seen'); echo 'ok'; exit(); } diff --git a/css/style.css b/css/style.css index 09a4c0b..34ba146 100644 --- a/css/style.css +++ b/css/style.css @@ -460,11 +460,13 @@ body.single-jobs .wrap{ } -.jobs-modal-form h3{ +.jobs-modal-form .modal-title-small{ margin: 0 0 10px; + font-weight: bold; } -.jobs-modal-form h4{ +.jobs-modal-form .modal-title{ + font-size: 20px; margin: 0 0 30px; padding: 0; font-weight: bold; diff --git a/images/backend-settings-banner.png b/images/backend-settings-banner.png new file mode 100644 index 0000000..8f597dd Binary files /dev/null and b/images/backend-settings-banner.png differ diff --git a/include/class-bg-analytics.php b/include/class-bg-analytics.php index 54cfbf8..6c89357 100644 --- a/include/class-bg-analytics.php +++ b/include/class-bg-analytics.php @@ -19,22 +19,22 @@ class BG_Analytics{ function __construct() { - $this->metrics_notice_seen = get_option('jobs_metrics_notice_seen_v2'); + //$this->metrics_notice_seen = get_option('jobs_metrics_notice_seen_v2'); $this->metrics_shareable = get_option('jobs_metrics_shareable'); - $this->file_location_notice_seen = get_option('jobs_file_location_notice_seen'); + $this->file_location_notice_seen = get_option('jobs_file_location_notice_seen_v2'); - //var_dump($this->metrics_notice_seen); - - if( !$this->metrics_notice_seen ) - add_action( 'admin_notices', array($this, 'maybe_display_notice') ); + // if( !$this->metrics_notice_seen ) + // add_action( 'admin_notices', array($this, 'maybe_display_notice') ); if( !$this->file_location_notice_seen ) add_action( 'admin_notices', array($this, 'maybe_display_files_notice') ); - if( $this->send_analytics_data() ){ - $this->track_metrics(); - } + + // !!! TRACKING DEPRICATED !!! + // if( $this->send_analytics_data() ){ + // $this->track_metrics(); + // } //$this->track_metrics(); } diff --git a/include/class-job-add-edit.php b/include/class-job-add-edit.php index ef7dd35..2e0918a 100644 --- a/include/class-job-add-edit.php +++ b/include/class-job-add-edit.php @@ -410,6 +410,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a $global_company_logo = get_option('jobs_company_logo'); $global_hiring_organization = get_option('jobs_hiring_organization'.'_'.Job_Postings::$lang); + $global_hiring_organization = htmlspecialchars($global_hiring_organization); $horg_placeholder = ''; if( $global_hiring_organization != '' ) $horg_placeholder = 'Global: '. $global_hiring_organization; @@ -420,6 +421,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a $single_company_logo = isset( $values[$key] ) && $values[$key][0] != '' ? esc_attr( $values[$key][0] ) : ''; $hiring_organization = isset( $values['position_hiring_organization_name'] ) && $values['position_hiring_organization_name'][0] != '' ? esc_attr( $values['position_hiring_organization_name'][0] ) : ''; + $hiring_organization = htmlspecialchars($hiring_organization); //if(!$hiring_organization) $hiring_organization = get_option('blogname'); // if( $single_company_logo ){ @@ -506,6 +508,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a # INPUT $value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : ''; + $value = htmlspecialchars($value); $pdf_ico = ''; @@ -516,6 +519,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a # INPUT $value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : $name; + $value = htmlspecialchars($value); echo ''; //echo '

'.$placeholder.'

'; @@ -525,6 +529,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a # INPUT $value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : $name; + $value = htmlspecialchars($value); //echo ''; //echo '

'.$placeholder.'

'; @@ -534,6 +539,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a # INPUT $value = isset( $values[$key] ) ? strip_tags( $values[$key][0] ) : $name; + $value = htmlspecialchars($value); $style = isset( $values[$key.'-style'] ) ? esc_attr( $values[$key.'-style'][0] ) : 'primary-style'; echo ''; @@ -544,6 +550,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a # INPUT $value = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : ''; + $value = htmlspecialchars($value); echo ''; //echo '

'.$placeholder.'

'; @@ -553,6 +560,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a case 'textarea': # INPUT $value = isset( $values[$key] ) ? $values[$key][0] : ''; + $value = htmlspecialchars($value); echo ''; break; @@ -587,14 +595,17 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a echo JobAddEdit::getDatalist( $key . '_addressRegion' ); $streetAddress = isset( $values[$key.'_streetAddress'] ) ? esc_attr( $values[$key.'_streetAddress'][0] ) : ''; + $streetAddress = htmlspecialchars($streetAddress); echo ''; $postalCode = isset( $values[$key.'_postalCode'] ) ? esc_attr( $values[$key.'_postalCode'][0] ) : ''; + $postalCode = htmlspecialchars($postalCode); echo ''; $city = isset( $values[$key] ) ? esc_attr( $values[$key][0] ) : ''; + $city = htmlspecialchars($city); echo ''; @@ -603,9 +614,11 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a $addressRegion = isset( $values[$key.'_addressRegion'] ) ? esc_attr( $values[$key.'_addressRegion'][0] ) : ''; + $addressRegion = htmlspecialchars($addressRegion); echo ''; $addressCountry = isset( $values[$key.'_addressCountry'] ) ? esc_attr( $values[$key.'_addressCountry'][0] ) : ''; + $addressCountry = htmlspecialchars($addressCountry); echo ''; echo ''; @@ -631,6 +644,7 @@ public static function renderFields( $fields, $post, $position = 'sort-left', $a echo '
'; $val = isset($job_remote_data[$key]['type']) ? $job_remote_data[$key]['type'] : ''; + $val = htmlspecialchars($val); echo ''; echo ''; $val2 = isset($job_remote_data[$key]['name']) ? $job_remote_data[$key]['name'] : ''; + $val2 = htmlspecialchars($val2); echo ''; 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 '
'; @@ -341,7 +344,7 @@ public static function get_modal_input( $options = array() ){ $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