WordPress.org

Forums

Clear Cache for Me
[resolved] Bug in 'menu updated' add_action line (17 posts)

  1. Ov3rfly
    Member
    Posted 10 months ago #

    Line 16 in Clear Cache for Me 0.3 has a bug:

    add_action( 'wp_update_nav_menu', 'clear_cache_for_me', 10 );

    It should be changed to this:

    add_action( 'wp_update_nav_menu', 'ccfm_clear_cache_for_me', 10 );

    Thanks for the great plugin.

    https://wordpress.org/plugins/clear-cache-for-widgets/

  2. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    Thank you! and sorry for the inconvenience. The fix is in version 0.4 which should be out now.

  3. Ov3rfly
    Member
    Posted 10 months ago #

    Thank you for quick fix.

    Another small suggestion to make the plugin even better, add a callback action so 3rd party code can hook into the process and know when the cache was cleared and if it was via button or menu update or widget update.

    Something like this at the end of function ccfm_clear_cache_for_me():

    do_action( 'ccfm_clear_cache_for_me', 'arg' );

    Where 'arg' would be 'button' or 'menu' or 'widgets' or similar.

    Then 3rd party code could deal with that in functions.php or similar.

    function ov3rfly_cache_cleared( $arg ) {
    	switch ( $arg ) {
    		...
    	}
    }
    add_action( 'ccfm_clear_cache_for_me', 'ov3rfly_cache_cleared' );

    The feature would require a few small changes, e.g. adding an arg to ccfm_clear_cache_for_me() and an extra function for wp_update_nav_menu action hook...

    This would be great.

    Thanks for the great plugin.

  4. Ov3rfly
    Member
    Posted 10 months ago #

    And here a small update 0.4.1, with do_action( 'ccfm_clear_cache_for_me' .. ) stub and enhanced for translation, with ccfm.pot file and german language files:

    http://wikisend.com/download/380796/clear-cache-for-widgets-0.4.1.zip
    (link valid 14 days from today)

    @webheadllc: Feel free to use the code and files as you like.

  5. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    Sounds easy enough. hooks for 3rd parties have been added and german language added in version 0.5.

    Thanks!

  6. Ov3rfly
    Member
    Posted 10 months ago #

    Thank you for quick update.

    Background for the $source request: Have some rewrite rules with own query_vars which show custom database data on a page like example.com/page/myvar1/myvar2/ and these "sub"-pages get cached fine in W3 Total Cache but are not flushed if the "Empty Cache" option is used. Now with your button and the new hook, it is possible to flush also these "sub"-pages (I just do a glob/unlink/rmdir with the relevant files/folders from the page-cache folder of W3TC).

    Noted the missing security against CSRF in 0.4 after my post yesterday and added wp_nonce_field and check_admin_referer to the forms which use both post now. Also fixed the html a bit, moved <p> into <form>. Also added an optional infotext above the button (as asked for by my client).

    http://wikisend.com/download/971474/clear-cache-for-widgets-0.5.1.zip
    (link valid 14 days from today)

    Edit: An esc_attr() could be added to infotext input or a better handling of " etc. chars in infotext.

    Again, feel free to use the code and files as you like.

  7. Ov3rfly
    Member
    Posted 10 months ago #

    Another small update, now using stripslashes() for the infotext and allowing html, why not trust the admin here.

    Also rearranged the code within ccfm_dashboard_widget_output() a bit so only one check for manage_options is required.

    http://wikisend.com/download/744184/clear-cache-for-widgets-0.5.2.zip
    (link valid 14 days from today)

  8. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    Thanks i'll put this in as soon as i have a chance to test it.

  9. Ov3rfly
    Member
    Posted 10 months ago #

    Another note, instead of stripslashes() better use wp_unslash() to clean the the infotext.

  10. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    Thanks again.

    I'll be updating the plugin today. I changed the label for the infotext field. It will show as "Instructions to show above button (optional):". If you have time to update the german that would be nice. if not that's ok.

  11. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    oh, and also added "Settings" as a header.

  12. Ov3rfly
    Member
    Posted 10 months ago #

    Thanks, here the new language files:
    http://wikisend.com/download/996234/clear-cache-for-widgets-lang.zip
    (link valid 2 days from today)

    These new strings were added:

    "Instructions to show above button (optional):"
    -> "Kurzanleitung oberhalb des Buttons (optional):"

    "Settings"
    -> "Einstellungen"

  13. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    updates should be in version 0.6. Thank you for all your help!

  14. Ov3rfly
    Member
    Posted 10 months ago #

    No problem, did the changes for a client anyway.

    0.6 works fine so far, good idea to also catch theme customizing.

    Found/added two more changed strings which were different since 0.5.x or not translated yet. Also updated the html a bit with some css to match the general look&feel of WordPress, see included screenshots before/after. Removed the label from the infotext, as submit buttons should not have clickable labels.

    Feel free to use the code for a future release.

    http://wikisend.com/download/577450/clear-cache-for-widgets-0.6.2.zip
    (link valid 14 days from today)

  15. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    Thanks. Added all your changes in 0.6.1.

  16. Ov3rfly
    Member
    Posted 10 months ago #

    0.6.1 works fine.

    For a future relase you could use above posted 0.6.2, some css-class naming is "ccfm" instead "ccf" there now and a margin-bottom has been added to h4 "Settings" headline. No need to do a release now as the changes are purely cosmetic...

  17. webheadllc
    Member
    Plugin Author

    Posted 10 months ago #

    oh, missed that. ok, will do.

Reply

You must log in to post.

About this Plugin

  • Clear Cache for Me
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic