What are your /app/ drop-ins?

sage9

#1

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?


#2

Advanced Custom Fields

I always need to set a local json directory so that I can track my ACF fields in Git. Here’s an easy drop-in for that:


#3

The Events Calendar

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.


#4

BEM menuwalker

I have a basic BEM(V) menu walker that I just leave at my app directory.


#5

@MWDelaney not using acf-builder? :crying_cat_face:

P.S. my directives are a mess. I was going to redo them once Sage is updated to 5.5 for ->if()


#6

My walker I use for Bulma inspired by @QWp6t 's walker.

Bonus tinymce.js with some examples for use with tinymce.php


#7

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'];
    }
}

Usage

get_post_ID('your-post-slug');
get_post_ID('your-review-slug', 'review');
get_post_ID(14);
get_post_ID();`

#8

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.

Here’s two different Woocommerce examples:


#9

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).

Anyway, hope it’s useful.