- This topic has 7 replies, 2 voices, and was last updated 4 years, 1 month ago by
David.
-
AuthorPosts
-
February 26, 2019 at 5:47 am #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.2GP Premium 1.7.8February 26, 2019 at 6:23 am #821997David
StaffCustomer SupportHi 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"]' ); } }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 26, 2019 at 6:45 am #822023Chantal
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.
February 26, 2019 at 6:56 am #822170David
StaffCustomer SupportCan 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
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 26, 2019 at 8:28 am #822299Chantal
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.
February 26, 2019 at 8:44 am #822336David
StaffCustomer SupportCan you retry the code here i made a small edit.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 26, 2019 at 9:01 am #822354Chantal
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?
February 26, 2019 at 9:02 am #822357David
StaffCustomer SupportAwesome! I don’t think its going to make any difference if that is still there.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.