Skip to content

Instantly share code, notes, and snippets.

@danjjohnson
danjjohnson / gist:7bcadb2d30fb28c72df88a5d8e1a9daa
Created December 4, 2019 15:27
WPJM Applications: Change posts per page for past applications shortcode
add_filter( 'job_manager_job_applications_past_args', 'change_past_application_args');
function change_past_application_args( $args ) {
$args['posts_per_page'] = 5; // Number of past applications to display on each page.
$args['offset'] = ( max( 1, get_query_var( 'paged' ) ) - 1 ) * $args['posts_per_page'];
return $args;
}
@danjjohnson
danjjohnson / gist:0104476b2554ed2ac574fb30e1af1f18
Created December 4, 2019 14:49
Change resume permalink base
function change_resume_slug( $args ) {
$args['rewrite']['slug'] = _x( 'cv', 'Resume permalink - resave permalinks after changing this', 'wp_job_manager_resumes' );
return $args;
}
add_filter( 'register_post_type_resume', 'change_resume_slug' );
@danjjohnson
danjjohnson / gist:5ab128f246e7af26fba5b097717c7dab
Created December 3, 2019 14:03
WPJM: Show hidden WooCommerce products when selecting a job package
add_filter( 'wcpl_get_job_packages_args', 'bk_show_hidden_job_packages');
function bk_show_hidden_job_packages( $args ) {
unset( $args['tax_query'][1] );
return $args;
}
@danjjohnson
danjjohnson / functions.php
Created October 16, 2019 07:49
Change the default Job Type in job submission form
add_filter( 'submit_job_form_fields', 'custom_submit_job_form_fields' );
function custom_submit_job_form_fields( $fields ) {
$fields['job']['job_type']['default'] = "freelance";
return $fields;
}
@danjjohnson
danjjohnson / gist:142e2f94be95b6a2b2f758164d3dc71c
Last active September 29, 2019 08:51
Change WC Paid Listings grace period
function job_manager_set_allowed_deletion_period() {
return 3;
}
add_filter( 'job_manager_job_listing_allowed_deletion_period', 'job_manager_set_allowed_deletion_period' );
@danjjohnson
danjjohnson / applications-recaptcha
Created September 9, 2019 15:18
Add recaptcha support for WPJM Applications.
<?php
// Define your keys here
define( 'RECAPTCHA_SITE_KEY', 'XXX' );
define( 'RECAPTCHA_SECRET_KEY', 'XXX' );
// Enqueue Google reCAPTCHA scripts
add_action( 'wp_enqueue_scripts', 'recaptcha_scripts' );
function recaptcha_scripts() {
wp_enqueue_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js' );
add_filter( 'woocommerce_box_office_scan_permission', 'modify_woocommerce_box_office_scan_permission' );
function modify_woocommerce_box_office_scan_permission( $has_permission ) {
// Do any required permission checks here
$has_permission = true;
return $has_permission;
}
@danjjohnson
danjjohnson / gist:887ed4b28dcd9f5963a247539d4fb47a
Created October 19, 2017 16:07
WooCommerce Product Add-ons - Set checkboxes to checked by default
// Set checkboxes to checked by default
jQuery(document).ready(function(){
jQuery('.addon-checkbox').attr( 'checked', 'checked' );
});
@danjjohnson
danjjohnson / gist:cc1d8eea8d9736534bbcd8ae0068644e
Last active June 9, 2017 14:04
Add 'position-filled' body class on filled single listings
add_filter( 'body_class', 'dj_add_position_filled_class' );
function dj_add_position_filled_class( $classes ) {
global $post;
if ( $post->post_type !== 'job_listing' ) {
return $classes;
}
if ( is_position_filled( $post ) ) {
$classes[] = 'position-filled';
}
@danjjohnson
danjjohnson / gist:8424a87c691231d2699b2a9904a3c7af
Created June 8, 2017 13:46
WPJM - change the job-category and job-type slugs
// Change the 'job-category' slug
add_filter( 'register_taxonomy_job_listing_category_args', 'change_job_listing_category_rewrite' );
function change_job_listing_category_rewrite( $options ) {
$options['rewrite'] = array(
'slug' => 'industria',
'with_front' => false,
'hierarchical' => false,
);
return $options;