The following code use to work for generating variables for open graph data, but when I updated to Joomla 4 I now get an error because JRequest is deprecated.
$option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); if ($option=="com_content" && $view=="article") { $ids = explode(':',JRequest::getString('id')); $article_id = $ids[0]; $article =& JTable::getInstance("content"); $article->load($article_id); $theArticle = $article->get("title"); $theImages = $article->get("images"); $pictures = json_decode($theImages); // Split the parameters apart $timage= "http://mywebsite.../".$pictures->{'image_intro'}; } $doc =& JFactory::getDocument(); $doc->addCustomTag( ' <meta name="twitter:title" content="'.mb_strimwidth(strip_tags($theArticle),0,225, " ...").'"=""/> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="yoursite"> <meta name="twitter:creator" content="yourcreator"> <meta name="twitter:url" content="'.JURI::current().'"> <meta name="twitter:description" content="'.mb_strimwidth(strip_tags($doc->getMetaData( 'description' )),0,225, " ...").'"=""/> <meta name="twitter:image" content="'.$timage.'"> <meta property="og:title" content="'.$this->escape($this->item->title).'"/> <meta property="og:type" content="article"/> <meta property="og:email" content="";/> <meta property="og:url" content="'.str_replace('" ','"',juri::current()).'"=""> <meta property="og:image" content="'.$timage.'"/> <meta property="og:site_name" content=""/> <meta property="og:description" content="'.strip_tags($this->item->introtext).'"/> '); How can I rewrite this to work with Joomla 4?