[Support request] How to Execute PHP when wp-config can't be amended?

Home Forums Support [Support request] How to Execute PHP when wp-config can't be amended?

Home Forums Support How to Execute PHP when wp-config can't be amended?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #821969
    Chantal

    Hi there, hoping you can help.

    My hosting company has added the following to my site’s wp-config:

    The constant definition has now been added to the website’s wp-config.php file:
    rskeens@web125:/data/s3500/dom7210/httpdocs$ grep GENERATE_HOOKS_DISALLOW_PHP wp-config.php
    define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );

    But the DISALLOW_FILE_EDIT is still defined. When I said it doesn’t seem to have had any effect, they responded “the DISALLOW_FILE_EDIT constant definition is always set as true for customers on our shared platform due to the inherent security risks associated with enabling it.”

    Is there any point in having that in the config file if the Execute PHP checkbox is still not accessible?

    I really need to execute the following code in the before_header hook (as WP-Toolset conditionals don’t work well here because the shortcode text displays in the screen reader on the site):

    <php if ( !wp_is_mobile() ) : ?;
    [wpv-view name=”sitewide-advert”]
    <php endif; ?>

    I know nothing about PHP. I wonder, can this be turned into a function and added to Code Snippets?

    GeneratePress 2.2.2
    GP Premium 1.7.8
    #821997
    David
    Staff
    Customer Support

    Hi there,

    you can try this in Code Snippets:

    add_action( 'generate_before_header', 'db_execute_shortcode' );
    function db_execute_shortcode() {
        if ( !wp_is_mobile() ) {
            echo do_shortcode( '[wpv-view name="sitewide-advert"]' );
        }
    }
    #822023
    Chantal

    Hi Dave,

    Thanks for your response. That’s not working unfortunately. If I delete the shortcode in Elements, the sitewide advert (the top banner displaying at the very top of the site) disappears completely which means the snippet hasn’t worked.

    I am trying to achieve the following: the top banner to disappear only if the site is viewed on a mobile device but to show on a desktop.

    I achieved this using conditional hooks but the shortcode text was displaying. The source code showed it was something to do with the Screen Reader. I contacted Toolset about this and they said Execute PHP was the way to go.

    #822170
    David
    Staff
    Customer Support

    Can you test this in Code Snippets:

    add_action( 'generate_before_header', 'db_snip_test' );
    function db_snip_test() {
        if ( !wp_is_mobile() ) {
            echo "I appear only on desktop";
        }
    }

    Let me know if the echoed text appears

    #822299
    Chantal

    Hi David, yes it does on the desktop. I’ll leave the code snippet activated if you want to see the text on the site.

    #822336
    David
    Staff
    Customer Support

    Can you retry the code here i made a small edit.

    #822354
    Chantal

    Yippee! Thank you David, that has worked. 🙂

    Should I ask my hosting company to remove the GP constant definition from wp-config? Or does it actually make a difference?

    #822357
    David
    Staff
    Customer Support

    Awesome! I don’t think its going to make any difference if that is still there.

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