ACF - Options page Hook (Wordpress)

cruzquer

I am really making a huge use of ACF's options pages and repeater fields. In order to reduce the amount of queries (from about 500 to 80) I'm caching some field outputs with the help of Wordpress Transient API.

I know the hook for ACF options pages is:

add_action( 'acf/save_post', 'reference_function') ); 

But the problem for me is, that I have multiple options pages. And I don't want all my functions to run when any options page is saved…

These are my current options pages

add_filter('acf/options_page/settings', 'my_acf_options_page_settings');
if(function_exists("register_options_page")) {
        acf_add_options_page();
        register_options_page('Spielübersicht');
        register_options_page('Mannschaft');
        register_options_page('SCHWALBE arena TV');
        register_options_page('Sponsoren');
        register_options_page('Werbung');
        register_options_page('Einstellung');
        register_options_page('Fanclubs');
        register_options_page('Sidebar');
    }

Is there a way to filter the action so that my transients are only created when the related options page is saved?

cruzquer

Luckily I was able to solve my problem! Have a look at my code in the plugins’ support forum: http://support.advancedcustomfields.com/forums/topic/acfsave_post-for-specific-options-page/

function clear_advert_main_transient() {
    $screen = get_current_screen();
    if (strpos($screen->id, "acf-options-adverts") == true) {
        delete_transient('advert_main_transient1');
        delete_transient('advert_main_transient2');
        delete_transient('advert_main_transient3');
    }
}
add_action('acf/save_post', 'clear_advert_main_transient', 20);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related