to the static page content where you want the links to appear. Enjoy! */ function wp_cl_styles() { $wp_cl_stylesheet = '' . "\n"; echo($wp_cl_stylesheet); } define('DEBUG',false); $link_formats = array ( 'default'=>array( 'label'=>"Username links to blog (No OpenID)", // sprintf args: $contact_rel, $contact_blog_link, $contact_fn 'format'=>'
  • %s
  • ', 'preview'=> '<li class="vcard"><a class="url fn" rel="aquaintance" href="http://example.com/blog" title="Example Blog">Example Username</a></li>' ), 'username_link_only' => array( 'label' => 'Username links to blog or openid (if user registered via OpenID)', // sprintf args: $openid_class, $contact_rel, $openid_uri_or_blog_link, $contact_fn 'format'=> '
  • %s
  • ', 'preview'=> '<li class="vcard"><a class="url fn openid" rel="aquaintance" href="http://username.example.com" title="Example OpenID">Example Username</a></li>' ), 'username_openid_blogname_bloglink' => array( 'label' => 'Username links to openid if user registered via OpenID, blogname links to their blog', // sprintf args: $openid_class, $contact_rel, $openid_uri, $contact_fn, $blog_link, $contact_rel, $blog_name 'format' => '
  • |%s' . '|%s|
  • ', 'preview' => '<li class="vcard"><a class="url fn openid" rel="aquaintance" href="http://username.example.com" title="Example OpenID">Example Username</a> &mdash <a class="url" href="http://example.com/blog" rel="aqcuaintance">Example Blog</a></li>' ), 'nested_links' => array( 'label' => 'Username links to blog. OpenID class output. Multiple links for the same user nested.', // sprintf args: $openid_class, $contact_rel, $contact_blog_link, $contact_fn 'format' => '%s', 'preview' => '<li class="vcard"> <span class="fn">Example Name</span> <ul> <li class="vcard"><a class="url openid" rel="aquaintance" href="http://example.com/blog">domain.com</a> </li> </ul;> </li>' ), ); if ( class_exists('WordpressOpenIDLogic') ) { $has_wp_openid = true; } else { $has_wp_openid = false; } $check_openid = get_option("cl_check_openid"); $check_openid = ($check_openid==''||$check_openid=='N') ? 'N' : 'Y'; $link_format = get_option("cl_link_format"); $link_format = $link_format=='' ? 'default' : $link_format; /* ========= admin ========= */ function cl_add_pages() { // Add a new submenu under Options: add_options_page('Contacts List Options', 'Contacts List', 8, __FILE__, 'cl_options_page'); } function cl_options_page () { global $link_formats, $check_openid, $link_format; // variables for the field and option names // Read in existing option value from database $hidden_field_name = 'cl_submit_hidden'; $opt_check_openid_val = get_option( 'cl_check_openid' ); $field_check_openid = 'cl_check_openid'; $opt_link_format_val = get_option( 'cl_link_format' ); $field_link_format = 'cl_link_format'; if( $_POST[ $hidden_field_name ] == 'Y' ) { // Read their posted value $check_openid = $_POST[ $field_check_openid ]; $link_format = $_POST[ $field_link_format ]; // Save the posted value in the database update_option( 'cl_check_openid', $check_openid ); update_option( 'cl_link_format', $link_format ); update_option( 'cl_by_category', isset($_POST['by_category'])?true:false ); // Put an options updated message on the screen ?>

    Options saved.

    '; // header echo "

    Contacts List Plugin Options

    "; // options form ?>

    Lookup Users with OpenID:

    Display by category? />

    Contact Link Format: $format_ary) { ?>
    type='radio' id='' name="cl_link_format" value='' />


    prefix."openid_identities WHERE url='$uri' LIMIT 1"; $results = $wpdb->get_results($sql); $row = array_shift($results); return get_userdata($row->user_id); } /* ========== the main work ========== */ function cl_generateblogroll($category='') { global $has_wp_openid, $check_openid, $link_formats, $link_format; if (DEBUG) print "
    link_format: $link_format
    "; $output = ''; if(!$category && get_option('cl_by_category')) {//display by category $terms = get_terms('link_category'); foreach($terms as $term) { $tmp = cl_generateblogroll($term->term_id); if($tmp) $output .= '

    '.htmlentities($term->name).'

    '."\n".$tmp; }//end foreach terms return $output; }//end if display by category $results = get_bookmarks("category=$category"); if (!$results) { return; } if (DEBUG) print "
    CHECK_OPENID? ".get_option("cl_check_openid")."
    "; $output .= "\n \n"; return $output; } function openid_for_user($user_id) { if (!$has_wp_openid) return null; // get openid url // this only works if wpopenid is installed, but i don't know yet // how to check for the plugin $sql = "SELECT uurl_id, url FROM ".$wpdb->prefix."openid_identities WHERE user_id = '$a_user->ID'"; if (DEBUG) print "
    " . print_r ($sql, true) . "
    "; $oid_results = $wpdb->get_results($sql); if (DEBUG) "
    " . print_r ($oid_results, true) . "
    "; $openid_uri = $oid_results[0]->url; return $openid_uri == '' ? null : $openid_uri; } function cl_page_callback($matches) { return cl_generateblogroll(); } function cl_page_filter($content) { $content = preg_replace_callback('||i', 'cl_page_callback', $content); return $content; } add_action('wp_head', 'wp_cl_styles'); add_filter('the_content', 'cl_page_filter'); /* Template Tag */ function cl_blogroll () { echo cl_generateblogroll(); } /* ============== widget ============== */ function widget_cl_init() { // Check for the required API functions if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') ) return; function widget_cl($args) { extract($args); $defaults = array(); $options = (array) get_option('widget_cl'); $m=array(); //print ""; if (empty($before_widget)) $before_widget='
    '; if (empty($after_widget)) $after_widget='
    '; foreach ( $defaults as $key => $value ) if ( !isset($options[$key]) ) $options[$key] = $defaults[$key]; echo $before_widget; echo $before_title; echo (!empty($options['title'])) ? $options['title'] : "Blogroll"; echo $after_title; echo cl_generateblogroll(); echo $after_widget; } register_sidebar_widget(array('Microformatted Blogroll', 'widgets'), 'widget_cl'); } add_action('widgets_init', 'widget_cl_init');