• Resolved omniafausta

    (@omniafausta)


    Hi I am making a childtheme and I know had to change stuff in the css and some of the php files, but I now have a problem with a javascript.

    The theme is Make,
    the Javascript is edit-page.js,
    the line that is troubling me is:

    // Builder template is selected by default
    self.cache.$pageTemplate.val('template-builder.php');

    This line makes a specific template my standard template instead of the standard template…
    And I want the standard template to be my standard.

    I know close to nothing about javascript unfortunately.
    The problem is solved if I remove that line from the script, but of course I don’t want to alter the original script, I want to do it in the childtheme.

    Do I need to replace the entire javascript with a copy without the line, and how would I do that?
    Or is it possiple to write something (in my functions.php for example) that would just get rid of that line (and keep the rest of the original javascript)
    Or is it possible to write a bit of script that would overrule the javascript in the choice of standard template.

    I hope I explaned it clearly, if you can help but need more info let me know!!

    Thanks in advance 😀

Viewing 1 replies (of 1 total)
  • Thread Starter omniafausta

    (@omniafausta)

    Okay, after searching some more, I still couldn’t find a way to just override that one part from the Javascript.

    So this is what I ended up doing:
    – I copied the .js to my childtheme,
    – edited the copy (comented out the line I didn’t want,
    – added a few lines to my functions.php tot deregister the old .js and enqueue the new one:

    // removing and replacing a javascript
    
    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
    
    function my_deregister_javascript() {
        wp_dequeue_script( 'ttfmake-admin-edit-page' );
        wp_deregister_script( 'ttfmake-admin-edit-page' );
    }
    
        wp_enqueue_script(
            'ttfmake-admin-edit-page-edited',
            get_template_directory_uri() . '/js/admin/edit-page.js',
            array( 'jquery' ),
            TTFMAKE_VERSION,
            true
        );

    And it works 😀

Viewing 1 replies (of 1 total)
  • The topic ‘change javascript from theme in childtheme’ is closed to new replies.