| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154 |
- <?php
- /**
- * Template Functions
- *
- * Template functions specifically created for job listings.
- *
- * @link https://wordpress.org/plugins/simple-job-board
- *
- * @package Simple_Job_Board
- * @subpackage Simple_Job_Board/Templates
- * @since 2.1.0
- */
- if (!function_exists('get_simple_job_board_template')) {
- /**
- * Get and include template files.
- *
- * @since 2.1.0
- *
- * @param mixed $template_name
- * @param array $args (default: array())
- * @param string $template_path (default: '')
- * @param string $default_path (default: '')
- * @return void
- */
- function get_simple_job_board_template($template_name, $args = array(), $template_path = 'simple_job_board', $default_path = '') {
- if ($args && is_array($args)) {
- extract($args);
- }
- include( locate_simple_job_board_template($template_name, $template_path, $default_path) );
- }
- }
- if (!function_exists('locate_simple_job_board_template')) {
- /**
- * Locate a template and return the path for inclusion.
- *
- * This is the load order:
- *
- * yourtheme / $template_path / $template_name
- * yourtheme / $template_name
- * $default_path / $template_name
- *
- * @since 2.1.0
- *
- * @param string $template_name
- * @param string $template_path (default: 'simple_job_board')
- * @param string|bool $default_path (default: '') False to not load a default
- * @return string $template_name
- */
- function locate_simple_job_board_template($template_name, $template_path = 'simple_job_board', $default_path = '') {
- // Look within passed path within the theme - this is priority
- $template = locate_template(
- array(
- trailingslashit($template_path) . $template_name,
- $template_name
- )
- );
- // Get default template
- if (!$template && $default_path !== false) {
- $default_path = $default_path ? $default_path : untrailingslashit(plugin_dir_path(dirname(__DIR__))) . '/templates/';
- if (file_exists(trailingslashit($default_path) . $template_name)) {
- $template = trailingslashit($default_path) . $template_name;
- }
- }
- // Return what we found
- return apply_filters('simple_job_board_locate_template', $template, $template_name, $template_path);
- }
- }
- if (!function_exists('get_simple_job_board_template_part')) {
- /**
- * Get template part (for templates in loops).
- *
- * @since 2.1.0
- *
- * @param string $slug
- * @param string $name (default: '')
- * @param string $template_path (default: 'simple_job_board')
- * @param string|bool $default_path (default: '') False to not load a default
- */
- function get_simple_job_board_template_part($slug, $name = '', $template_path = 'simple_job_board', $default_path = '') {
- $template = '';
- if ($name) {
- $template = locate_simple_job_board_template("{$slug}-{$name}.php", $template_path, $default_path);
- }
- // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/simple_job_board/slug.php
- if (!$template) {
- $template = locate_simple_job_board_template("{$slug}.php", $template_path, $default_path);
- }
- if ($template) {
- load_template($template, FALSE);
- }
- }
- }
- if (!function_exists('sjb_body_classes')) {
- /**
- * Add custom body classes
- *
- * @since 2.1.0
- *
- * @param array $classes
- * @return array
- */
- function sjb_body_classes($classes) {
- $classes = (array) $classes;
- $classes[] = trim(sanitize_title(wp_get_theme()));
- if (is_sjb()) {
- $classes[] = 'sjb';
- }
- return array_unique($classes);
- }
- }
- add_filter('body_class', 'sjb_body_classes');
- if (!function_exists('sjb_the_job_category')) {
- /**
- * Job Categories.
- *
- * @since 2.1.0
- */
- function sjb_the_job_category($post = NULL) {
- if ($job_categories = sjb_get_the_job_category($post)) {
- $count = sizeof($job_categories);
- foreach ($job_categories as $job_category) {
- echo $job_category->name;
- if ($count > 1) {
- echo ', ';
- }
- $count--;
- }
- }
- }
- }
- if ( !function_exists('sjb_get_the_job_category') ) {
- /**
- * sjb_get_the_job_category function.
- *
- * @since 2.1.0
- * @access public
- *
- * @param mixed $post (default: null)
- * @return void
- */
- function sjb_get_the_job_category($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost') {
- return;
- }
- $categories = wp_get_post_terms($post->ID, 'jobpost_category');
- /**
- * Job Categories.
- *
- * @since 2.1.0
- *
- * @param $categories Job Categories.
- * @param $post Post Object.
- */
- return apply_filters('sjb_the_job_category', $categories, $post);
- }
- }
- if (!function_exists('sjb_the_job_type')) {
- /**
- * sjb_the_job_type function.
- *
- * @since 2.1.0
- * @access public
- *
- * @return void
- */
- function sjb_the_job_type($post = NULL) {
- if ($job_types = sjb_get_the_job_type($post)) {
- $count = sizeof($job_types);
- foreach ($job_types as $job_type) {
- echo esc_attr(strip_tags($job_type->name));
- if ($count > 1) {
- echo ', ';
- }
- $count--;
- }
- }
- }
- }
- if (!function_exists('sjb_get_the_job_type')) {
- /**
- * sjb_get_the_job_type function.
- *
- * @since 2.1.0
- * @access public
- *
- * @param mixed $post (default: null)
- * @return void
- */
- function sjb_get_the_job_type($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost') {
- return;
- }
- $types = wp_get_post_terms($post->ID, 'jobpost_job_type');
- /**
- * Job Type.
- *
- * @since 2.1.0
- *
- * @param $types Job Types.
- * @param $post Post Object.
- */
- return apply_filters('sjb_the_job_type', $types, $post);
- }
- }
- if (!function_exists('sjb_the_job_location')) {
- /**
- * sjb_the_job_location function.
- *
- * @since 2.1.0
- *
- * @return void
- */
- function sjb_the_job_location($post = NULL) {
- $post = get_post($post);
- if ($job_locations = sjb_get_the_job_location($post)) {
- $count = sizeof($job_locations);
- foreach ($job_locations as $location) {
- echo esc_attr(strip_tags($location->name));
- if ($count > 1) {
- echo ', ';
- }
- $count--;
- }
- }
- }
- }
- if (!function_exists('sjb_get_the_job_location')) {
- /**
- * sjb_get_the_job_location function.
- *
- * @since 2.1.0
- *
- * @param mixed $post (default: NULL)
- * @return void
- */
- function sjb_get_the_job_location($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost') {
- return;
- }
- $locations = wp_get_post_terms($post->ID, 'jobpost_location');
- /**
- * Job Location.
- *
- * @since 2.1.0
- *
- * @param $locations Job Locations.
- * @param $post Post Object
- */
- return apply_filters('sjb_the_job_location', $locations, $post);
- }
- }
- if (!function_exists('sjb_the_company_name')) {
- /**
- * Display or retrieve the current company name with optional content.
- *
- * @since 2.1.0
- *
- * @param mixed $id (default: null)
- * @return void
- */
- function sjb_the_company_name($before = '', $after = '', $echo = true, $post = NULL) {
- $company_name = sjb_get_the_company_name($post);
- if (strlen($company_name) == 0)
- return;
- $company_name = esc_attr(strip_tags($company_name));
- $company_name = $before . $company_name . $after;
- if ($echo)
- echo $company_name;
- else
- return $company_name;
- }
- }
- if (!function_exists('sjb_get_the_company_name')) {
- /**
- * sjb_get_the_company_name function.
- *
- * @since 2.1.0
- *
- * @param int $post (default: null)
- * @return string
- */
- function sjb_get_the_company_name($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost') {
- return '';
- }
- /**
- * Company Name.
- *
- * @since 2.1.0
- *
- * @param $post->simple_job_board_company_name Company Name.
- * @param $post Post Object
- */
- return apply_filters('sjb_the_company_name', $post->simple_job_board_company_name, $post);
- }
- }
- if (!function_exists('sjb_the_job_posting_time')) {
- /**
- * Display or retrieve the job posting time.
- *
- * @since 2.1.0
- *
- * @param mixed $id (default: null)
- * @return void
- */
- function sjb_the_job_posting_time($post = NULL) {
- $job_posting_time = sjb_get_the_job_posting_time($post);
- if (strlen($job_posting_time) == 0)
- return;
- echo esc_attr(strip_tags($job_posting_time));
- }
- }
- if (!function_exists('sjb_get_the_job_posting_time')) {
- /**
- * sjb_get_the_job_posting_time function.
- *
- * @since 2.1.0
- *
- * @param int $post (default: null)
- * @return string
- */
- function sjb_get_the_job_posting_time($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost') {
- return '';
- }
- /**
- * Job Posted Date.
- *
- * @since 2.1.0
- *
- * @param human_time_diff(get_post_time('U'), current_time('timestamp')) Job Posted Date.
- * @param $post Post Object
- */
- return apply_filters('sjb_the_job_posting_time', human_time_diff(get_post_time('U'), current_time('timestamp')), $post);
- }
- }
- if (!function_exists('sjb_get_the_company_website')) {
- /**
- * sjb_get_the_company_website function.
- *
- * @since 2.1.0
- *
- * @param int $post (default: null)
- * @return void
- */
- function sjb_get_the_company_website($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost') {
- return;
- }
- $website = $post->simple_job_board_company_website;
- if ($website && !strstr($website, 'http:') && !strstr($website, 'https:')) {
- $website = 'http://' . $website;
- }
- /**
- * Company Website.
- *
- * @since 2.1.0
- *
- * @param $website Company Website
- * @param $post Post Object
- */
- return apply_filters('sjb_the_company_website', $website, $post);
- }
- }
- if (!function_exists('sjb_the_company_tagline')) {
- /**
- * Display or retrieve the current company tagline with optional content.
- *
- * @since 2.1.0
- *
- * @param mixed $id (default: null)
- * @return void
- */
- function sjb_the_company_tagline($before = '', $after = '', $echo = TRUE, $post = NULL) {
- $company_tagline = sjb_get_the_company_tagline($post);
- if (strlen($company_tagline) == 0)
- return;
- $company_tagline = esc_attr(strip_tags($company_tagline));
- $company_tagline = $before . $company_tagline . $after;
- if ($echo)
- echo $company_tagline;
- else
- return $company_tagline;
- }
- }
- if (!function_exists('sjb_get_the_company_tagline')) {
- /**
- * sjb_get_the_company_tagline function.
- *
- * @since 2.1.0
- *
- * @param int $post (default: 0)
- * @return void
- */
- function sjb_get_the_company_tagline($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost')
- return;
- /**
- * Company Tagline
- *
- * @since 2.1.0
- *
- * @param $post->simple_job_board_company_tagline Company Tagline
- * @param $post Post Object
- */
- return apply_filters('sjb_the_company_tagline', $post->simple_job_board_company_tagline, $post);
- }
- }
- if (!function_exists('sjb_the_company_logo')) {
- /**
- * sjb_the_company_logo function.
- *
- * @since 2.1.0
- *
- * @param string $size (default: 'full')
- * @param array or object array $atts {
- * associative array with "id" & "class" indexes
- *
- * @type string id => "logo id"
- *
- * @type string class => "logo class"
- * } (default: null)
- * @param mixed $default (default: null)
- * @return void
- */
- function sjb_the_company_logo($size = 'full', $atts = NULL, $default = NULL, $post = NULL) {
- $logo = sjb_get_the_company_logo($post);
- $id = NULL;
- $class = NULL;
- /* Get logo attributes */
- if (!empty($atts)) {
- if (is_array($atts)) {
- $id = isset($atts['id']) ? $atts['id'] : '';
- $class = isset($atts['class']) ? $atts['class'] : '';
- } else {
- $id = isset($atts->id) ? $atts->id : '';
- $class = isset($atts->class) ? $atts->class : '';
- }
- }
- if (!empty($logo) && ( strstr($logo, 'http') || file_exists($logo) )) {
- if ($size !== 'full') {
- $logo = sjb_get_resized_image($logo, $size);
- }
- echo '<img src="' . esc_attr($logo) . '" alt="' . esc_attr(sjb_get_the_company_name($post)) . '" class="sjb-img-responsive ' . $class . '" id="' . $id . '"/>';
- } elseif ($default) {
- echo '<img src="' . esc_attr($default) . '" alt="' . esc_attr(sjb_get_the_company_name($post)) . '" class="sjb-img-responsive ' . $class . '" id="' . $id . '"/>';
- } else {
- echo '<img src="' . esc_attr(apply_filters('simple_job_board_default_company_logo', plugin_dir_url(dirname(__FILE__)) . 'images/company.png')) . '" alt="' . esc_attr(sjb_get_the_company_name($post)) . '" class="sjb-img-responsive ' . $class . '" id="' . $id . '"/>';
- }
- }
- }
- if (!function_exists('sjb_get_the_company_logo')) {
- /**
- * sjb_get_the_company_logo function.
- *
- * @since 2.1.0
- *
- * @param mixed $post (default: null)
- * @return string $post->simple_job_board_company_logo Company logo
- */
- function sjb_get_the_company_logo($post = NULL) {
- $post = get_post($post);
- if ($post->post_type !== 'jobpost')
- return;
- /**
- * Company Logo
- *
- * @since 2.1.0
- *
- * @param $post->simple_job_board_company_logo Company Logo
- * @param $post Post Id
- */
- return apply_filters('sjb_the_company_logo', $post->simple_job_board_company_logo, $post);
- }
- }
- if (!function_exists('sjb_get_resized_image')) {
- /**
- * Resize and get url of the image
- *
- * @since 2.1.0
- *
- * @param string $logo
- * @param string $size
- * @return string $logo Company logo
- */
- function sjb_get_resized_image($logo, $size) {
- global $_wp_additional_image_sizes;
- if ($size !== 'full' && strstr($logo, WP_CONTENT_URL) && (isset($_wp_additional_image_sizes[$size]) || in_array($size, array('thumbnail', 'medium', 'large'
- )) )) {
- if (in_array($size, array('thumbnail', 'medium', 'large'))) {
- $img_width = get_option($size . '_size_w');
- $img_height = get_option($size . '_size_h');
- $img_crop = get_option($size . '_size_crop');
- } else {
- $img_width = $_wp_additional_image_sizes[$size]['width'];
- $img_height = $_wp_additional_image_sizes[$size]['height'];
- $img_crop = $_wp_additional_image_sizes[$size]['crop'];
- }
- $upload_dir = wp_upload_dir();
- $logo_path = str_replace(array($upload_dir['baseurl'], $upload_dir['url'], WP_CONTENT_URL), array($upload_dir['basedir'], $upload_dir['path'], WP_CONTENT_DIR), $logo);
- $path_parts = pathinfo($logo_path);
- $resized_logo_path = str_replace('.' . $path_parts['extension'], '-' . $size . '.' . $path_parts['extension'], $logo_path);
- if (strstr($resized_logo_path, 'http:') || strstr($resized_logo_path, 'https:')) {
- return $logo;
- }
- if (!file_exists($resized_logo_path)) {
- ob_start();
- $image = wp_get_image_editor($logo_path);
- if (!is_wp_error($image)) {
- $resize = $image->resize($img_width, $img_height, $img_crop);
- if (!is_wp_error($resize)) {
- $save = $image->save($resized_logo_path);
- if (!is_wp_error($save)) {
- $logo = dirname($logo) . '/' . basename($resized_logo_path);
- }
- }
- }
- ob_get_clean();
- } else {
- $logo = dirname($logo) . '/' . basename($resized_logo_path);
- }
- }
- return $logo;
- }
- }
- if (!function_exists('sjb_get_the_excerpt')) {
- /**
- * Custom Excerpt Function.
- *
- * @since 1.0.0
- *
- * @param string $charlength Character length.
- * @param string $readmore Read more Enable.
- * @param string $readmore_text Read more Text.
- * @return string $excerpt Excerpt of Job Description
- */
- function sjb_get_the_excerpt() {
- $excerpt = '<p>' . trim(preg_replace('/<a[^>]*>(.*)<\/a>/iU', '', get_the_excerpt())) . '</p>';
- $more = '<p><a href="' . get_the_permalink() . '" class="btn btn-primary">' . esc_html__('Read More', 'simple-job-board') . '</a></p>';
- return apply_filters('sjb_get_the_excerpt', $excerpt . $more, $excerpt, $more);
- }
- }
- if (!function_exists('sjb_keywords_search_by_title')) {
- /**
- * Search SQL filter for matching against post title only.
- *
- * @since 2.1.4
- *
- * @global Object WP_Query $wp_query
- *
- * @param string $search Searched Keyword
- * @return string $search Search Results from Post Title
- */
- function sjb_keywords_search_by_title($search, $wp_query) {
- if (!empty($search) && !empty($wp_query->query_vars['search_terms']) && isset($wp_query->query['post_type']) && 'jobpost' == $wp_query->query['post_type']) {
- global $wpdb;
- $q = $wp_query->query_vars;
- $n = !empty($q['exact']) ? '' : '%';
- $search = array();
- foreach ((array) $q['search_terms'] as $term)
- $search[] = $wpdb->prepare("$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like($term) . $n);
- if (!is_user_logged_in())
- $search[] = "$wpdb->posts.post_password = ''";
- $search = ' AND ' . implode(' AND ', $search);
- }
- return $search;
- }
- }
- /* Hook -> Keywords Search By Title */
- add_filter('posts_search', 'sjb_keywords_search_by_title', 10, 2);
- if (!function_exists('sjb_is_checked')) {
- /**
- * Assign Default Radio button Check
- *
- * @since 2.1.0
- */
- function sjb_is_checked($i) {
- $checked = ( $i == 0 ) ? "checked" : NULL;
- return $checked;
- }
- }
- if (!function_exists('sjb_job_listing_meta_display')) {
- /**
- * Displays job meta data on the single job page.
- *
- * @since 2.1.0
- */
- function sjb_job_listing_meta_display() {
- get_simple_job_board_template('single-jobpost/content-single-job-listing-meta.php', array());
- }
- }
- add_action('sjb_single_job_listing_start', 'sjb_job_listing_meta_display', 20);
- if (!function_exists('sjb_job_listing_features')) {
- /**
- * Displays job features data on the single job page.
- *
- * @since 2.1.0
- */
- function sjb_job_listing_features() {
- get_simple_job_board_template('single-jobpost/job-features.php', array());
- }
- }
- add_action('sjb_single_job_listing_end', 'sjb_job_listing_features', 20);
- if (!function_exists('sjb_job_listing_application_form')) {
- /**
- * Displays job application form on the single job page
- *
- * @since 2.1.0
- */
- function sjb_job_listing_application_form() {
- get_simple_job_board_template('single-jobpost/job-application.php', array());
- }
- }
- add_action('sjb_single_job_listing_end', 'sjb_job_listing_application_form', 30);
- if (!function_exists('sjb_job_listing_wrapper_start')) {
- /**
- * Output Content Wrapper start div's
- *
- * @since 2.2.0
- */
- function sjb_job_listing_wrapper_start() {
- get_simple_job_board_template('global/content-wrapper-start.php');
- }
- }
- add_action('sjb_before_main_content', 'sjb_job_listing_wrapper_start', 10);
- if (!function_exists('sjb_job_listing_wrapper_end')) {
- /**
- * Output Content Wrapper end div's
- *
- * @since 2.2.0
- */
- function sjb_job_listing_wrapper_end() {
- get_simple_job_board_template('global/content-wrapper-end.php');
- }
- }
- add_action('sjb_after_main_content', 'sjb_job_listing_wrapper_end', 10);
- if (!function_exists('sjb_job_listing_view')) {
- /**
- * Job Listing View
- *
- * This function displays the user defined job listing view.
- *
- * @since 2.2.3
- */
- function sjb_job_listing_view() {
- // Display the user defined job listing view
- if ('grid-view' === get_option('job_board_listing_view')) {
- get_simple_job_board_template('content-job-listing-grid-view.php');
- } else {
- get_simple_job_board_template('content-job-listing-list-view.php');
- }
- }
- }
- // Hook -> Job Listing View
- add_action('sjb_job_listing_view', 'sjb_job_listing_view', 10);
- if (!function_exists('sjb_job_features_count')) {
- /**
- * Return Count of Job Features.
- *
- * @since 2.2.0
- */
- function sjb_job_features_count() {
- global $post;
- $keys = get_post_custom_keys(get_the_ID());
- $count = 0;
- if ($keys != NULL):
- foreach ($keys as $key):
- if (substr($key, 0, 11) == 'jobfeature_') {
- $val = get_post_meta($post->ID, $key, TRUE);
- if (is_serialized($val)) {
- $val = unserialize($val);
- }
- if (!empty($val['value'])) {
- $count++;
- }
- }
- endforeach;
- endif;
- return $count;
- }
- }
- if (!function_exists('sjb_front_end_scripts')) {
- /**
- * Enqueue Frontend Styles & Scripts.
- *
- * @since 2.2.3
- */
- function sjb_front_end_scripts() {
- // Enqueue Scripts
- wp_enqueue_script('simple-job-board-validate-telephone-input');
- wp_enqueue_script('simple-job-board-validate-telephone-input-utiliy');
- wp_enqueue_script('simple-job-board-front-end');
- }
- }
- // Action -> Enqueue Frontend Styles & Scripts.
- add_action('sjb_enqueue_scripts', 'sjb_front_end_scripts');
- if (!function_exists('sjb_get_slugs')) {
- /**
- * Get Current Page Slug.
- *
- * @since 2.2.4
- */
- function sjb_get_slugs() {
- global $post;
- if (is_archive()) {
- $link = get_post_type_archive_link('jobpost');
- } else {
- $link = get_permalink($post->ID);
- }
- if (empty($link)) {
- return FALSE;
- } else {
- $link = str_replace(home_url('/'), '', $link);
- return $link;
- }
- }
- }
- if (!function_exists('sjb_is_keyword_search')) {
- /**
- * Is Category Filter
- *
- * @since 2.4.0
- */
- function sjb_is_keyword_search() {
- $is_search = ('yes' === get_option('job_board_search_bar') ) ? TRUE : FALSE;
- return $is_search;
- }
- }
- if (!function_exists('sjb_is_category_filter')) {
- /**
- * Is Category Filter
- *
- * @since 2.4.0
- */
- function sjb_is_category_filter() {
- $is_cat = ( NULL != get_terms('jobpost_category') && ( 'yes' === get_option('job_board_category_filter') ) ) ? TRUE : FALSE;
- return $is_cat;
- }
- }
- if (!function_exists('sjb_is_type_filter')) {
- /**
- * Is Job Type Filter
- *
- * @since 2.4.0
- *
- */
- function sjb_is_type_filter() {
- $is_type = ( NULL != get_terms('jobpost_job_type') && 'yes' === get_option('job_board_jobtype_filter') ) ? TRUE : FALSE;
- return $is_type;
- }
- }
- if (!function_exists('sjb_is_location_filter')) {
- /**
- * Is Job Location Filter
- *
- * @since 2.4.0
- */
- function sjb_is_location_filter() {
- $is_loc = ( NULL != get_terms('jobpost_location') && 'yes' === get_option('job_board_location_filter') ) ? TRUE : FALSE;
- return $is_loc;
- }
- }
- if (!function_exists('sjb_is_filter_dropdowns')) {
- /**
- * Is Job Filters
- *
- * @since 2.4.0
- */
- function sjb_is_filter_dropdowns() {
- $filters_dropdowns = ( sjb_is_category_filter() || sjb_is_type_filter() || sjb_is_location_filter() ) ? TRUE : FALSE;
- return apply_filters('sjb_is_filter_dropdowns', $filters_dropdowns);
- }
- }
- if (!function_exists('is_sjb')) {
- /**
- * is_sjb - Returns TRUE when Viewing the Jobpost Pages.
- *
- * @since 2.4.0
- *
- * @return bool
- */
- function is_sjb() {
- return apply_filters('is_sjb', ( is_jobpost() || is_jobpost_archive() || is_jobpost_taxonomy() || is_jobpost_shortcode() ) ? TRUE : FALSE );
- }
- }
- if (!function_exists('is_jobpost')) {
- /**
- * is_jobpost - Returns TRUE when Viewing the Jobpost Single Page.
- *
- * @since 2.4.0
- *
- * @return bool
- */
- function is_jobpost() {
- return is_singular(array('jobpost'));
- }
- }
- if (!function_exists('is_jobpost_archive')) {
- /**
- * is_jobpost_archive - Returns TRUE when Viewing the Job Archive Page.
- *
- * @since 2.4.0
- *
- * @return bool
- */
- function is_jobpost_archive() {
- return ( is_post_type_archive('jobpost') );
- }
- }
- if (!function_exists('is_jobpost_taxonomy')) {
- /**
- * is_jobpost_taxonomy - Returns TRUE when Viewing the Job Taxonomies.
- *
- * @since 2.4.0
- *
- * @return bool
- */
- function is_jobpost_taxonomy() {
- return is_tax(get_object_taxonomies('jobpost'));
- }
- }
- if (!function_exists('is_jobpost_shortcode')) {
- /**
- * is_jobpost_shortcode - Returns TRUE when Viewing the Job Listing.
- *
- * @since 2.4.0
- *
- * @return bool
- */
- function is_jobpost_shortcode() {
- global $post;
- return is_a($post, 'WP_Post') && has_shortcode($post->post_content, 'jobpost');
- }
- }
- if (!function_exists('sjb_the_title')) {
- /**
- * Display Job Title
- *
- * @since 2.4.4
- *
- * @param string $before Add string befor title.
- * @param string $after Add string after title.
- * @param bool $echo TRUE/FALSE
- * @param object $post Post Object
- * @return $job_title Job Title
- */
- function sjb_the_title($before = '', $after = '', $echo = TRUE, $post = NULL) {
- $job_title = sjb_get_the_title($post);
- if (strlen($job_title) == 0)
- return;
- $job_title = esc_attr(strip_tags($job_title));
- $job_title = $before . $job_title . $after;
- if ($echo)
- echo $job_title;
- else
- return $job_title;
- }
- }
- if (!function_exists('sjb_get_the_title')) {
- /**
- * Return Job Title
- *
- * @since 2.4.4
- *
- * @param object $post Post Object
- * @return $job_title Job Title
- */
- function sjb_get_the_title($post = NULL) {
- global $post;
- $title = get_the_title();
- /**
- * Job Title
- *
- * @since 2.4.4
- *
- * @param $title Job Title
- * @param $post Post Id
- */
- return apply_filters('sjb_the_title', $title, $post);
- }
- }
- /**
- * Single Job Content Start
- *
- * @since 2.5.0
- */
- if (!function_exists('sjb_single_job_content_start')) {
- function sjb_single_job_content_start() {
- get_simple_job_board_template('single-jobpost/single-job-wrapper-start.php');
- }
- }
- add_action('sjb_single_job_content_start', 'sjb_single_job_content_start');
- /**
- * Single Job Content End
- *
- * @since 2.5.0
- */
- if (!function_exists('sjb_single_job_content_end')) {
- function sjb_single_job_content_end() {
- get_simple_job_board_template('single-jobpost/single-job-wrapper-end.php');
- }
- }
- add_action('sjb_single_job_content_end', 'sjb_single_job_content_end');
- /**
- * Converts a string (e.g. 'yes' or 'no') to a bool.
- *
- * @since 2.6.0
- *
- * @param string $string String to convert.
- * @return bool
- */
- function sjb_string_to_bool( $string ) {
- return is_bool( $string ) ? $string : ( 'yes' === $string || 1 === $string || 'true' === $string || '1' === $string );
- }
|