Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_dashboard_cached_rss_widget [ WordPress Function ]

wp_dashboard_cached_rss_widget ( $widget_id, $callback, $check_urls = array() )
Parameters:
  • (string) $widget_id
  • (callback) $callback
  • (array) $check_urls RSS feeds
Returns:
  • (bool) False on failure. True on success.
Defined at:



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 options 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)

Source


<?php
function wp_dashboard_cached_rss_widget$widget_id$callback$check_urls = array() ) {
    
$loading '<p class="widget-loading hide-if-no-js">' __'Loading&#8230;' ) . '</p><p class="hide-if-js">' __'This widget requires JavaScript.' ) . '</p>';
    
$doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX );

    if ( empty(
$check_urls) ) {
        
$widgets get_option'dashboard_widget_options' );
        if ( empty(
$widgets[$widget_id]['url']) && ! $doing_ajax ) {
            echo 
$loading;
            return 
false;
        }
        
$check_urls = array( $widgets[$widget_id]['url'] );
    }

    
$cache_key 'dash_' md5$widget_id );
    if ( 
false !== ( $output get_transient$cache_key ) ) ) {
        echo 
$output;
        return 
true;
    }

    if ( ! 
$doing_ajax ) {
        echo 
$loading;
        return 
false;
    }

    if ( 
$callback && is_callable$callback ) ) {
        
$args array_slicefunc_get_args(), );
        
array_unshift$args$widget_id );
        
ob_start();
        
call_user_func_array$callback$args );
        
set_transient$cache_keyob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds)
    
}

    return 
true;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics