<?php

if (!defined('ABSPATH')) {
    exit;
}

add_filter(

    'the_content',

    function($content){

        if (!wnc_is_pro_active()) {

            return $content;

        }

        $options = wnc_get_options();

        if (empty($options['pro_auto_place'])) {

            return $content;

        }

        if (!is_singular()) {

            return $content;

        }

        $post_type = get_post_type();

        $allowed = false;

        if (

            $post_type === 'of5_location'

            && !empty($options['pro_auto_locations'])

        ) {

            $allowed = true;

        }

        if (

            $post_type === 'post'

            && !empty($options['pro_auto_posts'])

        ) {

            $allowed = true;

        }

        if (

            $post_type === 'page'

            && !empty($options['pro_auto_pages'])

        ) {

            $allowed = true;

        }

        if (

            $post_type === 'of5_event'

            && !empty($options['pro_auto_events'])

        ) {

            $allowed = true;

        }

        if (!$allowed) {

            return $content;

        }

        return $content

            . do_shortcode(

                '[where_next_button]'

            );

    },

    99

);