downloader = $downloader; $this->config = $config; $this->plugin_version = $plugin_version; $this->twig = $twig; } public function register_hook() { add_action( 'in_plugin_update_message-' . TWOFAS_PLUGIN_BASENAME, array( $this, 'show_upgrade_notice' ) ); } public function show_upgrade_notice() { try { $readme = $this->downloader->download( $this->config->get_readme_url() ); $paragraphs = $this->get_paragraphs( $readme ); } catch ( RuntimeException $e ) { $paragraphs = array(); } if ( empty( $paragraphs ) ) { return; } echo $this->twig->get_view( 'dashboard/admin/upgrade-notice.html.twig', array( 'paragraphs' => $paragraphs ) ); } /** * @param Readme $readme * * @return array * * @throws RuntimeException */ private function get_paragraphs( Readme $readme ) { $upgrade_notice = new Upgrade_Notice( $this->plugin_version, $readme ); return $upgrade_notice->get_paragraphs(); } }