Skip to content

Instantly share code, notes, and snippets.

@kraftbj
kraftbj / functions.php
Created September 24, 2015 21:32
Count of job listings in WP Job Manager
<?php // remove in an existing file
$count_posts = wp_count_posts( 'job_listing' );
echo $count_posts->publish;
@kraftbj
kraftbj / functions.php
Last active December 3, 2024 16:19
Add editor role to WPJM
<?php
/*
Plugin Name: Add Editor to WPJM Management
Plugin URI: http://wpjobmanager.com
Description: Custom plugin to add the editor to WPJM.
Version: 0.1
Author: Brandon Kraft
Author URI: https://kraft.im/
*/
@kraftbj
kraftbj / functions.php
Created September 22, 2015 15:02
WPJM Change resume submittal notification e-mail addresses
<?php //remove if adding to an existing file.
add_filter( 'resume_manager_new_resume_notification_recipient', 'bk_wpjm_resume_notif_rcpt' );
function bk_wpjm_resume_notif_rcpt( $email ){ // the $email var will be, by default, the admin e-mail set in WP Settings.
$new_rcpts = "[email protected],[email protected],[email protected]";
return $new_rcpts; // Note that this isn't returning the original admin e-mail in this form.
}
@kraftbj
kraftbj / functions.php
Last active September 17, 2015 19:15
Prefill the Locations field for a job posting to a particular town
<?php // remove this line if adding to an existing PHP file.
add_filter('submit_job_form_fields', 'bk_prefill_jobs_location');
function bk_prefill_jobs_location( $fields ) {
$fields['job']['job_location']['value'] = 'Granite Falls, WA';
return $fields;
}
@kraftbj
kraftbj / functions.php
Created September 16, 2015 15:22
Related Posts: Only return posts in same categories
<?php // do not include this line if pasting into an existing php file
// This function will only return posts that are related AND has ALL of the same categories.
function jp_only_rp_in_same_category( $categories, $post_id ) {
$category_objects = get_the_category( $post_id );
if ( ! empty( $categories ) ) {
$categories = array_merge( 'categories', 'category_objects' );
return $categories;
}
@kraftbj
kraftbj / functions.php
Created September 15, 2015 20:15
Improve WPJM search when using Polylang
<?php
/*
Plugin Name: WPJM + Polylang Shiv
Plugin URI: https://kraft.im/
Description: Let's have WP Job Manager return the right jobs based on language, right?
Author: Brandon Kraft
Author URI: https://kraft.im/
Version: 0.1
License: GPL
@kraftbj
kraftbj / var.php
Created August 20, 2015 22:32
Good ole' server variables
<?php
echo "<h1>Your server's port seems to be...</h1>";
echo "<p>" . $_SERVER['SERVER_PORT'] . "</p>";
@kraftbj
kraftbj / disable-math-check.php
Created August 17, 2015 22:22
Force Jetpack Protect to block a suspect IP; disallow the math check
<?php // do not include if pasting in an existing file that already has this.
add_filter( 'jpp_use_captcha_when_blocked', '__return_true');
@kraftbj
kraftbj / functions.php
Created July 3, 2015 19:57
Massively increase timeout time
<?php // don't include this in an existing file
add_filter('http_request_timeout', 'bk_massive_timeout' );
function bk_massive_timeout( $timeout ){
$timeout = 60;
return $timeout;
}
@kraftbj
kraftbj / functions.php
Created June 25, 2015 21:27
Change the width of the gallery widget
// The default is 265px
// this is a simple example to change them all. more options available.
add_filter( 'gallery_widget_content_width', 'bk_change_default_gallery_content_width' );
function bk_change_default_gallery_content_width(){
return 400;
}