tomjn / Frontenberg

A WP theme providing a read only demo of the post block editor on the frontend, provided as is, no support.
https://frontenberg.tomjn.com/
135 stars 30 forks source link

Have an error here #20

Closed altafhpatel closed 2 years ago

altafhpatel commented 3 years ago

public_html/wp-content/themes/guten/includes/restrictions.php on line 197

tomjn commented 3 years ago

Do you have an error message? That file only has 196 lines

altafhpatel commented 3 years ago

that is empty line when i remove

function block_apifetch_modifications() : void {
    $script = <<<SCRIPT
    wp.apiFetch.use( function ( options, next ) {
        if ( 'method' in options ) {
            if ( [ 'PATCH', 'PUT', 'DELETE' ].indexOf( options.method.toUpperCase() ) >= 0 ) {
                return new Promise( function( resolve, reject ) {
                    // Save Data
                    resolve(data);
                } );
            }
        }
        const result = next( options );
        return result;
    } );
    SCRIPT;
    wp_add_inline_script( 'wp-api-fetch', $script );
}

then there is no error

tomjn commented 3 years ago

@altafhpatel do you have the error message itself? Which version of PHP are you using? That code is necessary so removing it isn't an option

altafhpatel commented 3 years ago

@altafhpatel do you have the error message itself? Which version of PHP are you using? That code is necessary so removing it isn't an option

it's latest PHP version i think 7.4 ... it needs to be rewrite...

tomjn commented 3 years ago

@altafhpatel if you put it back in, what is the error message? Is it a syntax error? I need the PHP error message.

altafhpatel commented 3 years ago

Your PHP code changes were rolled back due to an error on line 198 of file wp-content/themes/guten/includes/restrictions.php. Please fix and try saving again.

syntax error, unexpected end of file

altafhpatel commented 3 years ago

Your PHP code changes were rolled back due to an error on line 198 of file wp-content/themes/guten/includes/restrictions.php. Please fix and try saving again.

syntax error, unexpected end of file

it's not the line 198 because i press some enters and comment it that's why it shows line 198... other wise it is the end of file error

tomjn commented 3 years ago

@altafhpatel have you been modifying that file via the theme editor? Frontenberg wasn't designed to take modifications, your theme should be identical to what's in github.

What changes were you trying to make that required you to modify that file?

altafhpatel commented 3 years ago

I didn't make any change just some line spaces that is why it shows wrong line number but the end of the file error... i think something is missing

tomjn commented 3 years ago

hmmm that's still a modification, does it work if you use the unmodified version? I'm not interested in versions that have been modified, even if it's just whitespace changes or the addition/removal of lines.

If that's what's causing this then the answer to your problem is do not modify the files. I can only see the version here on GitHub, I do not know what the change you have made is, just that when you make it you get syntax errors.

tomjn commented 3 years ago

I ran PHPCompatibility PHPCS suite on Frontenberg and no compatibility issues were found. It has been tested with your version of PHP ( 7.4 ), and is running on PHP 8.0 in production.

I do not understand why you would modify Frontenberg via the theme editor in the admin UI. Why would you want to do such a thing? I hope you're not trying to use Frontenberg to create a frontend editor for a client or project! That would be very insecure and unreliable. You should not modify Frontenberg.

Frontenberg is intended as a demonstration to show people the block editor without needing to install WordPress or login. It's locked down for a reason to prevent security issues, Frontenberg is not a frontend editor.