wp_dashboard_cached_rss_widget
函数
wp_dashboard_cached_rss_widget ( $widget_id, $callback, $check_urls = array(), $args )
- 参数
-
-
(string)
$widget_id
The widget ID.- Required: 是
-
(callable)
$callback
The callback function used to display each feed.- Required: 是
-
(array)
$check_urls
RSS feeds.- Required: 否
- Default: array()
-
(mixed)
$args
Optional additional parameters to pass to the callback function.- Required: 是
-
(string)
- 返回值
-
- (bool) True on success, false on failure.
- 定义位置
-
-
wp-admin/includes/dashboard.php
, line 1145
-
wp-admin/includes/dashboard.php
- 引入
- 2.5.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)
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) { $loading = ''; $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; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。