WordPress.org

Forums

Enabling PHP in posts (13 posts)

  1. mserms
    Member
    Posted 11 years ago #

    Is there any way to allow PHP code to run inside posts?

  2. idahocline
    Member
    Posted 11 years ago #

    should have a look at stevarino I did something for that.

  3. idahocline
    Member
    Posted 11 years ago #

    where do you added the code ?

  4. mserms
    Member
    Posted 11 years ago #

    I'm getting this error:

    Parse error: parse error, expecting ','' or ';'' in /home/mserms/public_html/blogtest/my-hacks.php(18) : eval()'d code on line 4

  5. idahocline
    Member
    Posted 11 years ago #

    which errors do you get exactly ?
    Are you using the following code ?

    function run_php($data) {
    if(false !== strpos($data, "<php>")) {
    $data = str_replace(array("\r\n","\r"), "\n", $data);
    $datas = split('</?php>', $data);
    $data = "echo <<<WP_PHP_PARSER0\n" . str_replace(array("\\","\$","\n","\r"), array("\\\\","\\\$","\\n","\\r"), $datas[0]);
    $j = 0;
    for($i = 1; $i < count($datas); $i += 2) {
    $data .= "\nWP_PHP_PARSER$j;\n" . str_replace(array('’', '“', '”'), array("'", '"', '"'), $datas[$i]);
    $j++;
    $data .= "echo <<<WP_PHP_PARSER$j\n" . str_replace(array("\\","\$","\n","\r"), array("\\\\","\\\$","\\n","\\r"), $datas[$i+1]);
    }
    $data .= "\nWP_PHP_PARSER$j;\n return true;";
    ob_start(); // run that data and grab what comes out
    if(! eval($data)){
    $fp = fopen($DOCUMENT_ROOT."wp-php.txt", 'w');
    fwrite($fp, $data);
    fclose($fp);
    }
    $data = ob_get_clean();
    }
    return $data;
    }
    add_filter('the_content', 'run_php');

  6. mserms
    Member
    Posted 11 years ago #

    I'm getting this error:

    Parse error: parse error, expecting ','' or ';'' in /home/mserms/public_html/blogtest/my-hacks.php(18) : eval()'d code on line 4

  7. mserms
    Member
    Posted 11 years ago #

    I'm getting this error:

    Parse error: parse error, expecting ','' or ';'' in /home/mserms/public_html/blogtest/my-hacks.php(18) : eval()'d code on line 4

  8. mserms
    Member
    Posted 11 years ago #

    I'm getting this error:

    Parse error: parse error, expecting ','' or ';'' in /home/mserms/public_html/blogtest/my-hacks.php(18) : eval()'d code on line 4

  9. idahocline
    Member
    Posted 11 years ago #

    just have a look at my version of the stuff here

  10. mserms
    Member
    Posted 11 years ago #

    I'm getting this error:

    Parse error: parse error, expecting ','' or ';'' in /home/mserms/public_html/blogtest/my-hacks.php(18) : eval()'d code on line 4

  11. idahocline
    Member
    Posted 11 years ago #

    can we continue this via mail ? Can you provide me your @mail ?

  12. mserms
    Member
    Posted 11 years ago #

    Sure, much easier.
    mark [at] scottishclimbs.com

  13. idahocline
    Member
    Posted 11 years ago #

    check your inbox... ;o)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.