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'=>"
Options saved.
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 A USER:" . print_r ($a_user, true) . ""; $has_openid = false; if (null !== $a_user && get_usermeta($a_user->ID, 'has_openid')) $has_openid = true; $openid_uri=''; if (DEBUG) print "
check_openid: $check_openid, has_openid: $has_openid, has_wp_openid: $has_wp_openid"; if($check_openid=='Y' && $has_openid && $has_wp_openid) { $openid_uri = openid_for_user($a_user->ID); } $contact_fn = wp_specialchars($row->link_name, ENT_QUOTES); // render the link if (DEBUG) "
contact_rel: $contact_rel, contact_fn: $contact_fn"; if (empty($contact_rel) or empty($contact_fn)) { continue; // skip ahead to next record } elseif (!($check_openid=='Y') or ($link_format=='default')) { $output .= "\t\t" . sprintf($link_formats[$link_format]['format'], $contact_rel, $contact_blog_link, $contact_fn); } else { $openid_class = $has_openid ? 'openid' : ''; $openid_uri_or_blog_link = $has_openid ? $openid_uri : $the_link; if (DEBUG) { print "
has_openid: $has_openid; openid_class: $openid_class; openid_uri_or_blog_link: $openid_uri_or_blog_link;"; } switch ($link_format) { case 'username_link_only': // Username links to blog or openid (if user registered via OpenID) // sprintf args: $openid_class, $contact_fn, $openid_uri_or_blog_link, $contact_rel $link = "\t\t" . sprintf($link_formats[$link_format]['format'], $openid_class, $contact_rel, $openid_uri_or_blog_link, $contact_fn); $output .= $link; break; case 'username_openid_blogname_bloglink': // 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 $fmtary = split("\|",$link_formats[$link_format]['format']); /* 0 -
" . 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=''; 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');