I’ve been using a plugin on WordPress that has been working for months. Suddenly I am seeing this error code:
Fatal error: Call to undefined function sb_get_single_sermon() in /home/drcraigjohnson/public_html/wp-content/plugins/sermon-browser/sermon.php on line 508
I found where this is being called in sermon.php:
/**
* Create the shortcode handler
*
* Standard shortcode handler that inserts the sermonbrowser output into the post/page
*
* @param array $atts
* @param string $content
* @return string
*/
function sb_shortcode($atts, $content=null) {
global $wpdb, $record_count, $sermon_domain;
ob_start();
$atts = shortcode_atts(array(
'filter' => sb_get_option('filter_type'),
'filterhide' => sb_get_option('filter_hide'),
'id' => isset($_REQUEST['sermon_id']) ? $_REQUEST['sermon_id'] : '',
'preacher' => isset($_REQUEST['preacher']) ? $_REQUEST['preacher'] : '',
'series' => isset($_REQUEST['series']) ? $_REQUEST['series'] : '',
'book' => isset($_REQUEST['book']) ? stripslashes($_REQUEST['book']) : '',
'service' => isset($_REQUEST['service']) ? $_REQUEST['service'] : '',
'date' => isset($_REQUEST['date']) ? $_REQUEST['date'] : '',
'enddate' => isset($_REQUEST['enddate']) ? $_REQUEST['enddate'] : '',
'tag' => isset($_REQUEST['stag']) ? stripslashes($_REQUEST['stag']) : '',
'title' => isset($_REQUEST['title']) ? stripslashes($_REQUEST['title']) : '',
'limit' => '0',
'dir' => isset($_REQUEST['dir']) ? stripslashes($_REQUEST['dir']) : '', ),
$atts);
if ($atts['id'] != '') {
if (strtolower($atts['id']) == 'latest') {
$atts['id'] = '';
$wpdb->query('SET SQL_BIG_SELECTS=1');
$query = $wpdb->get_results(sb_create_multi_sermon_query($atts, array(), 1, 1));
$atts['id'] = $query[0]->id;
}
$sermon = sb_get_single_sermon((int) $atts['id']);
if ($sermon)
eval('?>'.sb_get_option('single_output'));
else {
echo "<div class="sermon-browser-results"><span class="error">";
_e ('No sermons found.', $sermon_domain);
echo "</span></div>";
}
} else {
if (isset($_REQUEST['sortby']))
$sort_criteria = esc_sql($_REQUEST['sortby']);
else
$sort_criteria = 'm.datetime';
if (!empty($atts['dir']))
$dir = esc_sql($atts['dir']);
elseif ($sort_criteria == 'm.datetime')
$dir = 'desc';
else
$dir = 'asc';
$sort_order = array('by' => $sort_criteria, 'dir' => $dir);
if (isset($_REQUEST['pagenum']))
$page = $_REQUEST['pagenum'];
else
$page = 1;
$hide_empty = sb_get_option('hide_no_attachments');
$sermons = sb_get_sermons($atts, $sort_order, $page, (int)$atts['limit'], $hide_empty);
$output = '?>'.sb_get_option('search_output');
eval($output);
}
$content = ob_get_contents();
ob_end_clean();
return $content;
}
It’s being called from a file called frontend.php. Here is that code:
//Gets single sermon from the database
function sb_get_single_sermon($id) {
global $wpdb;
$id = (int) $id;
$sermon = $wpdb->get_row("SELECT m.id, m.title, m.datetime, m.start, m.end, m.description, p.id as pid, p.name as preacher, p.image as image, p.description as preacher_description, s.id as sid, s.name as service FROM {$wpdb->prefix}sb_sermons as m, {$wpdb->prefix}sb_preachers as p, {$wpdb->prefix}sb_services as s where m.preacher_id = p.id and m.service_id = s.id and m.id = {$id}");
$series = $wpdb->get_row("SELECT ss.id as ssid, ss.name as series FROM {$wpdb->prefix}sb_sermons as m, {$wpdb->prefix}sb_series as ss WHERE m.series_id = ss.id and m.id = {$id}");
if ($sermon) {
if ($series) {
$sermon->series = $series->series;
$sermon->ssid = $series->ssid;
}
else {
$sermon->series = '';
$sermon->ssid = 0;
}
$file = $code = $tags = array();
$stuff = $wpdb->get_results("SELECT f.id, f.type, f.name FROM {$wpdb->prefix}sb_stuff as f WHERE sermon_id = $id ORDER BY id desc");
$rawtags = $wpdb->get_results("SELECT t.name FROM {$wpdb->prefix}sb_sermons_tags as st LEFT JOIN {$wpdb->prefix}sb_tags as t ON st.tag_id = t.id WHERE st.sermon_id = {$sermon->id} ORDER BY t.name asc");
foreach ($rawtags as $tag) {
$tags[] = $tag->name;
}
foreach ($stuff as $cur)
${$cur->type}[] = $cur->name;
$sermon->start = unserialize($sermon->start);
$sermon->end = unserialize($sermon->end);
return array(
'Sermon' => $sermon,
'Files' => $file,
'Code' => $code,
'Tags' => $tags,
);
} else
return false;
}
I have tried copying / pasting the function directly into admin.php but that breaks because it’s declaring the function twice. So that tells me it’s being called, but not recognized.. I think. Any help is appreciated!