Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The following code makes several filter functions work on our website, and was written by a former dev. It triggers obnoxious behavior when used with third party js (reloading forms on click, loading errors on calendar functions, etc).

When commented out, it fixes so many problems other problems but breaks our filtering functions. The syntax seems to be a loopy double negative thing.

! function(o) {
    function t() {
        var t = o("#current-page-id").attr("class");
        o("#wp-admin-bar-edit .ab-item").attr("href", window.location.protocol + "//" + window.location.host + "/wp-admin/post.php?post=" + t + "&action=edit"), console.log(window.location.host + "/wp-admin/post.php?post=" + t + "&action=edit")
    }

I've attempted to dump it into its own file, then execute it conditionally (only on pages 12 and 16) in functions.php as follows:

function excludetroublescript() {
    if(is_page(12,16)) {
        wp_enqueue_script('january21-js.js','/assets/js', array('jquery'),'',false);
    }
}
add_action('wp-enqueue-script','excludetroublescript');

I find myself needing to code on occasion, but am clearly no engineer. I've given this quite a bit of time. Is there a quick fix that tidies up the original syntax or allows this to be included only on the pages we need it?

Thanks for any clues!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.7k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...