• Resolved astrasuite

    (@astrasuite)


    Hi,

    I have 2 WordPress installations hosted in one server, and installed Post Snippets in both.

    1. /home7/esoundsc/public_html/astrablog/wp_content/plugins/

    2. /home7/esoundsc/public_html/lyrics-soundart/lyrics-news/wp_content/plugins/

    Then, i have the following directory containing PHP and pictures :

    /home7/esoundsc/public_html/client-system-albums/cpmfetch/

    In No. 1, I have this PHP code inside a Post Snippet, for example:

    include $_SERVER['DOCUMENT_ROOT'] . "/client-system-albums/cpmfetch/cpmfetch.php";
      $objCpm = new cpm($_SERVER['DOCUMENT_ROOT'] . "/client-system-albums/cpmfetch/cpmfetch_config.php");
    

    Works perfectly, in No. 1

    I use the same PHP in No. 1 for No. 2 as well.

    Now in No.2, DOCUMENT_ROOT is different and is “/home7/esoundsc/public_html/lyrics-soundart”.

    So, I code the PHP inside a Post Snippet as :

    include $_SERVER['DOCUMENT_ROOT'] . "/../client-system-albums/cpmfetch/cpmfetch.php";
      $objCpm = new cpm($_SERVER['DOCUMENT_ROOT'] . "/../client-system-albums/cpmfetch/cpmfetch_config.php");

    However it fails on the 2nd line in the code, the WordPress post will not completely load and just shows hte heading. I tried a test by echoing Hello World as the first line and it works. It just fails on $objCpm = new cpm($_SERVER[‘DOCUMENT_ROOT’] . “/../client-system-albums/cpmfetch/cpmfetch_config.php”);

    I tried to hardcode the path like below, but didn’t work.

    /home7/esoundsc/public_html/client-system-albums/cpmfetch/cpmfetch_config.php

    What am I missing ? Sorry, I am no PHP expert.

    Thanks

    • This topic was modified 6 years, 8 months ago by astrasuite.

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter astrasuite

    (@astrasuite)

    P.S. There is another plugin called Insert_PHP. In a WordPress post, we just insert the PHP code in between [insert_php] and [/insert_php].

    I tried the code I have a problem with using this plugin, and it works perfectly.

    So, I am puzzled why it does not work if I put it in a snippet, for No 2 WordPress installation. For No 1 WordPress installation, no problem.

    Thanks

    Hi

    I can give you some ideas to look at but can’t really offer support for custom PHP code ??

    IS there some security on No2? Other things that are different between them?

    In the second code you use /../ for the path. I don’t think you need it.

    Kind regards
    David

    Thread Starter astrasuite

    (@astrasuite)

    There is no security in No. 2, it is just like No. 1…

    For the path, DOCUMENT_ROOT for 1 and 2 are not the same so I have to use /../ path.

    No. 2 is basically a subfolder inside the main domain (my service provider calls it AddOn domain), but it is configured as it’s own domain – i.e. No. 1 and No. 2 have different domains, but they are in the same server.

    For example :

    /public_html/abc-wordpress-no-1/ – it would appear in browser as abc.com/abc-wordpress/
    * DOCUMENT_ROOT is /public_html

    /public_html/xyz/xyz-wordpress-No-2/ – it would appear in browser as xyz.com/xyz-wordpress/
    * DOCUMENT_ROOT is /public_html/xyz

    and the PHP code is in /public_html/php-code/php-routine/

    It’s just puzzling. No 1 and No 2 are calling the same PHP program, the only difference is the path. It works if I use the plugin INSERT_PHP (php code is in between shortcode, not snippets).

    Will be thankful for any ideas to look for … Of course, I can continue to use another plugin for No. 2, but I’d like to use yours for consistency, and I like the idea of snippets better than in between shortcode.

    No. 2 is basically a subfolder inside the main domain (my service provider calls it AddOn domain), but it is configured as it’s own domain – i.e. No. 1 and No. 2 have different domains, but they are in the same server.

    Maybe you can ask your hoster about this. Ask them what the correct path should be. I also do not have any ideas, it is indeed strange.

    Thread Starter astrasuite

    (@astrasuite)

    Thanks, I found this on the web in one forum, how to debug. Just add these to the top of snippet or php file to include.

    error_reporting(E_ALL);
    ini_set(‘display_errors’, 1);

    So doing this, it told me about an error that a variable cannot be redeclared.

    Searched again on the internet, someone said use include_once instead of include just to be sure. So I did this, and voila, it works.

    It is still weird, however, as it was ok in No. 1. Anyway, it is resolved.

    Good news!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Post Snippet In a Subfolder’ is closed to new replies.