' . __('This dashboard widget queries Google Blog Search so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "
\n";
}
}
/**
* Checks to see if all of the feed url in $check_urls are cached.
*
* If $check_urls is empty, look for the rss feed url found in the dashboard
* widget optios of $widget_id. If cached, call $callback, a function that
* echoes out output for this widget. If not cache, echo a "Loading..." stub
* which is later replaced by AJAX call (see top of /wp-admin/index.php)
*
* @since unknown
*
* @param int $widget_id
* @param callback $callback
* @param array $check_urls RSS feeds
* @return bool False on failure. True on success.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
$loading = '
' . __( 'Loading…' ) . '
';
if ( empty($check_urls) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty($widgets[$widget_id]['url']) ) {
echo $loading;
return false;
}
$check_urls = array( $widgets[$widget_id]['url'] );
}
require_once( ABSPATH . WPINC . '/rss.php' );
init(); // initialize rss constants
$cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
foreach ( $check_urls as $check_url ) {
$status = $cache->check_cache( $check_url );
if ( 'HIT' !== $status ) {
echo $loading;
return false;
}
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 2 );
array_unshift( $args, $widget_id );
call_user_func_array( $callback, $args );
}
return true;
}
/**
* Empty widget used for JS/AJAX created output.
*
* Callback inserts content between before_widget and after_widget. Used when
* widget is in edit mode. Can also be used for custom widgets.
*
* @since unknown
*
* @param array $sidebar_args
* @param callback $callback Optional. Only used in edit mode.
*/
function wp_dashboard_empty( $sidebar_args, $callback = false ) {
extract( $sidebar_args, EXTR_SKIP );
echo $before_widget;
echo $before_title;
echo $widget_name;
echo $after_title;
// When in edit mode, the callback passed to this function is the widget_control callback
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 2 );
array_unshift( $args, $widget_id );
call_user_func_array( $callback, $args );
}
echo $after_widget;
}
/* Dashboard Widgets Controls. See also wp_dashboard_empty() */
// Temp
function wp_dashboard_empty_control() {
echo "This feature isn't enabled in this prototype.";
}
// Calls widget_control callback
/**
* Calls widget control callback.
*
* @since unknown
*
* @param int $widget_control_id Registered Widget ID.
*/
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_registered_widget_controls;
if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_registered_widget_controls[$widget_control_id]) && is_callable($wp_registered_widget_controls[$widget_control_id]['callback']) )
call_user_func_array( $wp_registered_widget_controls[$widget_control_id]['callback'], $wp_registered_widget_controls[$widget_control_id]['params'] );
}
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since unknown
*
* @param array $args Expects 'widget_id' and 'form_inputs'.
* @return bool|null False if no widget_id is given. Null on success.
*/
function wp_dashboard_rss_control( $args ) {
extract( $args );
if ( !$widget_id )
return false;
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();
if ( !isset($widget_options[$widget_id]) )
$widget_options[$widget_id] = array();
$number = 1; // Hack to use wp_widget_rss_form()
$widget_options[$widget_id]['number'] = $number;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
$_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] );
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
// title is optional. If black, fill it if possible
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
require_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss($widget_options[$widget_id]['url']);
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->channel['title']));
}
update_option( 'dashboard_widget_options', $widget_options );
}
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
}
?>