Hi there,
I find myself frequently reusing plugin-specific drop-ins in /app/, and I was inspired by this thread to share some of them here.
I’m going to share some of the /app/ additions I find myself reusing on a regular basis. Do you split up functionality this way? If so, what do you reuse a lot?
The Sage default template doesn’t play nice with The Events Calendar’s defaults, so I create a new custom template and force the selection of it using this.
I also usually want my wp_nav_menu item to correctly highlight as an ancestor when viewing an Event. This takes care of that, too.
I have a lot of helpers, but I use this one a good bit for shortcodes (such as specifying an argument to grab data from a different post via ID or slug) as well as getting the current page being edited in the backend.
/**
* Simple function to potentially get a post ID if $post is null
*
* @param mixed $post
* @param string $post_type
* @return int
*/
function get_post_ID($post = '', $post_type = 'post')
{
if (!empty($post) && !is_numeric($post)) {
if ($post = get_page_by_path($post, OBJECT, $post_type)) {
return $post->ID;
}
}
if (!empty($post) && is_numeric($post)) {
return $post;
}
if (!empty(get_the_ID())) {
return get_the_ID();
}
if (!empty($_GET['post']) && is_numeric($_GET['post'])) {
return (int)$_GET['post'];
}
}
I don’t have time to clean this up and organize it right now. But I figured I’ll drop it here and probably come back and clean it up, add more comments, and combine at a later date.
I find myself needing to do “Careers” listings more and more often, and WP Job Manager is a GREAT tool for this. The only problem is it doesn’t directly integrate with Formidable, my forms tool of choice, for applications.
So I dug into its hooks and came up with this:
It requires ACF and Formidable. It creates a WP Options page under the WP Job Manager menu which lets you choose a form.
It does NOT (currently) let you use the WP Job Manager “email” field to override the “send to” address in Formidable (most of my clients aren’t listing other peoples’ jobs, they just want to get applications for their own at careers@theirdomain.com or whatever, so I just haven’t needed to get this working yet).