/** * Alpus Patcher Admin JS * * @since 1.3.0 */ jQuery( document ).ready( function( $ ) { 'use strict'; $( '#patch-apply:not(.inactive)' ).on( 'click', function( e ) { e.preventDefault(); $( '#patcher-tbody' ).addClass( 'loading' ).append( '' ); $( '.alpus-patch-layout .button' ).attr( 'disabled', true ); $.ajax( { url: alpus_admin_vars.ajax_url, type: 'POST', data: { 'action': 'alpus_apply_patches', 'nonce': alpus_admin_vars.nonce, }, success: function( response ) { $( '.apply-alert' ).remove(); if ( response.success ) { if ( response.data ) { var update_patches = response.data.update, delete_patches = response.data.delete; if ( 'object' == typeof update_patches ) { update_patches = Object.keys( update_patches ); update_patches.forEach( patch => { $( '[data-path="update-' + patch ).remove(); } ); } if ( 'object' == typeof delete_patches ) { delete_patches = Object.keys( delete_patches ); delete_patches.forEach( patch => { $( '[data-path="delete-' + patch ).remove(); } ); } } if ( response.data.error ) { console.log( response.data ); $( '.alpus-patch-table-main' ).prepend( '
' + wp.i18n.__( 'The below patches could not be applied. Because your files have write permission or aren\'t existed.', 'alpus' ) + '
' + wp.i18n.__( 'All files patched successfully.', 'alpus' ) + '
' + wp.i18n.__( 'The API server could not be reached.', 'alpus' ) + '