문제

I have a localize script that have sensitive information that i dont want other users change it from the console. is it possible to Object freeze my localized script?

        wp_localize_script('test-script', 'test_ajax', array(
            'ajax_url' => admin_url('admin-ajax.php'),
            'nonce' => wp_create_nonce('test-nonce'),
            'action_thanks' => ACTION_THANKS,
            'univ_short_name' => UNIV_SHORT_NAME,
            'action_general' => ACTION_GENERAL,
            'action_catalog' => ACTION_CATALOG,
            'action_ebook' => ACTION_EBOOK,
            'university_id' => UNIVERSITY_ID,
            // in js needs to be converted to bool
            'is_sf' => IS_SF
        ));
도움이 되었습니까?

해결책

No, it is not possible to do this from wp_localize_script().

You would need to add add Object.freeze( text_ajax ); to the beginning of your script.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 wordpress.stackexchange
scroll top