tra('Include URL'), 'documentation' => 'PluginIncludeURL', 'description' => tra('Include the body content from a URL'), 'prefs' => ['wikiplugin_includeurl'], 'iconname' => 'link-external', 'introduced' => 15, 'tags' => [ 'basic' ], 'format' => 'html', 'params' => [ 'url' => [ 'required' => true, 'name' => tra('URL'), 'description' => tra('URL to external file to include.'), 'since' => '15.0', 'filter' => 'url', 'default' => '', ], ], ]; } function wikiplugin_includeurl($data, $params) { // Validate that "url" is set. if (empty($params['url'])) { return tr('Missing parameter url for plugin %0', 'includeurl') . '
'; } else { $url = $params['url']; $html = file_get_contents($url); // Only include the body part of the html file $matches = []; if (preg_match("//s", $html, $matches)) { // Find and strip the body $taggedBody = $matches[0]; $bodyEndIdx = strpos($taggedBody, '>'); if ($bodyEndIdx > 0) { $taggedBody = substr($taggedBody, $bodyEndIdx + 1); } $body = substr($taggedBody, 0, -7); } else { // No body tag. Return whole html $body = $html; } return $body; } }