'; 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 '

'; } ?>

Drop-Down Post List v

For information and updates, please visit:
/articles/drop-down-post-list-plugin-for-wordpress/

">

Options

Form Type   />   Jump menu
/>   List with button
Default Option  
If entered, this will be the default list option (does not link to anything)
Button Text  
Button is only shown if using 'list with button' form type
Sorting Method   />   By date - newest first
/>   By date - oldest first
/>   By title
Post Limit  
Limits the number of posts in the list (0 = no limit)
Add Before Form  
Code to display before the form
Add After Form  
Code to display after the form
Add Before List  
Code to display before the list
Add After List  
Code to display after the list
prefix; // Currently using a work-around for the version system // determines if pre or post 2.3 from wp_term_taxonomy $ver = 2.2; $wpv = $wpdb->get_results("show tables like '{$tp}term_taxonomy'"); if (count($wpv) > 0) { $ver = 2.3; } $ddpl_type = get_option('ddpl_type'); $ddpl_button = trim(get_option('ddpl_button')); $ddpl_default = stripslashes(trim(get_option('ddpl_default'))); $ddpl_sort = get_option('ddpl_sort'); $ddpl_limit = (int)get_option('ddpl_limit'); $ddpl_before_form = stripslashes(get_option('ddpl_before_form')); $ddpl_after_form = stripslashes(get_option('ddpl_after_form')); $ddpl_before_list = stripslashes(get_option('ddpl_before_list')); $ddpl_after_list = stripslashes(get_option('ddpl_after_list')); $t_out = ''; $table_prefix = $wpdb->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) { $cat_sel_code = ' '; if (!$all_cats) { $cat_sel_code = " AND {$table_prefix}post2cat.category_id = {$catID} "; } $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 {$cat_sel_code} AND post_status = 'publish' AND post_type != 'page' {$sort_code} {$limit_code} "); } else { // post 2.3 $cat_sel_code = ' '; if (!$all_cats) { $cat_sel_code = " AND {$table_prefix}term_taxonomy.term_id = {$catID} "; } $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' {$cat_sel_code} AND post_status = 'publish' AND post_type != 'page' {$sort_code} {$limit_code} "); } // use random ID when showing all if ($all_cats) { $randstr = ''; $maxchar = 8; $chars = str_shuffle('abcdef1234567890'); $len = strlen($chars); for ($i = 0; $i < $maxchar; $i++) { $randstr .= $chars[mt_rand(0, $len-1)]; } $catID = $randstr; } if ($ddpl_type == 'jump') { $t_out .= '
'; $t_out .= $ddpl_before_list; $t_out .= ''; $t_out .= $ddpl_after_list; $t_out .= '
'; } else { $t_out .= '
'; $t_out .= $ddpl_before_list; $t_out .= ''; $t_out .= $ddpl_after_list; $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'); ?>