/**
  * Displays MailChimp feed.
  *
  * Most notably, it adds necessary inline styles to whip email templates into shape.
  *
  * @param string $content Post content.
  * @return string Modified post content, specific to the MailChimp feed.
  */
 public function display_feed($content)
 {
     $dom_util = WP_DOM_Util::get_instance();
     $dom = new DOMDocument();
     $dom->preserveWhiteSpace = false;
     $dom->LoadHTML($dom_util->get_meta() . $content);
     $images = $dom->getElementsByTagName('img');
     foreach ($images as $image) {
         $image->setAttribute('style', 'max-width: 100%;');
     }
     do_action('wp_mailchimp_feed_modify_dom', $dom);
     $content = $dom_util->get_inner_html($dom->getElementsByTagName('body')->item(0));
     return $content;
 }
 /**
  * Get file list from boiler
  *
  * @return json this list
  */
 public function getFileFromChaudiere()
 {
     $r['response'] = true;
     $htmlCode = file_get_contents('http://' . CHAUDIERE . URL);
     $dom = new DOMDocument();
     $dom->LoadHTML($htmlCode);
     $links = $dom->GetElementsByTagName('a');
     $t_href = array();
     foreach ($links as $a) {
         $href = $a->getAttribute('href');
         if (preg_match("/csv/i", $href)) {
             array_push($t_href, array("file" => trim(str_replace(URL . "/", "", $href)), "url" => 'http://' . CHAUDIERE . $href));
         }
     }
     $r['listefiles'] = $t_href;
     $this->sendResponse($r);
 }
 /**
  * css_tricks_super_awesome_feed_image_magic. Nuff' Said!
  *
  * @since  1.0.0
  * @access public
  * @return string the feed content
  */
 public function css_tricks_super_awesome_feed_image_magic($content)
 {
     // Weirdness we need to add to strip the doctype with later.
     $content = '<div>' . $content . '</div>';
     $doc = new DOMDocument();
     $doc->LoadHTML($content);
     $images = $doc->getElementsByTagName('img');
     foreach ($images as $image) {
         $image->removeAttribute('height');
         $image->setAttribute('width', '320');
         $image->setAttribute('style', 'display: block;');
     }
     $figures = $doc->getElementsByTagName('figure');
     foreach ($figures as $figure) {
         $figure->setAttribute('style', 'display: block; margin: 0 0 10px 0;');
     }
     $iframes = $doc->getElementsByTagName('iframe');
     foreach ($iframes as $iframe) {
         $iframe->parentNode->removeChild($iframe);
     }
     // Strip weird DOCTYPE that DOMDocument() adds in
     $content = substr($doc->saveXML($doc->getElementsByTagName('div')->item(0)), 5, -6);
     return $content;
 }
Example #4
0
function wbw_super_awesome_feed_image_magic($content)
{
    // Weirdness we need to add to strip the doctype with later.
    $content = '<div>' . $content . '</div>';
    $doc = new DOMDocument();
    $doc->LoadHTML($content);
    $images = $doc->getElementsByTagName('img');
    foreach ($images as $image) {
        $image->removeAttribute('height');
        $image->setAttribute('width', '556');
    }
    // Strip weird DOCTYPE that DOMDocument() adds in
    $content = substr($doc->saveXML($doc->getElementsByTagName('div')->item(0)), 5, -6);
    return $content;
}
 /**
  * Gets the image DOM elements from content.
  *
  * @param string $content Content with some markup, usually post content.
  * @return DOMNodeList List of image elements found in content.
  */
 public function get_image_elements($content)
 {
     if (!empty($content)) {
         $dom_util = WP_DOM_Util::get_instance();
         $dom = new DOMDocument();
         $dom->preserveWhiteSpace = false;
         $dom->LoadHTML($dom_util->get_meta() . $content);
         return $dom->getElementsByTagName('img');
     }
     return new DOMNodeList();
 }
Example #6
0
function getPlayFabSiteStructureAsArray($link, $class)
{
    // Get HTML
    $pfdocs_client_content = file_get_contents($link);
    $pfdocs_client_docref = new DOMDocument();
    $pfdocs_client_docref->loadHTML($pfdocs_client_content);
    // Get Method Block
    $pfdocs_client_contentfinder = new DomXPath($pfdocs_client_docref);
    $pfdocs_client_finderresult = $pfdocs_client_contentfinder->query("//*[@class='" . $class . "']");
    if ($pfdocs_client_finderresult->length > 0) {
        // Get Methods
        $pfdocs_client_methods = $pfdocs_client_docref->saveHTML($pfdocs_client_finderresult->item(0));
        $pfdocs_client_methods_docref = new DOMDocument();
        $pfdocs_client_methods_docref->LoadHTML($pfdocs_client_methods);
        $pfdocs_client_methods_contentfinder = new DOMXPath($pfdocs_client_methods_docref);
        $pfdocs_client_methods_finderresult = $pfdocs_client_methods_contentfinder->evaluate("//li");
        $pfdocs_client_methods_result = array();
        foreach ($pfdocs_client_methods_finderresult as $entry) {
            //$pfdocs_client_methods_result[] = '<' . $entry->tagName . '>' . $entry->nodeValue .  '</' . $entry->tagName . '>';
            // Save each methods raw HTML
            $pfdocs_client_methods_result[] = $pfdocs_client_methods_docref->saveHTML($entry);
        }
        //print_r($pfdocs_client_methods_result);
        //exit();
        $pfdocs_client_docarray = array();
        $temp_lastcathead = "";
        $i = 0;
        foreach ($pfdocs_client_methods_result as $rawentry) {
            if (strpos($rawentry, "<div class=\"summary\">") == false) {
                $temp_doc = new DOMDocument();
                $temp_doc->loadHTML($rawentry);
                $temp_heads = $temp_doc->getElementsByTagName('span')->item(0);
                foreach ($temp_heads->childNodes as $temp_head) {
                    $temp_fcathead = $temp_doc->saveHTML($temp_head);
                    $temp_lastcathead = $temp_fcathead;
                }
            } else {
                preg_match_all('/<a[^>]+href=([\'"])(.+?)\\1[^>]*>/i', $rawentry, $temp_link);
                $temp_flink = $temp_link[2][0];
                $temp_doc = new DOMDocument();
                $temp_doc->loadHTML($rawentry);
                $temp_heads = $temp_doc->getElementsByTagName('a')->item(0);
                $temp_summs = $temp_doc->getElementsByTagName('div')->item(0);
                foreach ($temp_heads->childNodes as $temp_head) {
                    $temp_fcat = $temp_doc->saveHTML($temp_head);
                }
                foreach ($temp_summs->childNodes as $temp_sum) {
                    $temp_fsum = $temp_doc->saveHTML($temp_sum);
                }
                $pfdocs_client_docarray[$temp_lastcathead][$i]['name'] = $temp_fcat;
                $pfdocs_client_docarray[$temp_lastcathead][$i]['link'] = $temp_flink;
                $pfdocs_client_docarray[$temp_lastcathead][$i]['sum'] = $temp_fsum;
                $i++;
            }
        }
        return $pfdocs_client_docarray;
    }
}