Source: front/third-parties/wp-job-manager.php

<?php if ( ! defined( 'ABSPATH' ) ) {
	die( 'Cheatin&#8217; uh?' );
}

/**
 * Specific code for compatibility with WP Job Manager
 * @see https://wordpress.org/plugins/wp-job-manager/
 */

/**
 * Whether the WP Job Manager integration is active.
 *
 * @return (boolean)
 * @since  2.4.0
 */
function jsps_wpjm_integration_enabled() {
	/**
	 * Enables the WP Job Manager integration: on single job listings, the buttons are printed
	 * by the `single_job_listing_start` and `single_job_listing_end` WP Job Manager hooks
	 * instead of the `the_content` filter.
	 *
	 * @hook jsps_wpjm_integration
	 *
	 * @since  2.4.0 First version
	 * @param  {boolean} $enabled=true `false` to handle job listings like any other content.
	 * @return {boolean}
	 */
	return class_exists( 'WP_Job_Manager' ) && apply_filters( 'jsps_wpjm_integration', true );
}

/**
 * Whether WP Job Manager renders the current single job listing content (and fires its hooks).
 * In that case, the `the_content` filter must not add the buttons: they would be printed twice.
 *
 * @return (boolean)
 * @since  2.4.0
 */
function jsps_wpjm_handles_current_content() {
	return jsps_wpjm_integration_enabled()
		&& is_singular( 'job_listing' )
		&& in_the_loop()
		&& 'job_listing' === get_post_type()
		&& ! ( post_password_required() && ! is_super_admin() );
}

/**
 * Prints the buttons only once per job listing and position, whatever the hooks order.
 *
 * @param  (string) $position `start` or `end`.
 * @return (boolean) `true` if they have not been printed yet.
 * @since  2.4.0
 */
function jsps_wpjm_first_print( $position ) {
	static $printed = array();

	$key = get_the_ID() . '-' . $position;

	if ( isset( $printed[ $key ] ) ) {
		return false;
	}

	$printed[ $key ] = true;

	return true;
}

/**
 * Manage the printing of the buttons to the WP Job Manager content before the content.
 *
 * @author Geoffrey Crofte
 * @since 2.3.0
 * @return (string) The button printed if the right settings are applied.
 */
function nobs_include_buttons_at_start() {

	if ( ! jsps_wpjm_integration_enabled() || ! jsps_wpjm_first_print( 'start' ) ) {
		return;
	}

	$juiz_sps_options = jsps_get_option();

	// Don't go further if the display for this CPT isn't activated.
	if ( !isset( $juiz_sps_options['juiz_sps_display_in_types'] ) || ( isset($juiz_sps_options['juiz_sps_display_in_types']) && ! in_array( 'job_listing', $juiz_sps_options['juiz_sps_display_in_types'] ))) {
		return;
	}

	// Don't go further if the option doesn't include Both or Top for the display.
	$juiz_sps_display_where = isset( $juiz_sps_options['juiz_sps_display_where'] ) ? $juiz_sps_options['juiz_sps_display_where'] : '';
	if ( 'top' !== $juiz_sps_display_where && 'both' !== $juiz_sps_display_where ) {
		return;
	}

	$need_counters = $juiz_sps_options['juiz_sps_counter'] ? 1 : 0;

	$jsps_links = get_juiz_sps( array(), $need_counters );

	/**
	 * Allows you to do something before the concatenation with the post content. 
	 * 
	 * @hook juiz_sps_before_content_concat
	 *
	 * @since  2.0.0 First version
	 *
	 * @param  {string} $jsps_links              The HTML for all the front buttons.
	 * @param  {string} $juiz_sps_display_where  A keyword among `top`, `bottom` and `both`.
	 * @param  {string} $juiz_sps_options        All the plugin's options.
	 */
	do_action( 'juiz_sps_before_content_concat', $jsps_links, $juiz_sps_display_where, $juiz_sps_options );

	/**
	 * Allows you to filter the content printed before the WP Job Manager Content 
	 * 
	 * @hook juiz_sps_before_printing_to_wp_job_manager_start
	 *
	 * @since  2.3.0 First version
	 *
	 * @param  {string} $jsps_links              The HTML for all the front buttons.
	 * @param  {string} $juiz_sps_options        All the plugin's options.
	 */
	echo apply_filters( 'juiz_sps_before_printing_to_wp_job_manager_start', $jsps_links, $juiz_sps_options);
}
add_action('single_job_listing_start', 'nobs_include_buttons_at_start');

/**
 * Manage the printing of the buttons to the WP Job Manager content after the content.
 *
 * @author Geoffrey Crofte
 * @since 2.3.0
 * @return (string) The button printed if the right settings are applied.
 */
function nobs_include_buttons_at_end() {

	if ( ! jsps_wpjm_integration_enabled() || ! jsps_wpjm_first_print( 'end' ) ) {
		return;
	}
	$juiz_sps_options = jsps_get_option();

	// Don't go further if the display for this CPT isn't activated.
	if ( !isset( $juiz_sps_options['juiz_sps_display_in_types'] ) || ( isset($juiz_sps_options['juiz_sps_display_in_types']) && ! in_array( 'job_listing', $juiz_sps_options['juiz_sps_display_in_types'] ))) {
		return;
	}

	// Don't go further if the option doesn't include Both or Top for the display.
	$juiz_sps_display_where = isset( $juiz_sps_options['juiz_sps_display_where'] ) ? $juiz_sps_options['juiz_sps_display_where'] : '';
	if ( 'bottom' !== $juiz_sps_display_where && 'both' !== $juiz_sps_display_where ) {
		return;
	}

	$need_counters = $juiz_sps_options['juiz_sps_counter'] ? 1 : 0;

	$jsps_links = get_juiz_sps( array(), $need_counters );

	/**
	 * Allows you to do something before the concatenation with the post content. 
	 * 
	 * @hook juiz_sps_before_content_concat
	 *
	 * @since  2.0.0 First version
	 *
	 * @param  {string} $jsps_links              The HTML for all the front buttons.
	 * @param  {string} $juiz_sps_display_where  A keyword among `top`, `bottom` and `both`.
	 * @param  {string} $juiz_sps_options        All the plugin's options.
	 */
	do_action( 'juiz_sps_before_content_concat', $jsps_links, $juiz_sps_display_where, $juiz_sps_options );

	/**
	 * Allows you to filter the content printed after the WP Job Manager Content 
	 * 
	 * @hook juiz_sps_before_printing_to_wp_job_manager_end
	 *
	 * @since  2.3.0 First version
	 *
	 * @param  {string} $jsps_links              The HTML for all the front buttons.
	 * @param  {string} $juiz_sps_options        All the plugin's options.
	 */
	echo apply_filters( 'juiz_sps_before_printing_to_wp_job_manager_end', $jsps_links, $juiz_sps_options);
}
add_action('single_job_listing_end', 'nobs_include_buttons_at_end');