Support » Developing with WordPress » How to Set Icon for a Plugin to show up in WP Updates page

  • Resolved beatR

    (@codepage)


    Hi everybody!

    we distribute a plugin that is not listed on wordpress.org. Automatic update is implemented via wp_autoupdate script (i guess something standard) and hosted on our server.

    The plugin shows correcty on the WordPress Updates page
    /wp-admin/update-core.php

    But we would like it to show our own Icon there. How can i accomplish that?

    i see that icons should be filled here in update-core.php
    $icon = ‘update->icons[ $preferred_icon ] ) . ‘” alt=”” />’;

    Thanks!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi! Thanks. But this is somehow all for custom post types, not for plugins.
    we would like to have a plugin icon here:
    http://wpretarget.codepage.net/plugin_icon.png

    is it even possible to get an own png or svg in there or only standard dashicons?

    Thanks!!

    Moderator bcworkz

    (@bcworkz)

    The concept used in that second link could be applied to just about anything. It leverages the ‘content’ CSS property, so either an icon font or external files could be used.

    Hi
    how can it be applied to anything? i need to apply it to the plugin so it shows up in Update Dashboard (not in the admin menu on the left)

    this is the function used in the example:
    register_post_type( ‘Products’, $args );

    how would i do the same with a plugin?

    usually the icon would be copied to the assets folder in the wordpress repo and simply be named icon128-128.png (something like that). i tried this already, in the update target as well as on the testplatform).
    but we are not in the wordpress repo. see screenshot:
    http://wpretarget.codepage.net/plugin_icon.png

    how would i get our icon showing up in the update list?

    thanks!

    Moderator bcworkz

    (@bcworkz)

    Add the requisite CSS when the specific admin screen is requested. More on adding admin styles from a plugin is covered in Creating Admin Themes. I’m not suggesting you need an admin theme plugin. Only that the same technique of styling admin screens can be used. There ought to be a unique selector that only targets a specific page, but the enqueue CSS example given would still load the CSS file for all admin screens. That will work, but it’s not very efficient. Surely there’s a way to only enqueue the file for a particular request.

    The $hook_suffix passed in the “admin_enqueue_scripts” action hook should work for a conditional enqueuing. If all else fails you can check the request in $_SERVER.

    ah ok, i get it now. Simply setting the right CSS for the logo when the update Screen page is loaded… doesn’t sound very “according to documentation”, but i take it 🙂 since there doesnt seem to be a cleaner path.

    i think there should be a standard way to define the icon, especially since the code is actually there to pickup an icon in the plugin object. it could be done by default filename in the repo or local installation, or by defining it in the header of the plugin file (together with version, author etc.).

    anyway, it’s a detail. Thanks for taking the time to explain a solution to me!

    • This reply was modified 2 years, 11 months ago by beatR.
    Moderator bcworkz

    (@bcworkz)

    You’re welcome.

    The standard way to define an icon “according to documentation” is to be part of the WP plugin repository. Notice how the other icons are not local, they are all served from a domain belonging to the WP organization. If you do not wish to be in the repository for whatever reasons, that is perfectly fine, but you do miss out on some of the benefits of being part of the repository. You probably understand this concept in general, you just didn’t realize exactly what that entailed. At least a workaround is possible. It’s admittedly rather hacky 🙂

    There may be a different workaround. The normal icon src URL on the update screen comes from the transient “update_plugins”. Each plugin’s data is added to the transient when it’s determined that an update is available. You are probably more familiar with this process than I am. I assume the icon URLs are part of the data returned from the repository when an update is available. You could have code set the appropriate URL values during or after the transient data is appended. Probably just as hacky, but more aligned with the “standard way”.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to Set Icon for a Plugin to show up in WP Updates page’ is closed to new replies.