• Resolved kozakozak

    (@kozakozak)


    Specification:
    WampServer Version 3.1.0: Apache 2.4.27, PHP 5.6.31
    WordPress 4.9.5
    Google Maps CP 1.0.12

    Scenario:
    1. Create a page with [codepeople-post-map] shortcode
    2. Make sure your REST API is enabled
    3. Make a get request to <servername>/wp-json/wp/v2/pages

    Expected:
    Recieve a valid JOSN response begining with a ‘[‘ or ‘{‘ character

    Recieved:
    Two script tags and one link tag before the begining of JSON

    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script><link rel='stylesheet' id='cpm_style-css' href='https://akme/wp-content/plugins/codepeople-post-map/styles/cpm-styles.css' type='text/css' media='all' /><script src='https://akme/wp-content/plugins/codepeople-post-map/js/cpm.js'></script>[{"id":91,"date":"2015-02-27T11:23:25","date_gmt":"2015-02-27T11:23:25","guid":{"rendered":"http:\/\/akme\/?page_id=91"},"modified":"2015-05-27T21:59:04","modified_gmt":"2015-05-27T21:59:04","slug":"sowes","status":"publish","type":"page","link":"http:\/\/akme\/sowes\/","title":{"rendered":"SOWES"},"content":{"rendered":"<p><a>.....

    Possible solution:
    Codepeople developers might want to enclose line 841 to 847 in functions.php (load_resources function) in an IF statement to make sure these tags are only printed if current request is not coming to REST API like so:

    if (!(defined('REST_REQUEST') && REST_REQUEST)) {
    // ...Code here
    }

    They might not want to do that for various reasons.

    Workaround:
    Enable Load required resources (javascript files) in footer option in plugin settings

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘script and link tags added to REST API response’ is closed to new replies.