{"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 I hook In this case, the admin notice is displayed (I use \/**\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
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
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