コード例 #1
0
 /**
  * Get accessor method for instance property.
  *
  * @return WP_DOM_Util Instance of the class.
  */
 public static function get_instance()
 {
     // Check if an instance has not been created yet.
     if (null == self::$instance) {
         // Set instance of class.
         self::$instance = new self();
     }
     // Return instance.
     return self::$instance;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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();
 }