wp_dashboard_cached_rss_widget

The timeline below displays how wordpress function wp_dashboard_cached_rss_widget has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * 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)
 *
 * @since 2.5.0
 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
 *              by adding it to the function signature.
 *
 * @param string   $widget_id  The widget ID.
 * @param callable $callback   The callback function used to display each feed.
 * @param array    $check_urls RSS feeds.
 * @param mixed    ...$args    Optional additional parameters to pass to the callback function.
 * @return bool True on success, false on failure.
 */
function wp_dashboard_cached_rss_widget($widget_id, $callback, $check_urls = array(), ...$args)
{
    $doing_ajax = wp_doing_ajax();
    $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&hellip;') . '</p>';
    $loading .= wp_get_admin_notice(__('This widget requires JavaScript.'), array('type' => 'error', 'additional_classes' => array('inline', 'hide-if-js')));
    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']);
    }
    $locale = get_user_locale();
    $cache_key = 'dash_v2_' . md5($widget_id . '_' . $locale);
    $output = get_transient($cache_key);
    if (false !== $output) {
        echo $output;
        return true;
    }
    if (!$doing_ajax) {
        echo $loading;
        return false;
    }
    if ($callback && is_callable($callback)) {
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        // Default lifetime in cache of 12 hours (same as the feeds).
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
    }
    return true;
}

WordPress Version: 5.4

/**
 * 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)
 *
 * @since 2.5.0
 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
 *              by adding it to the function signature.
 *
 * @param string   $widget_id  The widget ID.
 * @param callable $callback   The callback function used to display each feed.
 * @param array    $check_urls RSS feeds.
 * @param mixed    ...$args    Optional additional parameters to pass to the callback function.
 * @return bool True on success, false on failure.
 */
function wp_dashboard_cached_rss_widget($widget_id, $callback, $check_urls = array(), ...$args)
{
    $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&hellip;') . '</p><div class="hide-if-js notice notice-error inline"><p>' . __('This widget requires JavaScript.') . '</p></div>';
    $doing_ajax = wp_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']);
    }
    $locale = get_user_locale();
    $cache_key = 'dash_v2_' . md5($widget_id . '_' . $locale);
    $output = get_transient($cache_key);
    if (false !== $output) {
        echo $output;
        return true;
    }
    if (!$doing_ajax) {
        echo $loading;
        return false;
    }
    if ($callback && is_callable($callback)) {
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        // Default lifetime in cache of 12 hours (same as the feeds).
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
    }
    return true;
}

WordPress Version: 5.3

/**
 * 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)
 *
 * @since 2.5.0
 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
 *              by adding it to the function signature.
 *
 * @param string   $widget_id  The widget ID.
 * @param callable $callback   The callback funtion used to display each feed.
 * @param array    $check_urls RSS feeds
 * @param mixed    ...$args    Optional additional parameters to pass to the callback function when it's called.
 * @return bool False on failure. True on success.
 */
function wp_dashboard_cached_rss_widget($widget_id, $callback, $check_urls = array(), ...$args)
{
    $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&hellip;') . '</p><div class="hide-if-js notice notice-error inline"><p>' . __('This widget requires JavaScript.') . '</p></div>';
    $doing_ajax = wp_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']);
    }
    $locale = get_user_locale();
    $cache_key = 'dash_v2_' . md5($widget_id . '_' . $locale);
    $output = get_transient($cache_key);
    if (false !== $output) {
        echo $output;
        return true;
    }
    if (!$doing_ajax) {
        echo $loading;
        return false;
    }
    if ($callback && is_callable($callback)) {
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}

WordPress Version: 4.8

/**
 * 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)
 *
 * @since 2.5.0
 *
 * @param string $widget_id
 * @param callable $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 = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><div class="hide-if-js notice notice-error inline"><p>' . __('This widget requires JavaScript.') . '</p></div>';
    $doing_ajax = wp_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']);
    }
    $locale = get_user_locale();
    $cache_key = 'dash_v2_' . md5($widget_id . '_' . $locale);
    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_slice(func_get_args(), 3);
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}

WordPress Version: 4.7

/**
 * 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)
 *
 * @since 2.5.0
 *
 * @param string $widget_id
 * @param callable $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 = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
    $doing_ajax = wp_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']);
    }
    $locale = get_locale();
    $cache_key = 'dash_' . md5($widget_id . '_' . $locale);
    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_slice(func_get_args(), 3);
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}

WordPress Version: 4.6

/**
 * 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)
 *
 * @since 2.5.0
 *
 * @param string $widget_id
 * @param callable $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 = '<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']);
    }
    $locale = get_locale();
    $cache_key = 'dash_' . md5($widget_id . '_' . $locale);
    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_slice(func_get_args(), 3);
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}

WordPress Version: 4.4

/**
 * 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)
 *
 * @since 2.5.0
 *
 * @param string $widget_id
 * @param callable $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 = '<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']);
    }
    $locale = get_locale();
    $cache_key = 'dash_' . md5($widget_id . '_' . $locale);
    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_slice(func_get_args(), 3);
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}

WordPress Version: 4.3

/**
 * 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)
 *
 * @since 2.5.0
 *
 * @param string $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 = '<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']);
    }
    $locale = get_locale();
    $cache_key = 'dash_' . md5($widget_id . '_' . $locale);
    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_slice(func_get_args(), 3);
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}

WordPress Version: 4.0

/**
 * 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)
 *
 * @since 2.5.0
 *
 * @param string $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 = '<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_slice(func_get_args(), 3);
        array_unshift($args, $widget_id, $check_urls);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}

WordPress Version: 3.7

/**
 * 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)
 *
 * @since 2.5.0
 *
 * @param string $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 = '<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_slice(func_get_args(), 2);
        array_unshift($args, $widget_id);
        ob_start();
        call_user_func_array($callback, $args);
        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
        // Default lifetime in cache of 12 hours (same as the feeds)
    }
    return true;
}