WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
MFUNC still not working (42 posts)

  1. christopheran
    Member
    Posted 10 months ago #

    Interesting...

    If I do this:

    --------------
    <? $test = "testing"; ?>

    <? echo $test; ?>
    -----------------

    I get the expected result.

    If I do this:

    --------------
    <? $test = "testing"; ?>

    <!--mfunc mysecret --> echo $test; <!--/mfunc mysecret -->
    -----------------

    I get nothing - nothing echos out.

    If I run this though:

    -----------

    <!--mfunc mysecret -->
    echo rand();
    <!--/mfunc mysecret -->

    -------------

    That works, so I know that W3TC is recognizing those tags and running the code im between as php...

    Any thoughts on this? I'm stuck because it won't echo what I need it too,

    Chris

  2. jjanev86
    Member
    Posted 10 months ago #

    This is temporary solution on version ...11

    First define in wp-config.php

    define('W3TC_DYNAMIC_SECURITY', 'secureword');

    <!-- mfunc secureword -->
     echo "code";
     <!-- /mfunc secureword -->

    BUT!!! This is working when i do not use minify in W3TC settings, thats why it is temporary solution. Perhaps minify is deleting <!-- ...

  3. donwilson
    Member
    Posted 10 months ago #

    I can confirm that minify does, indeed, delete mfunc/mclude comment strings. However, you can set mfunc and mclude to the ignore comments list in HTML minify settings. Unfortunately, doing so doesn't fix our issue either.

    When minify is used, fragmented caching definitely does not work as it should.

  4. azn137
    Member
    Posted 10 months ago #

    Ah, so minification works so well, it whacks its own code?

  5. donwilson
    Member
    Posted 10 months ago #

    Indeed. W3TC should add mfunc/mclude ignore functionality into its minifier and then process any mfunc/mclude calls before it's sent to the user. This is obviously the expected behavior but we lost the functionality several versions back.

  6. Airic
    Member
    Posted 10 months ago #

    Hi,
    Well, to make it work I have to:
    page cache disk + late "init"
    exclude mfunc form minify
    add define('W3TC_DYNAMIC_SECURITY', 'secureword'); in wp-config.php
    and use:
    <!--mfunc secureword -->
    wpads('article');
    <!--/mfunc secureword -->

    Hope it will help ;-)

    Eric

  7. Frederick Townes
    Member
    Plugin Author

    Posted 10 months ago #

    I have not been able to duplicate any issues with it together with Minify. mfunc code can only be used with theme template files, post/page content or widget areas. That is displayed content that is cached by the Page Cache.

    Code within mfunc does not know anything outside of the mfunc tags. So it can't call any functions, set variables etc in the template files themselves outside of the mfunc tags.

    You can only call functions defined in plugins and also WP functions if you enable late init.

  8. arnarstef
    Member
    Posted 5 months ago #

    Hey guys, sorry for the resurrection, this just seems like the only place that makes any sense regarding this. I have one question, why isn't it okay to do the

    define( 'W3TC_DYNAMIC_SECURITY', 'mysecretcode' );

    inside the functions.php file for example, this works on my end but I'm building a theme for selling so I have to be sure.

  9. geerthoekzema
    Member
    Posted 5 months ago #

    Hi Arnarstef,

    The W3TC_DYNAMIC_SECURITY is 'just' a constant. As far as i know it wont be a problem if you define this in functions.php. But i'll say: try it and look if it works ;)

  10. donwilson
    Member
    Posted 5 months ago #

    It's better to define it in wp-config.php, especially with the late init setting.

  11. arnarstef
    Member
    Posted 5 months ago #

    Could you elaborate as to why it is better? Is it going to cause problems if it's defined a bit later in the functions.php file?

  12. donwilson
    Member
    Posted 5 months ago #

    I don't know the exact mechanics of W3TC, but the plugin could pull and push the cache out even before the theme's functions.php is loaded. Also, with user agent groups showing mobile/tablet-specific themes, defining it in one location would make sense.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic