Site logo

Archived topic

No solution found for "Unable to execute PHP as DISALLOW_FILE_EDIT"

10 replies · Started by PREMKUMAR S on February 7, 2023

Viewing posts 1–11 of 11

Hello,

I have read all your documentation, but for some reason this message still appears, “Unable to execute PHP as DISALLOW_FILE_EDIT is defined.”

I am unsure what the problem is.

Added this in function php: add_filter( 'generate_hooks_execute_php', '__return_true' );

Tried deactivating the security plugin, I use malcare security plugin and also deactivated perfmatters plugin, cleared wp rocket cache.

Hi there,

the DISALLOW_FILE_EDIT is something that is normally defined in your wp-config.php
More info on that here:

https://docs.generatepress.com/article/disallow-php-execution/

This PHP Snippet only allows you to execute PHP in the GP Hook Element, it has no purpose for anywhere else.

add_filter( 'generate_hooks_execute_php', '__return_true' );

Where are you seeing the warning and what are you wanting to do ?

I don't want another plugin to eat my resources and that's why I've bought the generate press theme, and you are pushing me in the bush again.

Pls check my above statement, I have tried everything mentioned in this article: : https://docs.generatepress.com/article/disallow-php-execution/

Still the same problem and I need elements to create many things.

Hello there,

Can you check if the function you added in functions.php doesn't have curved quotation marks? The quotation marks need to be straight.

Example: add_filter( 'generate_hooks_execute_php', '__return_true' );

Also, to confirm, are you already using a Child theme?

i am using this exact one, add_filter( 'generate_hooks_execute_php', '__return_true' );

Yes, using child theme

Can you confirm that this code:

add_filter( 'generate_hooks_execute_php', '__return_true' );

is in your Child Theme > functions.php file ?

And if it is, is there any other code there ?

This is the code in child theme funcitons.php

<?php
/**
* Custom function PHP code will goes after it
* /
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time>';

if ( get_the_date() !== get_the_modified_date() ) {
$time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>';
}

$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);

return sprintf( '<span class="posted-on">%s</span> ',
$time_string
);
}, 10, 2 );

add_filter( 'generate_hooks_execute_php', '__return_true' );

it working amd i will close this thread as solved.

Glad to hear that

This archived topic is closed to new replies.