| @@ -442,8 +442,10 @@ | ||
| 442 | 442 | $(this).prop("disabled", true); |
| 443 | 443 | |
| 444 | 444 | //set 0 to add real id to delete |
| 445 | 445 | cookie_id = $(this).attr("cookieadmin_cookie_id"); |
| 446 | + // Get the patterns | |
| 447 | + const patterns = $("#cookieadmin-dialog-cookie-patterns").val(); | |
| 446 | 448 | |
| 447 | 449 | let cookie_info = { |
| 448 | 450 | name: $("#cookieadmin-dialog-cookie-name").val(), |
| 449 | 451 | id: cookie_id, |
| @@ -450,8 +452,12 @@ | ||
| 450 | 452 | description: $("#cookieadmin-dialog-cookie-desc").val(), |
| 451 | 453 | duration: $("#cookieadmin-dialog-cookie-duration").val(), |
| 452 | 454 | type: $("#cookieadmin-dialog-cookie-category").val() |
| 453 | 455 | }; |
| 456 | + | |
| 457 | + if(patterns){ | |
| 458 | + cookie_info.patterns = patterns; | |
| 459 | + } | |
| 454 | 460 | |
| 455 | 461 | $.each(cookie_info, function (i, val){ |
| 456 | 462 | if(!val){ |
| 457 | 463 | cookie_info = null; |
| @@ -565,8 +571,9 @@ | ||
| 565 | 571 | $("#cookieadmin_dialog_save_btn").attr("cookieadmin_cookie_id", cookie_id); |
| 566 | 572 | $("#cookieadmin-dialog-cookie-name").val(categorized_cookies[cookie_id]['cookie_name']); |
| 567 | 573 | $("#cookieadmin-dialog-cookie-desc").val(categorized_cookies[cookie_id]['description']); |
| 568 | 574 | $("#cookieadmin-dialog-cookie-duration").val(categorized_cookies[cookie_id]['expires']); |
| 575 | + $("#cookieadmin-dialog-cookie-patterns").val(categorized_cookies[cookie_id]['patterns']); | |
| 569 | 576 | if(!!categorized_cookies[cookie_id]['category']){ |
| 570 | 577 | $("#cookieadmin-dialog-cookie-category").val(categorized_cookies[cookie_id]['category']); |
| 571 | 578 | }else{ |
| 572 | 579 | $("#cookieadmin-dialog-cookie-category").val("unknown"); |
| @@ -687,9 +694,44 @@ | ||
| 687 | 694 | |
| 688 | 695 | cookieadminToolTip.css('opacity', 0); |
| 689 | 696 | }); |
| 690 | 697 | |
| 698 | + // Recommended plugins install/activate handler | |
| 699 | + $(document).on('click', '.cookieadmin-plugin-install-btn, .cookieadmin-plugin-activate-btn', function(e){ | |
| 700 | + e.preventDefault(); | |
| 701 | + var $btn = $(this); | |
| 702 | + var slug = $btn.data('slug'); | |
| 703 | + var is_install = $btn.hasClass('cookieadmin-plugin-install-btn'); | |
| 704 | + var originalText = $btn.text(); | |
| 705 | + | |
| 706 | + $btn.text(cookieadmin_policy.lang.processing).prop('disabled', true); | |
| 707 | + | |
| 708 | + $.ajax({ | |
| 709 | + url: ajaxurl, | |
| 710 | + method: 'POST', | |
| 711 | + data: { | |
| 712 | + action: 'cookieadmin_ajax_handler', | |
| 713 | + cookieadmin_act: is_install ? 'install_recommended_plugin' : 'activate_recommended_plugin', | |
| 714 | + cookieadmin_security: cookieadmin_policy.cookieadmin_nonce, | |
| 715 | + plugin: slug, | |
| 716 | + }, | |
| 717 | + dataType: 'json', | |
| 718 | + success: function(data){ | |
| 719 | + if(data.success){ | |
| 720 | + $btn.replaceWith('<span class="cookieadmin-badge cookieadmin-success">' + cookieadmin_policy.lang.active + '</span>'); | |
| 721 | + }else{ | |
| 722 | + $btn.text(originalText).prop('disabled', false); | |
| 723 | + alert(data.data && data.data.message ? data.data.message : cookieadmin_policy.lang.install_failed); | |
| 724 | + } | |
| 725 | + }, | |
| 726 | + error: function(){ | |
| 727 | + $btn.text(originalText).prop('disabled', false); | |
| 728 | + alert(cookieadmin_policy.lang.error_occurred); | |
| 729 | + }, | |
| 730 | + }); | |
| 731 | + }); | |
| 691 | 732 | |
| 733 | + | |
| 692 | 734 | }); |
| 693 | 735 | |
| 694 | 736 | function cookieadminAddCookieToTable(cookie_info){ |
| 695 | 737 | |
| @@ -701,8 +743,9 @@ | ||
| 701 | 743 | categorized_cookies[cookie_info.id]['cookie_name'] = cookie_info.name; |
| 702 | 744 | categorized_cookies[cookie_info.id]['description'] = cookie_info.description; |
| 703 | 745 | categorized_cookies[cookie_info.id]['expires'] = cookie_info.duration; |
| 704 | 746 | categorized_cookies[cookie_info.id]['category'] = cookie_info.type; |
| 747 | + categorized_cookies[cookie_info.id]['patterns'] = cookie_info.patterns; | |
| 705 | 748 | |
| 706 | 749 | if(cookie_info.duration > 0){ |
| 707 | 750 | cookie_info.duration += ' ' + cookieadmin_policy.lang.days; |
| 708 | 751 | }else{ |