post_title; // Get title $content = $page_data->post_content; anc_list_menu($content); } // if it's blog style page else if (is_home()){ $content = ""; if ( have_posts() ) : while ( have_posts() ) : the_post(); $content .= get_the_content(); endwhile; else: _e("Sorry, no posts matched your criteria."); endif; anc_list_menu($content); //echo "Sorry but this plugin only work on Wordpress pages."; } else { _e("Error: This page is not a tradicional Wordpress Page or a Wordpress Blog!"); } } // prints the menu with the links to the titles function anc_list_menu($content){ // list all tags $foo_tags = anc_get_tags($content); if($foo_tags[1] != 0){ $foo = -1; echo ""; }else{ //no tags found //_e("Not found any tag of the type that was selected to be parsed."); } } // retrieve all words between tags function anc_get_tags($content){ global $tags_to_parse; $options = get_option("anc_tags"); $tags_to_parse = $options["anc_tags"]; $pattern_search = "/(<".$tags_to_parse.".*>)(.*)(<\/".$tags_to_parse.">)/isxmU"; preg_match_all($pattern_search, $content, $patterns); $res = array(); array_push($res, $patterns[2]); array_push($res, count($patterns[2])); return $res; } // insert widget function anc_insert_init() { //register the widget register_sidebar_widget("Anchors Menu", "anc_widget_insert"); //register the widget control register_widget_control("Anchors Menu", "anc_widget_insert_control"); } function anc_widget_insert($args) { global $title, $tags_to_parse; extract($args); //get our options $options = get_option("anc_title"); $title = $options["anc_title"]; $options = get_option("anc_tags"); $tags_to_parse = $options["anc_tags"]; echo $before_widget; /*Insert any headers you want in the next line, between "?>" and ")(.*)(<\/".$tags_to_parse.">)/isxmU"; return preg_replace_callback($pattern_search, "anc_replacement", $content, -1); } // aux funtion to add_link_text function anc_replacement($matches){ global $tags_to_parse, $count; $count++; return ""."<".$tags_to_parse.">".$matches[2].""; } ?>