how can use /mfunc to if else <?php
-
as you can see, i dynamic my page`s footer,but when i use /mfunc code,i cant edit dashboard->customize …
this is the pic link
https://imgur.loukky.com/imgs/2021/09/d738424b8d0506f0.pngThe page I need help with: [log in to see the link]
-
Hello @loukky
Thank you for reaching out and I am happy to help!
Can you please share if you have any <PHP> tags within the mfunc comment?
Thanks!this is my theme`s footer.php
</div><!-- .cv-container --> <!-- if ( is_user_logged_in() ) { echo "<?php /* do_action( 'news_vibrant_footer' ); do_action('performance'); */?>" } else { echo "do_action( 'news_vibrant_footer' ); do_action('performance');"; }--> <!-- mfunc dynamic_tips --> do_action( 'news_vibrant_footer' ); do_action('performance'); <!-- /mfunc dynamic_tips --> </div><!-- #page --> <?php do_action( 'news_vibrant_after_page' ); wp_footer(); ?> </body> </html>and any other informations?
in fact.
do_action( 'news_vibrant_footer' ); do_action('performance');is i need to keep dynamic code.so i use mfunc to achieve this.
but as you can see, i cant edit
do_action( 'news_vibrant_footer' );
in customize after i use mfunc replace <?phpHello @loukky
Thank you for the information.
The solution is to not use wp functions/core in mfunc code.
e.g. instead of
do_action( ‘news_vibrant_footer’ );
use
render_my_news_vibrant_footer();
Alternatively, there was an option to run after init and look for late init.
Thanks!How can achieve init? for example?
Sorry i don’t understand wp function…i think it`s because mfunc not support <?php ?> tage
if i change to this<!-- mfunc dynamic_tips --> <?php do_action( 'news_vibrant_footer' ); do_action('performance'); ?> <!-- /mfunc dynamic_tips -->wp error
Parse error: syntax error, unexpected '<', expecting end of file in /www/wwwroot/loukky.com/wp-content/plugins/w3-total-cache/PgCache_ContentGrabber.php(1885) : eval()'d code on line 1-
This reply was modified 4 years, 8 months ago by
loukky.
Hello @loukky
Yes, you are correct. You should not use PHP tags within the
<!-- mfunc -->
Are you able to edit if you remove the mfunc wrap?
Thanks!hello @vmarko
if i remove the mfunc wrap,
that to be<?php do_action( 'news_vibrant_footer' ); do_action('performance'); ?>i can edit because this is the footer.php original code…
so i want to keep can edit and the same time is dynamic…Hello @loukky
Thank you for your patience.
WE’ve tested this with the theme you are using and once the Page Fragment Cache is set up correctly, the edit icons are there and work as expected.
Make sure to adddefine( 'W3TC_DYNAMIC_SECURITY', 'dynamic_tips' );to wp-config.php, switch Page cahing method to Disk: Basic and enable late initialization.
Also, make sure that the pages are not cached for logged-in users and make sure to purge the cache.
Thanks!hello @vmarko
i do them all ,not working….
i dont know whyi test on local site .. its not work either
dont use mfunc code:
https://imgur.loukky.com/imgs/2021/09/31575c7973c03a0c.png
after use mfunc code:
https://imgur.loukky.com/imgs/2021/09/eeef2701cd0ff5f0.pngHello @loukky
Thank you for the information.
In this case, the only solution is to remove the <!– mfunc –> comment, make your edit, and then again wrap the desired content with <!– mfunc –>
Thanks! -
This reply was modified 4 years, 8 months ago by
The topic ‘how can use /mfunc to if else <?php’ is closed to new replies.