Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Last active November 26, 2023 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfontjr/a642260c1a4a76a75118945d6f8d285e to your computer and use it in GitHub Desktop.
Save vfontjr/a642260c1a4a76a75118945d6f8d285e to your computer and use it in GitHub Desktop.
<?php
/*
Template Name: Developer Content
Template Post Type: post
*/
/**
* Genesis Framework.
*
*
*
* @package Masterminds\Templates
* @author Victor Font Consulting Group, LLC.
* @license GPL-2.0-or-later
*
* retrieve and display the content from the Developers Directory entry based on the post's id
*/
/* disaable wautop to prevent Formidable views from displaying incorrectly
* when displayed in a post
*/
remove_filter( 'the_content', 'wpautop' );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
add_action( 'genesis_entry_content', 'masterminds_display_developer_details' );
/**
* masterminds_get_directory_entry function.
*
* @access public
* @return false or directory entry with meta
*/
function masterminds_get_directory_entry_id() {
global $post;
$post_id = $post->ID;
$entry_id = masterminds_get_entry_id_by_post_id( $post_id );
if ( !$entry_id ) {
return false;
}
return $entry_id;
}
/**
* masterminds_get_entry_id_by_post_id function.
*
* @access public
* @param numeric $post_author(user id)
* @return false or directory entry id
*/
function masterminds_get_entry_id_by_post_id( $post_id ) {
global $wpdb;
/* create the variables for the formidable tables */
$wpdb_prefix = $wpdb->prefix;
$frm_items_table = $wpdb_prefix . 'frm_items';
/* always retrieve IDs by keys for software portability */
$form_id = FrmForm::get_id_by_key("masterminds-directory");
$sql = "SELECT id from `{$frm_items_table}` WHERE `post_id` = {$post_id} AND `form_id` = {$form_id"};
$results = $wpdb->get_var( $sql );
if ( null !== $results ) {
return $results;
} else {
return false;
}
}
function masterminds_display_developer_details() {
$entry_id = masterminds_get_directory_entry_id();
if (!$entry_id ) {
return;
}
echo FrmProDisplaysController::get_shortcode( array( 'id' => 6096, 'filter' => 'limited', 'entry' => $entry_id, 'wautop' => 0 ) );
}
// This file handles single entries, but only exists for the sake of child theme forward compatibility.
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment