careers.php 1.48 KB
<?php
    
    function offshore_career_locations( $id ) {
        $states = get_the_terms( $id, 'state' );
        $countries = get_the_terms( $id, 'country' );
        $states_arr = array();
        $countries_arr = array();
        $output = '';
        if ( $states && $countries && ! is_wp_error( $states ) && ! is_wp_error( $countries ) ) {
            foreach ( $states as $term ) {
                $states_arr[] = ucfirst( $term->name );
            }
            foreach ( $countries as $term ) {
                $countries_arr[] = ucfirst( $term->name );
            }
            $locations = array_combine( $states_arr, $countries_arr );
            if( $locations ){
                $output .= '<div class="location">';
                $i = 1; $count = count( $locations );
                foreach ( $locations as $state => $country ) {
                    $output .= '<p class="state">' . esc_html( $state ) . '</p>';
                    $output .= '<p class="country">' . esc_html( $country ) . '</p>';
                }
                $output .= '</div>';
            }
        }
        return $output;
    }

    function offshore_work_type( $id, $type ) {
        $terms = get_the_terms( $id, $type );
        $output = '';
        if ( $terms && ! is_wp_error( $terms ) ) {
            foreach ( $terms as $term ) {
                $output .= '<span class="designation-type">' . strtoupper( esc_html( $term->name ) ) . '</span>';
            }
        
        }
        return $output;
    }