'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')) {
$menutitle = '
' . ' ';
add_options_page($menutitle. 'Feed reading Blogroll', $menutitle. 'Feed reading Blogroll', 8, basename(__FILE__), 'feedreading_blogroll_options_subpanel');
}
}
/**
* Add configure-link to plugin-list
*
* @since WordPress 2.7
* @param unknown_type $links
* @return unknown
*/
function feedreading_blogroll_addConfigureLink($links) {
$settings_link = ''.__('Settings').'';
array_unshift( $links, $settings_link );
return $links;
}
/**
* 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']) or
isset($_POST['jsSorting']) or
isset($_POST['jsSortingTimeout'])
){
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');
wp_register_script('feedreading_sorter', WP_PLUGIN_URL.'/feed-reading-blogroll/sortlist.js');
wp_enqueue_script('feedreading_sorter');
wp_register_script('feedreading_main', WP_CONTENT_URL.'/feedreading_blogroll.js');
wp_enqueue_script('feedreading_main');
} else if(is_admin()){
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-tabs');
}
}
/**
* Images/ Icons in base64-encoding
* @see http://bueltge.de/test/image2base64/
* @use function feedreading_blogroll_get_resource_url() for display
*/
if( isset($_GET['resource']) && !empty($_GET['resource'])) {
# base64 encoding
$feedreading_resources = array(
'ssprc.gif' =>
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABG'.
'dBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1h'.
'Z2VSZWFkeXHJZTwAAAK4SURBVBgZBcFfaFV1AADg7/zO2Zy7A3'.
'fVebdEQ2yCoeVfmmhQGlRgmCg0sEAoeivvWy/BiigYvoi9hPYg'.
'EfQYKGVgiIhaaJPSVlC6hU7v9Pon166755577+n7ovRtvZ3LjU'.
'iUAQQEAAQAQBO3HWrc8HHSudyIwRfLShuJOwgJUUSIiAIhIkSI'.
'iRAhb3H7Urnz++MSibLSRtKY/s3EuPsH9y4TAnFAIEYUyHN6Fr'.
'NkA0uOlxMQdxC6WL8bsJusxt+nuPYdrVlE5DkiHk7TtYg2QRtR'.
'wuMKV79l4hy1Kh0Fnn6dVw/zxBAgIsuoZzQbNEgEhIjHFX7/mh'.
'CRBBavY92bLFjOcwe4fIRrp0ibNFKyFnWCgID+zez9iu2f8NQu'.
'ZiY4/QE3zgIb3qW0jjSl3iRr0iBoQ0yEjgJ9q3l2H68cpncFY1'.
'/wzxlgywHyedQzshZ1goAID37j5PuMHaFWpaObbR/Ss5Szh5id'.
'prOHNTupN8naNEgEhEAemLurfv20cxfGXElXKi7qc/9en709ty'.
'z88XNfTixSLBY99JJnJqu2pbFEGyLiXLap7JsT5/2Xd9r31htq'.
'tZqpqSnHf0p136l6bd9+cRyrVCrGxsbcbKySgJDTt8aFyYbrlX'.
'/tGR527NP3nJ+c0z8wYO3atSYezbl48KDp6WlbV5Zs27vfyckd'.
'EiBi7q5fxy8pFAqgvHrGmT8bhoeHFYtFs7OzqtWqo0ePKj8/6B'.
'cUehdKNJA30TJw/5yfHw2A0cvztNoNo6OjCoUCqNVq8mZm9MRF'.
'O97ZqnrrpvijQb365w8pDpo/v9vZ8WnpXGrV+i02DW21bNkyrV'.
'ZLqVQyNDTkhe3bDawY9Nf4VdfGrzyI0pf1dvYb0a/cajE52+Oz'.
'25t1L3lSx7wu7Zw9d36wMJtzbOkurSjI0rp7lamZBTMPdv4PY0'.
'MOogadRGMAAAAASUVORK5CYII='.
'');
if(array_key_exists($_GET['resource'], $feedreading_resources)) {
$content = base64_decode($feedreading_resources[ $_GET['resource'] ]);
$lastMod = filemtime(__FILE__);
$client = ( isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false );
// Checking if the client is validating his cache and if it is current.
if (isset($client) && (strtotime($client) == $lastMod)) {
// Client's cache IS current, so we just respond '304 Not Modified'.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 304);
exit;
} else {
// Image not cached or cache outdated, we respond '200 OK' and output the image.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $lastMod).' GMT', true, 200);
header('Content-Length: '.strlen($content));
header('Content-Type: image/' . substr(strrchr($_GET['resource'], '.'), 1) );
echo $content;
exit;
}
}
}
/**
* Display Images/ Icons in base64-encoding
* @return $resourceID
*/
function feedreading_blogroll_get_resource_url($resourceID) {
return trailingslashit( get_bloginfo('url') ) . '?resource=' . $resourceID;
}
/**
* 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(!is_admin()){
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');
}
} else if(is_admin()){
$adminStyleFile = WP_PLUGIN_URL.'/feed-reading-blogroll/feedreading_blogroll_admin.css';
wp_register_style('feedreading_admin_style', $adminStyleFile);
wp_enqueue_style('feedreading_admin_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'])));
$feedreading_blogroll_settings['jsSorting'] = trim(strip_tags(stripslashes($_POST['jsSorting'])));
$feedreading_blogroll_settings['jsSortingTimeout'] = trim(strip_tags(stripslashes($_POST['jsSortingTimeout'])));
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_generate_javascript(FALSE);
$feedreading_blogroll_settings = feedreading_blogroll_setOptions();
$plugins = get_plugins();
$cats = feedreading_blogroll_get_linkcats();
$menutitle = '
' . ' ';
if ($feedreading_blogroll_flash != ''){
?>
and content-directory are writable. This is no longer necessary. You should make the content-directory read-only (chmod 755) now for security-reasons.
This plugin requires only JavaScript-file itself to be writable.', 'feedreading_blogroll'); ?>