Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Save Resume Meta
*
* @param mixed $post_id
* @param mixed $post
*/
public function save_resume_data( $post_id, $post ) {
global $wpdb;
@danjjohnson
danjjohnson / functions.php
Created June 1, 2016 12:08
WPJM: Unstick featured jobs.
add_filter ( 'get_job_listings_query_args', 'unstick_featured_jobs' );
function unstick_featured_jobs( $query_args ) {
$query_args['orderby'] = 'date';
$query_args['order'] = 'DESC';
return $query_args;
}
@danjjohnson
danjjohnson / functions.php
Last active January 18, 2017 17:04 — forked from bryceadams/gist:ee0a1c65d8ecf6015bb6
WPJM: Send an email to employer when their job is approved.
function listing_published_send_email($post_id) {
if( 'job_listing' != get_post_type( $post_id ) ) {
return;
}
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = "
Hi ".$author->display_name.",
Your listing, ".$post->post_title." has just been approved at ".get_permalink( $post_id ).". Well done!
@danjjohnson
danjjohnson / functions.php
Last active May 26, 2016 08:42
WPJM: Add job type to base URL
function job_listing_post_type_link( $permalink, $post ) {
// Abort if post is not a job
if ( $post->post_type !== 'job_listing' )
return $permalink;
// Abort early if the placeholder rewrite tag isn't in the generated URL
if ( false === strpos( $permalink, '%' ) )
return $permalink;
// Get the custom taxonomy terms in use by this post
@danjjohnson
danjjohnson / functions.php
Created May 23, 2016 13:55
WPJM: Specify language for geolocation
// Add to theme functions.php
add_filter( 'job_manager_geolocation_endpoint', 'change_geocode_lang' );
function change_geocode_lang( $endpoint ) {
// Use language from https://developers.google.com/maps/faq#using-google-maps-apis
return add_query_arg( 'language', 'en-GB', $endpoint );
}
@danjjohnson
danjjohnson / functions.php
Created May 23, 2016 13:46
WPJM - Specify language to use for geocoding
// Add to theme functions.php
add_filter( 'job_manager_geolocation_endpoint', 'change_geocode_lang' );
function change_geocode_lang( $endpoint ) {
// Use language from https://developers.google.com/maps/faq#using-google-maps-apis
return add_query_arg( 'language', 'en-GB', $endpoint );
}
@danjjohnson
danjjohnson / functions.php
Last active February 19, 2017 05:14
WP Job Manager: Append the post id to the permalink slug
function custom_job_post_type_link( $post_id, $post ) {
// don't add the id if it's already part of the slug
$permalink = $post->post_name;
if ( strpos( $permalink, strval( $post_id ) ) ) {
return;
}
// unhook this function to prevent infinite looping
remove_action( 'save_post_job_listing', 'custom_job_post_type_link', 10, 2 );
@danjjohnson
danjjohnson / functions.php
Created April 29, 2016 07:37
WP Job Manager: Send an email to employer when their job listing expires
function listing_expired_send_email($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = "
Hi ".$author->display_name.",
Your listing, ".$post->post_title." has now expired: ".get_permalink( $post_id );
wp_mail($author->user_email, "Your job listing has expired", $message);
}
add_action('expired_job_listing', 'listing_expired_send_email');
@danjjohnson
danjjohnson / functions.php
Last active April 27, 2016 15:30
WP Job Manager: Remove default values from job permalink slug
// Remove company name
add_filter( 'submit_job_form_prefix_post_name_with_company', '__return_false' );
// Remove location
add_filter( 'submit_job_form_prefix_post_name_with_location', '__return_false' );
// Remove job type
add_filter( 'submit_job_form_prefix_post_name_with_job_type', '__return_false' );
@danjjohnson
danjjohnson / content-single-job_listing.php
Created April 26, 2016 10:21
WP Job Manager: Password protect all content on single job page
<?php global $post; ?>
<div class="single_job_listing" itemscope itemtype="http://schema.org/JobPosting">
<meta itemprop="title" content="<?php echo esc_attr( $post->post_title ); ?>" />
<?php if ( get_option( 'job_manager_hide_expired_content', 1 ) && 'expired' === $post->post_status ) : ?>
<div class="job-manager-info"><?php _e( 'This listing has expired.', 'wp-job-manager' ); ?></div>
<?php else : ?>
<?php
/**
* single_job_listing_start hook