Skip to content

Instantly share code, notes, and snippets.

Avatar
🦋
in the zone

Myles McNamara tripflex

🦋
in the zone
View GitHub Profile
@tripflex
tripflex / functions.php
Created Oct 1, 2021
Change job permalinks max characters to 50 when using WP Job Manager Visibility plugin
View functions.php
<?php
add_filter( 'job_manager_visibility_admin_job_permalink_max_slug_chars', 'smyles_max_job_permalink_chars' );
add_filter( 'job_manager_visibility_job_permalink_max_slug_chars', 'smyles_max_job_permalink_chars' );
function smyles_max_job_permalink_chars( $chars ){
return 50;
}
@tripflex
tripflex / content-email_job_listing.php
Created Aug 27, 2021
Job Alerts email support HTML link
View content-email_job_listing.php
<?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 Aug 24, 2021
Remove specific fields from submit form based on current user role when using WP Job Manager Field Editor
View functions.php
<?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 Sep 10, 2021
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
View functions.php
<?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 ) {
if ( empty( $object_id ) || empty( $meta_key ) ) {
return $do;
}
@tripflex
tripflex / functions.php
Last active Aug 20, 2021
Allow zero value fields support for NUMBER field type in WP Job Manager
View functions.php
<?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 Aug 16, 2021
Add custom Search and Filtering section on Astoundify Company Listings single company Jobs tab page
View functions.php
<?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 Aug 11, 2021
Disable S&F on Single Company Jobs List Page (when using Astoundify Company Listings)
View functions.php
<?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 Aug 9, 2021
Hide categories/taxonomies not associated with listings from showing in WP Job Manager Search and Filtering
View functions.php
<?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 Aug 2, 2021
Replace double byte space characters in Job and Resume keyword string before search
View functions.php
<?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 Jul 12, 2021
Output Resume ID at Meta Start
View functions.php
<?php
add_action( 'single_resume_meta_start', 'smyles_output_resume_listing_id' );
function smyles_output_resume_listing_id(){
echo 'Listing ID: ' . get_the_ID();
}