get_results("SELECT DISTINCT series FROM {$wpdb->prefix}buybooks WHERE series NOT LIKE ''", ARRAY_A);
if(@$_REQUEST['btbe_id'] > 0 && @$_REQUEST['realdelete'] == 1) {
$wpdb->delete($wpdb->prefix.'buybooks', array('id' => $_REQUEST['btbe_id']), '%d');
echo '
Book deleted.
Return to the Book List
';
exit;
}
if(@$_REQUEST['btbe_add'] == 1) {
if(empty($_REQUEST['title'])) {
$btbe_message = __("You must enter a title!", 'author-showcase');
}
else {
if(isset($_REQUEST['cover'])) {
$spliturl = parse_url(esc_url($_REQUEST['cover']));
$path = $spliturl['path'];
}
else {
$path = '';
}
$book = array(
'created' => date('Y-m-d H:i:s', time()),
'updated' => date('Y-m-d H:i:s', time()),
'title' => esc_attr(@$_REQUEST['title']),
'subtitle' => isset($_REQUEST['subtitle']) ? esc_attr(@$_REQUEST['subtitle']) : '',
'author' => isset($_REQUEST['author']) ? esc_attr(@$_REQUEST['author']) : '',
'series' => isset($_REQUEST['series']) ? esc_attr(@$_REQUEST['series']) : '',
'series_num' => isset($_REQUEST['series_num']) ? esc_attr(@$_REQUEST['series_num']) : '',
'blurb' => isset($_REQUEST['blurb']) ? esc_textarea(@$_REQUEST['blurb']) : '',
'cover' => $path,
'asin' => isset($_REQUEST['asin']) ? esc_attr(@$_REQUEST['asin']) : '',
'isbn' => isset($_REQUEST['isbn']) ? esc_attr(@$_REQUEST['isbn']) : '',
'book_page' => isset($_REQUEST['book_page']) ? esc_attr(@$_REQUEST['book_page']) : '',
'short_blurb' => isset($_REQUEST['short_blurb']) ? esc_textarea(@$_REQUEST['short_blurb']) : '',
);
$services = array();
foreach ($_REQUEST as $idx => $r) {
if(strpos($idx, 'sername') !== false) {
$int = filter_var($idx, FILTER_SANITIZE_NUMBER_INT);
$name = isset($_REQUEST['sername'.$int]) ? esc_attr(@$_REQUEST['sername'.$int]) : '';
$icon = isset($_REQUEST['sericon'.$int]) ? esc_attr(@$_REQUEST['sericon'.$int]) : '';
$link = isset($_REQUEST['serlink'.$int]) ? esc_url(@$_REQUEST['serlink'.$int]) : '';
$services[] = array(
'name' => $name,
'icon' => $icon,
'link' => $link
);
}
}
$book['services'] = json_encode($services);
if(@$_REQUEST['btbe_id'] != "") {
unset($book['created']);
$wpdb->update($wpdb->prefix.'buybooks', $book, array('id' => esc_sql($_REQUEST['btbe_id'])), array('%s','%s','%s','%s','%s','%s','%s','%s'));
}
else {
$wpdb->insert( $wpdb->prefix.'buybooks', $book, array( '%s','%s','%s','%s','%s','%s','%s','%s','%s' ) );
$_REQUEST['btbe_id'] = $wpdb->insert_id;
}
$btbe_message = __('Book saved!', 'author-showcase').' '.__('Add another or return to the Book List?', 'author-showcase');
}
}
if(@$_REQUEST['btbe_id'] > 0 && !isset($_REQUEST['btbe_add'])) {
$record = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}buybooks WHERE id = '".esc_sql($_REQUEST['btbe_id'])."'", ARRAY_A);
if(!$record) { echo 'Book not found!'; exit; }
$_REQUEST = array_merge($_REQUEST, $record);
$services = json_decode($record['services'], true);
}
?>
Update this Book
Add a Book
0 && @$_REQUEST['delete'] > 0) : ?>