Skip to content

Instantly share code, notes, and snippets.

View tripflex's full-sized avatar
🦋
in the zone

Myles McNamara tripflex

🦋
in the zone
View GitHub Profile
@tripflex
tripflex / content-email_job_listing.php
Created August 27, 2021 22:40
Job Alerts email support HTML link
<?php
/**
* Generates the content used in the notification email.
*
* This template can be overridden by copying it to yourtheme/wp-job-manager-alerts/content-email_job_listing.php.
*
* @see https://wpjobmanager.com/document/template-overrides/
* @author Automattic
* @package WP Job Manager - Alerts
* @category Template
@tripflex
tripflex / functions.php
Created August 24, 2021 00:09
Remove specific fields from submit form based on current user role when using WP Job Manager Field Editor
<?php
add_filter( 'submit_job_form_fields', 'smyles_remove_fields_by_user_role', 999999999999 );
function smyles_remove_fields_by_user_role( $fields ){
$fields_to_remove = array( 'job_salary', 'some_other_meta_key' );
$user = wp_get_current_user();
if ( in_array( 'employer', (array) $user->roles ) ) {
@tripflex
tripflex / functions.php
Last active November 18, 2021 21:38
Show resume details when anonymous custom field is not configured (and using WP Job Manager Visibility) - Requires WP Job Manager Visibility 1.6.1 or newer
<?php
add_filter( 'job_manager_visibility_get_placeholder_do_process', 'smyles_check_can_view_resume_from_listing', 10, 3 );
add_filter( 'job_manager_visibility_get_meta_do_process', 'smyles_check_can_view_resume_from_listing', 10, 3 );
function smyles_check_can_view_resume_from_listing( $do, $object_id, $meta_key ) {
/**
* Meta keys defined here do not rely on the "anonymous_resume" settings to process
* through the visibility handling. These MUST include a prepended underscore.
@tripflex
tripflex / functions.php
Last active August 20, 2021 16:53
Allow zero value fields support for NUMBER field type in WP Job Manager
<?php
add_filter( 'submit_job_form_fields', 'smyles_allow_zero_value_field' );
function smyles_allow_zero_value_field( $fields ){
$fields['job']['METAKEY']['before_sanitize'] = true;
return $fields;
}
add_filter( 'job_manager_get_posted_number_field', 'smyles_allow_zero_value_number_field_handler' );
@tripflex
tripflex / functions.php
Created August 16, 2021 22:53
Add custom Search and Filtering section on Astoundify Company Listings single company Jobs tab page
<?php
add_filter( 'search_and_filtering_afjcl_company_jobs_tab_shortcode', 'sf_company_jobs_tab_shortcode' );
function sf_company_jobs_tab_shortcode( $sc ){
return '[jobs filter_section_id="2451"]';
}
@tripflex
tripflex / functions.php
Created August 11, 2021 00:57
Disable S&F on Single Company Jobs List Page (when using Astoundify Company Listings)
<?php
add_filter( 'company_listings_tabs', 'smyles_company_listings_tabs_disable_sf' );
function smyles_company_listings_tabs_disable_sf( $tabs ){
if( isset( $tabs['jobs'] ) ){
$tabs['jobs']['callback'] = 'company_listings_company_jobs_tab_no_sf';
}
return $tabs;
@tripflex
tripflex / functions.php
Created August 9, 2021 21:49
Hide categories/taxonomies not associated with listings from showing in WP Job Manager Search and Filtering
<?php
add_filter( 'search_and_filtering_get_taxonomy_data_options_args', 'smyles_sf_tax_hide_empty' );
function smyles_sf_tax_hide_empty( $args ){
$args['hide_empty'] = true;
return $args;
}
@tripflex
tripflex / functions.php
Created August 2, 2021 23:15
Replace double byte space characters in Job and Resume keyword string before search
<?php
add_filter( 'job_manager_get_listings_args', 'smyles_double_space_replace', 999999 );
add_filter( 'resume_manager_get_resumes_args', 'smyles_double_space_replace', 999999 );
/**
* Replace Double Byte Space with Regular Space in Search Keywords
*
* @param $args
*
* @return mixed
@tripflex
tripflex / functions.php
Created July 12, 2021 23:01
Output Resume ID at Meta Start
<?php
add_action( 'single_resume_meta_start', 'smyles_output_resume_listing_id' );
function smyles_output_resume_listing_id(){
echo 'Listing ID: ' . get_the_ID();
}
@tripflex
tripflex / file-field.php
Created June 21, 2021 21:04
Cariera 1.5.1+ new file-field.php template file when using WP Job Manager Field Editor 1.11.3 or older
<?php
$classes = array( 'input-text', 'cariera-file-upload' );
$allowed_mime_types = array_keys( ! empty( $field['allowed_mime_types'] ) ? $field['allowed_mime_types'] : get_allowed_mime_types() );
$field_name = isset( $field['name'] ) ? $field['name'] : $key;
$field_name .= ! empty( $field['multiple'] ) ? '[]' : '';
$classes[] = "file-" . esc_attr( $key );
$use_ajax = ! empty( $field['ajax'] ) && field_editor_user_can_upload_file_via_ajax();
if ( $use_ajax ) {
wp_enqueue_script( 'wp-job-manager-ajax-file-upload' );