';
update_option('ddpl_type', 'jump');
update_option('ddpl_button', 'View');
update_option('ddpl_default', '(select a post)');
update_option('ddpl_sort', 'date_desc');
update_option('ddpl_limit', 0);
update_option('ddpl_before_form', '');
update_option('ddpl_after_form', '');
update_option('ddpl_before_list', '');
update_option('ddpl_after_list', '');
echo 'Default Options Loaded!';
echo '
';
} else if (isset($_POST['info_update'])) {
echo '';
update_option('ddpl_type', (string)$_POST["ddpl_type"]);
update_option('ddpl_button', (string)$_POST["ddpl_button"]);
update_option('ddpl_default', (string)$_POST["ddpl_default"]);
update_option('ddpl_sort', (string)$_POST["ddpl_sort"]);
update_option('ddpl_limit', (int)$_POST["ddpl_limit"]);
update_option('ddpl_before_form', (string)$_POST["ddpl_before_form"]);
update_option('ddpl_after_form', (string)$_POST["ddpl_after_form"]);
update_option('ddpl_before_list', (string)$_POST["ddpl_before_list"]);
update_option('ddpl_after_list', (string)$_POST["ddpl_after_list"]);
echo 'Configuration Updated!';
echo '
';
} ?>
prefix;
$sort_code = 'ORDER BY post_date DESC';
switch ($ddpl_sort) {
case 'date_desc':
$sort_code = 'ORDER BY post_date DESC';
break;
case 'date_asc':
$sort_code = 'ORDER BY post_date ASC';
break;
case 'title':
$sort_code = 'ORDER BY post_title ASC';
break;
}
$limit_code = '';
if ($ddpl_limit > 0) {
$limit_code = ' LIMIT ' . $ddpl_limit;
}
if ($ver < 2.3) {
$post_list = (array)$wpdb->get_results("
SELECT ID, post_title, post_date
FROM {$table_prefix}posts, {$table_prefix}post2cat
WHERE {$table_prefix}posts.ID = {$table_prefix}post2cat.post_id
AND {$table_prefix}post2cat.category_id = {$catID}
AND post_status = 'publish'
AND post_type != 'page'
{$sort_code}
{$limit_code}
");
} else { // post 2.3
$post_list = (array)$wpdb->get_results("
SELECT ID,
post_title,
post_date
FROM {$table_prefix}posts, {$table_prefix}term_relationships, {$table_prefix}term_taxonomy
WHERE {$table_prefix}posts.ID = {$table_prefix}term_relationships.object_id
AND {$table_prefix}term_relationships.term_taxonomy_id = {$table_prefix}term_taxonomy.term_taxonomy_id
AND {$table_prefix}term_taxonomy.taxonomy = 'category'
AND {$table_prefix}term_taxonomy.term_id = {$catID}
AND post_status = 'publish'
AND post_type != 'page'
{$sort_code}
{$limit_code}
");
}
if ($ddpl_type == 'jump') {
$t_out .= '';
} else {
$t_out .= '';
}
return $ddpl_before_form . $t_out . $ddpl_after_form;
}
function ddpl_check($content) {
// remove P tags around html comments (comment out to disable)
$content = preg_replace('/\s*\s*<\/p>/i', "", $content);
$results = array();
preg_match_all("//", $content, $results);
$i = 0;
foreach ($results[0] as $r) {
$content = str_replace($r, ddpl_list($results[1][$i]), $content);
$i++;
}
return $content;
}
function ddpl_head() {
echo "
";
}
add_action('admin_menu', 'ddpl_add_option_pages');
add_filter('the_content', 'ddpl_check');
add_action('wp_head', 'ddpl_head');
?>