0) { $ipp_check = $_POST["ddsg_items_per_page"]; } } update_option('ddsg_items_per_page', (string) $ipp_check); update_option('ddsg_comments_on_posts', (bool) $_POST["ddsg_comments_on_posts"]); update_option('ddsg_comments_on_pages', (bool) $_POST["ddsg_comments_on_pages"]); update_option('ddsg_show_zero_comments', (bool) $_POST["ddsg_show_zero_comments"]); update_option('ddsg_hide_duplicates', (bool) $_POST["ddsg_hide_duplicates"]); update_option('ddsg_blank_title', (bool) $_POST["ddsg_blank_title"]); update_option('ddsg_show_excerpt', (string) $_POST["ddsg_show_excerpt"]); update_option('ddsg_p_or_p_first', (string) $_POST["ddsg_p_or_p_first"]); update_option('ddsg_p_or_p_shown', (string) $_POST["ddsg_p_or_p_shown"]); update_option('ddsg_page_nav', (string) $_POST["ddsg_page_nav"]); update_option('ddsg_page_nav_where', (string) $_POST["ddsg_page_nav_where"]); update_option('ddsg_xml_path', (string) $_POST["ddsg_xml_path"]); update_option('ddsg_xml_where', (string) $_POST["ddsg_xml_where"]); update_option('ddsg_post_sort_order', (string) $_POST["ddsg_post_sort_order"]); update_option('ddsg_page_sort_order', (string) $_POST["ddsg_page_sort_order"]); update_option('ddsg_cat_text', (string) $_POST["ddsg_cat_text"]); update_option('ddsg_first_nc', (string) $_POST["ddsg_first_nc"]); update_option('ddsg_first_nw', (string) $_POST["ddsg_first_nw"]); update_option('ddsg_hide_protected', (bool) $_POST["ddsg_hide_protected"]); update_option('ddsg_sm_name', (string) $_POST["ddsg_sm_name"]); update_option('ddsg_new_window', (bool) $_POST["ddsg_new_window"]); update_option('ddsg_show_post_date', (bool) $_POST["ddsg_show_post_date"]); update_option('ddsg_post_date_format', (string) $_POST["ddsg_post_date_format"]); update_option('ddsg_exclude_cats', (string) $_POST["ddsg_exclude_cats"]); update_option('ddsg_exclude_pages', (string) $_POST["ddsg_exclude_pages"]); update_option('ddsg_continued_msg', (string) $_POST["ddsg_continued_msg"]); update_option('ddsg_xml_text', (string) $_POST["ddsg_xml_text"]); update_option('ddsg_no_title_text', (string) $_POST["ddsg_no_title_text"]); echo "Configuration Updated!"; ?>

Dagon Design Sitemap Generator v2.7

">

For information and new versions, visit this plugin's page.

General Options
Items per page:
Set to 0 for unlimited
If using permalinks, enter slug of sitemap page:
If not using permalinks, leave blank
What to show: />   Show pages and posts
/>   Just show posts
/>   Just show pages
If showing both, which first: />   Posts first
/>   Pages first
Post sort order:
Page sort order:
Show multiple-category posts only in first category: />
For posts without titles: />    Display default title (configure in Language settings below)
Show excerpts:
Open sitemap links in new window: />
Show Extra Information
Show dates after posts: />
Post date format:
Use PHP date() formatting. Default: F jS, Y
Show comment count after posts: />
Show comment count after pages: />
If displaying comment counts, show when zero: />
Exclusions
Exclude categories:
Category slugs, separated by commas
Exclude pages:
Page slugs, separated by commas
(subpages will also be excluded)
Hide password-protected items: />
Navigation
Sitemap navigation method:
Show sitemap navigation:
XML Sitemap Options

   If you use a plugin to generate a XML sitemap, you can have the sitemap display a link to it.

Full path to XML sitemap:
Show the XML sitemap link:
Language Settings

   Some of these settings will only be used if they are needed, based on the options above.

Text to show before categories:
Text to show when continuing:
Text to show for empty post/page titles:
XML sitemap link text:
get_results(" SELECT post_parent FROM {$table_prefix}posts WHERE post_date < NOW() AND post_status != 'draft' AND post_status != 'attachment' AND post_parent != 0 GROUP BY post_parent "); $pid_list = array(); if (!empty($temp_list)) { foreach ($temp_list as $item) { $pid_list[] = $item->post_parent; } } return $pid_list; } // generate category list function ddsg_gen_cat_list() { global $wpdb, $table_prefix, $ddsg_cats, $ddsg_exclude_cats; $c_items = (array)$wpdb->get_results(" SELECT cat_ID, cat_name, category_parent FROM {$table_prefix}categories ORDER BY category_parent, cat_ID "); $cat_count = 0; foreach ($c_items as $c_item) { $ddsg_cats[$cat_count]['id'] = $c_item->cat_ID; $ddsg_cats[$cat_count]['name'] = $c_item->cat_name; $ddsg_cats[$cat_count]['pid'] = $c_item->category_parent; $cat_count++; } } function in_array_i($strItem, $arItems) { $bFound = FALSE; foreach ((array)$arItems as $strValue) { if (strtoupper($strItem) == strtoupper($strValue)) { $bFound = TRUE; } } return $bFound; } // generate list of pages function ddsg_generate_data_pages($id = 0, $level = 0) { global $wpdb, $table_prefix, $ddsg_data, $ddsg_temp_index, $ddsg_page_sort_order, $ddsg_hide_protected, $ddsg_pids, $ddsg_exclude_pages; $extra_checks = ""; if ($ddsg_hide_protected) { $extra_checks = " AND post_password = '' "; } $items = $wpdb->get_results(" SELECT post_title, ID, post_parent, post_name FROM {$table_prefix}posts, {$table_prefix}post2cat, {$table_prefix}categories WHERE post_parent = '$id' AND post_status = 'static' AND ID = {$table_prefix}post2cat.post_id AND {$table_prefix}post2cat.category_id = {$table_prefix}categories.cat_ID AND post_date < NOW() AND post_status != 'draft' AND post_status != 'attachment' $extra_checks ORDER BY {$ddsg_page_sort_order}, cat_name "); if (empty($items)) { return; } $last_pid = 0; foreach ((array)$items as $item) { if (!in_array_i($item->post_name, $ddsg_exclude_pages)) { if ($item->post_parent > $last_pid) { $level = $level + 1; } else if ($item->post_parent < $last_pid) { $level = $level - 1; } $last_pid = $item->post_parent; $ddsg_data[$ddsg_temp_index]['id'] = $item->ID; $ddsg_data[$ddsg_temp_index]['status'] = "static"; $ddsg_data[$ddsg_temp_index]['level'] = $level; $ddsg_data[$ddsg_temp_index]['title'] = $item->post_title; $ddsg_temp_index++; if (in_array((int)$item->ID, (array)$ddsg_pids)) { ddsg_generate_data_pages($item->ID, $level); } } } } // generate list of posts function ddsg_generate_data_posts($id = 0, $level = 0) { global $wpdb, $table_prefix, $ddsg_data, $ddsg_temp_index, $ddsg_post_sort_order; global $ddsg_hide_duplicates, $ddsg_hide_protected, $ddsg_show_post_date, $ddsg_exclude_cats; $extra_checks = ""; if ($ddsg_hide_protected) { $extra_checks = " AND post_password = '' "; } $items = $wpdb->get_results(" SELECT post_title, ID, post_status, cat_ID, post_date, cat_name FROM {$table_prefix}posts, {$table_prefix}post2cat, {$table_prefix}categories WHERE post_parent = '$id' AND post_status != 'static' AND ID = {$table_prefix}post2cat.post_id AND {$table_prefix}post2cat.category_id = {$table_prefix}categories.cat_ID AND post_date < NOW() AND post_status != 'draft' AND post_status != 'attachment' $extra_checks ORDER BY cat_name, {$ddsg_post_sort_order} "); if (empty($items)) { return; } foreach ((array)$items as $item) { $is_dup = 0; if ($ddsg_hide_duplicates) { foreach ($ddsg_data as $d) { if ($d['id'] == $item->ID) { $is_dup = 1; } } } if (!$is_dup) { if (!in_array_i($item->cat_name, $ddsg_exclude_cats)) { $ddsg_data[$ddsg_temp_index]['id'] = $item->ID; $ddsg_data[$ddsg_temp_index]['status'] = $item->post_status; $ddsg_data[$ddsg_temp_index]['cat_id'] = $item->cat_ID; $ddsg_data[$ddsg_temp_index]['title'] = $item->post_title; if ($ddsg_show_post_date) { $ddsg_data[$ddsg_temp_index]['date'] = $item->post_date; } $ddsg_temp_index++; if (in_array((int)$item->ID, (array)$ddsg_pids)) { ddsg_generate_data_posts($item->ID, $level); } } } } } // return number of comments for post or page function ddsg_num_comments($id, $display) { global $wpdb, $table_prefix; global $ddsg_comments_on_pages; global $ddsg_comments_on_posts; global $ddsg_show_zero_comments; if (!$ddsg_comments_on_pages && $display == 'page') return ""; if (!$ddsg_comments_on_posts && $display == 'post') return ""; $num = $wpdb->get_var(" SELECT COUNT(1) FROM {$table_prefix}comments WHERE comment_post_ID = {$id} AND comment_approved = '1' "); if ($num > 0) { return " (" . $num . ")"; } else if ($ddsg_show_zero_comments) { return " (0)"; } return ""; } function ddsg_get_page_parent($id, $level = 0) { // returns parent name of id (used in processing of data) global $wpdb, $table_prefix, $ddsg_data, $ddsg_new_window; while ($ddsg_data[$id]['level'] != $level) { $id--; } $pid = $ddsg_data[$id]['id']; $result = $wpdb->get_row(" SELECT post_title FROM {$table_prefix}posts WHERE ID = '$pid' "); return '' . $result->post_title . ''; } function get_cat_trail($cat_id) { global $ddsg_cats, $ddsg_new_window, $ddsg_exclude_cats; $output1 = ""; $i = 0; while ($ddsg_cats[$i]['id'] != $cat_id) { $i++; } $pid = $ddsg_cats[$i]['pid']; /* while ($pid > 0) { $i = 0; while ($ddsg_cats[$i]['id'] != $pid) { $i++; } */ if (in_array_i($ddsg_cats[$i]['name'], $ddsg_exclude_cats)) { $output1 = "(hidden) » " . $output1; } else { $output1 = '' . $ddsg_cats[$i]['name'] . ' ' . $output1; } /* $pid = $ddsg_cats[$i]['pid']; } */ return $output1; } function ddsg_get_title($i) { global $ddsg_data; global $ddsg_blank_title; global $ddsg_show_excerpt; global $wpdb; global $table_prefix; global $ddsg_first_nc; global $ddsg_first_nw; global $ddsg_no_title_text; $tt = ""; // There is a title if (strlen($ddsg_data[$i]['title']) > 0) { $tt .= $ddsg_data[$i]['title']; } else { if ($ddsg_blank_title) { $tt .= $ddsg_no_title_text; } } switch ($ddsg_show_excerpt) { case 'excerptc': $the_text = $wpdb->get_var("SELECT post_content FROM " . $table_prefix . "posts WHERE ID=" . $ddsg_data[$i]['id']); $tt .= ' - ' . substr(strip_tags(trim($the_text)) , 0, $ddsg_first_nc) . "... "; break; case 'excerptw': $the_text = $wpdb->get_var("SELECT post_content FROM " . $table_prefix . "posts WHERE ID=" . $ddsg_data[$i]['id']); $the_text = strip_tags(trim($the_text)); $t_array = explode(" ", $the_text, $ddsg_first_nw + 1); $t_output = NULL; for ($n = 0; $n < $ddsg_first_nw; $n++) { if ($t_array[$n]) { $t_output .= $t_array[$n] . " "; } } $tt .= ' - ' . $t_output . "... "; break; } return $tt; } function ddsg_process_data($data1, $limit, $offset) { global $ddsg_data; global $ddsg_comments_on_posts; global $ddsg_comments_on_pages; global $ddsg_cat_text; global $ddsg_new_window; global $ddsg_show_post_date; global $ddsg_post_date_format; global $ddsg_continued_msg; $last_cat = 0; $last_id = 0; $first_page = 1; $last_cp = ""; $data1 = NULL; $start_item = $offset; $end_item = $offset + $limit; if (($limit == 0) || ($end_item > count($ddsg_data))) { $end_item = count($ddsg_data); } $data1 .= '
"; } } // Get previous / current levels $c_level = $ddsg_data[$i]['level']; if (($i > $start_item) && ($i > 0)) { $p_level = $ddsg_data[$i - 1]['level']; } else { $p_level = 0; } // List pages if ($ddsg_data[$i]['status'] == 'static') { if (($i == $start_item) && ($c_level > 0)) { $data1 .= "
  • " . ddsg_get_page_parent($i). " " . $ddsg_continued_msg; } if ($c_level > $p_level) { for ($n = 1; $n < ($c_level - $p_level); $n++) { $data1 .= "
  • "; } } else if ($ddsg_data[$i + 1]['status'] != 'static') { $data1 .= ""; for ($n = 0; $n < $c_level; $n++) { $data1 .= ""; } } } } $data1 .= "
    "; return $data1; } function ddsg_generate_nav($total_pages, $start_page) { global $wp_query; global $ddsg_page_nav; global $ddsg_sm_name; $output1 = NULL; // permalinks enabled if (strlen($ddsg_sm_name) > 0) { $the_url = get_bloginfo('url'); if ($the_url{strlen($the_url)-1} != "/") { $the_url = $the_url . "/" . $ddsg_sm_name . "/"; } if ($total_pages > 1) { if ($ddsg_page_nav == 1) { $output1 .= "

    Page " . $start_page . " of " . $total_pages; if ($start_page > 1) { $output1 .= ' : Previous Page'; } if ($start_page < $total_pages) { $output1 .= ' : Next Page'; } $output1 .= "

    "; } else if ($ddsg_page_nav == 2) { $output1 .= '

    Pages: '; for ($i = 1; $i <= $total_pages; $i++) { if ($i == $start_page) { $output1 .= $i . " "; } else { $output1 .= '' . $i . ' '; } } $output1 .= "

    "; } } } else { // permalinks not enabled $the_url = get_bloginfo('url'); if ($the_url{strlen($the_url)-1} != "/") { $the_url = $the_url . "/index.php"; } if ($total_pages > 1) { if ($ddsg_page_nav == 1) { $output1 .= '

    Page ' . $start_page . ' of ' . $total_pages; if ($start_page > 1) { $output1 .= ' : Previous Page'; } if ($start_page < $total_pages) { $output1 .= ' : Next Page'; } $output1 .= "

    "; } else if ($ddsg_page_nav == 2) { $output1 .= '

    Pages: '; for ($i = 1; $i <= $total_pages; $i++) { if ($i == $start_page) { $output1 .= $i . " "; } else { $output1 .= '' . $i . ' '; } } $output1 .= "

    "; } } } return $output1; } function ddsg_permalinks($rules) { global $wp_rewrite, $ddsg_sm_name; $ddsg_sm_name = get_option('ddsg_sm_name'); if ($wp_rewrite->use_verbose_rules || !isset($wp_rewrite->use_verbose_rules)) { $match_form = '$1'; } else { $match_form = '$matches[1]'; } if ($ddsg_sm_name) { $newrules[$ddsg_sm_name . '/?([0-9]{1,})/?$'] = 'index.php?&pagename=' . $ddsg_sm_name . '&pg=' . $match_form; $newrules = array_merge($newrules,$rules); return $newrules; } else { return $rules; } } function ddsg_query_vars ( $vars ) { $vars[] = "pg"; return $vars; } function ddsg_create_sitemap() { global $ddsg_show_zero_comments; global $ddsg_comments_on_posts; global $ddsg_comments_on_pages; global $ddsg_page_nav; global $ddsg_blank_title; global $ddsg_show_excerpt; global $ddsg_post_sort_order; global $ddsg_page_sort_order; global $ddsg_cat_text; global $ddsg_hide_duplicates; global $ddsg_first_nc; global $ddsg_first_nw; global $ddsg_hide_protected; global $ddsg_sm_name; global $ddsg_new_window; global $ddsg_show_post_date; global $ddsg_post_date_format; global $ddsg_p_or_p_shown; global $ddsg_exclude_cats; global $ddsg_exclude_pages; global $ddsg_continued_msg; global $ddsg_no_title_text; global $ddsg_data; global $ddsg_cats; global $ddsg_temp_index; global $ddsg_pids; $ddsg_items_per_page = get_option('ddsg_items_per_page'); $ddsg_p_or_p_first = get_option('ddsg_p_or_p_first'); $ddsg_p_or_p_shown = get_option('ddsg_p_or_p_shown'); $ddsg_comments_on_posts = get_option('ddsg_comments_on_posts'); $ddsg_comments_on_pages = get_option('ddsg_comments_on_pages'); $ddsg_show_zero_comments = get_option('ddsg_show_zero_comments'); $ddsg_hide_duplicates = get_option('ddsg_hide_duplicates'); $ddsg_xml_path = get_option('ddsg_xml_path'); $ddsg_xml_where = get_option('ddsg_xml_where'); $ddsg_page_nav = get_option('ddsg_page_nav'); $ddsg_page_nav_where = get_option('ddsg_page_nav_where'); $ddsg_blank_title = get_option('ddsg_blank_title'); $ddsg_show_excerpt = get_option('ddsg_show_excerpt'); $ddsg_post_sort_order = get_option('ddsg_post_sort_order'); $ddsg_page_sort_order = get_option('ddsg_page_sort_order'); $ddsg_cat_text = get_option('ddsg_cat_text'); $ddsg_first_nc = get_option('ddsg_first_nc'); $ddsg_first_nw = get_option('ddsg_first_nw'); $ddsg_hide_protected = get_option('ddsg_hide_protected'); $ddsg_sm_name = get_option('ddsg_sm_name'); $ddsg_new_window = get_option('ddsg_new_window'); $ddsg_show_post_date = get_option('ddsg_show_post_date'); $ddsg_post_date_format = get_option('ddsg_post_date_format'); $ddsg_exclude_cats = get_option('ddsg_exclude_cats'); $ddsg_exclude_pages = get_option('ddsg_exclude_pages'); $ddsg_continued_msg = get_option('ddsg_continued_msg'); $ddsg_xml_text = get_option('ddsg_xml_text'); $ddsg_no_title_text = get_option('ddsg_no_title_text'); $ddsg_data = array(array()); $ddsg_cats = array(array()); $ddsg_temp_index = 0; // turn options into useable ones if (trim($ddsg_exclude_pages)) { $ddsg_exclude_pages = (array)split(",", $ddsg_exclude_pages); for ($i = 0; $i < sizeof($ddsg_exclude_pages); $i++) { $ddsg_exclude_pages[$i] = trim($ddsg_exclude_pages[$i]); } } else { $ddsg_exclude_pages = Array(""); } if (trim($ddsg_exclude_cats)) { $ddsg_exclude_cats = (array)split(",", $ddsg_exclude_cats); for ($i = 0; $i < sizeof($ddsg_exclude_cats); $i++) { $ddsg_exclude_cats[$i] = trim($ddsg_exclude_cats[$i]); } } else { $ddsg_exclude_cats = Array(""); } if ($ddsg_new_window) { $ddsg_new_window = " target='_blank' "; } else { $ddsg_new_window = ""; } switch ($ddsg_post_sort_order) { case 'title': $ddsg_post_sort_order = "post_title"; break; case 'datea': $ddsg_post_sort_order = "post_date ASC"; break; case 'dated': $ddsg_post_sort_order = "post_date DESC"; break; } switch ($ddsg_page_sort_order) { case 'title': $ddsg_page_sort_order = "post_title"; break; case 'datea': $ddsg_page_sort_order = "post_date ASC"; break; case 'dated': $ddsg_page_sort_order = "post_date DESC"; break; } $ddsg_cat_text = trim($ddsg_cat_text); if (strlen($ddsg_cat_text) > 0) { $ddsg_cat_text = $ddsg_cat_text . " "; } $ddsg_sm_name = trim($ddsg_sm_name); if (strlen($ddsg_sm_name) == 0) { $ddsg_sm_name = NULL; } // Get list of parent IDs $ddsg_pids = ddsg_get_pids(); // Get categories ddsg_gen_cat_list(); // Get posts and/or pages if ($ddsg_p_or_p_shown == 'posts') { ddsg_generate_data_posts(); } else if ($ddsg_p_or_p_shown == 'pages') { ddsg_generate_data_pages(); } else if ($ddsg_p_or_p_shown == 'both') { if ($ddsg_p_or_p_first == 'posts') { ddsg_generate_data_posts(); ddsg_generate_data_pages(); } else { ddsg_generate_data_pages(); ddsg_generate_data_posts(); } } // prepare output $the_output = NULL; // Get start page $start_page = 1; if (get_query_var("pg")) { $start_page = get_query_var("pg"); } // Get number of pages if ($ddsg_items_per_page < 1) { $total_pages = 1; $start_page = 1; } else { $total_pages = ceil(count($ddsg_data) / $ddsg_items_per_page); } $offset = $ddsg_items_per_page * ($start_page - 1); if ($ddsg_items_per_page > 0) { $limit = $ddsg_items_per_page; } else { $limit = 0; } // Generate navigation $nav_text = ddsg_generate_nav($total_pages, $start_page); // Navigation on top? if ($ddsg_page_nav_where == "top" || $ddsg_page_nav_where == "both") { $the_output .= $nav_text; } // Generate the actual output $the_output .= ddsg_process_data($the_output, $limit, $offset); // Navigation on bottom? if ($ddsg_page_nav_where == "bottom" || $ddsg_page_nav_where == "both") { $the_output .= "

     

    " . $nav_text; } // Show link to XML sitemap? if (trim($ddsg_xml_path)) { if (($ddsg_xml_where == 'every') OR ($start_page == $total_pages)) { $the_output .= ''; } } $the_output .= '

    sitemap plugin by dagondesign.com

    '; return $the_output; } function ddsg_generate_sitemap($content) { if (strpos($content, "")) { $content = preg_replace('/

    \s*\s*<\/p>/i', "", $content); $content = str_replace("", ddsg_create_sitemap(), $content); } return $content; } add_filter('query_vars', 'ddsg_query_vars'); add_filter('rewrite_rules_array', 'ddsg_permalinks'); add_filter('the_content', 'ddsg_generate_sitemap'); add_action('admin_menu', 'ddsg_add_option_pages'); ?>