to the static page content where you want the links to appear. Enjoy! */ ?> ' . "\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>" ), ); 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 ); // Put an options updated message on the screen ?>

    Options saved.

    '; // header echo "

    Contacts List Plugin Options

    "; // options form ?>

    Lookup Users with OpenID:

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


    LOOKING FOR:"; //print_r ($data); //print ""; $uri = normalize_uri($uri); $sql = "SELECT id FROM ". $wpdb->users ." WHERE user_url LIKE '%$uri%'"; $results = $wpdb->get_results($sql); //print "
    RESULTS:";
    	//print_r ($sql);
    	//print_r ($results);
    	//print "
    "; if (!$results) { if (strpos($uri,'/')) { $uri = substr($uri,0,(strpos($uri,'/'))); // chop any path and try just the domain next //print "
    $uri
    "; $sql = "SELECT id FROM ". $wpdb->users . " WHERE user_url LIKE '%$uri%'"; $results = $wpdb->get_results($sql); } if (!$results) { return; } } foreach ($results as $row) { return get_userdata($row->id); } } /* ========== the main work ========== */ function cl_generateblogroll() { global $wpdb, $has_wp_openid, $check_openid, $link_formats, $link_format; if (DEBUG) print "
    link_format: $link_format
    "; $output = ''; global $wpdb; $sql = "SELECT link_url, link_name, link_rel, link_description, link_notes FROM $wpdb->links WHERE link_visible = 'Y' ORDER BY link_name" ; $results = $wpdb->get_results($sql); 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');