'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 Settings and options * @since WordPress 2.7 */ function feedreading_blogroll_register_setting(){ if (function_exists('register_setting')) { register_setting('feedreading_blogroll_settings_group', 'feedreading_blogroll_settings'); } } /** * The uninstall-hook for the plugin * @since WordPress 2.7 */ function feedreading_blogroll_uninstall_hook() { delete_option('feedreading_blogroll_settings'); } /** * 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['customCSSDir']) or isset($_POST['displayStyle'])){ return TRUE; } else { return FALSE; } } /** * Enqueue scripts after WordPress has finished loading but before any headers are sent. * @since WordPress 2.7 */ function feedreading_blogroll_add_scripts(){ if (!is_admin()){ wp_enqueue_script('jquery'); } } /** * Enqueue styles after WordPress has finished loading but before any headers are sent. * @since WordPress 2.7 */ function feedreading_blogroll_add_styles(){ $feedreading_blogroll_settings = get_option('feedreading_blogroll_settings'); if ($feedreading_blogroll_settings['customCSSDir'] != ''){ $customStyleFile = $feedreading_blogroll_settings['customCSSDir'].'/feedreading_blogroll.css'; wp_register_style('feedreading_style', $customStyleFile); wp_enqueue_style('feedreading_style'); } else { $defaultStyleFile = WP_PLUGIN_URL.'/feed-reading-blogroll/feedreading_blogroll.css'; wp_register_style('feedreading_style', $defaultStyleFile); wp_enqueue_style('feedreading_style'); } } /** * 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'] = trim(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'] = trim(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'])); $feedreading_blogroll_settings['customCSSDir'] = trim(strip_tags(stripslashes($_POST['customCSSDir']))); update_option('feedreading_blogroll_settings', $feedreading_blogroll_settings); $feedreading_blogroll_settings['flash'] = __('Settings saved.'); } return $feedreading_blogroll_settings; } /** * Render the options-panel with form */ function feedreading_blogroll_options_subpanel(){ if (function_exists('wp_nonce_field') and !function_exists('settings_fields')) { if (feedreading_blogroll_vars_are_set()) check_admin_referer('plugin-feed-reading-blogroll-action_option_panel'); } else if (function_exists('settings_fields')) { if (feedreading_blogroll_vars_are_set()) check_admin_referer('feedreading_blogroll_settings_group-options'); } $feedreading_blogroll_settings = feedreading_blogroll_setOptions(); $plugins = get_plugins(); $cats = feedreading_blogroll_get_linkcats(); if ($feedreading_blogroll_flash != ''){ ?>

Feed Reading Blogroll

|

/>

name , $feedreading_blogroll_settings['linkCats'])==1) { ?> checked="checked" /> name); ?>
/>

/>
/>

/>
/>
/>
/>



/>
/>
/>
/>

link_name; $url=$bookmark->link_url; $urlFeed=$bookmark->link_rss; $image=$bookmark->link_image; ?>
  • :
  • :
  • :


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 () with list-items (
  • ...
  • ) */ function widget_feedreading_blogroll_list($before_title, $after_title, $bookmarks, $title){ $feedreading_blogroll_settings = get_option('feedreading_blogroll_settings'); $linkCssClass = $feedreading_blogroll_settings['linkCssClass']; $showLastUpdated = strcmp($feedreading_blogroll_settings['showLastUpdated'], 'showLastUpdated'); $showIcon = strcmp($feedreading_blogroll_settings['showIcon'], 'showIcon'); $showLastPostTitle = strcmp($feedreading_blogroll_settings['showLastPostTitle'], 'showLastPostTitle'); $showPreviewButton = strcmp($feedreading_blogroll_settings['previewButton'], 'previewButton'); $defaultIcon = $feedreading_blogroll_settings['defaultIcon']; $showTitle = strcmp($feedreading_blogroll_settings['showTitle'],'showTitle'); $displayStyle = $feedreading_blogroll_settings['displayStyle']; if ($title =='') $title = $feedreading_blogroll_settings['feedreadingTitle']; if ($showTitle == 0){ echo $before_title; echo $title; echo $after_title; } ?> link_name; $url=$bookmark->link_url; $urlFeed=$bookmark->link_rss; $image=$bookmark->link_image; $xfn=$bookmark->link_rel; ?> link_name; $url=$bookmark->link_url; $urlFeed=$bookmark->link_rss; $image=$bookmark->link_image; $xfn=$bookmark->link_rel; ?> link_name; $url=$bookmark->link_url; $urlFeed=$bookmark->link_rss; $image=$bookmark->link_image; $xfn=$bookmark->link_rel; ?> link_name; $url=$bookmark->link_url; $urlFeed=$bookmark->link_rss; $image=$bookmark->link_image; $xfn=$bookmark->link_rel; ?>