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 March 5, 2026 21:30
Fix Complianz Privacy Suite blocking WP Job Manager Search and Filtering from Working
<?php
add_filter( 'cmplz_whitelisted_script_tags', 'wpjmsf_cmplz_whitelist_script', 9999 );
function wpjmsf_cmplz_whitelist_script( $whitelisted_script_tags ) {
$whitelisted_script_tags[] = 'wpjm-search-filtering';
$whitelisted_script_tags[] = 'wpjmsf_';
return $whitelisted_script_tags;
}
@tripflex
tripflex / functions.php
Last active November 20, 2025 21:51
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 November 17, 2025 21:19
Allow zero (0) value fields in WP Job Manager when using WP Job Manager Field Editor
<?php
add_filter( 'submit_job_form_validate_fields_empty_values', 'smyles_submit_job_form_validate_fields_empty_values', 99, 2);
function smyles_submit_job_form_validate_fields_empty_values( $empty_values, $meta_key ){
// [ '', 0, 0.0, '0', null, false, [] ] is the default value (@see is_empty)
return [ '', 0.0, null, false, [] ];
}
@tripflex
tripflex / functions.php
Last active May 27, 2025 14:35
Programmatically create a WooCommerce Subscription and associated WooCommerce Order
<?php
public function give_user_subscription( $product, $user_id, $note = '' ){
// First make sure all required functions and classes exist
if( ! function_exists( 'wc_create_order' ) || ! function_exists( 'wcs_create_subscription' ) || ! class_exists( 'WC_Subscriptions_Product' ) ){
return false;
}
$order = wc_create_order( array( 'customer_id' => $user_id ) );
@tripflex
tripflex / functions.php
Last active April 29, 2025 14:57
How to add additional email addresses when email is sent to WordPress admin_email option value
<?php
/**
*
* WARNING: this only checks if the email is being sent to the same email as admin_email option.
* If for some reason another email is sent to that same email address, but it's not meant as an "admin email"
* this filter will still add those additional emails, just something to keep in mind.
*/
add_filter( 'wp_mail', 'my_custom_to_admin_emails' );
@tripflex
tripflex / functions.php
Last active March 19, 2025 11:59
WordPress Remove Filter (remove_filter converted to remove_class_filter) to remove Filter/Action without Class Object access. Works with WordPress 1.2+ (4.7+ support added 9-19-2016)
<?php
/**
* Make sure the function does not exist before defining it
*/
if( ! function_exists( 'remove_class_filter' ) ){
/**
* Remove Class Filter Without Access to Class Object
*
* In order to use the core WordPress remove_filter() on a filter added with the callback
@tripflex
tripflex / functions.php
Last active January 31, 2025 22:39
Change default Company Logo in WP Job Manager
<?php
// ^ there should only be one of these at the top of your child theme's functions.php file
add_filter( 'job_manager_default_company_logo', 'smyles_custom_job_manager_logo' );
function smyles_custom_job_manager_logo( $logo_url ){
// Change the value below to match the filename of the custom logo you want to use
// Place the file in a /images/ directory in your child theme's root directory.
// The example provided assumes "/images/custom_logo.png" exists in your child theme
@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
Last active January 26, 2025 09:22
How to remove default company fields from WP Job Manager (this example for Listify)
<?php
// Add your own function to filter the fields
add_filter( 'submit_job_form_fields', 'remove_listify_submit_job_form_fields', 9999999999 );
// This is your function which takes the fields, modifies them, and returns them
// You can see the fields which can be changed here: https://github.com/mikejolley/WP-Job-Manager/blob/master/includes/forms/class-wp-job-manager-form-submit-job.php
function remove_listify_submit_job_form_fields( $fields ) {
if( ! isset( $fields['company'] ) ) return $fields;
@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 );