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'=>'
',
'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
?>
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 "
';
$output .= "\n";
}//end foreach contacts
}//end if nested_links
$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='