HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System: Linux atalantini.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64
User: root (0)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: //opt/plugins/posts-like-dislike/js/pld-backend.js
jQuery(document).ready(function ($) {
    var info_timer;
    /**
     * Tab Show and hide
     */
    $('.pld-wrap .nav-tab').click(function () {
        var settings_ref = $(this).data('settings-ref');
        $('.pld-wrap .nav-tab').removeClass('nav-tab-active');
        $(this).addClass('nav-tab-active');
        $('.pld-settings-section').hide();
        $('.pld-settings-section[data-settings-ref="' + settings_ref + '"]').show();
        if (settings_ref == 'help' || settings_ref == 'about') {
            $('.pld-settings-action').hide();
        } else {
            $('.pld-settings-action').show();
        }

    });

    /**
     * Template Preview Toggle
     */
    $('.pld-template-dropdown').change(function () {
        var template = $(this).val();
        if (template != 'custom') {
            $('.pld-custom-ref').hide();
            $('.pld-template-ref').show();
            $('.pld-each-template-preview').hide();
            $('.pld-each-template-preview[data-template-ref="' + template + '"]').show();
        } else {
            $('.pld-each-template-preview').hide();
            $('.pld-template-ref').hide();
            $('.pld-custom-ref').show();
        }

    });

    /**
     * Colorpicker Initialize
     */
    $('.pld-colorpicker').wpColorPicker();

    /**
     * Open Media Uploader
     */
    $('.pld-file-uploader').click(function () {
        var selector = $(this);

        var image = wp.media({
            title: 'Upload Image',
            // mutiple: true if you want to upload multiple files at once
            multiple: false
        }).open()
                .on('select', function (e) {
                    // This will return the selected image from the Media Uploader, the result is an object
                    var uploaded_image = image.state().get('selection').first();
                    // We convert uploaded_image to a JSON object to make accessing it easier
                    // Output to the console uploaded_image
                    console.log(uploaded_image);
                    var image_url = uploaded_image.toJSON().url;
                    // Let's assign the url value to the input field
                    selector.parent().find('input[type="text"]').val(image_url);
                    selector.parent().find('.pld-preview-holder').html('<img src="' + image_url + '"/>');
                });
    });

    /**
     * Save Settings
     */
    $('.pld-settings-form').submit(function (e) {
        e.preventDefault();

        var settings_data = $(this).serialize();
        $.ajax({
            type: 'post',
            url: pld_admin_js_object.admin_ajax_url,
            data: {
                action: 'pld_settings_save_action',
                settings_data: settings_data,
                _wpnonce: pld_admin_js_object.admin_ajax_nonce
            },
            beforeSend: function (xhr) {
                clearTimeout(info_timer);
                $('.pld-info-wrap').slideDown(500);
                $('.pld-info').html(pld_admin_js_object.messages.wait)
                $('.pld-loader').show();
            },
            success: function (res) {
                $('.pld-loader').hide();
                $('.pld-info').html(res);
                info_timer = setTimeout(function () {
                    $('.pld-info-wrap').slideUp(500);
                }, 5000);

            }
        });
    });

    /**
     * Close Info 
     * 
     */
    $('.pld-close-info').click(function () {
        $(this).parent().slideUp(500);
    });

    /**
     * Default settings restore
     */
    $('.pld-settings-restore-trigger').click(function () {
        if (confirm(pld_admin_js_object.messages.restore_confirm)) {
            $.ajax({
                type: 'post',
                url: pld_admin_js_object.admin_ajax_url,
                data: {
                    action: 'pld_settings_restore_action',
                    _wpnonce: pld_admin_js_object.admin_ajax_nonce
                },
                beforeSend: function (xhr) {
                    clearTimeout(info_timer);
                    $('.pld-info-wrap').slideDown(500);
                    $('.pld-info').html(pld_admin_js_object.messages.wait)
                    $('.pld-loader').show();
                },
                success: function (res) {
                    $('.pld-loader').hide();
                    $('.pld-info').html(res);
                    location.reload();


                }
            });
        }
    });
});