Пример #1
0
 /**
  * Check the Content parser is working properly or not
  */
 public function testContentParsing()
 {
     require_once __DIR__ . '/../../../../wp-load.php';
     $content = file_get_contents(__DIR__ . '/testResources/content.html');
     $filterKeywords = array('whiteList' => array('pagemaker'), 'blackList' => array('desktop'));
     $filterMode = 'white_list';
     $contentParser = new Content();
     echo $parsedContent = $contentParser->convertContent($content, $filterKeywords, $filterMode);
 }
Пример #2
0
/**
 * vital function which is hooked into the_content filter.
 * this function parse the content of posts and pages, changes the <abbr> tags into wiki links.
 * after a successful parsing it stores the data into post meta for future caching.
 * 
 * @param string $content The Post/Page content
 * @return string $parsedContent parsed content based on filter keywords
 */
function addWikiLinkToContent($content)
{
    $pluginState = get_option('wikiPluginState');
    if (!$pluginState) {
        return $content;
    }
    $postId = get_the_ID();
    $cachedContent = get_post_meta($postId, 'wikiCache', TRUE);
    if (!empty($cachedContent)) {
        return $cachedContent;
    }
    $filterKeyWords = array('whiteList' => (array) json_decode(get_option('wikiWhiteList')), 'blackList' => (array) json_decode(get_option('wikiBlackList')));
    $filterMode = get_option('wikiFilterState');
    $contentLib = new Content();
    $parsedContent = $contentLib->convertContent($content, $filterKeyWords, $filterMode);
    update_post_meta($postId, 'wikiCache', $parsedContent);
    return $parsedContent;
}