| 1 |
<?php |
| 2 |
/** |
| 3 |
* Snippet Name: RSS Feed to dashboard |
| 4 |
* Snippet URL: https://jeweltheme.com/category/master-addons/feed/ |
| 5 |
*/ |
| 6 |
|
| 7 |
add_action('wp_dashboard_setup', 'ma_el_dashboard_widgets'); |
| 8 |
|
| 9 |
function ma_el_array_flatten($array) { |
| 10 |
if (!is_array($array)) { |
| 11 |
return false; |
| 12 |
} |
| 13 |
$result = array(); |
| 14 |
foreach ($array as $key => $value) { |
| 15 |
if (is_array($value)) { |
| 16 |
$result = array_merge($result, array_values($value)); |
| 17 |
} else { |
| 18 |
$result[$key] = $value; |
| 19 |
} |
| 20 |
} |
| 21 |
return $result; |
| 22 |
} |
| 23 |
|
| 24 |
function ma_el_dashboard_widgets() { |
| 25 |
global $wp_meta_boxes; |
| 26 |
unset( |
| 27 |
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'], |
| 28 |
$wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'], |
| 29 |
$wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] |
| 30 |
); |
| 31 |
|
| 32 |
// add a custom dashboard widget |
| 33 |
wp_add_dashboard_widget( |
| 34 |
'dashboard_custom_feed', |
| 35 |
'News from siteXY', |
| 36 |
'dashboard_custom_feed_output' ); |
| 37 |
} |
| 38 |
|
| 39 |
function dashboard_custom_feed_output() { |
| 40 |
echo '<div class="rss-widget">'; |
| 41 |
wp_widget_rss_output(array( |
| 42 |
'url' => 'https://jeweltheme.com/feed', |
| 43 |
'title' => 'Whats up at siteXY', |
| 44 |
'items' => 4, |
| 45 |
'show_summary' => 1, |
| 46 |
'show_author' => 0, |
| 47 |
'show_date' => 1 |
| 48 |
)); |
| 49 |
echo "</div>"; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|