$dashboard['owp_dashboard_news'], ); $wp_meta_boxes['dashboard']['normal']['core'] = array_merge( $widget, $dashboard ); } /** * OceanWP News & Updates * * @since 1.4.9 */ public function dashboard_news_widget() { // Get theme $owp = wp_get_theme( 'oceanwp' ); // OceanWP img url $owp_img = OE_URL . 'assets/img/oceanwp.png'; ?>
vget( 'Version' ) ); ?>

oceanwp_cached_rss_widget( 'owp_dashboard_news', array( $this, 'oceanwp_news_output' ) ); ?>
oceanwp_rss_output( self::$feed ); } /** * Display the RSS entries in a list. * * @since 1.4.9 */ public function oceanwp_rss_output( $rss, $args = array() ) { if ( is_string( $rss ) ) { $rss = fetch_feed($rss); } elseif ( is_array($rss) && isset($rss['url']) ) { $args = $rss; $rss = fetch_feed($rss['url']); } elseif ( !is_object($rss) ) { return; } if ( is_wp_error($rss) ) { if ( is_admin() || current_user_can('manage_options') ) echo '

' . __( 'RSS Error:', 'ocean-extra' ) . ' ' . $rss->get_error_message() . '

'; return; } $default_args = array( 'show_summary' => 1, 'items' => 4 ); $args = wp_parse_args( $args, $default_args ); $items = (int) $args['items']; $show_summary = (int) $args['show_summary']; if ( !$rss->get_item_quantity() ) { echo ''; $rss->__destruct(); unset($rss); return; } echo ''; $rss->__destruct(); unset($rss); } /** * Checks to see if all of the feed url in $check_urls are cached. * * @since 1.4.9 * * @param string $widget_id * @param callable $callback * @param array $check_urls RSS feeds * @return bool False on failure. True on success. */ function oceanwp_cached_rss_widget( $widget_id, $callback ) { $loading = '

' . __( 'Loading…' ) . '

' . __( 'This widget requires JavaScript.', 'ocean-extra' ) . '

'; $check_urls = self::$feed; $locale = get_user_locale(); $cache_key = 'owp_feed_data_' . md5( $widget_id . '_' . $locale ); if ( false !== ( $output = get_transient( $cache_key ) ) ) { echo $output; return true; } if ( empty( $check_urls ) ) { 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; } /** * Script * * @since 1.4.9 */ public function script( $hook ) { $screen = get_current_screen(); if ( 'dashboard' === $screen->id ) { wp_enqueue_style( 'oceanwp-news', plugins_url( '/assets/css/admin.min.css', dirname( __FILE__ ) ) ); } } } endif; new OceanWP_Dashboard_News();