summaryrefslogtreecommitdiff
blob: 45548b4ef76b3c087d096c5572b0e8bb53151da3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*****************************************************************************************************/
/*                                                                                                   */
/*                                    	'UPGRADE ADMIN NOTICE'				                         */
/*                                                                                                   */
/*****************************************************************************************************/

function WMP_UPGRADE_NOTICE(){

    var JSObject = this;
    this.changingStatus = false;

    /*****************************************************************************************************/
    /*                                                                                                   */
    /*                                            FUNCTION INIT                                          */
    /*                                                                                                   */
    /*****************************************************************************************************/
    this.init = function(){
        this.addButtonsActions();
    };


    /*****************************************************************************************************/
    /*                                                                                                   */
    /*                                  FUNCTION ADD BUTTONS ACTIONS                                     */
    /*                                                                                                   */
    /*****************************************************************************************************/
    this.addButtonsActions = function(){

        var $upgradeNotice = jQuery('.wmp_upgrade_notice .notice-dismiss');

        if ($upgradeNotice.length > 0) {

            $upgradeNotice.on("click", function () {

                if (JSObject.changingStatus == true)
                    return;

                JSObject.changingStatus = true;

                jQuery.post(
                    ajaxurl,
                    {
                        'action': 'wmp_settings_save',
                        'wmp_option_upgrade_notice_updated': 0
                    },
                    function (response) {

                        JSObject.changingStatus = false;
                    }
                );
            });
        }
    }
}

// normally this part will be added in the html document using JSInterface, but this notice can appear outside the admin pages
if (window.WMPJSInterface && window.WMPJSInterface != null){
    jQuery(document).ready(function(){

        var WMP_UI_upgradenotice = new WMP_UPGRADE_NOTICE();
        WMP_UI_upgradenotice.init();
    });
}