Version Description
Download this release
Release Info
Developer | cssimmon |
Plugin | Backup and Restore WordPress – WPBackItUp Backup Plugin |
Version | 1.16.0 |
Comparing to | |
See all releases |
Code changes from version 1.15.7 to 1.16.0
- js/wp-backitup-admin.min.js +1 -1
- lib/includes/admin-actions.php +33 -0
- lib/includes/class-cron.php +107 -0
- lib/includes/class-usage.php +338 -0
- lib/includes/class-wpbackitup-admin.php +13 -0
- lib/includes/update_plugin.php +4 -0
- readme.txt +7 -1
- views/settings.php +13 -1
- wp-backitup.php +3 -21
js/wp-backitup-admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var WPBNewBackupData={},ajaxNamespace="wpbackitup-safe",ENUM={GDRIVE:"GDRIVE",AMAZONS3:"AMAZONS3",DROPBOX:"DROPBOX"},CLOUDSTATUS={READY:"ready",UPLOADING:"uploading",UPLOADED:"uploaded",ERROR:"error"},wpbackitup_get_action_name=function(e){return ajaxNamespace+"_"+e},AjaxGetSafe=function(e){return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:wpbackitup_get_action_name(e),security:WPBackItUpSafeLocals[e]},dataType:"json"})},AjaxGetCore=function(e){var a=wpbackitup_local[e];return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:"wp-backitup_"+e,security:a},dataType:"json"})},AjaxPostSafe=function(e,a){var a=a||{};return a.action=wpbackitup_get_action_name(e),a.security=WPBackItUpSafeLocals[e],jQuery.ajax({url:ajaxurl,type:"POST",data:a,dataType:"json"})};!function(e){"use strict";if(document.querySelector("#wpbackitup-core-backup"))var a=new Vue({el:"#wpbackitup-core-backup",data:{cloudStatus:{},isNewRowAvailable:!1,backupNewRow:{}},methods:{getAvailableBackups:function(){AjaxGetCore("get_available_backups").then(function(e){if(e.success)for(var t=0;t<e.data.length;t++){var i=e.data[t].backup_job_id,s=e.data[t].backup_job_cloud_status;a.$set(a.cloudStatus,i,s)}})},getBackupStatus:function(){var e=WPBNewBackupData;if("success"===e.backupStatus){var a=e.backupName,t=a.lastIndexOf("_"),i=a.substring(t+1);this.isNewRowAvailable=!0,this.backupNewRow={name:e.backupName,type:e.backupRuntype,date:e.backupDate,duration:e.backupDuration,status:e.backupStatus,row:99999,jobId:i,zipExist:!0},WPBNewBackupData={}}}},mounted:function(){this.getAvailableBackups(),this.getBackupStatusInterval=setInterval(function(){0!==Object.keys(WPBNewBackupData).length&&this.getBackupStatus()}.bind(this),1e3),this.getAvailableBackupsInterval=setInterval(function(){this.getAvailableBackups()}.bind(this),3e3)},beforeDestroy:function(){clearInterval(this.getAvailableBackupsInterval),clearInterval(this.getBackupStatusInterval)}})}(jQuery),function(e){function a(){e(".viewloglink").click(function(){var a=e(this).attr("href");return e("#backup_name").val(a),e("#viewlog").submit(),!1})}function t(){e(".downloadbackuplink").bind("click",function(){var a=e(this).attr("href");return e("#backup_file").val(a),e(this).append('<i class="fa fa-check"></i>'),e(this).css({color:"green"}),e("#download_backup").submit(),!1})}function i(a,i){var n=({action:f("backup_zip_filelist"),job_id:a},i.replace(/[^A-Za-z0-9\-]/g,"")),o=0,c="",l='<div id="'+n+'"> <h2>'+wpbackitup_local.bl_backup_set+" <em>"+i+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button><span id="wpbiu-note-response">'+wpbackitup_local.bl_note_saved_success+"</span></div> <p>"+wpbackitup_local.bl_backup_download+'</p> <table class="widefat" id="datatable"> <tbody>';e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_zip_filelist"),job_id:a},dataType:"json"}).done(function(i){i.data?(e.each(i.data,function(){var a=e(this)[0].name.split(/[\/]+/).pop(),t=e(this)[0].size,i=e(this)[0].file_exists;if(console.log(a,t),a.indexOf("-backupset-")>-1)c='<p><a class="downloadbackuplink" href="'+a+'"><i class="fa fa-cloud-download fa-3x"></i> <strong>'+wpbackitup_local.bl_backup_download_single+"</strong></a> <br><em>"+wpbackitup_local.bl_please_note+t+wpbackitup_local.bl_may_timeout+"</em></p>";else{o++;var s="";o%2!=0&&(s="alternate"),l+='<tr class="'+s+'" id="row'+o+'">',l+=i?'<td><a class="downloadbackuplink" href="'+a+'">'+a+"</a></td>":"<td>"+a+"</td>",l+="<td>"+t+"</td> </tr>"}}),l+=c+"</tbody></table></div>",e("#TB_ajaxContent").html(l),t(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-note-box").val(a.data)}}),e("#wpbiu-note-btn").click(function(){var t=e("#wpbiu-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-note-response").fadeIn()})}),e("#wpbiu-note-box").focus(function(){e("#wpbiu-note-response").hide()})):s(i,null,null)}).fail(function(e,a,t){s(e,a,t)})}function s(e,a,t){var i="Error-Invalid response from server: ";a&&(i+=a+"\n"),t&&(i+=t+"\n"),i+="\nResponse: \n\n"+JSON.stringify(e),alert(i)}function n(){var a={action:f("restore_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),e(a).find(".isa_error").fadeIn(1500),clearInterval(window.intervalDefine)),e(this).html()==-2&&e(a).find(".isa_warning").fadeIn(1500),99==e(this).html()&&(e(a).find(".isa_success").fadeIn(1500),clearInterval(window.intervalDefine))})})}function o(){var a={action:f("backup_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){if(x)return clearInterval(window.intervalDefine),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").fadeOut(200),e(".backup-cancelled").fadeIn(200),!1;var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),clearInterval(window.intervalDefine),c()),e(this).html()==-2&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".wpbackitup-warning").fadeIn(1500)),99==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500),clearInterval(window.intervalDefine),c())})})}function c(){var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_response_reader")},dataType:"json"});a.always(function(a,t,i){if(console.log("Backup Response:"+JSON.stringify(a)),"undefined"!=typeof a.backupStatus&&"undefined"!=typeof a.backupMessage){if(console.log("JSON Backup Status:"+a.backupStatus),console.log("JSON Backup Message:"+a.backupMessage),y)return;switch(y=!0,a.backupStatus){case"success":if(console.log("JSON success response received."),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden"),e(".isa_success").show,e(".backup-success").fadeIn(1500),_(a),"undefined"!=typeof a.backupWarnings){var s=e(".backup-warning"),n=a.backupWarnings;n.forEach(function(e){var a=e.warningMessage;s.append('<li class="isa_warning">'+wpbackitup_local.warning+": "+a+"</li>")}),s.fadeIn(1500)}break;case"error":console.log("JSON error response received.");var o=wpbackitup_local.unexpected_err;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+": "+o,l=e(".backup-error");l.html(c),l.addClass("isa_error"),l.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden");break;default:console.log("Unexpected JSON response status received.");var o=wpbackitup_local.unexpected_err2;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+"(JS998) : "+o,u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden")}}else{console.log("NON JSON response received."),console.log("Backup Response:"+i),c=wpbackitup_local.unexpected_err3+": ",c+="</br>"+wpbackitup_local.response+": "+JSON.stringify(a),c+="</br>"+wpbackitup_local.status+": "+t,c+="</br>"+wpbackitup_local.error+": "+JSON.stringify(i),e(".backup-status").hide();var u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.show(),e(".status-icon").fadeOut(200)}})}function l(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-success").hide(),e(".default-status").hide(),e(".backup-error").hide(),e(".backup-cancelled").hide(),e("ul.backup-status").children().children().hide(),e(".backup-errors").children().children().hide(),e(".backup-success").children().children().hide(),e(".backup-status").show(),y=!1,window.intervalDefine=setInterval(o,5e3)}function u(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-status").show(),y=!1,clearInterval(window.intervalDefine),window.intervalDefine=setInterval(o,5e3)}function r(){e(".restore-icon").css("visibility","visible"),e(".default-status, .upload-status").hide(),e("ul.restore-status").children().children().hide(),e(".restore-errors").children().children().hide(),e(".restore-success").children().children().hide(),e(".restore-status, .restore-errors, .restore-success").show(),e(".preparing-icon").css("visibility","visible"),e(".preparing").find(".status-icon").fadeIn(1500),window.intervalDefine=setInterval(n,5e3)}function p(a){var t=new plupload.Uploader(a);t.init(),t.bind("FilesAdded",function(a,t){plupload.each(t,function(a){e("#filelist").append('<div id="media-item-'+a.id+'" class="media-item child-of-0"><img class="pinkynail" alt="" src="'+site_url+'/wp-includes/images/media/archive.png"><div class="filename new" id="'+a.id+'">'+a.name+" (<span>"+plupload.formatSize(0)+"</span> of "+plupload.formatSize(a.size)+') <div class="progress" style="width: 0%;"></div></div></div>')}),a.refresh(),a.start()}),t.bind("UploadProgress",function(a,t){e("#"+t.id+" .progress").width(.15*t.percent+"%"),e("#"+t.id+" span").html(plupload.formatSize(parseInt(t.size*t.percent/100)))}),t.bind(" ChunkUploaded",function(e,a,t){console.log("Chunk Uploaded:"),console.log(t),d(t,e,a)&&console.log("chunk error")}),t.bind("Error",function(a,t){console.log("PlUpload Error:"),console.log(t);var i="error-item-"+t.file.id;e("#"+i).length||e("#filelist").append('<div class="error-div error" id="'+i+'" ><strong>'+t.file.name+" has failed to upload due to error: </strong> <span>"+t.message+"</span> </div>")}),t.bind("FileUploaded",function(a,t,i){console.log("File Uploaded"),console.log(i),d(i,a,t)?console.log("uploaded error"):(console.log("uploaded success"),e("#"+t.id+" .progress").css("background-color","green"),e("#import-uploads").show())})}function d(e,a,t){if("200"!=e.status)return alert("Unknown server response status: "+e.code),console.log(e),b(a,t,999,e.response),!0;try{return response_json=jQuery.parseJSON(e.response),!!response_json.error&&(b(a,t,100,response_json.error),!0)}catch(i){return console.log("Unexpected JSON Error"+i),b(a,t,998,e.response),!0}}function b(a,t,i,s){t.status=plupload.FAILED,a.trigger("Error",{code:i,message:s,file:t}),e("#media-item-"+t.id).hide()}function _(i){"undefined"!=typeof i&&(WPBNewBackupData=i,e("#nofiles")&&e("#nofiles").remove(),a(),t())}function f(e){return w+"_"+e}function k(){notification_bar=e("#wp-backitup-notification-parent"),notification_bar.fadeOut("slow")}function h(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("error",!1),notification_bar.toggleClass("updated",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}function g(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("updated",!1),notification_bar.toggleClass("error",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}var w="wp-backitup",v=0;a(),t();try{"undefined"!=typeof wpbackitup_plupload_config&&p(wpbackitup_plupload_config)}catch(m){console.log(m)}e(".logs_backup").click(function(){var a=e(this).attr("href");return e("#backup_file").val(a),e("#download_logs").val(),e("#download_backup").submit(),!1}),e("#scheduled-backups-accordian").click(function(){scheduled_backups=e("#scheduled-backups"),scheduled_backups_button=e("#scheduled-backups-accordian"),e(this).is(".fa-angle-double-down")?(scheduled_backups.fadeIn("slow"),scheduled_backups_button.toggleClass("fa-angle-double-down",!1),scheduled_backups_button.toggleClass("fa-angle-double-up",!0)):(scheduled_backups_button.toggleClass("fa-angle-double-down",!0),scheduled_backups_button.toggleClass("fa-angle-double-up",!1),scheduled_backups.fadeOut("slow"))}),e("#upload-backups-accordian").click(function(){upload_backups=e("#wpbackitup-plupload-modal"),upload_backups_button=e("#upload-backups-accordian"),e(this).is(".fa-angle-double-down")?(upload_backups.fadeIn("slow"),upload_backups_button.toggleClass("fa-angle-double-down",!1),upload_backups_button.toggleClass("fa-angle-double-up",!0)):(upload_backups_button.toggleClass("fa-angle-double-down",!0),upload_backups_button.toggleClass("fa-angle-double-up",!1),upload_backups.fadeOut("slow"))}),e("#wpbackitup-zip").bind("change",function(){var a=this.files[0].size,t=e("#maxfilesize").val();"undefined"!=a&&"undefined"!=t&&""!=a&&""!=t&&a>t&&(alert(wpbackitup_local.upload_file_size_exceed),e("#wpbackitup-zip").val(""))}),e("#import-uploads").click(function(){setTimeout(function(){window.location.reload()},100)}),e(document.body).on("click",".thickbox",function(){if(!e(this).parents(".wpbiu-restore-item").length){var a=e(this).data("jobid");console.log(a);var t=this.name;i(a,t)}}),e(document.body).on("click",".thickbox",function(){var a=e(this).data("jobid"),t=e(this).attr("name");if(e(this).parents(".wpbiu-restore-item").length){var i="<h2>"+wpbackitup_local.bl_backup_set+" <em>"+t+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-restore-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-restore-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button> <span id="wpbiu-restore-note-response">'+wpbackitup_local.bl_note_saved_success+"</span> </div>";e("#wpbiu-restore-note").html(i),e("#wpbiu-restore-note-response").hide(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-restore-note-box").val(a.data)}}),e("#wpbiu-restore-note-btn").click(function(){var t=e("#wpbiu-restore-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-restore-note-response").fadeIn()})})}e("#wpbiu-restore-note-box").focus(function(){e("#wpbiu-restore-note-response").hide()})});var y=!1;e("#wp-backitup-notification-widget-close").click(function(){notification_bar=e("#wp-backitup-notification-widget"),notification_bar.fadeOut("slow");var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("delete_transient")},dataType:"json"});a.always(function(a,t,i){a!==!1&&(notification_bar.removeClass(),notification_bar.addClass("notice"),notification_bar.addClass("notice-"+a.message_type),e("#wp-backitup-notification-widget-message p").html(a.message),notification_bar.hide().fadeIn("slow"))})}),e("#wp-backitup-notification-close").click(function(){k()}),e("#wp-backitup-save_schedule_form").submit(function(){var a=new FormData;a.append("action",f("update-schedule")),a.append("_wpnonce",e("#wp-backitup_nonce-update-schedule").val()),a.append("_wp_http_referer",e("[name='_wp_http_referer']").val());var t=[];return e.each(e("input[name='dow']:checked"),function(){t.push(e(this).val())}),a.append("days_selected",t),jQuery.ajax({url:ajaxurl,type:"POST",cache:!1,contentType:!1,processData:!1,dataType:"json",data:a,success:function(e,a,t){switch(response=e.message,console.log("Success:"+response),response){case"success":h(wpbackitup_local.scheduled_saved);break;case"error":g(wpbackitup_local.scheduled_not_saved)}},error:function(e,a,t){console.log("Error."+a+":"+t)},complete:function(e,a){console.log("Complete")}}),!1});var j=null;e(".backup-button").click(function(a){a.preventDefault(),x=!1,e("#backup-button").attr("disabled","disabled"),e("#cancel-button").removeClass("cancel-hidden"),e("#cancel-button").removeAttr("disabled"),e("#cancel-button").fadeIn(200),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup")},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),l()}}),j.always(function(e,a,t){console.log("Backup Button Click - Always"),console.log(e.message),"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})});var x=!1;e(".cancel-button").click(function(a){a.preventDefault(),e("#cancel-button").attr("disabled","disabled"),null!=j&&(j.abort(),j=null),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("cancel_backup"),job_id:v},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),u()}}),j.always(function(e,a,t){console.log("Cancel Button Click - Always"),console.log(e),"undefined"!=typeof e.success&&1==e.success?console.log("Job Cancelled successfully"):console.log("Job was not cancelled successfully"),x=!0})}),e("#datatable").on("click","a.restoreRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.confirm_restore)){var t=this.title;this.id.replace("restoreRow","row");userid=e("input[name=user_id]").val();var i=e.ajax({url:ajaxurl,type:"post",data:{action:f("restore"),selected_file:t,user_id:userid},cache:!1,dataType:"json",beforeSend:function(){console.log("BeforeSend:Nothing to report."),r()}});i.always(function(e,a,t){"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})}}),e("#datatable").on("click","a.deleteRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.sure)){var t=this.title,i=e(this).data("id"),s=this.id.replace("deleteRow","row");e.ajax({url:ajaxurl,type:"post",data:{action:f("delete_file"),filed:t,post_id:i},success:function(a){var t=a.search("deleted");0==t?e("#"+s).remove():alert(wpbackitup_local.file_not_del)}})}})}(jQuery),function(e){"use strict";var a="wp-backitup",t=function(e){return a+"_"+e},i=function(a){return e.ajax({url:ajaxurl,type:"GET",data:{action:t(a)},dataType:"json"})},s=function(a,i){var i=i||{};return i.action=t(a),i.security=e("#wpbackitup-core-ajax-nonce").val(),e.ajax({url:ajaxurl,type:"POST",data:i,dataType:"json"})};e(window).load(function(){if(document.querySelector("#wpbackitup-core-settings")){Vue.use(VueTabs);var e=new Vue({el:"#wpbackitup-core-settings",data:{loading:!1,updated:!1,emailsArray:[],errorMessages:{},backup_retained_number:3,logging:!1,single_file_db:!1,single_file_backupset:!1,rversion_compare:!1,remove_supporting_zip_files:!1,backup_plugins_filter:[],backup_themes_filter:[],backup_uploads_filter:[],backup_others_filter:[],dbFilterOptions:[],db_filters:[],backup_dbtables_batch_size:1e4,backup_sql_merge_batch_size:1e4,backup_sql_batch_size:1e4,backup_plugins_batch_size:5e3,backup_themes_batch_size:5e3,backup_uploads_batch_size:500,backup_others_batch_size:500,backup_zip_max_size:524288e3,backup_max_timeout:120,delete_all:!1,safe_sync:!1},computed:{dbFilterHasSearch:function(){return 0==this.dbFilterOptions.length},dbFilterPlaceholder:function(){return this.dbFilterOptions.length>0?wpbackitup_local.settings_select_database_table_to_filter:wpbackitup_local.settings_no_database_table_to_filter}},methods:{handleEmailInput:function(e){},handleTagsInput:function(e){},setSettings:function(){var a={data:{notification_email:this.emailsArray.join(","),backup_retained_number:this.backup_retained_number,logging:this.logging,single_file_db:this.single_file_db,single_file_backupset:this.single_file_backupset,rversion_compare:this.rversion_compare,remove_supporting_zip_files:this.remove_supporting_zip_files,backup_plugins_filter:this.backup_plugins_filter.join(","),backup_themes_filter:this.backup_themes_filter.join(","),backup_uploads_filter:this.backup_uploads_filter.join(","),backup_others_filter:this.backup_others_filter.join(","),backup_dbtables_filter_list:this.db_filters.map(function(e){return e.value}).join(","),backup_dbtables_batch_size:this.backup_dbtables_batch_size,backup_sql_merge_batch_size:this.backup_sql_merge_batch_size,backup_sql_batch_size:this.backup_sql_batch_size,backup_plugins_batch_size:this.backup_plugins_batch_size,backup_themes_batch_size:this.backup_themes_batch_size,backup_uploads_batch_size:this.backup_uploads_batch_size,backup_others_batch_size:this.backup_others_batch_size,backup_zip_max_size:this.backup_zip_max_size,backup_max_timeout:this.backup_max_timeout,delete_all:this.delete_all,safe_sync:this.safe_sync}};console.log(a),s("set_settings",a).then(function(a){a.success?(e.updated=!0,e.errorMessages={},swal(wpbackitup_local.settings_save_awesome,wpbackitup_local.settings_save_success_message,"success")):(e.errorMessages=a.data,swal(wpbackitup_local.settings_save_oops,wpbackitup_local.settings_save_error_message,"error"))})},getSettings:function(){this.loading=!0,i("get_settings").then(function(a){e.loading=!1,a.success&&(console.log(a),e.emailsArray=a.data.notification_email.split(",").filter(Boolean),e.backup_retained_number=a.data.backup_retained_number,e.logging="1"===a.data.logging,e.single_file_db="1"===a.data.single_file_db,e.rversion_compare="1"===a.data.rversion_compare,e.single_file_backupset="1"===a.data.single_file_backupset,e.remove_supporting_zip_files="1"===a.data.remove_supporting_zip_files,e.backup_plugins_filter=a.data.backup_plugins_filter.split(",").filter(Boolean),e.backup_themes_filter=a.data.backup_themes_filter.split(",").filter(Boolean),e.backup_uploads_filter=a.data.backup_uploads_filter.split(",").filter(Boolean),e.backup_others_filter=a.data.backup_others_filter.split(",").filter(Boolean),e.db_filters=a.data.backup_dbtables_filter_list.split(",").filter(Boolean).map(function(e){return{label:e,value:e}}),e.dbFilterOptions=Object.keys(a.data.backup_dbtables_filterable).map(function(e){var t=a.data.backup_dbtables_filterable[e];return{label:t,value:t}}),e.backup_dbtables_batch_size=a.data.backup_dbtables_batch_size,e.backup_sql_merge_batch_size=a.data.backup_sql_merge_batch_size,e.backup_sql_batch_size=a.data.backup_sql_batch_size,e.backup_plugins_batch_size=a.data.backup_plugins_batch_size,e.backup_themes_batch_size=a.data.backup_themes_batch_size,e.backup_uploads_batch_size=a.data.backup_uploads_batch_size,e.backup_others_batch_size=a.data.backup_others_batch_size,e.backup_zip_max_size=a.data.backup_zip_max_size,e.backup_max_timeout=a.data.backup_max_timeout,e.delete_all="1"===a.data.delete_all,e.safe_sync="1"===a.data.safe_sync)})}},created:function(){this.getSettings()}})}})}(jQuery);
|
1 |
+
var WPBNewBackupData={},ajaxNamespace="wpbackitup-safe",ENUM={GDRIVE:"GDRIVE",AMAZONS3:"AMAZONS3",DROPBOX:"DROPBOX"},CLOUDSTATUS={READY:"ready",UPLOADING:"uploading",UPLOADED:"uploaded",ERROR:"error"},wpbackitup_get_action_name=function(e){return ajaxNamespace+"_"+e},AjaxGetSafe=function(e){return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:wpbackitup_get_action_name(e),security:WPBackItUpSafeLocals[e]},dataType:"json"})},AjaxGetCore=function(e){var a=wpbackitup_local[e];return jQuery.ajax({url:ajaxurl,type:"GET",data:{action:"wp-backitup_"+e,security:a},dataType:"json"})},AjaxPostSafe=function(e,a){var a=a||{};return a.action=wpbackitup_get_action_name(e),a.security=WPBackItUpSafeLocals[e],jQuery.ajax({url:ajaxurl,type:"POST",data:a,dataType:"json"})};!function(e){"use strict";if(document.querySelector("#wpbackitup-core-backup"))var a=new Vue({el:"#wpbackitup-core-backup",data:{cloudStatus:{},isNewRowAvailable:!1,backupNewRow:{}},methods:{getAvailableBackups:function(){AjaxGetCore("get_available_backups").then(function(e){if(e.success)for(var t=0;t<e.data.length;t++){var i=e.data[t].backup_job_id,s=e.data[t].backup_job_cloud_status;a.$set(a.cloudStatus,i,s)}})},getBackupStatus:function(){var e=WPBNewBackupData;if("success"===e.backupStatus){var a=e.backupName,t=a.lastIndexOf("_"),i=a.substring(t+1);this.isNewRowAvailable=!0,this.backupNewRow={name:e.backupName,type:e.backupRuntype,date:e.backupDate,duration:e.backupDuration,status:e.backupStatus,row:99999,jobId:i,zipExist:!0},WPBNewBackupData={}}}},mounted:function(){this.getAvailableBackups(),this.getBackupStatusInterval=setInterval(function(){0!==Object.keys(WPBNewBackupData).length&&this.getBackupStatus()}.bind(this),1e3),this.getAvailableBackupsInterval=setInterval(function(){this.getAvailableBackups()}.bind(this),3e3)},beforeDestroy:function(){clearInterval(this.getAvailableBackupsInterval),clearInterval(this.getBackupStatusInterval)}})}(jQuery),function(e){function a(){e(".viewloglink").click(function(){var a=e(this).attr("href");return e("#backup_name").val(a),e("#viewlog").submit(),!1})}function t(){e(".downloadbackuplink").bind("click",function(){var a=e(this).attr("href");return e("#backup_file").val(a),e(this).append('<i class="fa fa-check"></i>'),e(this).css({color:"green"}),e("#download_backup").submit(),!1})}function i(a,i){var n=({action:f("backup_zip_filelist"),job_id:a},i.replace(/[^A-Za-z0-9\-]/g,"")),o=0,c="",l='<div id="'+n+'"> <h2>'+wpbackitup_local.bl_backup_set+" <em>"+i+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button><span id="wpbiu-note-response">'+wpbackitup_local.bl_note_saved_success+"</span></div> <p>"+wpbackitup_local.bl_backup_download+'</p> <table class="widefat" id="datatable"> <tbody>';e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_zip_filelist"),job_id:a},dataType:"json"}).done(function(i){i.data?(e.each(i.data,function(){var a=e(this)[0].name.split(/[\/]+/).pop(),t=e(this)[0].size,i=e(this)[0].file_exists;if(console.log(a,t),a.indexOf("-backupset-")>-1)c='<p><a class="downloadbackuplink" href="'+a+'"><i class="fa fa-cloud-download fa-3x"></i> <strong>'+wpbackitup_local.bl_backup_download_single+"</strong></a> <br><em>"+wpbackitup_local.bl_please_note+t+wpbackitup_local.bl_may_timeout+"</em></p>";else{o++;var s="";o%2!=0&&(s="alternate"),l+='<tr class="'+s+'" id="row'+o+'">',l+=i?'<td><a class="downloadbackuplink" href="'+a+'">'+a+"</a></td>":"<td>"+a+"</td>",l+="<td>"+t+"</td> </tr>"}}),l+=c+"</tbody></table></div>",e("#TB_ajaxContent").html(l),t(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-note-box").val(a.data)}}),e("#wpbiu-note-btn").click(function(){var t=e("#wpbiu-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-note-response").fadeIn()})}),e("#wpbiu-note-box").focus(function(){e("#wpbiu-note-response").hide()})):s(i,null,null)}).fail(function(e,a,t){s(e,a,t)})}function s(e,a,t){var i="Error-Invalid response from server: ";a&&(i+=a+"\n"),t&&(i+=t+"\n"),i+="\nResponse: \n\n"+JSON.stringify(e),alert(i)}function n(){var a={action:f("restore_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),e(a).find(".isa_error").fadeIn(1500),clearInterval(window.intervalDefine)),e(this).html()==-2&&e(a).find(".isa_warning").fadeIn(1500),99==e(this).html()&&(e(a).find(".isa_success").fadeIn(1500),clearInterval(window.intervalDefine))})})}function o(){var a={action:f("backup_status_reader"),job_id:v};e.post(ajaxurl,a,function(a){if(x)return clearInterval(window.intervalDefine),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").fadeOut(200),e(".backup-cancelled").fadeIn(200),!1;var t=e(a);t.each(function(){var a="."+e(this).attr("class"),t="."+e(this).attr("class")+"-icon";0==e(this).html()&&(e(a).find(".status").hide(),e(a).find(".status-icon").hide()),1==e(this).html()&&(e(t).css("visibility","visible"),e(a).find(".status").fadeOut(200),e(a).find(".status-icon").fadeIn(1500)),2==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500)),e(this).html()==-1&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".fail").fadeIn(1500),clearInterval(window.intervalDefine),c()),e(this).html()==-2&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".wpbackitup-warning").fadeIn(1500)),99==e(this).html()&&(e(a).find(".status-icon").fadeOut(200),e(a).find(".status").fadeIn(1500),clearInterval(window.intervalDefine),c())})})}function c(){var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_response_reader")},dataType:"json"});a.always(function(a,t,i){if(console.log("Backup Response:"+JSON.stringify(a)),"undefined"!=typeof a.backupStatus&&"undefined"!=typeof a.backupMessage){if(console.log("JSON Backup Status:"+a.backupStatus),console.log("JSON Backup Message:"+a.backupMessage),y)return;switch(y=!0,a.backupStatus){case"success":if(console.log("JSON success response received."),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden"),e(".isa_success").show,e(".backup-success").fadeIn(1500),_(a),"undefined"!=typeof a.backupWarnings){var s=e(".backup-warning"),n=a.backupWarnings;n.forEach(function(e){var a=e.warningMessage;s.append('<li class="isa_warning">'+wpbackitup_local.warning+": "+a+"</li>")}),s.fadeIn(1500)}break;case"error":console.log("JSON error response received.");var o=wpbackitup_local.unexpected_err;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+": "+o,l=e(".backup-error");l.html(c),l.addClass("isa_error"),l.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden");break;default:console.log("Unexpected JSON response status received.");var o=wpbackitup_local.unexpected_err2;"undefined"!=typeof a.backupMessage&&(o=a.backupMessage);var c=wpbackitup_local.error+"(JS998) : "+o,u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.fadeIn(1500),e(".status-icon").fadeOut(200),e("#backup-button").removeAttr("disabled"),e("#cancel-button").addClass("cancel-hidden")}}else{console.log("NON JSON response received."),console.log("Backup Response:"+i),c=wpbackitup_local.unexpected_err3+": ",c+="</br>"+wpbackitup_local.response+": "+JSON.stringify(a),c+="</br>"+wpbackitup_local.status+": "+t,c+="</br>"+wpbackitup_local.error+": "+JSON.stringify(i),e(".backup-status").hide();var u=e(".backup-error");u.html(c),u.addClass("isa_error"),u.show(),e(".status-icon").fadeOut(200)}})}function l(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-success").hide(),e(".default-status").hide(),e(".backup-error").hide(),e(".backup-cancelled").hide(),e("ul.backup-status").children().children().hide(),e(".backup-errors").children().children().hide(),e(".backup-success").children().children().hide(),e(".backup-status").show(),y=!1,window.intervalDefine=setInterval(o,5e3)}function u(){e(".backup-icon").css("visibility","visible"),e(".backup-icon").show(),e(".backup-status").show(),y=!1,clearInterval(window.intervalDefine),window.intervalDefine=setInterval(o,5e3)}function r(){e(".restore-icon").css("visibility","visible"),e(".default-status, .upload-status").hide(),e("ul.restore-status").children().children().hide(),e(".restore-errors").children().children().hide(),e(".restore-success").children().children().hide(),e(".restore-status, .restore-errors, .restore-success").show(),e(".preparing-icon").css("visibility","visible"),e(".preparing").find(".status-icon").fadeIn(1500),window.intervalDefine=setInterval(n,5e3)}function p(a){var t=new plupload.Uploader(a);t.init(),t.bind("FilesAdded",function(a,t){plupload.each(t,function(a){e("#filelist").append('<div id="media-item-'+a.id+'" class="media-item child-of-0"><img class="pinkynail" alt="" src="'+site_url+'/wp-includes/images/media/archive.png"><div class="filename new" id="'+a.id+'">'+a.name+" (<span>"+plupload.formatSize(0)+"</span> of "+plupload.formatSize(a.size)+') <div class="progress" style="width: 0%;"></div></div></div>')}),a.refresh(),a.start()}),t.bind("UploadProgress",function(a,t){e("#"+t.id+" .progress").width(.15*t.percent+"%"),e("#"+t.id+" span").html(plupload.formatSize(parseInt(t.size*t.percent/100)))}),t.bind(" ChunkUploaded",function(e,a,t){console.log("Chunk Uploaded:"),console.log(t),d(t,e,a)&&console.log("chunk error")}),t.bind("Error",function(a,t){console.log("PlUpload Error:"),console.log(t);var i="error-item-"+t.file.id;e("#"+i).length||e("#filelist").append('<div class="error-div error" id="'+i+'" ><strong>'+t.file.name+" has failed to upload due to error: </strong> <span>"+t.message+"</span> </div>")}),t.bind("FileUploaded",function(a,t,i){console.log("File Uploaded"),console.log(i),d(i,a,t)?console.log("uploaded error"):(console.log("uploaded success"),e("#"+t.id+" .progress").css("background-color","green"),e("#import-uploads").show())})}function d(e,a,t){if("200"!=e.status)return alert("Unknown server response status: "+e.code),console.log(e),b(a,t,999,e.response),!0;try{return response_json=jQuery.parseJSON(e.response),!!response_json.error&&(b(a,t,100,response_json.error),!0)}catch(i){return console.log("Unexpected JSON Error"+i),b(a,t,998,e.response),!0}}function b(a,t,i,s){t.status=plupload.FAILED,a.trigger("Error",{code:i,message:s,file:t}),e("#media-item-"+t.id).hide()}function _(i){"undefined"!=typeof i&&(WPBNewBackupData=i,e("#nofiles")&&e("#nofiles").remove(),a(),t())}function f(e){return w+"_"+e}function k(){notification_bar=e("#wp-backitup-notification-parent"),notification_bar.fadeOut("slow")}function h(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("error",!1),notification_bar.toggleClass("updated",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}function g(a){notification_bar_message=e("#wp-backitup-notification-message"),notification_bar_message.html("<p>"+a+"</p>"),notification_bar=e("#wp-backitup-notification-parent"),notification_bar.toggleClass("updated",!1),notification_bar.toggleClass("error",!0),notification_bar.show(),e("html, body").animate({scrollTop:0},"slow")}var w="wp-backitup",v=0;a(),t();try{"undefined"!=typeof wpbackitup_plupload_config&&p(wpbackitup_plupload_config)}catch(m){console.log(m)}e(".logs_backup").click(function(){var a=e(this).attr("href");return e("#backup_file").val(a),e("#download_logs").val(),e("#download_backup").submit(),!1}),e("#scheduled-backups-accordian").click(function(){scheduled_backups=e("#scheduled-backups"),scheduled_backups_button=e("#scheduled-backups-accordian"),e(this).is(".fa-angle-double-down")?(scheduled_backups.fadeIn("slow"),scheduled_backups_button.toggleClass("fa-angle-double-down",!1),scheduled_backups_button.toggleClass("fa-angle-double-up",!0)):(scheduled_backups_button.toggleClass("fa-angle-double-down",!0),scheduled_backups_button.toggleClass("fa-angle-double-up",!1),scheduled_backups.fadeOut("slow"))}),e("#upload-backups-accordian").click(function(){upload_backups=e("#wpbackitup-plupload-modal"),upload_backups_button=e("#upload-backups-accordian"),e(this).is(".fa-angle-double-down")?(upload_backups.fadeIn("slow"),upload_backups_button.toggleClass("fa-angle-double-down",!1),upload_backups_button.toggleClass("fa-angle-double-up",!0)):(upload_backups_button.toggleClass("fa-angle-double-down",!0),upload_backups_button.toggleClass("fa-angle-double-up",!1),upload_backups.fadeOut("slow"))}),e("#wpbackitup-zip").bind("change",function(){var a=this.files[0].size,t=e("#maxfilesize").val();"undefined"!=a&&"undefined"!=t&&""!=a&&""!=t&&a>t&&(alert(wpbackitup_local.upload_file_size_exceed),e("#wpbackitup-zip").val(""))}),e("#import-uploads").click(function(){setTimeout(function(){window.location.reload()},100)}),e(document.body).on("click",".thickbox",function(){if(!e(this).parents(".wpbiu-restore-item").length){var a=e(this).data("jobid");console.log(a);var t=this.name;i(a,t)}}),e(document.body).on("click",".thickbox",function(){var a=e(this).data("jobid"),t=e(this).attr("name");if(e(this).parents(".wpbiu-restore-item").length){var i="<h2>"+wpbackitup_local.bl_backup_set+" <em>"+t+'</em></h2> <div class="wpbiu-notes"> <textarea class="backupnotes" id="wpbiu-restore-note-box" placeholder="'+wpbackitup_local.bl_note_placeholder+'"></textarea> <button id="wpbiu-restore-note-btn" class="button-primary">'+wpbackitup_local.bl_note_save+'</button> <span id="wpbiu-restore-note-response">'+wpbackitup_local.bl_note_saved_success+"</span> </div>";e("#wpbiu-restore-note").html(i),e("#wpbiu-restore-note-response").hide(),e.ajax({url:ajaxurl,type:"post",data:{action:f("backup_get_note"),job_id:a},success:function(a){e("#wpbiu-restore-note-box").val(a.data)}}),e("#wpbiu-restore-note-btn").click(function(){var t=e("#wpbiu-restore-note-box").val();e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup_add_note"),job_id:a,note:t},dataType:"json"}).success(function(a){e("#wpbiu-restore-note-response").fadeIn()})})}e("#wpbiu-restore-note-box").focus(function(){e("#wpbiu-restore-note-response").hide()})});var y=!1;e("#wp-backitup-notification-widget-close").click(function(){notification_bar=e("#wp-backitup-notification-widget"),notification_bar.fadeOut("slow");var a=e.ajax({url:ajaxurl,type:"POST",data:{action:f("delete_transient")},dataType:"json"});a.always(function(a,t,i){a!==!1&&(notification_bar.removeClass(),notification_bar.addClass("notice"),notification_bar.addClass("notice-"+a.message_type),e("#wp-backitup-notification-widget-message p").html(a.message),notification_bar.hide().fadeIn("slow"))})}),e("#wp-backitup-notification-close").click(function(){k()}),e("#wp-backitup-save_schedule_form").submit(function(){var a=new FormData;a.append("action",f("update-schedule")),a.append("_wpnonce",e("#wp-backitup_nonce-update-schedule").val()),a.append("_wp_http_referer",e("[name='_wp_http_referer']").val());var t=[];return e.each(e("input[name='dow']:checked"),function(){t.push(e(this).val())}),a.append("days_selected",t),jQuery.ajax({url:ajaxurl,type:"POST",cache:!1,contentType:!1,processData:!1,dataType:"json",data:a,success:function(e,a,t){switch(response=e.message,console.log("Success:"+response),response){case"success":h(wpbackitup_local.scheduled_saved);break;case"error":g(wpbackitup_local.scheduled_not_saved)}},error:function(e,a,t){console.log("Error."+a+":"+t)},complete:function(e,a){console.log("Complete")}}),!1});var j=null;e(".backup-button").click(function(a){a.preventDefault(),x=!1,e("#backup-button").attr("disabled","disabled"),e("#cancel-button").removeClass("cancel-hidden"),e("#cancel-button").removeAttr("disabled"),e("#cancel-button").fadeIn(200),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("backup")},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),l()}}),j.always(function(e,a,t){console.log("Backup Button Click - Always"),console.log(e.message),"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})});var x=!1;e(".cancel-button").click(function(a){a.preventDefault(),e("#cancel-button").attr("disabled","disabled"),null!=j&&(j.abort(),j=null),j=e.ajax({url:ajaxurl,type:"POST",data:{action:f("cancel_backup"),job_id:v},cache:!1,dataType:"json",beforeSend:function(e,a){console.log("BeforeSend:Nothing to report."),u()}}),j.always(function(e,a,t){console.log("Cancel Button Click - Always"),console.log(e),"undefined"!=typeof e.success&&1==e.success?console.log("Job Cancelled successfully"):console.log("Job was not cancelled successfully"),x=!0})}),e("#datatable").on("click","a.restoreRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.confirm_restore)){var t=this.title;this.id.replace("restoreRow","row");userid=e("input[name=user_id]").val();var i=e.ajax({url:ajaxurl,type:"post",data:{action:f("restore"),selected_file:t,user_id:userid},cache:!1,dataType:"json",beforeSend:function(){console.log("BeforeSend:Nothing to report."),r()}});i.always(function(e,a,t){"undefined"!=typeof e.job_id?(v=e.job_id,console.log("Job_Id:"+e.job_id)):console.log("No Job Id found:"+e)})}}),e("#datatable").on("click","a.deleteRow",function(a){if(a.preventDefault(),confirm(wpbackitup_local.sure)){var t=this.title,i=e(this).data("id"),s=this.id.replace("deleteRow","row");e.ajax({url:ajaxurl,type:"post",data:{action:f("delete_file"),filed:t,post_id:i},success:function(a){var t=a.search("deleted");0==t?e("#"+s).remove():alert(wpbackitup_local.file_not_del)}})}})}(jQuery),function(e){"use strict";var a="wp-backitup",t=function(e){return a+"_"+e},i=function(a){return e.ajax({url:ajaxurl,type:"GET",data:{action:t(a)},dataType:"json"})},s=function(a,i){var i=i||{};return i.action=t(a),i.security=e("#wpbackitup-core-ajax-nonce").val(),e.ajax({url:ajaxurl,type:"POST",data:i,dataType:"json"})};e(window).load(function(){if(document.querySelector("#wpbackitup-core-settings")){Vue.use(VueTabs);var e=new Vue({el:"#wpbackitup-core-settings",data:{loading:!1,updated:!1,emailsArray:[],errorMessages:{},backup_retained_number:3,logging:!1,single_file_db:!1,single_file_backupset:!1,rversion_compare:!1,remove_supporting_zip_files:!1,backup_plugins_filter:[],backup_themes_filter:[],backup_uploads_filter:[],backup_others_filter:[],dbFilterOptions:[],db_filters:[],allow_usage_tracking:!1,backup_dbtables_batch_size:1e4,backup_sql_merge_batch_size:1e4,backup_sql_batch_size:1e4,backup_plugins_batch_size:5e3,backup_themes_batch_size:5e3,backup_uploads_batch_size:500,backup_others_batch_size:500,backup_zip_max_size:524288e3,backup_max_timeout:120,delete_all:!1,safe_sync:!1},computed:{dbFilterHasSearch:function(){return 0==this.dbFilterOptions.length},dbFilterPlaceholder:function(){return this.dbFilterOptions.length>0?wpbackitup_local.settings_select_database_table_to_filter:wpbackitup_local.settings_no_database_table_to_filter}},methods:{handleEmailInput:function(e){},handleTagsInput:function(e){},setSettings:function(){var a={data:{notification_email:this.emailsArray.join(","),backup_retained_number:this.backup_retained_number,logging:this.logging,single_file_db:this.single_file_db,single_file_backupset:this.single_file_backupset,rversion_compare:this.rversion_compare,remove_supporting_zip_files:this.remove_supporting_zip_files,backup_plugins_filter:this.backup_plugins_filter.join(","),backup_themes_filter:this.backup_themes_filter.join(","),backup_uploads_filter:this.backup_uploads_filter.join(","),backup_others_filter:this.backup_others_filter.join(","),backup_dbtables_filter_list:this.db_filters.map(function(e){return e.value}).join(","),backup_dbtables_batch_size:this.backup_dbtables_batch_size,backup_sql_merge_batch_size:this.backup_sql_merge_batch_size,backup_sql_batch_size:this.backup_sql_batch_size,backup_plugins_batch_size:this.backup_plugins_batch_size,backup_themes_batch_size:this.backup_themes_batch_size,backup_uploads_batch_size:this.backup_uploads_batch_size,backup_others_batch_size:this.backup_others_batch_size,backup_zip_max_size:this.backup_zip_max_size,backup_max_timeout:this.backup_max_timeout,delete_all:this.delete_all,safe_sync:this.safe_sync,allow_usage_tracking:this.allow_usage_tracking}};console.log(a),s("set_settings",a).then(function(a){a.success?(e.updated=!0,e.errorMessages={},swal(wpbackitup_local.settings_save_awesome,wpbackitup_local.settings_save_success_message,"success")):(e.errorMessages=a.data,swal(wpbackitup_local.settings_save_oops,wpbackitup_local.settings_save_error_message,"error"))})},getSettings:function(){this.loading=!0,i("get_settings").then(function(a){e.loading=!1,a.success&&(console.log(a),e.emailsArray=a.data.notification_email.split(",").filter(Boolean),e.backup_retained_number=a.data.backup_retained_number,e.logging="1"===a.data.logging,e.single_file_db="1"===a.data.single_file_db,e.rversion_compare="1"===a.data.rversion_compare,e.single_file_backupset="1"===a.data.single_file_backupset,e.remove_supporting_zip_files="1"===a.data.remove_supporting_zip_files,e.backup_plugins_filter=a.data.backup_plugins_filter.split(",").filter(Boolean),e.backup_themes_filter=a.data.backup_themes_filter.split(",").filter(Boolean),e.backup_uploads_filter=a.data.backup_uploads_filter.split(",").filter(Boolean),e.backup_others_filter=a.data.backup_others_filter.split(",").filter(Boolean),e.db_filters=a.data.backup_dbtables_filter_list.split(",").filter(Boolean).map(function(e){return{label:e,value:e}}),e.dbFilterOptions=Object.keys(a.data.backup_dbtables_filterable).map(function(e){var t=a.data.backup_dbtables_filterable[e];return{label:t,value:t}}),e.allow_usage_tracking=a.data.allow_usage_tracking,e.backup_dbtables_batch_size=a.data.backup_dbtables_batch_size,e.backup_sql_merge_batch_size=a.data.backup_sql_merge_batch_size,e.backup_sql_batch_size=a.data.backup_sql_batch_size,e.backup_plugins_batch_size=a.data.backup_plugins_batch_size,e.backup_themes_batch_size=a.data.backup_themes_batch_size,e.backup_uploads_batch_size=a.data.backup_uploads_batch_size,e.backup_others_batch_size=a.data.backup_others_batch_size,e.backup_zip_max_size=a.data.backup_zip_max_size,e.backup_max_timeout=a.data.backup_max_timeout,e.delete_all="1"===a.data.delete_all,e.safe_sync="1"===a.data.safe_sync)})}},created:function(){this.getSettings()}})}})}(jQuery);
|
lib/includes/admin-actions.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Actions
|
4 |
+
*
|
5 |
+
* @package WPBackItUp
|
6 |
+
* @subpackage Admin/Actions
|
7 |
+
* @copyright Copyright (c) 2018, Chris Simmons
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 1.15.5
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Processes all WPBackItUp actions sent via POST and GET by looking for the 'wpbackitup-action'
|
17 |
+
* request and running do_action() to call the function
|
18 |
+
*
|
19 |
+
* @since 1.0
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
function wpbackitup_process_actions() {
|
23 |
+
|
24 |
+
if ( isset( $_POST['wpbackitup_action'] ) ) {
|
25 |
+
do_action( 'wpbackitup_' . $_POST['wpbackitup_action'], $_POST );
|
26 |
+
}
|
27 |
+
|
28 |
+
if ( isset( $_GET['wpbackitup_action'] ) ) {
|
29 |
+
do_action( 'wpbackitup_' . $_GET['wpbackitup_action'], $_GET );
|
30 |
+
}
|
31 |
+
}
|
32 |
+
add_action( 'admin_init', 'wpbackitup_process_actions' );
|
33 |
+
|
lib/includes/class-cron.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* WPBackItUp Cron Class
|
8 |
+
*
|
9 |
+
* This class handles scheduled events
|
10 |
+
*
|
11 |
+
* @since 1.15.8
|
12 |
+
*/
|
13 |
+
class WPBackItUp_Cron {
|
14 |
+
|
15 |
+
|
16 |
+
public function __construct() {
|
17 |
+
add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
|
18 |
+
add_action( 'init', array( $this, 'schedule_events' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Registers new cron schedules
|
23 |
+
*
|
24 |
+
* @param array $schedules
|
25 |
+
* @return array
|
26 |
+
*/
|
27 |
+
public function add_schedules( $schedules = array() ) {
|
28 |
+
// Adds once weekly to the existing schedules.
|
29 |
+
$schedules['weekly'] = array(
|
30 |
+
'interval' => 604800,
|
31 |
+
'display' => __( 'Once Weekly', 'wpbackitup' )
|
32 |
+
);
|
33 |
+
|
34 |
+
// Adds once daily to the existing schedules.
|
35 |
+
$schedules['daily'] = array(
|
36 |
+
'interval' => 86400,
|
37 |
+
'display' => __( 'Once Weekly', 'wpbackitup' )
|
38 |
+
);
|
39 |
+
|
40 |
+
return $schedules;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Schedules events
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
public function schedule_events() {
|
49 |
+
$this->schedule_weekly_events();
|
50 |
+
$this->schedule_daily_events();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Schedule weekly events
|
55 |
+
*
|
56 |
+
* @access private
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
private function schedule_weekly_events() {
|
60 |
+
if ( ! wp_next_scheduled( 'wpbackitup_weekly_scheduled_events' ) ) {
|
61 |
+
wp_schedule_event( current_time( 'timestamp', true ), 'weekly', 'wpbackitup_weekly_scheduled_events' );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Schedule daily events
|
67 |
+
*
|
68 |
+
* @access private
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
private function schedule_daily_events() {
|
72 |
+
if ( ! wp_next_scheduled( 'wpbackitup_daily_scheduled_events' ) ) {
|
73 |
+
wp_schedule_event( current_time( 'timestamp', true ), 'daily', 'wpbackitup_daily_scheduled_events' );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Unscheduled all WPBackItUp events
|
79 |
+
*
|
80 |
+
*/
|
81 |
+
public static function unschedule_events() {
|
82 |
+
wp_clear_scheduled_hook('wpbackitup_daily_scheduled_events');
|
83 |
+
wp_clear_scheduled_hook('wpbackitup_weekly_scheduled_events');
|
84 |
+
}
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Abstraction for WordPress cron checking, to avoid code duplication.
|
89 |
+
*
|
90 |
+
*/
|
91 |
+
static function doing_cron() {
|
92 |
+
|
93 |
+
// Bail if not doing WordPress cron (>4.8.0)
|
94 |
+
if ( function_exists( 'wp_doing_cron' ) && wp_doing_cron() ) {
|
95 |
+
return true;
|
96 |
+
|
97 |
+
// Bail if not doing WordPress cron (<4.8.0)
|
98 |
+
} elseif ( defined( 'DOING_CRON' ) && ( true === DOING_CRON ) ) {
|
99 |
+
return true;
|
100 |
+
}
|
101 |
+
|
102 |
+
// Default to false
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
$wpb_cron = new WPBackItUp_Cron();
|
lib/includes/class-usage.php
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Tracking functions for reporting plugin usage for users that have opted in
|
4 |
+
*
|
5 |
+
* @since 1.15.4
|
6 |
+
* @package Wpbackitup_Premium
|
7 |
+
* @subpackage Wpbackitup_Premium/includes
|
8 |
+
* @author WP BackItUp <wpbackitup@wpbackitup.com>
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( !defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Usage tracking
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
class WPBackItUp_Usage {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Log Name
|
25 |
+
*
|
26 |
+
* @access private
|
27 |
+
*/
|
28 |
+
private $log_name;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Usage data
|
32 |
+
*
|
33 |
+
* @access private
|
34 |
+
*/
|
35 |
+
private $data;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Usage data Schema Version
|
39 |
+
*
|
40 |
+
* @access private
|
41 |
+
*/
|
42 |
+
private $data_schema_version="20180501";
|
43 |
+
|
44 |
+
|
45 |
+
public function __construct() {
|
46 |
+
$this->log_name = 'debug_usage';//default log name
|
47 |
+
|
48 |
+
add_action( 'init', array( $this, 'schedule_events' ) );
|
49 |
+
add_action( 'wpbackitup_opt_into_tracking', array( $this, 'optin_usage_tracking' ) );
|
50 |
+
add_action( 'wpbackitup_opt_out_of_tracking', array( $this, 'optout_usage_tracking' ) );
|
51 |
+
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Check if the user has opted into tracking
|
56 |
+
*
|
57 |
+
* @access private
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
public function is_tracking_allowed() {
|
61 |
+
return (bool) WPBackItUp_Utility::get_option( 'allow_usage_tracking', false );
|
62 |
+
}
|
63 |
+
|
64 |
+
public function set_tracking_allowed($value) {
|
65 |
+
|
66 |
+
//When set to true - fire event
|
67 |
+
if (true===$value){
|
68 |
+
$this->ut_event( true );
|
69 |
+
}
|
70 |
+
|
71 |
+
return WPBackItUp_Utility::set_option( 'allow_usage_tracking', true===$value ? 1: 0);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Generate usage data
|
76 |
+
*
|
77 |
+
* @access private
|
78 |
+
* @return void
|
79 |
+
* @throws Exception
|
80 |
+
*/
|
81 |
+
private function setup_data() {
|
82 |
+
|
83 |
+
try {
|
84 |
+
$data = array();
|
85 |
+
|
86 |
+
//add home url but strip out the http
|
87 |
+
$domain = parse_url( get_home_url(), PHP_URL_HOST );
|
88 |
+
$data['ut-id'] = $domain; //pk
|
89 |
+
|
90 |
+
$data['version'] = $this->data_schema_version;
|
91 |
+
$data['domain'] = $domain;
|
92 |
+
|
93 |
+
// Retrieve current theme info
|
94 |
+
$theme_data = wp_get_theme();
|
95 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
96 |
+
|
97 |
+
$data['php_version'] = phpversion();
|
98 |
+
|
99 |
+
$data['wp_version'] = get_bloginfo( 'version' );
|
100 |
+
$data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
|
101 |
+
|
102 |
+
$data['multisite'] = is_multisite();
|
103 |
+
$data['url'] = home_url();
|
104 |
+
$data['theme'] = $theme;
|
105 |
+
|
106 |
+
// Retrieve current plugin information
|
107 |
+
if ( ! function_exists( 'get_plugins' ) ) {
|
108 |
+
include ABSPATH . '/wp-admin/includes/plugin.php';
|
109 |
+
}
|
110 |
+
|
111 |
+
$plugins = array_keys( get_plugins() );
|
112 |
+
$active_plugins = get_option( 'active_plugins', array());
|
113 |
+
|
114 |
+
$current_path = dirname(plugin_basename(__FILE__));
|
115 |
+
$current_root = current(explode("/",$current_path));
|
116 |
+
$current_plugin=$current_root;
|
117 |
+
|
118 |
+
foreach ( $plugins as $key => $plugin ) {
|
119 |
+
if ( in_array( $plugin, $active_plugins ) ) {
|
120 |
+
// Remove active plugins from list so we can show active and inactive separately
|
121 |
+
unset( $plugins[ $key ] );
|
122 |
+
|
123 |
+
//Current Plugin
|
124 |
+
if (strpos($plugin, $current_root) !== false) {
|
125 |
+
$current_plugin=$plugin;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
$data['source'] = $current_plugin;
|
130 |
+
$data['active_plugins'] = $active_plugins;
|
131 |
+
$data['inactive_plugins'] = $plugins;
|
132 |
+
$data['locale'] = get_locale();
|
133 |
+
|
134 |
+
|
135 |
+
/** Plugin Data Points **/
|
136 |
+
|
137 |
+
$data['wpbackitup_version'] = WPBACKITUP__VERSION;
|
138 |
+
|
139 |
+
$wpb_license = new WPBackItUp_License();
|
140 |
+
$data['wpbackitup_license_key'] = $wpb_license->get_license_key();
|
141 |
+
|
142 |
+
$data['wpbackitup_backup_count'] = WPBackItUp_Utility::get_option( 'successful_backup_count' );
|
143 |
+
|
144 |
+
$this->data = $data;
|
145 |
+
|
146 |
+
} catch (Exception $e) {
|
147 |
+
WPBackItUp_Logger::log_error($this->log_name,__METHOD__,'Exception: ' .$e);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Send the data to the usage service
|
155 |
+
*
|
156 |
+
* @access private
|
157 |
+
*
|
158 |
+
* @param bool $override If we should override the tracking setting.
|
159 |
+
* @param bool $ignore_last_checkin If we should ignore when the last check in was.
|
160 |
+
*
|
161 |
+
* @return bool
|
162 |
+
* @throws Exception
|
163 |
+
*/
|
164 |
+
public function ut_event( $override = false, $ignore_last_checkin = false ) {
|
165 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Begin:' . var_export($override,true) .':' . var_export($ignore_last_checkin,true) );
|
166 |
+
|
167 |
+
try {
|
168 |
+
|
169 |
+
//Check for user permission
|
170 |
+
if ( ! $this->is_tracking_allowed() && ! $override ) {
|
171 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Exit 1' );
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
|
175 |
+
// Send a maximum of once per week
|
176 |
+
$last_send = $this->get_last_send();
|
177 |
+
if ( is_numeric( $last_send ) && $last_send > strtotime( '-1 week' ) && ! $ignore_last_checkin ) {
|
178 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Exit 2' );
|
179 |
+
return false;
|
180 |
+
}
|
181 |
+
|
182 |
+
$this->setup_data();
|
183 |
+
$response = wp_remote_post( 'https://5bx6m4uwn0.execute-api.us-east-1.amazonaws.com/prod/utv2', array(
|
184 |
+
'method' => 'POST',
|
185 |
+
'timeout' => 8,
|
186 |
+
'redirection' => 5,
|
187 |
+
'httpversion' => '1.1',
|
188 |
+
'blocking' => false,
|
189 |
+
'body' => json_encode( $this->data ),
|
190 |
+
'user-agent' => 'WPBACKITUP/' . WPBACKITUP__VERSION . '; ' . get_bloginfo( 'url' )
|
191 |
+
) );
|
192 |
+
WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Usage Tracking Response:' . var_export( $response, true ));
|
193 |
+
|
194 |
+
$this->set_last_send();
|
195 |
+
return true;
|
196 |
+
|
197 |
+
} catch (Exception $e) {
|
198 |
+
$this->set_last_send();
|
199 |
+
WPBackItUp_Logger::log_error($this->log_name,__METHOD__,'Exception: ' .$e);
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Get the last time a checkin was sent
|
207 |
+
*
|
208 |
+
* @access private
|
209 |
+
* @return false|string
|
210 |
+
*/
|
211 |
+
private function get_last_send() {
|
212 |
+
return WPBackItUp_Utility::get_option( 'ut_last_send' );
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Set the send value
|
217 |
+
*
|
218 |
+
* @param null $value
|
219 |
+
* @return bool
|
220 |
+
*/
|
221 |
+
private function set_last_send($value=null){
|
222 |
+
if (null==$value) $value=time();
|
223 |
+
return WPBackItUp_Utility::set_option( 'ut_last_send', $value );
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Set the tracking notice off
|
228 |
+
*
|
229 |
+
* @return bool
|
230 |
+
*/
|
231 |
+
private function set_tracking_notice_off(){
|
232 |
+
return WPBackItUp_Utility::set_option( 'tracking_notice', 1 );
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* is the tracking notice off
|
237 |
+
*
|
238 |
+
* @return bool
|
239 |
+
*/
|
240 |
+
private function is_tracking_notice_off(){
|
241 |
+
return (bool) WPBackItUp_Utility::get_option( 'tracking_notice',false );
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Schedule a weekly checkin
|
247 |
+
*
|
248 |
+
* We send once a week (while tracking is allowed) to check in, which can be
|
249 |
+
* used to determine active sites.
|
250 |
+
*
|
251 |
+
* @return void
|
252 |
+
*/
|
253 |
+
public function schedule_events() {
|
254 |
+
if ( WPBackItUp_Cron::doing_cron() ) {
|
255 |
+
add_action( 'wpbackitup_weekly_scheduled_events', array( $this, 'ut_event' ) );
|
256 |
+
//add_action( 'wpbackitup_daily_scheduled_events', array( $this, 'ut_event' ) );
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Check for a new opt-in via the admin notice
|
262 |
+
*
|
263 |
+
* @return void
|
264 |
+
*/
|
265 |
+
public function optin_usage_tracking( $data ) {
|
266 |
+
|
267 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
268 |
+
return;
|
269 |
+
}
|
270 |
+
|
271 |
+
$this->set_tracking_allowed(true);
|
272 |
+
$this->set_tracking_notice_off();
|
273 |
+
|
274 |
+
wp_redirect( remove_query_arg( 'wpbackitup_action' ) ); exit;
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Check for a new opt-in via the admin notice
|
279 |
+
*
|
280 |
+
* @return void
|
281 |
+
*/
|
282 |
+
public function optout_usage_tracking( $data ) {
|
283 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
284 |
+
return;
|
285 |
+
}
|
286 |
+
|
287 |
+
$this->set_tracking_allowed(false);
|
288 |
+
$this->set_tracking_notice_off();
|
289 |
+
wp_redirect( remove_query_arg( 'wpbackitup_action' ) ); exit;
|
290 |
+
}
|
291 |
+
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Display the admin notice to users that have not opted-in or out
|
295 |
+
*
|
296 |
+
* @return void
|
297 |
+
*/
|
298 |
+
public function admin_notice() {
|
299 |
+
|
300 |
+
//only show on wpbackitup pages
|
301 |
+
if(! isset($_GET['page']) || false === strpos($_GET['page'],'wp-backitup-backup')) return;
|
302 |
+
|
303 |
+
if ( $this->is_tracking_notice_off()) {
|
304 |
+
return;
|
305 |
+
}
|
306 |
+
|
307 |
+
if ( $this->is_tracking_allowed() ) {
|
308 |
+
return;
|
309 |
+
}
|
310 |
+
|
311 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
|
315 |
+
if (
|
316 |
+
( stristr( network_site_url( '/' ), 'dev' ) !== false ||
|
317 |
+
stristr( network_site_url( '/' ), 'localhost' ) !== false ||
|
318 |
+
stristr( network_site_url( '/' ), ':8888' ) !== false // This is common with MAMP on OS X
|
319 |
+
) && WPBACKITUP__DEBUG!==true ){
|
320 |
+
|
321 |
+
//Turn off usage for dev
|
322 |
+
$this->set_tracking_notice_off();
|
323 |
+
|
324 |
+
} else {
|
325 |
+
$optin_url = add_query_arg( 'wpbackitup_action', 'opt_into_tracking' );
|
326 |
+
$optout_url = add_query_arg( 'wpbackitup_action', 'opt_out_of_tracking' );
|
327 |
+
|
328 |
+
echo '<div class="updated"><p>';
|
329 |
+
//echo sprintf( __( 'Allow WPBackItUp to anonymously track how this plugin is used so we can make it better? Only data needed to help support and improve this plugin will ever be collected. No sensitive data is tracked and we\'ll never share this data with anyone.', 'wp-backitup' ) );
|
330 |
+
echo sprintf( __( 'Allow WPBackItUp to anonymously track how this plugin is used so we can make it better?', 'wp-backitup' ) );
|
331 |
+
echo ' <a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'wp-backitup' ) . '</a>';
|
332 |
+
echo ' <a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow', 'wp-backitup' ) . '</a>';
|
333 |
+
echo sprintf( __( '<br/>Only data needed to help support and improve this plugin will ever be collected. No sensitive data is tracked and we\'ll never share this data with anyone.', 'wp-backitup' ) );
|
334 |
+
echo '</p></div>';
|
335 |
+
}
|
336 |
+
}
|
337 |
+
}
|
338 |
+
$wpb_tracking = new WPBackItUp_Usage();
|
lib/includes/class-wpbackitup-admin.php
CHANGED
@@ -514,6 +514,9 @@ class WPBackitup_Admin {
|
|
514 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-license.php' );
|
515 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-cleanup.php' );
|
516 |
|
|
|
|
|
|
|
517 |
|
518 |
// This class is used for showing a review nag
|
519 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-admin-notice.php' );
|
@@ -1251,6 +1254,10 @@ class WPBackitup_Admin {
|
|
1251 |
* Get all settings value
|
1252 |
*/
|
1253 |
public function ajax_backup_get_settings(){
|
|
|
|
|
|
|
|
|
1254 |
$settings = array(
|
1255 |
'logging' => $this->get_option('logging'),
|
1256 |
'notification_email' => $this->get_option('notification_email'),
|
@@ -1277,6 +1284,7 @@ class WPBackitup_Admin {
|
|
1277 |
'single_file_backupset'=> $this->get_option('single_file_backupset'),
|
1278 |
'single_file_db'=> $this->get_option('single_file_db'),
|
1279 |
'remove_supporting_zip_files'=> $this->get_option('remove_supporting_zip_files'),
|
|
|
1280 |
);
|
1281 |
|
1282 |
wp_send_json_success($settings);
|
@@ -1454,6 +1462,11 @@ class WPBackitup_Admin {
|
|
1454 |
//** Safe Sync ON/OFF **//
|
1455 |
$data['safe_sync'] = $data['safe_sync'] === 'true' ? 1: 0;
|
1456 |
|
|
|
|
|
|
|
|
|
|
|
1457 |
// Update the options value with the data submitted
|
1458 |
foreach( $data as $key => $val ) {
|
1459 |
$this->set_option($key, $val);
|
514 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-license.php' );
|
515 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-cleanup.php' );
|
516 |
|
517 |
+
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-cron.php' );
|
518 |
+
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-usage.php' );
|
519 |
+
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/admin-actions.php' );
|
520 |
|
521 |
// This class is used for showing a review nag
|
522 |
require_once( WPBACKITUP__PLUGIN_PATH . '/lib/includes/class-admin-notice.php' );
|
1254 |
* Get all settings value
|
1255 |
*/
|
1256 |
public function ajax_backup_get_settings(){
|
1257 |
+
|
1258 |
+
$ut = new WPBackItUp_Usage();
|
1259 |
+
$tracking_allowed = $ut->is_tracking_allowed();
|
1260 |
+
|
1261 |
$settings = array(
|
1262 |
'logging' => $this->get_option('logging'),
|
1263 |
'notification_email' => $this->get_option('notification_email'),
|
1284 |
'single_file_backupset'=> $this->get_option('single_file_backupset'),
|
1285 |
'single_file_db'=> $this->get_option('single_file_db'),
|
1286 |
'remove_supporting_zip_files'=> $this->get_option('remove_supporting_zip_files'),
|
1287 |
+
'allow_usage_tracking'=> $tracking_allowed,
|
1288 |
);
|
1289 |
|
1290 |
wp_send_json_success($settings);
|
1462 |
//** Safe Sync ON/OFF **//
|
1463 |
$data['safe_sync'] = $data['safe_sync'] === 'true' ? 1: 0;
|
1464 |
|
1465 |
+
//** Usage Tracking ON/OFF **//
|
1466 |
+
$ut = new WPBackItUp_Usage();
|
1467 |
+
$ut->set_tracking_allowed($data['allow_usage_tracking'] === 'true' ? true: false);
|
1468 |
+
unset($data['allow_usage_tracking']);//pop off array
|
1469 |
+
|
1470 |
// Update the options value with the data submitted
|
1471 |
foreach( $data as $key => $val ) {
|
1472 |
$this->set_option($key, $val);
|
lib/includes/update_plugin.php
CHANGED
@@ -33,6 +33,10 @@ function wpbackitup_update_plugin() {
|
|
33 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'Current Plugin Minor Version:' . $current_plugin_minor_ver );
|
34 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'Target Plugin Minor Version:' . $target_plugin_minor_ver );
|
35 |
|
|
|
|
|
|
|
|
|
36 |
//If current version = 0 then this is an install
|
37 |
if ($current_plugin_major_ver==0){
|
38 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'New Install.');
|
33 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'Current Plugin Minor Version:' . $current_plugin_minor_ver );
|
34 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'Target Plugin Minor Version:' . $target_plugin_minor_ver );
|
35 |
|
36 |
+
//fire to help troubleshoot upgrade issues
|
37 |
+
$ut = new WPBackItUp_Usage();
|
38 |
+
$ut->ut_event(true,true);
|
39 |
+
|
40 |
//If current version = 0 then this is an install
|
41 |
if ($current_plugin_major_ver==0){
|
42 |
WPBackItUp_Logger::log_info($log_name,__METHOD__, 'New Install.');
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: backup, backups, back up, backup plugin, database backup, multisite backup
|
|
4 |
Requires at least: 3.8.0
|
5 |
Requires PHP: 5.2.4
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 1.15.
|
8 |
Author URI: https://www.wpbackitup.com
|
9 |
Donate link: https://www.wpbackitup.com
|
10 |
License: GPLv2 or later
|
@@ -214,6 +214,12 @@ Our online documentation and full list of FAQs can be found at [support.wpbackit
|
|
214 |
|
215 |
|
216 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
= 1.15.7 =
|
218 |
*Release Date - May 4, 2018
|
219 |
|
4 |
Requires at least: 3.8.0
|
5 |
Requires PHP: 5.2.4
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 1.15.7
|
8 |
Author URI: https://www.wpbackitup.com
|
9 |
Donate link: https://www.wpbackitup.com
|
10 |
License: GPLv2 or later
|
214 |
|
215 |
|
216 |
== Changelog ==
|
217 |
+
= 1.16 =
|
218 |
+
*Release Date - May 18, 2018
|
219 |
+
|
220 |
+
* UPDATE: Updates for WordPress version 4.9.6
|
221 |
+
* UPDATE: Updates to usage tracking
|
222 |
+
|
223 |
= 1.15.7 =
|
224 |
*Release Date - May 4, 2018
|
225 |
|
views/settings.php
CHANGED
@@ -135,6 +135,18 @@
|
|
135 |
<p><?php _e('* These settings should only be modified by advanced users or when when working with WPBackItUp support.', 'wp-backitup') ?></p>
|
136 |
</div>
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
</v-tab>
|
139 |
|
140 |
|
@@ -256,7 +268,6 @@
|
|
256 |
</div>
|
257 |
</div>
|
258 |
|
259 |
-
|
260 |
<div class="widget">
|
261 |
<h3 class="promo"><i class="fa fa-trash-o"></i> <?php _e('Remove Data on Uninstall?', 'wp-backitup') ?></h3>
|
262 |
<p>
|
@@ -267,6 +278,7 @@
|
|
267 |
<button class="button-primary" v-on:click="setSettings()"><?php _e("Save", 'wp-backitup') ?></button>
|
268 |
</div>
|
269 |
</div>
|
|
|
270 |
</v-tab>
|
271 |
</vue-tabs>
|
272 |
</div>
|
135 |
<p><?php _e('* These settings should only be modified by advanced users or when when working with WPBackItUp support.', 'wp-backitup') ?></p>
|
136 |
</div>
|
137 |
|
138 |
+
<div class="widget">
|
139 |
+
<h3 class="promo"><i class="fa fa-heartbeat"></i> <?php _e('Help us make WPBackItUp better!', 'wp-backitup') ?></h3>
|
140 |
+
<p><input type="checkbox" v-model="allow_usage_tracking" checked="allow_usage_tracking === true">
|
141 |
+
<label for="wpbackitup_allow_tracking"><?php _e('Allow WPBackItUp to anonymously track how this plugin is used so we can make it better.', 'wp-backitup') ?></label></p>
|
142 |
+
<p><?php _e('Only data needed to help support and improve this plugin will ever be collected. No sensitive data is tracked and we\'ll never share this data with anyone.', 'wp-backitup') ?></p>
|
143 |
+
<div class="submit">
|
144 |
+
<button class="button-primary" v-on:click="setSettings()"><?php _e("Save", 'wp-backitup') ?></button>
|
145 |
+
</div>
|
146 |
+
|
147 |
+
<p class="error" v-if="errorMessages['notification_email'] !== '' ">{{ errorMessages['notification_email'] }}</p>
|
148 |
+
</div>
|
149 |
+
|
150 |
</v-tab>
|
151 |
|
152 |
|
268 |
</div>
|
269 |
</div>
|
270 |
|
|
|
271 |
<div class="widget">
|
272 |
<h3 class="promo"><i class="fa fa-trash-o"></i> <?php _e('Remove Data on Uninstall?', 'wp-backitup') ?></h3>
|
273 |
<p>
|
278 |
<button class="button-primary" v-on:click="setSettings()"><?php _e("Save", 'wp-backitup') ?></button>
|
279 |
</div>
|
280 |
</div>
|
281 |
+
|
282 |
</v-tab>
|
283 |
</vue-tabs>
|
284 |
</div>
|
wp-backitup.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
7 |
* Author: WPBackItUp
|
8 |
* Author URI: https://www.wpbackitup.com
|
9 |
-
* Version: 1.
|
10 |
* Text Domain: wp-backitup
|
11 |
*
|
12 |
* License: GPL3
|
@@ -32,8 +32,8 @@ define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
|
|
32 |
define( 'WPBACKITUP__CLASSNAMESPACE', 'WPBackItUp' );
|
33 |
|
34 |
define( 'WPBACKITUP__MAJOR_VERSION', 1);
|
35 |
-
define( 'WPBACKITUP__MINOR_VERSION',
|
36 |
-
define( 'WPBACKITUP__MAINTENANCE_VERSION',
|
37 |
define( 'WPBACKITUP__BUILD_VERSION', 0); //Used for hotfix releases
|
38 |
|
39 |
define( 'WPBACKITUP__VERSION',sprintf("%d.%d.%d.%d", WPBACKITUP__MAJOR_VERSION, WPBACKITUP__MINOR_VERSION,WPBACKITUP__MAINTENANCE_VERSION,WPBACKITUP__BUILD_VERSION));
|
@@ -100,24 +100,6 @@ define( 'WPBACKITUP__SQL_BATCH_SIZE', 10000);
|
|
100 |
register_activation_hook( __FILE__, array( 'WPBackitup_Admin', 'activate' ) );
|
101 |
register_deactivation_hook( __FILE__, array( 'WPBackitup_Admin', 'deactivate' ) );
|
102 |
|
103 |
-
function wpbackitup_modify_cron_schedules($schedules) {
|
104 |
-
$schedules['every4hours'] = array('interval' => 14400, 'display' => sprintf(__('Every %s hours', 'wp-backitup'), 4));
|
105 |
-
$schedules['every8hours'] = array('interval' => 28800, 'display' => sprintf(__('Every %s hours', 'wp-backitup'), 8));
|
106 |
-
$schedules['every_1_minutes'] = array('interval' => 60, 'display' => sprintf(__('WPBUP - Every %s minutes', 'wp-backitup'), 1));
|
107 |
-
$schedules['every_3_minutes'] = array('interval' => 180, 'display' => sprintf(__('WPBUP - Every %s minutes', 'wp-backitup'), 3));
|
108 |
-
$schedules['every_5_minutes'] = array('interval' => 300, 'display' => sprintf(__('WPBUP - Every %s minutes', 'wp-backitup'), 5));
|
109 |
-
$schedules['every_10_minutes'] = array('interval' => 600, 'display' => sprintf(__('WPBUP - Every %s minutes', 'wp-backitup'), 10));
|
110 |
-
$schedules['every_30_minutes'] = array('interval' => 1800, 'display' => sprintf(__('WPBUP - Every %s minutes', 'wp-backitup'), 30));
|
111 |
-
|
112 |
-
$schedules['weekly'] = array('interval' => 604800, 'display' => __('WPBUP - Once Weekly', 'wp-backitup'));
|
113 |
-
$schedules['monthly'] = array('interval' => 2592000, 'display' => __('WPBUP - Once Monthly', 'wp-backitup'));
|
114 |
-
$schedules['every4hours'] = array('interval' => 14400, 'display' => sprintf(__('WPBUP - Every %s hours', 'wp-backitup'), 4));
|
115 |
-
$schedules['every8hours'] = array('interval' => 28800, 'display' => sprintf(__('WPBUP - Every %s hours', 'wp-backitup'), 8));
|
116 |
-
return $schedules;
|
117 |
-
}
|
118 |
-
|
119 |
-
add_filter('cron_schedules', 'wpbackitup_modify_cron_schedules', 30);
|
120 |
-
|
121 |
function wpbackitup_register_post_types() {
|
122 |
|
123 |
$backup_args = array(
|
6 |
* Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
|
7 |
* Author: WPBackItUp
|
8 |
* Author URI: https://www.wpbackitup.com
|
9 |
+
* Version: 1.16.0
|
10 |
* Text Domain: wp-backitup
|
11 |
*
|
12 |
* License: GPL3
|
32 |
define( 'WPBACKITUP__CLASSNAMESPACE', 'WPBackItUp' );
|
33 |
|
34 |
define( 'WPBACKITUP__MAJOR_VERSION', 1);
|
35 |
+
define( 'WPBACKITUP__MINOR_VERSION', 16);
|
36 |
+
define( 'WPBACKITUP__MAINTENANCE_VERSION', 0); //Dont forget to update version in header on WP release
|
37 |
define( 'WPBACKITUP__BUILD_VERSION', 0); //Used for hotfix releases
|
38 |
|
39 |
define( 'WPBACKITUP__VERSION',sprintf("%d.%d.%d.%d", WPBACKITUP__MAJOR_VERSION, WPBACKITUP__MINOR_VERSION,WPBACKITUP__MAINTENANCE_VERSION,WPBACKITUP__BUILD_VERSION));
|
100 |
register_activation_hook( __FILE__, array( 'WPBackitup_Admin', 'activate' ) );
|
101 |
register_deactivation_hook( __FILE__, array( 'WPBackitup_Admin', 'deactivate' ) );
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
function wpbackitup_register_post_types() {
|
104 |
|
105 |
$backup_args = array(
|