admin管理员组

文章数量:1124688

I have a wordpress plugin for a third party site I run. I runs in conjunction with the standard text editor module used in pagebuilders (Beaver Builder, Divi, Elementor, etc), but for some reason, it's stopped working since WP 6.4.x

The the plugin takes options, and then uses a simple JS function to build and insert a shortcode.

For reasons unknown, it has begun throwing a "Reference Error: Can't find variable : BuildButtonSC

The (abbreviated) code for the HTML and JS is:

<div id="tripSelector">

<h2>Insert Button</h2>
<div style="">
    <select class="all_trips" name="all_trips">
        <option value="">Select a Trip</option>
        <option value="4">Bob's Bimini Boat Tours</option>
        <option value="18">Bob's Second Tour</option>
    </select>
</div>

[snipped additional fields]

<div>
    <input type="button" class="button-primary" value="Add Button for This Trip" onclick="BuildButtonSC(); return false;">

    <input type="button" class="button" value="Cancel" style="color:#bbb;" href="#" onclick="tb_remove(); return false;">
</div>

</div>

<script>
jQuery(function($) {
    $('#TB_window .all_trips').change(function(){
        var sel=$("#TB_window .all_trips").val();
    });
}); 

function BuildButtonSC(){
    var thistrip =      jQuery("#TB_window .all_trips").val();
    var button_class =  jQuery("#TB_window .rezbs_btn").val();
    var button_label =  jQuery("#TB_window .btn_label").val();
    if( button_class == '' ){ button_class = 'rezbs_button'; }
    if( button_label == '' ){ button_label = 'Book Now!'; }
    var theShortcode = '[rezbs_button id="' + thistrip + '" label="' + button_label + '" class="' + button_class + '"]';
    window.send_to_editor(theShortcode);
    tb_remove();
}
</script>

At a loss as to what is wrong with this one.

Can anyone spot a possible issue?

本文标签: javascriptWordpress PluginElementor and the ReferenceError nightmare