ACF - Hook Options Page (Wordpress)

I really use ACF options pages and relay fields. To reduce the number of requests (from 500 to 80), I cache some output using the Wordpress Transient API.

I know the hook for ACF options pages:

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

But the problem for me is that I have several pages with options. And I do not want all my functions to start when saving any parameter page ...

These are my current settings 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 created only when the linked options page is saved?

+4
source share
1 answer

, ! : 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);
+5

Source: https://habr.com/ru/post/1569816/


All Articles