I second swosko’s praise for your plug-in. Simple and straightforward, it was pretty much exactly what I needed for a client’s site who just didn’t want to have keep updating his résumé in so many places. He wanted to show his LinkedIn résumé almost verbatim, with just a couple of items removed, and your plug-in did this with the least meddling.
Just a couple quick suggestions for possible enhancements:
? Remove LinkedIn-specific stuff like “My connections” link.
? Strip out the “more” and “less” links that may appear in Past Experience section of the Summary block.
* Add some options for the output of the resume, such as showing or hiding certain block and individual elements (e.g. the Summary). Perhaps beyond the scope of this plug-in…
* Consider adding a filter hook so people can do further modifications to the output code. Something like this:
function lnhr_stripout_hresume($content) {
...
$hresume = apply_filters( 'lnhr_resume', $hresume );
return $hresume;
}
For my purposes, I added the filter hook mentioned above and then did some further parsing outside the plug-in to remove unwanted elements. I used PHP DOMDocument to convert the résumé so I could find and remove nodes without complicated regexes (why don’t more people do this?).
// tidy up output of LinkedIn hResume plug
add_filter('lnhr_resume', 'lnhr_tidy');
function lnhr_tidy($content) {
$doc = new DOMDocument("1.0", get_option('blog_charset'));
$doc->loadHTML($content);
$xpath = new DOMXPath($doc);
DOMremoveHTMLElements($xpath, 'id', 'overview');
DOMremoveHTMLElements($xpath, 'id', 'additional-information');
DOMremoveHTMLElements($xpath, 'class', 'adr');
DOMremoveHTMLElements($xpath, 'class', 'actions');
DOMremoveHTMLElements($xpath, 'class', 'organization-details');
DOMremoveHTMLTags($doc, 'hr');
$content = preg_replace('%^.*<body>|</body>.*$%si', '', $doc->saveHTML());
return $content;
}
function DOMremoveHTMLTags($doc, $search) {
$tags = $doc->getElementsByTagName($search);
$tagsToRemove = array(); // https://us2.php.net/manual/en/domnode.removechild.php#90292
foreach ($tags as $tag) {
$tagsToRemove[] = $tag;
}
foreach ($tagsToRemove as $tag) {
$tag->parentNode->removeChild($tag);
}
}
// https://www.php.net/manual/en/domdocument.getelementbyid.php#96500
// https://us2.php.net/manual/en/domxpath.query.php
function DOMremoveHTMLElements($xpath, $type, $search) {
$elements = $xpath->query("//*[@$type='$search']");
if (!is_null($elements)) {
foreach ($elements as $element) {
$element->parentNode->removeChild($element);
}
}
}
Cheers, and thanks again for the nice plug-in!