Skip to content

Commit

Permalink
Use updated version of simple-html-dom-parser library
Browse files Browse the repository at this point in the history
Replaces an old version with one updated for PHP 7.3. This is needed b/c
PHP 7.3 changes how it handles regular expressions; the PCRE extension was
upgraded: https://secure.php.net/manual/en/migration73.other-changes.php#migration73.other-changes.pcre

Closes #173
  • Loading branch information
tnorthcutt committed Feb 4, 2019
1 parent afd6225 commit 0f1c7e9
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1,730 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"description": "ConvertKit WordPress plugin",
"type": "project",
"license": "GPLv3",
"require": {},
"require": {
"kub-at/php-simple-html-dom-parser": "^1.7"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"vlucas/phpdotenv": "^2.4",
Expand Down
51 changes: 49 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions includes/class-convertkit-api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* ConvertKit PI class
* ConvertKit API class
*
* @package ConvertKit
* @author ConvertKit
Expand Down Expand Up @@ -396,10 +396,6 @@ public function get_resource( $url ) {

if ( ! is_wp_error( $response ) ) {

if ( ! function_exists( 'str_get_html' ) ) {
require_once( CONVERTKIT_PLUGIN_PATH . '/lib/simple-html-dom/simple-html-dom.php' );
}

if ( ! function_exists( 'url_to_absolute' ) ) {
require_once( CONVERTKIT_PLUGIN_PATH . '/lib/url-to-absolute/url-to-absolute.php' );
}
Expand All @@ -413,7 +409,8 @@ public function get_resource( $url ) {

$body = wp_remote_retrieve_body( $response );

$html = str_get_html( $body );
/** @var \simple_html_dom\simple_html_dom $html */
$html = \KubAT\PhpSimple\HtmlDomParser::str_get_html( $body );
foreach ( $html->find( 'a, link' ) as $element ) {
if ( isset( $element->href ) ) {
$element->href = url_to_absolute( $url, $element->href );
Expand Down
Loading

0 comments on commit 0f1c7e9

Please sign in to comment.