把回去用 WordPress 編輯的按鈕藏起來,避免在 Elementor 模式下被點到

被點到會導致 elementor 破版,而且很容易被點到 QQ

add_action('admin_head', 'gathering_design_prevent_switch_back_to_wordpress_editor');

function gathering_design_prevent_switch_back_to_wordpress_editor() {

    global $current_screen;

    if ($current_screen->base == 'post') {
        ?>
            <script>
            window.jQuery(function() {
                const display = window.jQuery('#elementor-switch-mode-button .elementor-switch-mode-off').css('display')
                if (display === 'none') {
                    window.jQuery('#elementor-switch-mode-button').hide()
                }
            })
            </script>
        <?php
    }
}