• Resolved haffy

    (@haffy)


    Hi,
    I am trying to change the look on a plugin called Sirvoy. I know there is an ID called ‘book_languages_and_terms’, but the Console cand find it even though I see it in the generated code (I have only added the shortcode for it).
    First I thought my JS was to early in the code, so I tried to do a while loop.

    
    let elm = document.getElementById('book_languages_and_terms');
    
    while(elm !== null) {
      document.getElementById('book_languages_and_terms').style.display = 'none';
    } 
    

    But maby I did something wrong there. But the main problem is that I can′t find it in the console, even though I see it in the code. Have I missed something?

    The site is in MAMP mode right now, so I can′t provide a link. As I also have another problem with another plugin (https://www.ads-software.com/support/topic/adding-slider-to-html/), maby there is something wrong in my functions.php file?

    
    <?php
    
        /*
         * WordPress functions file for Cortijo La Fe Theme.
         */
    
        function wp_la_fe_setup() {
    
            // Make theme available for translation.
            //load_theme_textdomain( 'whaaaaaaaaaatIsTHis', get_template_directory() . '/languages' );
    
            // Add default posts and comments RSS feed links to head.
            add_theme_support( 'automatic-feed-links' );
    
            // This theme uses wp_nav_menu().
            register_nav_menus( array('primary' => __( 'Primary Menu', 'Cortijo La Fe' ),) );
    
            add_theme_support( 'html5', array('search-form', 'gallery', 'caption') );
    
            add_theme_support( 'post-thumbnails' );
            //set_post_thumbnail_size( 1024, 768 );
    
            add_image_size('slides', 960, 400, true);
    
            /*
            *add_image_size('name' (e.g. slides), width (e.g. 960), height (e.g. 400), true
            *(croppable -> true or false));
            */
    
            // Let WP manage titles.
            add_theme_support( 'title-tag' );
    
            // Add RSS / Feeds support
            add_theme_support( 'automatic-feed-links' );
    
            // Add support for responsive embedded content.
            add_theme_support( 'responsive-embeds' );
    
            // Hide the adminbar.
            show_admin_bar(false);
    
        }
    
        add_action( 'after_setup_theme', 'wp_la_fe_setup' );
    
        //
        // Load stylesheets and scripts.
        //
    
        function load_stylesheets_scripts() {
    
            wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/modules/bootstrap/css/bootstrap.css');
            wp_enqueue_style( 'style', get_stylesheet_uri() );
    
            wp_enqueue_script( 'jquery', get_template_directory_uri() .'/modules/jquery-3.3.1.slim.min.js');
            wp_enqueue_script( 'bootstrap', get_template_directory_uri() .'/modules/bootstrap/js/bootstrap.bundle.js');
    
        }
    
        add_action( 'wp_enqueue_scripts','load_stylesheets_scripts');
    
        //
        // Register Custom Navigation Walker
        //
    
        function register_navwalker(){
        require_once get_template_directory() . '/modules/class-wp-bootstrap-navwalker.php';
        }
    
        add_action( 'after_setup_theme', 'register_navwalker' );
    
    • This topic was modified 5 years, 4 months ago by haffy.
    • This topic was modified 5 years, 4 months ago by haffy.
    • This topic was modified 5 years, 4 months ago by haffy.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t see anything alarming in your functions.php. You are probably correct, that the element is added by JS after your code runs. However, your while loop logic is flawed. If the element is not initially found, elm is null and your code never tries again later. Anyway, looping until something shows up is not a good approach. If you ensure your code runs after the code that adds the element, you shouldn’t have to loop until it shows up, it should already exist. Ensure your code runs late by enqueuing your script while listing the code that adds the element as a dependency. In the wp_enqueue_script() call, also specify that your script should be loaded in the footer.

    If your intent is to hide this element why not just place the CSS for it in the Additional CSS panel of the customizer? Why use JS to hide it?

    Thread Starter haffy

    (@haffy)

    I tried to use JS as I wanted to do it with JS ?? To learn. And it did not work with CSS.

    I have solved it by changing the CSS at the developer’s site (it′s a connected plugin with a shortcode), so it gets its CSS from there. That′s why I was trying to make a while loop to grab it when it was loaded.

    Moderator bcworkz

    (@bcworkz)

    Cool! FWIW, you can override external CSS with local inline CSS. You need to ensure your override comes after the external reference. You solved it though, that’s all that matters.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Changing the look on a plugin’ is closed to new replies.