[Resolved] GP Elements, raw php code from Author and Custom Post Navigation elements

Home Forums Support [Resolved] GP Elements, raw php code from Author and Custom Post Navigation elements

Home Forums Support GP Elements, raw php code from Author and Custom Post Navigation elements

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2062379
    Wendy

    For both the Custom Post Navigation and Author Box elements, the php code in the element (accessed and edited from the Elements page) seems to not be getting processed on the server. Instead it is output as an HTML comment partially and partially output as text; the raw PHP code is displayed on the page.

    The page source for the author box is pasted below. Is anyone else having this problem?

    		<div class="author-box">
    	<?php 
    	
    	global $post;
    	
    	$author_id = $post->post_author;
    	
    	?>
    	
    	<div class="avatar"><?php echo get_avatar( get_the_author_meta( $author_id )); ?></div>
     
            <h5 class="author-title"><?php printf( esc_attr__( 'About %s', 'the author' ), get_the_author_meta( 'display_name') );?></h5>
    	
    				<div class="author-summary">
    	
            <p class="author-description"><?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?></p>
     
            <div class="author-links">
     
                <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>" title="Read more">
                    ...
                </a>
     
            </div>
     
        </div>
    #2062389
    Wendy

    Just after I posted my topic I went to one of the Elements in question and noticed this (finally): Unable to execute PHP as DISALLOW_FILE_EDIT is defined. I just changed hosting environments and the default wp-config.php file includes a definition for DISALLOW_FILE_EDIT as FALSE. I removed the definition, and checked the “Execute PHP” box and the now the code is executed.

    That resolves the problem. Still, I must ask: What does file editing have to do with the execution of the php in GP Elements anyway?

    Thank you!

    #2062396
    Elvin
    Staff
    Customer Support

    Hi Wendy,

    Alternative to this, you can actually keep DISALLOW_FILE_EDIT set to true but you’ll have to add this line directly below it on wp-config.php:

    define( 'GENERATE_HOOKS_DISALLOW_PHP', true );

    I recommend reading more here and follow the link pointing to WordPress article about DISALLOW_FILE_EDIT – https://docs.generatepress.com/article/disallow-php-execution/

    A wise man once said:
    "Have you cleared your cache?"

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.