Plugin Directory

Changeset 3246395


Ignore:
Timestamp:
02/25/2025 11:22:08 AM (13 months ago)
Author:
recruitly
Message:

Fix issue with multiple sectors in taxonomies.

Location:
recruitly/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • recruitly/trunk/admin/dataloader.php

    r3246334 r3246395  
    104104    ));
    105105
    106     $sector_id = recruitly_get_taxonomy_id($job->sector, 'jobsector');
    107106    $job_type_id = recruitly_get_taxonomy_id($job->jobType, 'jobtype');
    108107
     
    262261    }
    263262
     263    $sector_ids = [];
     264
     265    try {
     266        if (isset($job->sector) && !empty($job->sector)) {
     267            $sectors = array_map('trim', explode(',', $job->sector)); // Split CSV string into array
     268            foreach ($sectors as $sector) {
     269                try {
     270                    $sector_id = recruitly_get_taxonomy_id($sector, 'jobsector');
     271                    if (!empty($sector_id)) {
     272                        $sector_ids[] = $sector_id; // Collect valid term IDs
     273                    }
     274                } catch (Throwable $ex) {
     275                    echo esc_html($ex->getMessage());
     276                }
     277            }
     278        }
     279    } catch (Throwable $ex) {
     280        echo esc_html($ex->getMessage());
     281    }
     282
     283    if (!empty($sector_ids)) {
     284        wp_set_post_terms($post_id, $sector_ids, 'jobsector', false);
     285    }
     286
    264287    if (!empty($industry_ids)) {
    265288        wp_set_post_terms($post_id, $industry_ids, 'jobindustry', false);
     
    280303    if (!empty($job_type_id)) {
    281304        wp_set_post_terms($post_id, array($job_type_id), 'jobtype', false);
    282     }
    283 
    284     if (!empty($sector_id)) {
    285         wp_set_post_terms($post_id, array($sector_id), 'jobsector', false);
    286305    }
    287306
     
    331350    ));
    332351
    333     $sector_id = recruitly_get_taxonomy_id($job->sector, 'jobsector');
    334352    $job_type_id = recruitly_get_taxonomy_id($job->jobType, 'jobtype');
    335353
     
    519537    }
    520538
     539    $sector_ids = [];
     540
     541    try {
     542        if (isset($job->sector) && !empty($job->sector)) {
     543            $sectors = array_map('trim', explode(',', $job->sector)); // Split CSV string into array
     544            foreach ($sectors as $sector) {
     545                try {
     546                    $sector_id = recruitly_get_taxonomy_id($sector, 'jobsector');
     547                    if (!empty($sector_id)) {
     548                        $sector_ids[] = $sector_id; // Collect valid term IDs
     549                    }
     550                } catch (Throwable $ex) {
     551                    echo esc_html($ex->getMessage());
     552                }
     553            }
     554        }
     555    } catch (Throwable $ex) {
     556        echo esc_html($ex->getMessage());
     557    }
     558
     559    if (!empty($sector_ids)) {
     560        wp_set_post_terms($post_id, $sector_ids, 'jobsector', false);
     561    }else {
     562        wp_set_post_terms($post_id, [], 'jobsector', false); // Clear all terms if no industries are specified
     563    }
     564
    521565    // Assign or clear industry terms
    522566    if (!empty($industry_ids)) {
     
    540584    if (!empty($job_type_id)) {
    541585        wp_set_post_terms($post_id, array($job_type_id), 'jobtype', false);
    542     }
    543 
    544     if (!empty($sector_id)) {
    545         wp_set_post_terms($post_id, array($sector_id), 'jobsector', false);
    546586    }
    547587
  • recruitly/trunk/readme.txt

    r3246355 r3246395  
    44Requires at least: 4.5
    55Tested up to: 6.7.1
    6 Stable tag: 2.0.27
     6Stable tag: 2.0.28
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    122122* Fix issue with multiple industries in taxonomies.
    123123
     124= 2.0.28 =
     125* Fix issue with multiple sectors in taxonomies.
     126
    124127== Upgrade Notice ==
    125128
  • recruitly/trunk/recruitly.php

    r3246355 r3246395  
    44Plugin URI: https://recruitly.io
    55Description: Recruitly job board integration.
    6 Version: 2.0.27
     6Version: 2.0.28
    77Author: Recruitly
    88Author URI: https://recruitly.io
     
    1515    exit; // Exit if accessed directly
    1616}
    17 define('RECRUITLY_PLUGIN_VERSION', '2.0.27');
     17define('RECRUITLY_PLUGIN_VERSION', '2.0.28');
    1818
    1919defined('RECRUITLY_POST_TYPE') or define('RECRUITLY_POST_TYPE', 'current-vacancies');
Note: See TracChangeset for help on using the changeset viewer.