• Resolved Webby Scots

    (@webby-scots)


    Hi,

    The staging site is referencing the plugin files from the main site. My php code runs (I have done echos to see) only in the wp-admin area, not frontend. The js files are being served from the main site – using plugins_url(). Any solutions I can try?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Rene Hermenau

    (@renehermi)

    Hi @webby-scots

    > The js files are being served from the main site – using plugins_url().

    If you hardcoded urls in your plugins then this cannot be handled by wp staging.
    WP staging can not search & replace through your files. It only makes path adjustments to the cloned database tables. So to prevent this you should not use hard paths in your code. Instead https://hostname.com use get_site_url() and so on.

    > The staging site is referencing the plugin files from the main site. My php code runs (I have done echos to see) only in the wp-admin area, not frontend.

    Do you have some real code example for me?

    WP Staging copies the entire site into a subfolder and the clone of your site is 100% independent from the live site. So if you change code of a plugin on the live site it’s under normal circumstances not possible that this affects a plugin on the staging site and vice versa.

    You could copy a helper plugin file to wp-content/mu-plugins/ which scans all HTML (via manipulating bufferd output) and preg_replaces occurencies of example.com/ not followed by the staging dir name with example.com/staging_dir

    One would have to take care about serialized URLs e.g. in script tags.

    Also CSS files will usually contain e.g. background-images with links to the origin’s site ressources. This is probably the cause for this unanswered issue also.

    If all this the plugin denies to deal with path issues it’s practically rather unreliable to use it in a SEO safe way.

    Plugin Author Rene Hermenau

    (@renehermi)

    Hi Frank,

    that would be a smart approach. Have to think more about this but I like the idea.

    Serialized URLs in script tags should not be an often happened issue as they are generated dynamically with data either from the database which has been run through the search & replace method of wp staging already or with data from PHP constants or variables which are built dynamically.

    If @webby-scots sends me a real code sample I can check why his js file was returned from the main site. As already said, I assume it has been hardcoded.
    plugins_url() should never return the path of the main site when it is executed on the staging site.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Staging references live’ is closed to new replies.