phpQuery::newDocument PHP Method

newDocument() public static method

Chainable.
public static newDocument ( unknown_type $markup = null, $contentType = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
$markup unknown_type
return phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery
    public static function newDocument($markup = null, $contentType = null)
    {
        if (!$markup) {
            $markup = '';
        }
        $documentID = self::createDocumentWrapper($markup, $contentType);
        return new phpQueryObject($documentID);
    }

Usage Example

Example #1
0
 public function get_data()
 {
     if (!class_exists('phpQuery')) {
         include dirname(__FILE__) . '/phpQuery.php';
     }
     $response = wp_remote_get($this->url . '/tags');
     if (is_wp_error($response)) {
         return false;
     }
     phpQuery::newDocument($response['body']);
     $version = false;
     $zip_url = false;
     foreach (pq('table.tags a.name') as $tag) {
         $tag = pq($tag);
         if (version_compare($tag->text(), $version, '>=')) {
             $href = $tag->attr('href');
             $commit = substr($href, strrpos($href, '/') + 1);
             $zip_url = $this->url . '/snapshot/' . $commit . '.zip';
             $version = $tag->text();
             $updated_at = $tag->parent()->prev()->text();
         }
     }
     $this->new_version = $version;
     $this->zip_url = $zip_url;
     $this->updated_at = date('Y-m-d', strtotime($updated_at));
     $this->description = pq('div.page_footer_text')->text();
 }
All Usage Examples Of phpQuery::newDocument