• Resolved Mehmet Tahta

    (@x12x63)


    Hello,

    When i try to run removing disqus from home page, i got this error:

    AH01071: Got error ‘PHP message: PHP Parse error: syntax error, unexpected ‘version’ (T_STRING) in /var/www/vhosts/mtahta.com/httpdocs/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()’d code on line 1\n’, referer: https://mtahta.com/wp-admin/admin.php?page=snippets

    I don’t want to disable mod security or any security related settings. Any suggestion?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hey,

    This is an issue with one of your snippets. Unfortunately, it’s not easy to discern which one from this error message, but it will be one where you have version on the first line of the snippet code.

    Good luck!

    Thread Starter Mehmet Tahta

    (@x12x63)

    Hello Shea,

    I used only removing disqus from home page snippet. I copied the codes from your Github page, which you can reach at: https://github.com/lukecav/code-snippets-wp-speed-up/blob/master/remove-count.js-in-disqus-from-loading-on-homepage.code-snippets.xml
    I don’t use anything else. I disabled mod security and whitelisted my ip from WordFence plugin, then i could run this plugin. But unfortunately it don’t works.

    Plugin Author Shea Bunge

    (@bungeshea)

    Hey,

    That’s not actually my GitHub page at all – it belongs to someone completely different. I didn’t realise that a collection like this existed, so that’s pretty cool.

    What you have copied is an export file. It’s intended to be uploaded to your site through though the Snippets > Import menu, not copied and pasted directly as snippet code.

    If you remove the snippet you currently have and upload the file through the correct page instead, it should work perfectly fine – no changes to security plugins necessary.

    Thread Starter Mehmet Tahta

    (@x12x63)

    Oh, totally my bad. Yes its pretty cool.

    I fixed the problem myself. I changed class-disqus-public.php file, I added new lines to these lines:

    // Don't load any Disqus scripts on feed pages.
    if ( is_feed() ) {
    	return false;
    		}

    under these lines, i added:

    if ( is_front_page() ) {
    	return false;
    }

    It works, but i am not sure what will i do after this plugin updated.

    Plugin Author Shea Bunge

    (@bungeshea)

    Does the snippet not work after you import and activate it?

    Thread Starter Mehmet Tahta

    (@x12x63)

    I didn’t used it. It gives HTTP 500 error when i want to run it. While waiting your response, i look around the disqus plugin and changed these lines and fixed it myself. I am using mod security and wordfence. Mod security blocks your plugin because it has “eval” code line in it. Check my first message, it was access log which i get from Plesk.

    In snippet-ops.php file at 352 line number, you use eval. Eval is mostly used for illegal things, so mod security blocks it. If is there any way to change the code without using eval, you should do it.

    • This reply was modified 6 years, 8 months ago by Mehmet Tahta.
    Plugin Author Shea Bunge

    (@bungeshea)

    eval(), when used in this context, is not insecure, and it’s a bit obtuse for security plugins to just block it blindly. But I didn’t realise that you disabling those features was to use the plugin itself, not just as part of trying to get the snippet to work. Unfortunately, at the moment this seems like the best method for executing snippets – I do have an idea for improving it in the future, but it’s not something that can happen immediately.

    Perhaps you could try just creating a new snippet using this code and see if it works:

    remove_action( 'pre_comment_on_post', 'dsq_pre_comment_on_post' );
    add_action( 'the_post', function () {
        if ( is_front_page() ) {
            remove_filter('comments_template', 'dsq_comments_template');
        }
    } );

    I would advise against just editing the plugin file directly, as these changes will be lost when you upgrade the plugin.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘HTTP 500 Error’ is closed to new replies.