Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function enqueue_custom_admin_script() {
- // Check if we are in the admin area and the current user is an editor but not an administrator
- if (is_admin() && current_user_can('editor') && !current_user_can('administrator')) {
- wp_enqueue_script('jquery');
- add_action('admin_footer', 'hide_elements_on_dom_change');
- }
- }
- add_action('admin_enqueue_scripts', 'enqueue_custom_admin_script');
- function hide_elements_on_dom_change() {
- echo '
- <script>
- jQuery(document).ready(function($) {
- // Function to hide the desired elements
- function hideElements() {
- $(".rank-math-ca-top-section, .rank-math-ca-keywords-wrapper").attr("style", "display: none !important;");
- // Hide the button with the classes "rank-math-general-tab" and "is-active"
- $("button.rank-math-general-tab.is-active").attr("style", "display: none !important;");
- }
- // Check if MutationObserver is supported by the browser
- if ("MutationObserver" in window) {
- // Observe changes in the entire document
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- // If the added nodes include a node with the classes "rank-math-content-ai-wrapper" and "is-opened"
- if ($(mutation.addedNodes).hasClass("rank-math-content-ai-wrapper") && $(mutation.addedNodes).hasClass("is-opened")) {
- hideElements();
- }
- });
- });
- // Start observing changes
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- }
- });
- </script>';
- }
Advertisement
Add Comment
Please, Sign In to add comment