Skip to content

Instantly share code, notes, and snippets.

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

Myles tripflex

🦋
in the zone
View GitHub Profile
@tripflex
tripflex / functions.php
Created January 31, 2025 20:47
Prevent WP Job Manager Resumes from Translating the resume slug in the URL
<?php
add_filter('register_post_type_resume', 'modify_resume_rewrite_slug', 99, 1);
function modify_resume_rewrite_slug($args) {
// don't translate the value
$args['rewrite']['slug'] = 'resume';
return $args;
}
@tripflex
tripflex / functions.php
Created January 9, 2025 22:28
Make sure job_location translation is handled correctly (as core WPJM pulls directly from database)
<?php
add_filter( 'the_job_location', 'smyles_the_job_location_translatable', 99, 2 );
function smyles_the_job_location_translatable( $job_location, $post ){
// We don't want to override the auto generated geolocation address information
if ( get_option( 'job_manager_display_location_address' ) === '1' ) {
return $job_location;
}
return get_job_field('job_location', $post->ID );
@tripflex
tripflex / functions.php
Created November 26, 2024 23:13
Job URL apply type custom URL for not logged in users (when using WP Job Manager Packages 1.3.5+)
<?php
add_filter( 'job_manager_packages_job_application_url_type_packages_permalink_not_logged_in', function( $url ) {
return 'https://domain.com/please-register'; // Replace with your desired URL
});
@tripflex
tripflex / functions.php
Created November 26, 2024 21:23
[candidate_photo] shortcode to output candidate photo (as thumbnail, etc)
<?php
function display_candidate_photo_shortcode($atts) {
// Check if the function exists before calling it
if (function_exists('the_candidate_photo')) {
ob_start();
// Options are full, thumbnail, medium, large
the_candidate_photo( 'thumbnail' );
return ob_get_clean();
} else {
return 'Candidate photo function not available.';
@tripflex
tripflex / functions.php
Last active April 22, 2024 19:11
WP Job Manager set TinyMCE to defaults (color picker, etc)
<?php
// This is my own personal modified version that I recommend
add_filter( 'submit_job_form_wp_editor_args', 'smyles_wpjm_wp_editor_wp_defaults', 99999 );
function smyles_wpjm_wp_editor_wp_defaults( $args ) {
$args['tinymce'] = array(
'plugins' => 'charmap,colorpicker,hr,lists,paste,tabfocus,textcolor,wordpress,wpautoresize,wplink,wpdialogs,wptextpattern,wpview,image',
'paste_as_text' => true,
@tripflex
tripflex / functions.php
Created March 1, 2024 23:27
Set reply-to for every email sent from WP Job Manager Emails (overrides any configuration in templates)
<?php
add_filter( 'job_manager_emails_send_reply_to', 'smyles_custom_reply_to' );
function smyles_custom_reply_to( $reply_to ){
return '[email protected]';
}
@tripflex
tripflex / functions.php
Created February 20, 2024 21:15
Disable translatepress/translation of S&F fields from backend
<?php
add_filter( 'search_and_filtering_fields_translate_fields', 'smyles_skip_translate_fields' );
function smyles_skip_translate_fields( $fields ){
return array();
}
@tripflex
tripflex / functions.php
Created January 8, 2024 22:34
Auto populate a field based on user logged in status when using WP Job Manager Field Editor
<?php
add_filter( 'field_editor_auto_populate_is_user_logged_in', 'smyles_is_user_logged_in_populate' );
function smyles_is_user_logged_in_populate( $value ){
return is_user_logged_in() ? 1 : 0;
}
@tripflex
tripflex / functions.php
Created January 4, 2024 22:21
Only output Remote label without Google Map Link when remote position and using WP Job Manager Field Editor
<?php
add_filter( 'the_job_location_map_link', 'smyles_disable_output_remote_location_link', 9999, 3 );
function smyles_disable_output_remote_locations( $link, $location, $post ){
if( $post->_remote_position ){
return apply_filters( 'the_job_location_anywhere_text', __( 'Remote', 'wp-job-manager' ) );
}
return $link;
@tripflex
tripflex / functions.php
Created December 27, 2023 21:00
Field editor format output using comma instead of period, and vice versa
<?php
add_filter('field_editor_get_custom_field_listing_meta', 'format_job_price_for_germany', 10, 4);
function format_job_price_for_germany($field_value, $field_slug, $listing_id, $args) {
// Check if the field slug is 'job_price'
if ($field_slug == 'job_price') {
// Ensure the field value is not empty and is a numeric value
if (!empty($field_value) && is_numeric($field_value)) {
// Format the number to German standards: comma for decimal and period for thousands