'widget_feedreading_blogroll', 'description' => __('widget_feedreading_blogroll widget description ') ); wp_register_sidebar_widget('widget_feedreading_blogroll', 'Live Blogroll', 'widget_feedreading_blogroll', $widget_ops); register_widget_control('widget_feedreading_blogroll', 'widget_feedreading_blogroll_control'); } /** * Register with options-page */ function feedreading_blogroll_register_options() { if (function_exists('add_options_page')) { add_options_page('Feed reading Blogroll', 'Feed reading Blogroll', 8, basename(__FILE__), 'feedreading_blogroll_options_subpanel'); } } /** * Get link-categories from database * @ return resultset containing term_id and term_id */ function feedreading_blogroll_get_linkcats(){ global $wpdb; $cats = $wpdb->get_results("SELECT $wpdb->terms.term_ID, $wpdb->terms.name FROM $wpdb->terms join $wpdb->term_taxonomy on $wpdb->terms.term_id=$wpdb->term_taxonomy.term_id WHERE $wpdb->term_taxonomy.taxonomy = 'link_category' order by name"); return $cats; } /* * Returns true, if new values are contained in POST-request, else false * @return boolean */ function feedreading_blogroll_vars_are_set(){ if (isset($_POST['linkCssClass']) or isset($_POST['showLastUpdated']) or isset($_POST['showLastPostTitle']) or isset($_POST['feedreadingTitle']) or isset($_POST['showTitle']) or isset($_POST['showIcon']) or isset($_POST['defaultIcon']) or isset($_POST['googleAPIKey']) or isset($_POST['previewButton']) or isset($_POST['linkCats']) or isset($_POST['groupByLinkCats']) or isset($_POST['orderBy']) or isset($_POST['orderDirection']) or isset($_POST['displayStyle'])){ return TRUE; } else { return FALSE; } } /* * read http-data and set options. * * @return array with updated plugin-options */ function feedreading_blogroll_setOptions() { $feedreading_blogroll_settings = get_option('feedreading_blogroll_settings'); if (feedreading_blogroll_vars_are_set()) { $feedreading_blogroll_settings['linkCssClass'] = strip_tags(stripslashes($_POST['linkCssClass'])); $feedreading_blogroll_settings['linkCats'] = $_POST['linkCats']; $feedreading_blogroll_settings['groupByLinkCats'] = strip_tags(stripslashes($_POST['groupByLinkCats'])); $feedreading_blogroll_settings['orderBy'] = strip_tags(stripslashes($_POST['orderBy'])); $feedreading_blogroll_settings['orderDirection'] = strip_tags(stripslashes($_POST['orderDirection'])); $feedreading_blogroll_settings['showLastUpdated'] = strip_tags(stripslashes($_POST['showLastUpdated'])); $feedreading_blogroll_settings['showLastPostTitle'] = strip_tags(stripslashes($_POST['showLastPostTitle'])); $feedreading_blogroll_settings['feedreadingTitle'] = strip_tags(stripslashes($_POST['feedreadingTitle'])); $feedreading_blogroll_settings['displayStyle'] = strip_tags(stripslashes($_POST['displayStyle'])); $feedreading_blogroll_settings['showTitle'] = strip_tags(stripslashes($_POST['showTitle'])); $feedreading_blogroll_settings['defaultIcon'] = strip_tags(stripslashes($_POST['defaultIcon'])); $feedreading_blogroll_settings['showIcon'] = strip_tags(stripslashes($_POST['showIcon'])); $feedreading_blogroll_settings['googleAPIKey'] = strip_tags(stripslashes($_POST['googleAPIKey'])); $feedreading_blogroll_settings['previewButton'] = strip_tags(stripslashes($_POST['previewButton'])); update_option('feedreading_blogroll_settings', $feedreading_blogroll_settings); $feedreading_blogroll_settings['flash'] = __('Settings saved.'); } return $feedreading_blogroll_settings; } /* * render the option-panel with form */ function feedreading_blogroll_options_subpanel(){ if (feedreading_blogroll_vars_are_set()) check_admin_referer('plugin-feed-reading-blogroll-action_option_panel'); $feedreading_blogroll_settings = feedreading_blogroll_setOptions(); $plugins = get_plugins(); $cats = feedreading_blogroll_get_linkcats(); if ($feedreading_blogroll_flash != ''){ ?>
name , $feedreading_blogroll_settings['linkCats'])==1){?>
checked="checked" /> name); ?>
/>
/>
/>
Minimal
/>
Classic
/>
Blogger(TM)
/>
Banners
',''); } /** * transforms the plugin-options into an argument-string that works with the WordPress-function "get_bookmarks()" * @return String with arguments for the WordPress-function "get_bookmarks()" */ function feedreading_blogroll_bookmarkArgs($usedForGroupedBookmarks, $cat){ $args=''; $feedreading_blogroll_settings = get_option('feedreading_blogroll_settings'); $feedreadingTitle = $feedreading_blogroll_settings['feedreadingTitle']; $linkCats = $feedreading_blogroll_settings['linkCats']; $orderBy = $feedreading_blogroll_settings['orderBy']; $orderDirection = $feedreading_blogroll_settings['orderDirection']; $catOption =''; $catDelim =''; if (!is_null($linkCats)) { foreach ((array)$linkCats as $l){ $catOption = $catOption.$catDelim.$l; $catDelim =','; } } $args='order='.$orderDirection.'&orderby='.$orderBy; if (!$usedForGroupedBookmarks){ // use all linkcats $args='category_name='.$catOption.'&'.$args; } else { // use single linkcat $args='category_name='.$cat.'&'.$args; } return $args; } /* * render content of widget */ function widget_feedreading_blogroll_content($before_title, $after_title){ $feedreading_blogroll_settings = get_option('feedreading_blogroll_settings'); $groupByLinkCats = strcmp($feedreading_blogroll_settings['groupByLinkCats'],'groupByLinkCats'); $linkCats = $feedreading_blogroll_settings['linkCats']; // fetch bookmarks from wordpress if ( $groupByLinkCats==0){ if (!is_null($linkCats)) { foreach ((array)$linkCats as $linkCat){ $bookmarks = get_bookmarks(feedreading_blogroll_bookmarkArgs(TRUE, $linkCat)); widget_feedreading_blogroll_list($before_title, $after_title, $bookmarks, $linkCat); } } } else { $bookmarks = get_bookmarks(feedreading_blogroll_bookmarkArgs(FALSE,'')); widget_feedreading_blogroll_list($before_title, $after_title, $bookmarks, ''); } } /** * render the blogroll. This is an HTML-unordered-list (