{"id":3413,"date":"2017-02-16T18:18:11","date_gmt":"2017-02-16T17:18:11","guid":{"rendered":"https:\/\/en.florianbrinkmann.de\/?p=3413"},"modified":"2020-02-09T10:59:56","modified_gmt":"2020-02-09T09:59:56","slug":"displaying-admin-notice-when-update-for-specific-plugin-is-available","status":"publish","type":"post","link":"https:\/\/florianbrinkmann.com\/en\/displaying-admin-notice-when-update-for-specific-plugin-is-available-3413\/","title":{"rendered":"Displaying admin notice when update for specific plugin is available"},"content":{"rendered":"\n

I use the German Market<\/em> plugin for generating invoices and use a custom font which is not integrated into the plugin by default, so I have to re-upload it after updating the plugin. So I do not forget this, I implemented an admin notice which is displayed if a German Market update is available. That is not very difficult, and this is the complete code:<\/p>\n\n\n

\/**\n * Display admin notice so I remember uploading the Clavo font after updating German Market\n *\/<\/span>\nfunction<\/span> fbn_german_market_typography_notice<\/span>(<\/span>) <\/span>{\n $update_plugins_transient = get_site_transient( 'update_plugins'<\/span> );\n if<\/span> ( $update_plugins_transient->response['woocommerce-german-market\/WooCommerce-German-Market.php'<\/span>] ) {\n add_action( 'all_admin_notices'<\/span>, function<\/span> (<\/span>) <\/span>{ ?>\n <div<\/span> class<\/span>=\"notice notice-warning\"<\/span>><\/span>\n <p<\/span>><\/span><strong<\/span>><\/span>Nach dem \u00bbGerman Market\u00ab-Update den Clavo-Font f\u00fcr Rechnungen wieder hochladen!<\/strong<\/span>><\/span><\/p<\/span>><\/span>\n <\/div<\/span>><\/span><\/span>\n <?php } );\n }\n}\n\nadd_action( 'admin_init'<\/span>, 'fbn_german_market_typography_notice'<\/span> );<\/code><\/div>Code language:<\/span> JavaScript<\/span> (<\/span>javascript<\/span>)<\/span><\/small><\/pre>\n\n\n

I hook fbn_german_market_typography_notice()<\/code> to admin_init<\/code>. First, the function saves the value of the update_plugins<\/code> transient, which stores information about available plugin updates. If $update_plugins_transient->response['woocommerce-german-market\/WooCommerce-German-Market.php']<\/code> is not empty, an update is available.<\/p>\n\n\n\n

In this case, the admin notice is displayed (I use all_admin_notices<\/code>, so the notice is not only showed in the network admin), which hopefully will remind me to upload the font for the invoices \u2026 \ud83d\ude42<\/p>\n\n\n\n

Of course, the array key is different for every plugin. You can take a look at the value of the transient via var_dump( $update_plugins_transient );<\/code> to find the correct key.<\/p>\n\n\n\n

PS: More on admin notices in the post \u00bbAdmin Notices in Plugin UIs\u00ab by Caspar H\u00fcbinger<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

I use the German Market plugin for generating invoices and use a custom font which is not integrated into the plugin by default, so I have to re-upload it after updating the plugin. So I do not forget this, I implemented an admin notice which is displayed if a German Market update is available. That […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","wpf_show_in_dewp_planet_feed":false,"flobn_post_versions":"","lazy_load_responsive_images_disabled":false},"categories":[6],"tags":[],"wp-worthy-pixel":{"ignored":false,"public":null,"server":null,"url":null},"wp-worthy-type":"normal","_links":{"self":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3413"}],"collection":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/comments?post=3413"}],"version-history":[{"count":2,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3413\/revisions"}],"predecessor-version":[{"id":5914,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/posts\/3413\/revisions\/5914"}],"wp:attachment":[{"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/media?parent=3413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/categories?post=3413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/florianbrinkmann.com\/en\/wp-json\/wp\/v2\/tags?post=3413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}