Support » Plugin: Remote Content Shortcode » Handle invalid HTML

  • Resolved TecBrat

    (@tecbrat)


    When attempting to use selector="" , and the remote content had multiple spans with the same id, the system returned PHP errors. I realize the actual problem lies in the remote content, but if we had a way to deal with it, it would be helpful.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Update to provide actual error message and attempted work-around

    Error:
    Warning: DOMDocument::importNode() [domdocument.importnode]: ID pricePerFt already defined in /[MY PATH]l/wp-content/plugins/remote-content-shortcode/inc/phpQuery.php on line 590

    error repeats serveral times

    Unsuccessful work around:
    Try to replace before manipulating DOM
    find='~id="pricePerFt"~' replace='~class="pricePerFt"~'

    The regex worked, so it just means that selector="" happens before find/replace

    Next Step:
    I’ll edit the core file to suppress the error, knowing that any update will break my work-around.

    Plugin Author doublesharp

    (@doublesharp)

    @tecbrat, thanks for the email, and I just pushed an update so you may lose your changes.

    In version 1.4.2 I added some filters that should accomplish what you’re looking for. Just before the content is passed to phpQuery, I am applying a filter like so:

    
    // include phpQuery	
    include_once( 'inc/phpQuery.php' );
    // filter the content
    $response = apply_filters( 'remote_content_shortcode_phpQuery', $response, $url, $selector, $remove );
    // load the response HTML DOM
    phpQuery::newDocument( $response );
    

    You can filter the response however you would like by adding a filter:

    
    add_filter('remote_content_shortcode_phpQuery', function($response, $url, $selector, $remove) {
       return 'The new content!';
    }, 10, 4);
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Handle invalid HTML’ is closed to new replies.