The MU forums have moved to WordPress.org

Edit the primary and secondary dashboard (32 posts)

  1. enseignement
    Member
    Posted 15 years ago #

    Hello,

    I've looked into dashboard.php and have seen we could easily change that to display our news ...
    But i've read in this forum that it was hardcoded for old users and that it will be only available to new users.

    How could I add my news by default for all users ...
    Benjamin

  2. tdjcbe
    Member
    Posted 15 years ago #

    Do you mean the rss feeds within the boxes? I'm seeing edit links when signed in as site admin.

  3. enseignement
    Member
    Posted 15 years ago #

    Yes, but I guess that this is on a blog by blog basis.
    So that it will be edited to my admin dashboard but will not be replicated to all my users.

    Am I right ?

  4. tdjcbe
    Member
    Posted 15 years ago #

    No, the changes go down to the endusers. It's siteadmin editable only.

  5. enseignement
    Member
    Posted 15 years ago #

    Sure about that ?
    Sh***

  6. tdjcbe
    Member
    Posted 15 years ago #

    Works on the testbed. Haven't tried it live yet though.

    If you want to allow endusers to be able to edit them, there are a couple of plugins that work for regular wordpress. Haven't tried them on mu yet though:

    http://www.viper007bond.com/wordpress-plugins/dashboard-widget-manager/

  7. enseignement
    Member
    Posted 15 years ago #

    OK. This is JUST COMPLETELY wrong ...
    - Have edited my dashboard rss (super admin)... and it's not replicated on the others ...
    - other users can edit their rss ..

    Who has a real answer on this ?

  8. enseignement
    Member
    Posted 15 years ago #

    O:9:"MagpieRSS":19:{s:6:"parser";i:0;s:12:"current_item";a:0:{}s:5:"items";a:10:{i:0;a:12:{s:5:"title";s:15:"WordPress 2.3.1";s:4:"link";s:55:"http://wordpress.org/development/2007/10/wordpress-231/";s:8:"comments";s:64:"http://wordpress.org/development/2007/10/wordpress-231/#comments";s:7:"pubdate";s:31:"Fri, 26 Oct 2007 20:55:30 +0000";s:2:"dc";a:1:{s:7:"creator";s:4:"Ryan";}s:8:"category";s:8:"Releases";s:4:"guid";s:55:"http://wordpress.org/development/2007/10/wordpress-231/";s:11:"description";s:367:"WordPress 2.3.1 is now available. 2.3.1 is a bug-fix and security release for the 2.3 series.

    [...]
    join the wp-testers mailing list and download the beta here.</p>
    ";}}s:7:"channel";a:7:{s:5:"title";s:26:"WordPress Development Blog";s:4:"link";s:32:"http://wordpress.org/development";s:11:"description";s:33:"WordPress development and updates";s:7:"pubdate";s:31:"Fri, 26 Oct 2007 20:56:28 +0000";s:9:"generator";s:36:"http://wordpress.org/?v=2.4-bleeding";s:8:"language";s:2:"en";s:7:"tagline";s:33:"WordPress development and updates";}s:9:"textinput";a:0:{}s:5:"image";a:0:{}s:9:"feed_type";s:3:"RSS";s:12:"feed_version";s:3:"2.0";s:5:"stack";a:0:{}s:9:"inchannel";b:0;s:6:"initem";b:0;s:9:"incontent";b:0;s:11:"intextinput";b:0;s:7:"inimage";b:0;s:13:"current_field";s:0:"";s:17:"current_namespace";b:0;s:19:"_CONTENT_CONSTRUCTS";a:6:{i:0;s:7:"content";i:1;s:7:"summary";i:2;s:4:"info";i:3;s:5:"title";i:4;s:7:"tagline";i:5;s:9:"copyright";}s:13:"last_modified";s:31:"Fri, 26 Oct 2007 20:56:28 GMT
    ";s:4:"etag";s:36:""670971ce9c5db07d67746f30b3921b70"
    ";}

    Etc. etc. ... I have found this in my database ... Normal ?

  9. enseignement
    Member
    Posted 15 years ago #

    OK. I've edited the dashboard.php, edited the main blog rss in the dashboard (siteadmin)... and ran the upgrade function ..

    But it's still the same rss displayed ..
    How could I solve this please ?

    Benjamin

  10. dsader
    Member
    Posted 15 years ago #

    Here's what I figure. The dashboard feed urls are stored and then called as option from the db. Change the option and it changes the feed.

    Whatever you plugin to change the feed must change the default db url option or ignore it.

    Unset the original widget, add your own, with its unique option in the db.

  11. lunabyte
    Member
    Posted 15 years ago #

    Hmmm, might be good for a site_option, with site admins only getting the edit link.

  12. enseignement
    Member
    Posted 15 years ago #

    Definitely lunabyte !
    Dsader, sorry but I did not get how to do it ... Could you be more specific ?

  13. lunabyte
    Member
    Posted 15 years ago #

    I will note though, that the dashboard feeds do have a filter on them.

    The bad thing about that though? It only seems to get called when there isn't a value in the database. Which in that case, once the default values are in there then that's it until the user edits them.

    Guess one could always make a quick script to run, and update the db. That's a pretty big pain for a lot of blogs though. Not to mention if you want to go changing it every so often.

  14. enseignement
    Member
    Posted 15 years ago #

    No, but i've ran the upgrade script and now everyone gets the wordpress feeds ...
    I think it could be solved by using the update script ... but don't know where to start ... :(

  15. lunabyte
    Member
    Posted 15 years ago #

    I stuck a trac ticket in for this, for reference, since this deals with site admins and site options, and not something specific that would be of use (or could be used) in the WP core.

  16. enseignement
    Member
    Posted 15 years ago #

    Super thanks !

  17. Konstan
    Member
    Posted 15 years ago #

    I never undestood why it was hardcoded :(

    With 1.3.3, I would edit the files and then all blogs would get the feed of my dev. blog, but now old users are stuck with the new feeds and I cant change them.

    An option to edit the default feeds to all blogs would be nice.

  18. dsader
    Member
    Posted 15 years ago #

    enseignement, here's what I would do.
    Step 1: Unregister the built in dashboard feed widget altogether:
    <?php
    function ds_unregister_dashboard_feed() {
    wp_unregister_sidebar_widget('dashboard_primary');
    wp_unregister_widget_control('dashboard_primary');
    wp_unregister_sidebar_widget('dashboard_secondary');
    wp_unregister_widget_control('dashboard_secondary');
    }
    add_action('wp_dashboard_setup','ds_unregister_dashboard_feed');
    ?>

    Step 2: Write a new widget, copy 'n pasted from the original(or tinker any widget that'll fetch an RSS). Replace any feeds with yours (as a site_option if you prefer). Register the new dashboard widget in the usual way.

    I agree with lunabyte too that the dashboard feed should be a site option, akin to the "Admin Notice Feed" in recent WPMU trunk wpmu-options.php.

  19. enseignement
    Member
    Posted 15 years ago #

    I'll pass this time (no time at all for the moment)... Sorry about that but thanks anyway ..
    I'll disable the display of the dashboard for the moment ...

  20. tdjcbe
    Member
    Posted 15 years ago #

    Who has a real answer on this

    Sorry about that. Could have sworn that it did it the way I was thinking that it would.

    Kind of defeats the purpose of those edit links.

    If you want, the URL are found within /wp-admin/includes/dashboard.php if you want to re-hardcode them.

  21. tdjcbe
    Member
    Posted 15 years ago #

    OK, I noticed that after editing the file in question and taking a look at the Dashboard, the wordpress feeds were still in there. The problem is the URLs are being saved within the blog's option table under dashboard_secondary_output. You have to clear that bit of data before the correct feeds show.

  22. enseignement
    Member
    Posted 15 years ago #

    Do you have a way to clean that up ?

  23. dsader
    Member
    Posted 15 years ago #

    I think I've got it. Changing(permantantly) the primary feed option in the default dashboard widget can be done with something(mu-plugin) like the following.

    add_action( 'wp_dashboard_setup', 'snowflake_dash_feeds');
    function snowflake_dash_feeds() {
    		$widget_options['dashboard_primary'] = array(
    			'link' => 'http://snowflake.domain.org/snowflake/',
    			'url' => 'http://snowflake.domain.org/snowflake/feed/',
    			'title' => 'Snowflakes',
    			'items' => 5,
    			'show_summary' => 1,
    			'show_author' => 0,
    			'show_date' => 1
    		);
    update_option( 'dashboard_widget_options', $widget_options );
    wp_unregister_widget_control('dashboard_primary');
    }
  24. enseignement
    Member
    Posted 15 years ago #

    Will it work also for users that have already the sidebar by default ?
    How to edit the secondary feed ?
    Benjamin

  25. dsader
    Member
    Posted 15 years ago #

    Does this do your work for you?
    add_action( 'wp_dashboard_setup', 'snowflake_dash2_feeds');
    function snowflake_dash2_feeds() {
    $widget_options['dashboard_secondary'] = array(
    'link' => 'http://snowflake.domain.org/snowflake/',
    'url' => 'http://snowflake.domain.org/snowflake/feed/',
    'title' => 'Snowflakes',
    'items' => 5,
    'show_summary' => 1,
    'show_author' => 0,
    'show_date' => 1
    );
    update_option( 'dashboard_widget_options', $widget_options );
    wp_unregister_widget_control('dashboard_secondary');
    }

  26. enseignement
    Member
    Posted 15 years ago #

    Do I just have to save this as a php file and put it in the mu-plugins folder ?

  27. enseignement
    Member
    Posted 15 years ago #

    I've created a .php file and put in mu-plugins.
    Works like a charm (except that sometimes, one of the rss feed is not loaded ...).

    benjamin

  28. dsader
    Member
    Posted 15 years ago #

    The "sometimes" occurs because the dashboard rss widgets are cached. It'll display the new feed but the old title, etc. I have to "force a reload" from my browser a couple o' times when testing. After the correct feed is cached, it seems to work O.K.

  29. enseignement
    Member
    Posted 15 years ago #

    I have one question.
    Why in dashboard did I found this
    I would like to display the name of the author, or the title of the blog in the secondary_output ... not again the title.

    Is it normal behaviour ?

    $author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] );

  30. enseignement
    Member
    Posted 15 years ago #

    Answering to myself :
    Should be :
    $author = $item['dc']['creator'];
    if you wanna display the author of each blog.

    Benjamin

About this Topic

  • Started 15 years ago by enseignement
  • Latest reply from Konstan