1<?php 2 3use ComboStrap\ExceptionNotFound; 4use ComboStrap\Meta\Api\Metadata; 5use ComboStrap\PageKeywords; 6 7 8/** 9 * 10 * https://developers.google.com/search/blog/2009/09/google-does-not-use-keywords-meta-tag 11 */ 12class action_plugin_combo_metakeywords extends DokuWiki_Action_Plugin 13{ 14 15 16 17 18 19 public function register(Doku_Event_Handler $controller) 20 { 21 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'meta_keywords', array()); 22 } 23 24 /** 25 * Add a key words description 26 * @param $event 27 * @param $param 28 * @throws ExceptionNotFound 29 */ 30 function meta_keywords(&$event, $param) 31 { 32 33 34 try { 35 $page = action_plugin_combo_metacanonical::getContextPageForHeadHtmlMeta(); 36 } catch (ExceptionNotFound $e) { 37 return; 38 } 39 40 try { 41 $keywords = $page->getKeywordsOrDefault(); 42 } catch (ExceptionNotFound $e) { 43 return; 44 } 45 46 Metadata::upsertMetaOnUniqueAttribute( 47 $event->data['meta'], 48 "name", 49 [ 50 "name" => PageKeywords::PROPERTY_NAME, 51 "content" => implode(",", $keywords) 52 ] 53 ); 54 55 56 } 57 58 59} 60