' . __('Settings', 'admin-dashboard-rss-feed') . '';
return $wsx_rss_feed_link;
}
// Create custom plugin settings menu
add_action('admin_menu', 'wsx_rss_feed_admin_page');
function wsx_rss_feed_admin_page()
{
// create new top-level menu
add_options_page('Admin Dashboard RSS Feed Plugin Settings', 'Admin Dashboard RSS Feed', 'manage_options', __FILE__, 'wsx_rss_feed_admin_settings_page');
// call register settings function
add_action('admin_init', 'wsx_rss_feed_admin_settings');
}
function wsx_rss_feed_styles()
{
wp_register_style('wsx-rss-styles', plugin_dir_url(__FILE__) . 'admin/css/style.css');
wp_enqueue_style('wsx-rss-styles');
}
add_action('admin_enqueue_scripts', 'wsx_rss_feed_styles');
function wsx_rss_feed_admin_settings()
{
// register our settings
// Save attachment ID
if (isset($_POST['image_attachment_id'])):
update_option('wsx_rss_feed_image_attachment_id', absint($_POST['image_attachment_id']));
endif;
if($_GET['page'] == "admin-dashboard-rss-feed/admin-rss-feed.php") {
wp_enqueue_media();
}
// Get the Company Logo Title
register_setting('wsx-rss-feed-settings-group', 'wsx_logo_title');
// Get the Company Logo Target Link
register_setting('wsx-rss-feed-settings-group', 'wsx_logo_target_link');
// Feed URL
register_setting('wsx-rss-feed-settings-group', 'wsx_rss_feed_url');
// Feed Count
register_setting('wsx-rss-feed-settings-group', 'wsx_rss_feed_count');
}
function wsx_rss_feed_admin_settings_page() { ?>
Admin Dashboard RSS Feed Settings
"")
{
$rss_feed_url = esc_attr(get_option('wsx_rss_feed_url'));
}
else
{
echo "Enter the valid feed URL";
}
$wsx_rss_feeds = array("$rss_feed_url");
// Loop through Feeds
foreach($wsx_rss_feeds as $feed):
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed($feed);
if (!is_wp_error($rss)): // Checks that the object is created correctly
// Figure out how many total items there are, and choose a limit
$feed_count = esc_attr(get_option('wsx_rss_feed_count'));
if ($feed_count <> "")
{
$feed_count = esc_attr(get_option('wsx_rss_feed_count'));
}
else
{
$feed_count = "5";
}
// echo $feed_count;
$maxitems = $rss->get_item_quantity($feed_count);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
// Get RSS title
$rss_title = '' . strtoupper($rss->get_title()) . '';
endif;
// Display the container
$wsx_logo_url = wp_get_attachment_url(get_option('wsx_rss_feed_image_attachment_id'));
$wsx_logo_title = esc_attr(get_option('wsx_logo_title'));
$wsx_logo_target_link = esc_attr(get_option('wsx_logo_target_link'));
echo '