Difficulty
Challenging
This post is for users of the Voxel Theme
Stay up to date with the latest information from an RSS feed. In this post, we used the RSS feed for the Voxel Theme.
Simply add the code below to your Child Theme’s functions.php file. get the Voxel Child Theme here.
If you hover over the heading of each widget, you will see a configure option to set the number of feeds to show.
// WordPress dashboard setup.
function binaryBlackboard_add_dashbaord_widgets() {
// Adds the Voxel Latest documentation dashboard widget.
wp_add_dashboard_widget(
'voxel_dashboard_support_tickets',
__( 'Voxel Latest Support Tickets', 'voxel' ),
'voxel_dashboard_support_tickets_feed',
'voxel_dashboard_support_tickets_feed_num'
);
// Adds the Voxel Latest documentation dashboard widget.
wp_add_dashboard_widget(
'voxel_dashboard_documentation',
__( 'Voxel Latest Documentation', 'voxel' ),
'voxel_dashboard_documentation_feed',
'voxel_dashboard_documentation_feed_num'
);
}
add_action( 'wp_dashboard_setup', 'binaryBlackboard_add_dashbaord_widgets' );
// Set the default number of Support Tickets feeds to display by defualt.
function voxel_dashboard_support_tickets_defaults() {
return array(
'items' => 5,
);
}
// Set the default number of Voxel Documentation feeds to display by defualt.
function voxel_dashboard_documentation_defaults() {
return array(
'items' => 5,
);
}
/**
*
* Voxel Support Tickets Feed.
*
*/
function voxel_dashboard_support_tickets_feed() {
$options = wp_parse_args(
get_option('voxel_dashboard_support_tickets' ),
voxel_dashboard_support_tickets_defaults()
);
$ticket_feeds = array(
array(
'url' => 'https://getvoxel.io/questions/feed/',
'items' => $options['items'],
'target' => '_blank',
'show_summary' => true,
'show_date' => true,
'show_author' => true,
),
);
foreach ( $ticket_feeds as $feed_type => $args ) {
$args['type'] = $feed_type;
$link = $args['url'];
echo '';
ob_start();
wp_widget_rss_output( $link, $args );
$buffer = ob_get_clean();
$result = str_replace("';
}
}
function voxel_dashboard_support_tickets_feed_num() {
$options = wp_parse_args(
get_option( 'voxel_dashboard_support_tickets' ),
voxel_dashboard_support_tickets_defaults()
);
if ( isset( $_POST['submit'] ) ) {
if ( isset( $_POST['rss_items'] ) && intval( $_POST['rss_items'] ) > 0 ) {
$options['items'] = intval( $_POST['rss_items'] );
}
update_option( 'voxel_dashboard_support_tickets', $options );
}
?>
'https://getvoxel.io/docs/feed/',
'items' => $options['items'],
'target' => '_blank',
'show_summary' => true,
'show_date' => true,
'show_author' => false,
),
);
foreach ( $documentation_feeds as $feed_type => $args ) {
$args['type'] = $feed_type;
$link = $args['url'];
echo '';
ob_start();
wp_widget_rss_output( $link, $args );
$buffer = ob_get_clean();
$result = str_replace("';
}
}
function voxel_dashboard_documentation_feed_num() {
$options = wp_parse_args(
get_option( 'voxel_dashboard_documentation' ),
voxel_dashboard_documentation_defaults()
);
if ( isset( $_POST['submit'] ) ) {
if ( isset( $_POST['rss_items'] ) && intval( $_POST['rss_items'] ) > 0 ) {
$options['items'] = intval( $_POST['rss_items'] );
}
update_option( 'voxel_dashboard_documentation', $options );
}
?>